diff --git a/TODO b/TODO index 39ffaae0e..98bafb55e 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,9 @@ TODO list: - - strengthen SQL queries - world: first fetch all, then upgrade - mirrors: one more and in random order - trigger: Regenerating cracklib dictionary - Community repositories - server: handle multiple packages for each scope with these abilities: - - enable/disable it - purge function - remove binkeywords, not used - add external trigger for splashutils diff --git a/libraries/activatorTools.py b/libraries/activatorTools.py index 9840e2bfb..be4f3153d 100644 --- a/libraries/activatorTools.py +++ b/libraries/activatorTools.py @@ -65,7 +65,7 @@ def sync(options, justTidy = False): else: ask = etpUi['ask'] etpUi['ask'] = True - rc = packages([ "sync" , "--ask" ]) + rc = packages(["sync"]) etpUi['ask'] = ask # then sync the database, if the packages sync completed successfully if (rc == False): @@ -456,13 +456,14 @@ def packages(options): print_info(red(" * ")+blue("Total download ")+brown("size:\t\t\t\t")+bold(bytesIntoHuman(str(totalDownloadSize)))) print_info(red(" * ")+blue("Total upload ")+green("size:\t\t\t\t")+bold(bytesIntoHuman(str(totalUploadSize)))) + if (etpUi['pretend']): - rc = askquestion("\n Would you like to run the steps above ?") - if rc == "No": - print "\n" - continue - elif (etpUi['pretend']): continue + if (etpUi['ask']): + rc = askquestion("\n Would you like to run the steps above ?") + if rc == "No": + print "\n" + continue # queues management successfulUploadCounter = 0 diff --git a/libraries/databaseTools.py b/libraries/databaseTools.py index e2690c197..bc65bd2cf 100644 --- a/libraries/databaseTools.py +++ b/libraries/databaseTools.py @@ -483,13 +483,17 @@ class etpDatabase: dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"addPackage: here is the list of similar packages (that will be removed) found for "+etpData['category']+"/"+etpData['name']+": "+str(searchsimilar)) removelist = set() - for oldpkg in searchsimilar: - # get the package slot - idpackage = oldpkg[1] - slot = self.retrieveSlot(idpackage) - if (etpData['slot'] == slot): - # remove! - removelist.add(idpackage) + if not etpData['injected']: # read: if package has been injected, we'll skip the removal of packages in the same slot, usually used server side btw + for oldpkg in searchsimilar: + # get the package slot + idpackage = oldpkg[1] + slot = self.retrieveSlot(idpackage) + isinjected = self.isInjected(idpackage) + if isinjected: + continue # we merely ignore packages with negative counters, since they're the injected ones + if (etpData['slot'] == slot): + # remove! + removelist.add(idpackage) for pkg in removelist: self.removePackage(pkg) @@ -760,6 +764,22 @@ class etpDatabase: ) ) + # injected? + if etpData['injected']: + try: + self.cursor.execute( + 'INSERT into injected VALUES ' + '(?)' + , ( idpackage, ) + ) + except: # FIXME: remove this before 1.0 + self.createInjectedTable() + self.cursor.execute( + 'INSERT into injected VALUES ' + '(?)' + , ( idpackage, ) + ) + # compile messages try: for message in etpData['messages']: @@ -1083,6 +1103,11 @@ class etpDatabase: self.cursor.execute('DELETE FROM triggers WHERE idpackage = '+idpackage) except: pass + try: + # inject table + self.cursor.execute('DELETE FROM injected WHERE idpackage = '+idpackage) + except: + pass # Remove from installedtable if exists self.removePackageFromInstalledTable(idpackage) @@ -1605,6 +1630,7 @@ class etpDatabase: data['mirrorlinks'].append([mirror,mirrorlinks]) data['slot'] = mydata[14] + data['injected'] = self.isInjected(idpackage) mycontent = self.retrieveContent(idpackage, extended = True) data['content'] = {} for cdata in mycontent: @@ -2392,6 +2418,28 @@ class etpDatabase: self.storeInfoCache(idpackage,'isSystemPackage',rslt) return rslt + def isInjected(self,idpackage): + dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isInjected: called.") + + cache = self.fetchInfoCache(idpackage,'isInjected') + if cache != None: return cache + + try: + self.cursor.execute('SELECT idpackage FROM injected WHERE idpackage = (?)', (idpackage,)) + except: # FIXME: remove this for 1.0 + self.createInjectedTable() + self.cursor.execute('SELECT idpackage FROM injected WHERE idpackage = (?)', (idpackage,)) + + result = self.cursor.fetchone() + rslt = False + if result: + dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isInjected: package is in system.") + rslt = True + dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isInjected: package is NOT in system.") + + self.storeInfoCache(idpackage,'isInjected',rslt) + return rslt + def areCompileFlagsAvailable(self,chost,cflags,cxxflags): dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"areCompileFlagsAvailable: called.") @@ -3061,7 +3109,12 @@ class etpDatabase: def createSystemPackagesTable(self): dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"createSystemPackagesTable: called.") - self.cursor.execute('CREATE TABLE systempackages ( idpackage INTEGER );') + self.cursor.execute('CREATE TABLE systempackages ( idpackage INTEGER PRIMARY KEY );') + self.commitChanges() + + def createInjectedTable(self): + dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"createInjectedTable: called.") + self.cursor.execute('CREATE TABLE injected ( idpackage INTEGER PRIMARY KEY );') self.commitChanges() def createProtectTable(self): @@ -3069,15 +3122,15 @@ class etpDatabase: self.cursor.execute('DROP TABLE IF EXISTS configprotect;') self.cursor.execute('DROP TABLE IF EXISTS configprotectmask;') self.cursor.execute('DROP TABLE IF EXISTS configprotectreference;') - self.cursor.execute('CREATE TABLE configprotect ( idpackage INTEGER, idprotect INTEGER );') - self.cursor.execute('CREATE TABLE configprotectmask ( idpackage INTEGER, idprotect INTEGER );') + self.cursor.execute('CREATE TABLE configprotect ( idpackage INTEGER PRIMARY KEY, idprotect INTEGER );') + self.cursor.execute('CREATE TABLE configprotectmask ( idpackage INTEGER PRIMARY KEY, idprotect INTEGER );') self.cursor.execute('CREATE TABLE configprotectreference ( idprotect INTEGER PRIMARY KEY, protect VARCHAR );') self.commitChanges() def createInstalledTable(self): dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"createInstalledTable: called.") self.cursor.execute('DROP TABLE IF EXISTS installedtable;') - self.cursor.execute('CREATE TABLE installedtable ( idpackage INTEGER, repositoryname VARCHAR );') + self.cursor.execute('CREATE TABLE installedtable ( idpackage INTEGER PRIMARY KEY, repositoryname VARCHAR );') self.commitChanges() def addDependRelationToDependsTable(self, iddependency, idpackage): diff --git a/libraries/entropyConstants.py b/libraries/entropyConstants.py index 0f0c4bf42..74fd506a8 100644 --- a/libraries/entropyConstants.py +++ b/libraries/entropyConstants.py @@ -64,6 +64,7 @@ etpData = { 'eclasses': u"", # eclasses used by the ebuild 'needed': u"", # runtime libraries needed by the package 'trigger': u"", # this will become a bool, containing info about external trigger presence + 'injected': bool, # if the package has been injected manually, this will be true } ''' @@ -109,6 +110,7 @@ DROP TABLE IF EXISTS needed; DROP TABLE IF EXISTS neededreference; DROP TABLE IF EXISTS triggers; DROP TABLE IF EXISTS countersdata; +DROP TABLE IF EXISTS injected; """ etpSQLInit = """ @@ -223,12 +225,12 @@ CREATE TABLE flags ( ); CREATE TABLE configprotect ( - idpackage INTEGER, + idpackage INTEGER PRIMARY KEY, idprotect INTEGER ); CREATE TABLE configprotectmask ( - idpackage INTEGER, + idpackage INTEGER PRIMARY KEY, idprotect INTEGER ); @@ -238,16 +240,20 @@ CREATE TABLE configprotectreference ( ); CREATE TABLE systempackages ( - idpackage INTEGER + idpackage INTEGER PRIMARY KEY +); + +CREATE TABLE injected ( + idpackage INTEGER PRIMARY KEY ); CREATE TABLE installedtable ( - idpackage INTEGER, + idpackage INTEGER PRIMARY KEY, repositoryname VARCHAR ); CREATE TABLE sizes ( - idpackage INTEGER, + idpackage INTEGER PRIMARY KEY, size INTEGER ); diff --git a/libraries/entropyTools.py b/libraries/entropyTools.py index 067976a34..d21e71cc3 100644 --- a/libraries/entropyTools.py +++ b/libraries/entropyTools.py @@ -1448,7 +1448,7 @@ def appendXpak(tbz2file, atom): return tbz2file # This function extracts all the info from a .tbz2 file and returns them -def extractPkgData(package, etpBranch = etpConst['branch'], silent = False): +def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inject = False): entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"extractPkgData: called -> package: "+str(package)) data = {} @@ -1543,6 +1543,13 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False): except IOError: pass + if not silent: print_info(yellow(" * ")+red(info_package+"Getting package injection information..."),back = True) + # fill slot, if it is + if inject: + data['injected'] = True + else: + data['injected'] = False + if not silent: print_info(yellow(" * ")+red(info_package+"Getting package eclasses information..."),back = True) # fill eclasses list data['eclasses'] = []