Skip to content

Commit 770e8ab

Browse files
committed
fixed: remove duplicates a package in Active packages
1 parent 10fcb6f commit 770e8ab

File tree

7 files changed

+78
-30
lines changed

7 files changed

+78
-30
lines changed

HelperResources/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v7.6
1+
v7.7

PackageManager.py

Lines changed: 72 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ def StopThread (self):
711711
#
712712
# process package Add/Remove actions
713713
def run (self):
714+
global RestartPackageManager
715+
714716
changes = False
715717
while self.threadRunning:
716718
# if package was added or removed, don't wait for queue empty
@@ -728,7 +730,28 @@ def run (self):
728730
# no changes so do idle processing:
729731
# add packages in /data that aren't included in package list
730732
else:
733+
# restart package manager if a duplice name found in PackageList
734+
# or if name is not valid
735+
DbusIf.LOCK ()
736+
existingPackages = []
737+
duplicateFound = False
738+
for (index, package) in enumerate (PackageClass.PackageList):
739+
packageName = package.PackageName
740+
if packageName in existingPackages or not PackageClass.PackageNameValid (packageName):
741+
duplicateFound = True
742+
break
743+
existingPackages.append (packageName)
744+
del existingPackages
745+
DbusIf.UNLOCK ()
746+
# exit this thread so no more package adds/removes are possible
747+
# PackageManager will eventually reset
748+
if duplicateFound:
749+
logging.critical ("duplicate " + packageName + " found in package list - restarting PackageManager")
750+
RestartPackageManager = True
751+
return
752+
731753
PackageClass.AddStoredPackages ()
754+
732755
changes = False
733756
continue
734757
except:
@@ -1738,7 +1761,7 @@ def AddPackage ( cls, packageName=None, gitHubUser=None, gitHubBranch=None, sour
17381761
# this is all done while the package list is locked !!!!
17391762

17401763
@classmethod
1741-
def RemovePackage (cls, packageName=None, packageIndex=None ):
1764+
def RemovePackage (cls, packageName=None, packageIndex=None, isDuplicate=False ):
17421765
# packageName specified so this is a call from the GUI
17431766
if packageName != None:
17441767
guiRequestedRemove = True
@@ -1785,8 +1808,10 @@ def RemovePackage (cls, packageName=None, packageIndex=None ):
17851808

17861809
# if package is installed, don't remove it
17871810
if matchFound and not packageIsInstalled:
1811+
# if not just removing a duplicate
17881812
# block future automatic adds since the package is being removed
1789-
PackageClass.SetAutoAddOk (packageName, False)
1813+
if not isDuplicate:
1814+
PackageClass.SetAutoAddOk (packageName, False)
17901815

17911816
# move packages after the one to be remove down one slot (copy info)
17921817
# each copy overwrites the lower numbered package
@@ -1803,8 +1828,8 @@ def RemovePackage (cls, packageName=None, packageIndex=None ):
18031828
toPackage.SetGitHubVersion (fromPackage.GitHubVersion )
18041829
toPackage.SetPackageVersion (fromPackage.PackageVersion )
18051830
toPackage.SetInstalledVersion (fromPackage.InstalledVersion )
1806-
toPackage.SetIncompatible (fromPackage.Incompatible, self.IncompatibleDetails,
1807-
self.IncompatibleResolvable )
1831+
toPackage.SetIncompatible (fromPackage.Incompatible, fromPackage.IncompatibleDetails,
1832+
fromPackage.IncompatibleResolvable )
18081833
toPackage.SetInstallOk (fromPackage.InstallOk)
18091834

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

4163-
DbusIf.LOCK ()
4164-
for (index, package) in enumerate (PackageClass.PackageList):
4165-
packageName = package.PackageName
4166-
# valid package name
4167-
if PackageClass.PackageNameValid (packageName):
4191+
while True:
4192+
DbusIf.LOCK ()
4193+
runAgain = False
4194+
existingPackages = []
4195+
for (index, package) in enumerate (PackageClass.PackageList):
4196+
packageName = package.PackageName
4197+
# valid package name
4198+
if PackageClass.PackageNameValid (packageName):
4199+
4200+
flagFile = "/data/setupOptions/" + packageName + "/FORCE_REMOVE"
4201+
# forced removal flag
4202+
if os.path.exists (flagFile):
4203+
os.remove (flagFile)
4204+
forcedRemove = True
4205+
if os.path.exists ("/etc/venus/nstalledVersion-" + packageName):
4206+
logging.warning ( "uninstalling " + packageName + " prior to forced remove" )
4207+
directUninstall (packageName)
4208+
# now remove the package
4209+
logging.warning ( "forced remove of " + packageName )
4210+
PackageClass.RemovePackage (packageIndex=index)
4211+
runAgain = True
4212+
break
4213+
elif packageName in existingPackages:
4214+
logging.warning ( "removing duplicate " + packageName )
4215+
PackageClass.RemovePackage (packageIndex=index, isDuplicate=True)
4216+
runAgain = True
4217+
break
41684218

4169-
package.UpdateVersionsAndFlags ()
4219+
# invalid package name (including a null string) so remove the package from the list
4220+
else:
4221+
logging.warning ( "removing package with invalid name " + packageName )
4222+
PackageClass.RemovePackage (packageIndex=index)
4223+
runAgain = True
4224+
break
41704225

4171-
# do not force remove SetupHelper !!!!!
4172-
if packageName != "SetupHelper":
4173-
continue
4174-
flagFile = "/data/setupOptions/" + packageName + "/FORCE_REMOVE"
4175-
# no forced removal flag
4176-
if not os.path.exists (flagFile):
4177-
continue
4178-
# need to force remove but package is installed so uninstall first
4179-
if package.InstalledVersion != "":
4180-
directUninstall (packageName)
4181-
# now remove the package
4182-
PackageClass.RemovePackage (packageIndex=index)
4183-
os.remove (flagFile)
4184-
# invalid package name (including a null string) so remove the package from the list
4185-
else:
4186-
PackageClass.RemovePackage (packageIndex=index)
4187-
DbusIf.UNLOCK ()
4226+
# package not removed above - add its name to list that will be checked for duplicates
4227+
existingPackages.append (packageName)
4228+
4229+
DbusIf.UNLOCK ()
4230+
if not runAgain:
4231+
break
4232+
del existingPackages
41884233

41894234
DbusIf.UpdateDefaultPackages ()
41904235

blindInstall/SetupHelperVersion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v7.6
1+
v7.7

changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v7.7:
2+
fixed: remove duplicates a package in Active packages
3+
14
v7.6:
25
fixed: Package editor menus shows Now / Later in stead of Proceed / Cancel
36
for Show Details

venus-data-UninstallPackages.tgz

0 Bytes
Binary file not shown.

venus-data.tgz

451 Bytes
Binary file not shown.

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v7.6
1+
v7.7

0 commit comments

Comments
 (0)