Skip to content

Commit

Permalink
fixed: remove duplicates a package in Active packages
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed Mar 19, 2024
1 parent 10fcb6f commit 770e8ab
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 30 deletions.
2 changes: 1 addition & 1 deletion HelperResources/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v7.6
v7.7
99 changes: 72 additions & 27 deletions PackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ def StopThread (self):
#
# process package Add/Remove actions
def run (self):
global RestartPackageManager

changes = False
while self.threadRunning:
# if package was added or removed, don't wait for queue empty
Expand All @@ -728,7 +730,28 @@ def run (self):
# no changes so do idle processing:
# add packages in /data that aren't included in package list
else:
# restart package manager if a duplice name found in PackageList
# or if name is not valid
DbusIf.LOCK ()
existingPackages = []
duplicateFound = False
for (index, package) in enumerate (PackageClass.PackageList):
packageName = package.PackageName
if packageName in existingPackages or not PackageClass.PackageNameValid (packageName):
duplicateFound = True
break
existingPackages.append (packageName)
del existingPackages
DbusIf.UNLOCK ()
# exit this thread so no more package adds/removes are possible
# PackageManager will eventually reset
if duplicateFound:
logging.critical ("duplicate " + packageName + " found in package list - restarting PackageManager")
RestartPackageManager = True
return

PackageClass.AddStoredPackages ()

changes = False
continue
except:
Expand Down Expand Up @@ -1738,7 +1761,7 @@ def AddPackage ( cls, packageName=None, gitHubUser=None, gitHubBranch=None, sour
# this is all done while the package list is locked !!!!

@classmethod
def RemovePackage (cls, packageName=None, packageIndex=None ):
def RemovePackage (cls, packageName=None, packageIndex=None, isDuplicate=False ):
# packageName specified so this is a call from the GUI
if packageName != None:
guiRequestedRemove = True
Expand Down Expand Up @@ -1785,8 +1808,10 @@ def RemovePackage (cls, packageName=None, packageIndex=None ):

# if package is installed, don't remove it
if matchFound and not packageIsInstalled:
# if not just removing a duplicate
# block future automatic adds since the package is being removed
PackageClass.SetAutoAddOk (packageName, False)
if not isDuplicate:
PackageClass.SetAutoAddOk (packageName, False)

# move packages after the one to be remove down one slot (copy info)
# each copy overwrites the lower numbered package
Expand All @@ -1803,8 +1828,8 @@ def RemovePackage (cls, packageName=None, packageIndex=None ):
toPackage.SetGitHubVersion (fromPackage.GitHubVersion )
toPackage.SetPackageVersion (fromPackage.PackageVersion )
toPackage.SetInstalledVersion (fromPackage.InstalledVersion )
toPackage.SetIncompatible (fromPackage.Incompatible, self.IncompatibleDetails,
self.IncompatibleResolvable )
toPackage.SetIncompatible (fromPackage.Incompatible, fromPackage.IncompatibleDetails,
fromPackage.IncompatibleResolvable )
toPackage.SetInstallOk (fromPackage.InstallOk)

# package variables
Expand Down Expand Up @@ -4157,34 +4182,54 @@ def main():
# remove any packages with their forced removal flag is set
# package conflicts are sometimes resolved by uninstalling a package
# (done in their setup script eg GuiMods force removes GeneratorConnector)
# remove duplicate packages
# could be time-consuming (uninstall, removal and checking all packages)
# lock is really unecessary since threads aren't running yet
#
# if a package is removed, start at the beginning of the list again

DbusIf.LOCK ()
for (index, package) in enumerate (PackageClass.PackageList):
packageName = package.PackageName
# valid package name
if PackageClass.PackageNameValid (packageName):
while True:
DbusIf.LOCK ()
runAgain = False
existingPackages = []
for (index, package) in enumerate (PackageClass.PackageList):
packageName = package.PackageName
# valid package name
if PackageClass.PackageNameValid (packageName):

flagFile = "/data/setupOptions/" + packageName + "/FORCE_REMOVE"
# forced removal flag
if os.path.exists (flagFile):
os.remove (flagFile)
forcedRemove = True
if os.path.exists ("/etc/venus/nstalledVersion-" + packageName):
logging.warning ( "uninstalling " + packageName + " prior to forced remove" )
directUninstall (packageName)
# now remove the package
logging.warning ( "forced remove of " + packageName )
PackageClass.RemovePackage (packageIndex=index)
runAgain = True
break
elif packageName in existingPackages:
logging.warning ( "removing duplicate " + packageName )
PackageClass.RemovePackage (packageIndex=index, isDuplicate=True)
runAgain = True
break

package.UpdateVersionsAndFlags ()
# invalid package name (including a null string) so remove the package from the list
else:
logging.warning ( "removing package with invalid name " + packageName )
PackageClass.RemovePackage (packageIndex=index)
runAgain = True
break

# do not force remove SetupHelper !!!!!
if packageName != "SetupHelper":
continue
flagFile = "/data/setupOptions/" + packageName + "/FORCE_REMOVE"
# no forced removal flag
if not os.path.exists (flagFile):
continue
# need to force remove but package is installed so uninstall first
if package.InstalledVersion != "":
directUninstall (packageName)
# now remove the package
PackageClass.RemovePackage (packageIndex=index)
os.remove (flagFile)
# invalid package name (including a null string) so remove the package from the list
else:
PackageClass.RemovePackage (packageIndex=index)
DbusIf.UNLOCK ()
# package not removed above - add its name to list that will be checked for duplicates
existingPackages.append (packageName)

DbusIf.UNLOCK ()
if not runAgain:
break
del existingPackages

DbusIf.UpdateDefaultPackages ()

Expand Down
2 changes: 1 addition & 1 deletion blindInstall/SetupHelperVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v7.6
v7.7
3 changes: 3 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v7.7:
fixed: remove duplicates a package in Active packages

v7.6:
fixed: Package editor menus shows Now / Later in stead of Proceed / Cancel
for Show Details
Expand Down
Binary file modified venus-data-UninstallPackages.tgz
Binary file not shown.
Binary file modified 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 @@
v7.6
v7.7

0 comments on commit 770e8ab

Please sign in to comment.