Skip to content

Commit

Permalink
add code to handle directory renames
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed Dec 28, 2024
1 parent e52f42d commit 3f54d44
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 34 deletions.
1 change: 0 additions & 1 deletion CommonResources

This file was deleted.

10 changes: 7 additions & 3 deletions HelperResources/CommonResources
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,8 @@ updateActiveFile ()
fi

# the location of the active file must exist
local pathToActive=$(dirname "$activeFile")
if [ ! -e "$pathToActive" ]; then
logMessage "path to $activeFile does not exist - skiping patch"
if [ ! -e $(dirname "$activeFile") ]; then
logMessage "path to $activeFile does not exist - skiping update"
return 1
fi

Expand Down Expand Up @@ -784,6 +783,11 @@ checkFileSets ()
else
activeFile=$file
fi
if ! [ -e $( dirname "$activeFile" ) ]; then
logMessage "no parent directory $activeFile - skipping checks"
continue
fi

# package already installed, use .orig file for comparisons
if [ -f "$activeFile.orig" ]; then
activeFile="$activeFile.orig"
Expand Down
10 changes: 6 additions & 4 deletions PackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,15 @@ def VersionToNumber (version):
# and others part will be part the main version number
else:
numberPartsLength -= 1
versionNumber += int (numberParts [numberPartsLength])
if numberParts [numberPartsLength] != "":
versionNumber += int (numberParts [numberPartsLength])

# include core version number
versionNumber += int (numberParts [0]) * 10000000000000
if numberPartsLength >= 2:
if numberPartsLength >= 1 and numberParts [0] != "":
versionNumber += int (numberParts [0]) * 10000000000000
if numberPartsLength >= 2 and numberParts [1] != "":
versionNumber += int (numberParts [1]) * 1000000000
if numberPartsLength >= 3:
if numberPartsLength >= 3 and numberParts [2] != "":
versionNumber += int (numberParts [2]) * 100000

return versionNumber
Expand Down
6 changes: 6 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v8.23:
add code to updatePackage and CommonResources to handle directory renames
(e.g., dbus-generator-starter to dbus-generator)
fixed: PackageManager crash if version string contains invalid characters
updatePackage: fixed: USE_ORIGINAL flag files not created in some cases

v8.22:
fixed: missing log file and directories are not created
until the PackageManager service starts
Expand Down
1 change: 0 additions & 1 deletion defaultPackageList
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Package GitHubUser Tag/branch/version
SetupHelper kwindrem latest
GuiMods kwindrem latest
ExtTransferSwitch kwindrem latest
ShutdownMonitor kwindrem latest
VeCanSetup kwindrem latest
RpiDisplaySetup kwindrem latest
Expand Down
72 changes: 48 additions & 24 deletions updatePackage
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ for package in $packageList; do
cp -pR "$sourceVeLib" "$workingVeLib"
fi
fi

# clean up flag files from a previous run
rm -f "$workingFiles"/*/INCOMPATIBLE_VERSION
rm -f "$workingFiles"/*/UNUSED_FILE_SET
Expand Down Expand Up @@ -841,7 +840,6 @@ for package in $packageList; do
done
done # for file in fileListPatched
fi # check patch files

beginProgress "$package: updating file sets"

# process only versioned files
Expand Down Expand Up @@ -876,14 +874,15 @@ for package in $packageList; do
oldReplacementVersion="-"
oldReplacementIsFile=false
oldReplacementIsUseOrig=false
blockIsUnused=true
addOrigToFileSet=false
blockIsUsed=false
for (( i1 = start; i1 < $allFileSetsLength; i1++ )); do
IFS=':' read version versionNumber <<< "${allFileSets[$i1]}"
fileSet="$workingFiles/$version"
if [ -e "$fileSet/INCOMPATIBLE_VERSION" ] || [ -e "$fileSet/UNUSED_FILE_SET" ]; then
fileSetUnused=true
fileSetUsed=false
else
fileSetUnused=false
fileSetUsed=true
fi
replacement="$fileSet/$baseName"
stockFileSet="$stockFiles/$version"
Expand All @@ -903,11 +902,17 @@ for package in $packageList; do
elif [ -f "$replacement.USE_ORIGINAL" ]; then
useOrig=true
fi
# skip this version if parent directory does not exist
if ! [ -e $( dirname "$stockFile" ) ]; then
fileSetUsed=false
fi
if (( i1 == start )); then
startVersion=$version
fi

if [ -e "$stockFile" ]; then
if ! $fileSetUsed ; then
thisOrig=""
elif [ -e "$stockFile" ]; then
thisOrig="$stockFile"
# error if file set exists but no stock file
elif [ -e "$stockFileSet" ]; then
Expand All @@ -931,22 +936,24 @@ for package in $packageList; do
fi
includeInBlock=false
# nothing to compare - include in same block
if [ -z "$compareReference" ] || [ -z "$thisOrig" ]; then
includeInBlock=true
elif [ "$thisOrig" == "$compareReference" ]; then
includeInBlock=true
# orig exists and DOES match others in block
elif cmp -s "$thisOrig" "$compareReference" > /dev/null ; then
includeInBlock=true
if $fileSetUsed ; then
if [ -z "$compareReference" ] || [ -z "$thisOrig" ]; then
includeInBlock=true
elif [ "$thisOrig" == "$compareReference" ]; then
includeInBlock=true
# orig exists and DOES match others in block
elif cmp -s "$thisOrig" "$compareReference" > /dev/null ; then
includeInBlock=true
fi
fi

# start a new block
if ! $includeInBlock ; then
break
fi

if ! $fileSetUnused ; then
blockIsUnused=false
if $fileSetUsed ; then
blockIsUsed=true
fi

# save version of old replacement files for next loop
Expand All @@ -955,11 +962,14 @@ for package in $packageList; do
oldReplacementVersion=$version
oldReplacementIsFile=true
oldReplacementIsUseOrig=false
addOrigToFileSet=true
fi
elif $useOrig && [ "$oldReplacementVersion" == "-" ]; then
oldReplacementVersion=$version
oldReplacementIsFile=false
oldReplacementIsUseOrig=true
# retain .orig so that SetupHelper can create USE_ORIGINAL flag files for missing file sets
addOrigToFileSet=true
fi

(( end = i1 ))
Expand All @@ -968,14 +978,14 @@ for package in $packageList; do
# first compatible file set - move replacements here
# unused file sets are permitted for the destination file set
# but if a used file set is later found, it is preferred
if (( to == -1 )) && ! $fileSetUnused; then
if (( to == -1 )) && $fileSetUsed; then
(( to = i1 ))
toFileSet="$fileSet"
toVersion=$( basename "$toFileSet" )
fi
done # end locate block
if (( to == -1 )); then
if ! $blockIsUnused; then
if $blockIsUsed; then
logMessage "ERROR $package: $baseName no destination file set for block $startVersion $endVersion - can't relocate files"
fi
else
Expand All @@ -999,10 +1009,10 @@ for package in $packageList; do
mv "$oldReplacement" "$toReplacement"
fi
versionedFileExists=true
else
elif [ -e $( dirname "$toReplacement" ) ]; then
touch "$toReplacement.CHECK_REPLACEMENT"
fi
if ! $oldReplacementIsUseOrig ; then
if $addOrigToFileSet ; then
if [ -f "$toStockFile" ]; then
cp "$toStockFile" "$toReplacement.orig"
elif [ -f "$oldReplacement.orig" ]; then
Expand Down Expand Up @@ -1032,9 +1042,11 @@ for package in $packageList; do
useOrig=true
fi

if $useOrig && ! $oldReplacementIsUseOrig ; then
logMessage "WARNING $package: $baseName has replacement - USE_ORIGINAL removed"
rm -f "$replacement.USE_ORIGINAL"
if $useOrig ; then
if ! $oldReplacementIsUseOrig ; then
logMessage "WARNING $package: $baseName has replacement - USE_ORIGINAL removed"
rm -f "$replacement.USE_ORIGINAL"
fi
fi

# a second replacement is found - remove if matches, error if different
Expand All @@ -1050,7 +1062,7 @@ for package in $packageList; do
if $updateReplacements ; then
rm -f "$replacement"*
if $oldReplacementIsUseOrig; then
touch "$toReplacement.USE_ORIGINAL"
touch "$replacement.USE_ORIGINAL"
# links are created even if replacement does not exist
else
ln -sf "../$toVersion/$baseName" "$replacement"
Expand Down Expand Up @@ -1182,7 +1194,19 @@ for package in $packageList; do
done
fi
if [ -f "$replacement.CHECK_REPLACEMENT" ]; then
logMessage "ERROR $package $baseName: no replacement for $version"
enclosingDir=$( dirname "$stockFile1" )
if [ -e "$enclosingDir" ]; then
dirName=$( basename "$enclosingDir" )
logMessage "ERROR $package "$dirName"/$baseName: no replacement for $version"
# grab a copy of the orig file to make creating the replacement easier
if ! [ -e "$replacement.orig" ]; then
if [ -e "$stockFile1" ]; then
cp "$stockFile1" "$replacement.orig"
else
logMessage "ERROR $package $"dirName"/$baseName: no stock file for $version"
fi
fi
fi
fi

# validate sym link
Expand Down
Binary file removed venus-data-UninstallPackages.tgz
Binary file not shown.
Binary file removed venus-data.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8.22
v8.23

0 comments on commit 3f54d44

Please sign in to comment.