Skip to content

Commit

Permalink
added checks for file set errors before attempting auto install
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed May 4, 2022
1 parent 1da8af1 commit a040ee8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
24 changes: 18 additions & 6 deletions CommonResources
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ source "$setupHelperDir/DbusSettingsResources"
# checkFileSets EXITS locally

scriptAction='NONE'
installFailed=false

# flags to control setup script exit behavior
rebootNeeded=false
Expand Down Expand Up @@ -213,6 +214,8 @@ updateActiveFile ()
logMessage "ERROR: no replacement file for $sourceFile"
thisFileUpdated=false
scriptAction='UNINSTALL'
touch "$fileSet/INCOMPLETE"
installFailed=true
fi
return
fi
Expand Down Expand Up @@ -445,15 +448,20 @@ endScript ()
mv "$scriptDir/tmp" "$reinstallScriptsList"
fi

# clean up only - flag not used since package is being removed
rm -f "$installedFlag" # obsolete but remove it anyway
# flag package not installed since package is being removed
rm -f "$installedVersionFile"
rm -f "$installedFlag" # obsolete but remove it anyway
else
logMessage "unexpected script action $scriptAction - did not install or uninstall"
fi

# prioritize exit
if $versionNotCompatible ; then
# if installation was attempted but failed, exit without checking anything else
# or signaling GUI restart or reboot
if $installFailed ; then
logMessage "installation failed - package uninstalled - exiting"
exit $EXIT_FILE_SET_ERROR
elif $versionNotCompatible ; then
logMessage "version not compatible - exiting"
exit $EXIT_INCOMPATIBLE_VERSION
elif $platformNotCompatible ; then
Expand Down Expand Up @@ -722,11 +730,15 @@ fi
# attempting an install without the comand line prompting
# and needed options have not been set yet
# can't continue
if [ $scriptAction == 'INSTALL' ] && ! $optionsSet ; then
logMessage "required options have not been set - can't install"
exit $EXIT_OPTIONS_NOT_SET
if [ $scriptAction == 'INSTALL' ]; then
if ! $optionsSet ; then
logMessage "required options have not been set - can't install"
exit $EXIT_OPTIONS_NOT_SET
fi
fi
# if forcing an uninstall, skip file set checks
if [ $scriptAction != 'UNINSTALL' ]; then
# note _checkFileSets will exit if file set error exists
_checkFileSets
fi

21 changes: 16 additions & 5 deletions PackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,9 @@ def __init__( self, section, packageName = None ):
self.DownloadPending = False
self.InstallPending = False

self.AutoInstallOk = False
self.FileSetOk = False



# dbus Settings is the primary non-volatile storage for packageManager
Expand Down Expand Up @@ -1832,6 +1835,9 @@ def RemovePackage (cls, packageName=None, packageIndex=None ):
# must be called while LOCKED !!

def UpdateFileFlagsAndVersions (self):
global VersionToNumber
global VenusVersion
global VenusVersionNumber

packageName = self.PackageName

Expand All @@ -1855,6 +1861,7 @@ def UpdateFileFlagsAndVersions (self):
if not os.path.isdir (packageDir):
self.SetPackageVersion ("")
self.AutoInstallOk = False
self.FileSetOk = False
self.SetIncompatible ('')
return

Expand Down Expand Up @@ -1883,7 +1890,14 @@ def UpdateFileFlagsAndVersions (self):
if os.path.exists (flagFile):
self.AutoInstallOk = False
else:
self.AutoInstallOk = True
self.AutoInstallOk = True

# also check to see if file set has errors
flagFile = packageDir + "/FileSets/" + VenusVersion + "/INCOMPLETE"
if os.path.exists (flagFile):
self.FileSetOk = False
else:
self.FileSetOk = True

# platform is OK, now check versions
if incompatible == False:
Expand All @@ -1902,9 +1916,6 @@ def UpdateFileFlagsAndVersions (self):
else:
obsoleteVersion = fd.readline().strip()

global VersionToNumber
global VenusVersion
global VenusVersionNumber
firstVersionNumber = VersionToNumber (firstVersion)
obsoleteVersionNumber = VersionToNumber (obsoleteVersion)
if VenusVersionNumber < firstVersionNumber:
Expand Down Expand Up @@ -3061,7 +3072,7 @@ def mainLoop():
PushAction ( command='download' + ':' + packageName, source='AUTO' )
packageOperationOk = False # don't allow other operations if download was triggered

if packageOperationOk and package.AutoInstallOk and package.Incompatible == ''\
if packageOperationOk and package.AutoInstallOk and package.FileSetOk and package.Incompatible == ''\
and DbusIf.GetAutoInstall () and package.InstallVersionCheck ():
PushAction ( command='install' + ':' + packageName, source='AUTO' )

Expand Down
3 changes: 3 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v4.12:
added checks for file set errors before attempting auto install

v4.11:
added support for Venus OS v2.90~3 firmware

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v4.11
v4.12

0 comments on commit a040ee8

Please sign in to comment.