@@ -711,6 +711,8 @@ def StopThread (self):
711
711
#
712
712
# process package Add/Remove actions
713
713
def run (self ):
714
+ global RestartPackageManager
715
+
714
716
changes = False
715
717
while self .threadRunning :
716
718
# if package was added or removed, don't wait for queue empty
@@ -728,7 +730,28 @@ def run (self):
728
730
# no changes so do idle processing:
729
731
# add packages in /data that aren't included in package list
730
732
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
+
731
753
PackageClass .AddStoredPackages ()
754
+
732
755
changes = False
733
756
continue
734
757
except :
@@ -1738,7 +1761,7 @@ def AddPackage ( cls, packageName=None, gitHubUser=None, gitHubBranch=None, sour
1738
1761
# this is all done while the package list is locked !!!!
1739
1762
1740
1763
@classmethod
1741
- def RemovePackage (cls , packageName = None , packageIndex = None ):
1764
+ def RemovePackage (cls , packageName = None , packageIndex = None , isDuplicate = False ):
1742
1765
# packageName specified so this is a call from the GUI
1743
1766
if packageName != None :
1744
1767
guiRequestedRemove = True
@@ -1785,8 +1808,10 @@ def RemovePackage (cls, packageName=None, packageIndex=None ):
1785
1808
1786
1809
# if package is installed, don't remove it
1787
1810
if matchFound and not packageIsInstalled :
1811
+ # if not just removing a duplicate
1788
1812
# block future automatic adds since the package is being removed
1789
- PackageClass .SetAutoAddOk (packageName , False )
1813
+ if not isDuplicate :
1814
+ PackageClass .SetAutoAddOk (packageName , False )
1790
1815
1791
1816
# move packages after the one to be remove down one slot (copy info)
1792
1817
# each copy overwrites the lower numbered package
@@ -1803,8 +1828,8 @@ def RemovePackage (cls, packageName=None, packageIndex=None ):
1803
1828
toPackage .SetGitHubVersion (fromPackage .GitHubVersion )
1804
1829
toPackage .SetPackageVersion (fromPackage .PackageVersion )
1805
1830
toPackage .SetInstalledVersion (fromPackage .InstalledVersion )
1806
- toPackage .SetIncompatible (fromPackage .Incompatible , self .IncompatibleDetails ,
1807
- self .IncompatibleResolvable )
1831
+ toPackage .SetIncompatible (fromPackage .Incompatible , fromPackage .IncompatibleDetails ,
1832
+ fromPackage .IncompatibleResolvable )
1808
1833
toPackage .SetInstallOk (fromPackage .InstallOk )
1809
1834
1810
1835
# package variables
@@ -4157,34 +4182,54 @@ def main():
4157
4182
# remove any packages with their forced removal flag is set
4158
4183
# package conflicts are sometimes resolved by uninstalling a package
4159
4184
# (done in their setup script eg GuiMods force removes GeneratorConnector)
4185
+ # remove duplicate packages
4160
4186
# could be time-consuming (uninstall, removal and checking all packages)
4161
4187
# 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
4162
4190
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
4168
4218
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
4170
4225
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
4188
4233
4189
4234
DbusIf .UpdateDefaultPackages ()
4190
4235
0 commit comments