diff --git a/libraries/databaseTools.py b/libraries/databaseTools.py index e53195eb2..fbdeb35c0 100644 --- a/libraries/databaseTools.py +++ b/libraries/databaseTools.py @@ -2464,27 +2464,25 @@ class etpDatabase(TextInterface): def retrieveSources(self, idpackage): - ''' caching - cache = self.fetchInfoCache(idpackage,'retrieveSources') - if cache != None: return cache - ''' + ''' caching + cache = self.fetchInfoCache(idpackage,'retrieveSources') + if cache != None: return cache + ''' - self.cursor.execute('SELECT sourcesreference.source FROM sources,sourcesreference WHERE idpackage = (?) and sources.idsource = sourcesreference.idsource', (idpackage,)) - sources = self.fetchall2set(self.cursor.fetchall()) + self.cursor.execute('SELECT sourcesreference.source FROM sources,sourcesreference WHERE idpackage = (?) and sources.idsource = sourcesreference.idsource', (idpackage,)) + sources = self.fetchall2set(self.cursor.fetchall()) - ''' caching - self.storeInfoCache(idpackage,'retrieveSources',sources) - ''' - return sources + ''' caching + self.storeInfoCache(idpackage,'retrieveSources',sources) + ''' + return sources def retrieveContent(self, idpackage, extended = False, contentType = None): self.createContentIndex() # FIXME: remove this with 1.0 - # protect user from having a bad day - # developers can solve bad utf-8 data (and MUST), so we won't skip bad chars for them - if self.clientDatabase: - self.connection.text_factory = lambda x: unicode(x, "utf-8", "ignore") + # like portage does + self.connection.text_factory = lambda x: unicode(x, "raw_unicode_escape") extstring = '' if extended: @@ -2553,92 +2551,93 @@ class etpDatabase(TextInterface): def retrieveLicense(self, idpackage): - cache = self.fetchInfoCache(idpackage,'retrieveLicense') - if cache != None: return cache + cache = self.fetchInfoCache(idpackage,'retrieveLicense') + if cache != None: return cache - self.cursor.execute('SELECT license FROM baseinfo,licenses WHERE baseinfo.idpackage = (?) and baseinfo.idlicense = licenses.idlicense', (idpackage,)) - licname = self.cursor.fetchone()[0] + self.cursor.execute('SELECT license FROM baseinfo,licenses WHERE baseinfo.idpackage = (?) and baseinfo.idlicense = licenses.idlicense', (idpackage,)) + licname = self.cursor.fetchone()[0] - self.storeInfoCache(idpackage,'retrieveLicense',licname) - return licname + self.storeInfoCache(idpackage,'retrieveLicense',licname) + return licname def retrieveCompileFlags(self, idpackage): - cache = self.fetchInfoCache(idpackage,'retrieveCompileFlags') - if cache != None: return cache + cache = self.fetchInfoCache(idpackage,'retrieveCompileFlags') + if cache != None: return cache - self.cursor.execute('SELECT "idflags" FROM extrainfo WHERE idpackage = (?)', (idpackage,)) - idflag = self.cursor.fetchone()[0] - # now get the flags - self.cursor.execute('SELECT chost,cflags,cxxflags FROM flags WHERE idflags = (?)', (idflag,)) + self.cursor.execute('SELECT "idflags" FROM extrainfo WHERE idpackage = (?)', (idpackage,)) + idflag = self.cursor.fetchone()[0] + # now get the flags + self.cursor.execute('SELECT chost,cflags,cxxflags FROM flags WHERE idflags = (?)', (idflag,)) flags = self.cursor.fetchone() if not flags: flags = ("N/A","N/A","N/A") - self.storeInfoCache(idpackage,'retrieveCompileFlags',flags) - return flags + self.storeInfoCache(idpackage,'retrieveCompileFlags',flags) + return flags def retrieveDepends(self, idpackage): - # sanity check on the table - sanity = self.isDependsTableSane() - if not sanity: # is empty, need generation + # sanity check on the table + sanity = self.isDependsTableSane() + if not sanity: # is empty, need generation self.regenerateDependsTable(output = False) - self.cursor.execute('SELECT dependencies.idpackage FROM dependstable,dependencies WHERE dependstable.idpackage = (?) and dependstable.iddependency = dependencies.iddependency', (idpackage,)) - result = self.fetchall2set(self.cursor.fetchall()) + self.cursor.execute('SELECT dependencies.idpackage FROM dependstable,dependencies WHERE dependstable.idpackage = (?) and dependstable.iddependency = dependencies.iddependency', (idpackage,)) + result = self.fetchall2set(self.cursor.fetchall()) - return result + return result # You must provide the full atom to this function # WARNING: this function does not support branches # NOTE: server side uses this regardless branch specification because it already handles it in updatePackage() def isPackageAvailable(self,pkgatom): - pkgatom = entropyTools.removePackageOperators(pkgatom) - self.cursor.execute('SELECT idpackage FROM baseinfo WHERE atom = (?)', (pkgatom,)) - result = self.cursor.fetchone() - if result: - return result[0] - return -1 + pkgatom = entropyTools.removePackageOperators(pkgatom) + self.cursor.execute('SELECT idpackage FROM baseinfo WHERE atom = (?)', (pkgatom,)) + result = self.cursor.fetchone() + if result: + return result[0] + return -1 def isIDPackageAvailable(self,idpackage): - self.cursor.execute('SELECT idpackage FROM baseinfo WHERE idpackage = (?)', (idpackage,)) - result = self.cursor.fetchone() - if not result: - return False - return True + self.cursor.execute('SELECT idpackage FROM baseinfo WHERE idpackage = (?)', (idpackage,)) + result = self.cursor.fetchone() + if not result: + return False + return True # This version is more specific and supports branches def isSpecificPackageAvailable(self, pkgkey, branch): - pkgkey = entropyTools.removePackageOperators(pkgkey) - self.cursor.execute('SELECT idpackage FROM baseinfo WHERE atom = (?) AND branch = (?)', (pkgkey,branch,)) - result = self.cursor.fetchone() - if not result: - return False - return True + pkgkey = entropyTools.removePackageOperators(pkgkey) + self.cursor.execute('SELECT idpackage FROM baseinfo WHERE atom = (?) AND branch = (?)', (pkgkey,branch,)) + result = self.cursor.fetchone() + if not result: + return False + return True def isCategoryAvailable(self,category): - self.cursor.execute('SELECT idcategory FROM categories WHERE category = (?)', (category,)) - result = self.cursor.fetchone() - if not result: - return -1 - return result[0] + self.cursor.execute('SELECT idcategory FROM categories WHERE category = (?)', (category,)) + result = self.cursor.fetchone() + if not result: + return -1 + return result[0] def isProtectAvailable(self,protect): - self.cursor.execute('SELECT idprotect FROM configprotectreference WHERE protect = (?)', (protect,)) - result = self.cursor.fetchone() - if not result: - return -1 - return result[0] + self.cursor.execute('SELECT idprotect FROM configprotectreference WHERE protect = (?)', (protect,)) + result = self.cursor.fetchone() + if not result: + return -1 + return result[0] def isFileAvailable(self, file, extended = False): self.createContentIndex() # FIXME: remove this with 1.0 + if extended: self.cursor.execute('SELECT * FROM content WHERE file = (?)', (file,)) else: self.cursor.execute('SELECT idpackage FROM content WHERE file = (?)', (file,)) - result = self.cursor.fetchone() - if not result: + result = self.cursor.fetchone() + if not result: if extended: return False,() else: diff --git a/libraries/entropy.py b/libraries/entropy.py index 93a802463..f5a05b98e 100644 --- a/libraries/entropy.py +++ b/libraries/entropy.py @@ -2690,6 +2690,7 @@ class PackageInterface: shutil.copystat(imagepathDir,rootdir) for item in files: + fromfile = currentdir+"/"+item tofile = etpConst['systemroot']+fromfile[len(imageDir):] fromfile_encoded = fromfile @@ -2814,7 +2815,10 @@ class PackageInterface: pass # this also handles symlinks - shutil.move(fromfile_encoded,tofile_encoded) + # XXX + # XXX moving file using the raw format like portage does + # XXX + shutil.move(fromfile_encoded,tofile) except IOError,(errno,strerror): if errno == 2: @@ -2823,6 +2827,7 @@ class PackageInterface: else: rc = os.system("mv "+fromfile+" "+tofile) if (rc != 0): + print "ERRRRRRRRRROR" return 4 if (protected): # add to disk cache diff --git a/libraries/entropyTools.py b/libraries/entropyTools.py index 226e02817..6874e074c 100644 --- a/libraries/entropyTools.py +++ b/libraries/entropyTools.py @@ -1629,29 +1629,29 @@ def quickpkg(pkgdata, dirpath, edb = True, portdbPath = None, fake = False, comp # collect files for path in contents: + import pdb; pdb.set_trace() # convert back to filesystem str encoded_path = path path = path.encode('raw_unicode_escape') try: - exist = os.lstat(path) + exist = os.lstat(encoded_path) except OSError, e: continue # skip file - lpath = path arcname = path[1:] # remove trailing / ftype = pkgdata['content'][encoded_path] if str(ftype) == '0': ftype = 'dir' # force match below, '0' means databases without ftype if 'dir' == ftype and \ not stat.S_ISDIR(exist.st_mode) and \ - os.path.isdir(lpath): # workaround for directory symlink issues - lpath = os.path.realpath(lpath) + os.path.isdir(encoded_path): # workaround for directory symlink issues + lpath = os.path.realpath(encoded_path) - tarinfo = tar.gettarinfo(lpath, arcname) + tarinfo = tar.gettarinfo(encoded_path, arcname) tarinfo.uname = id_strings.setdefault(tarinfo.uid, str(tarinfo.uid)) tarinfo.gname = id_strings.setdefault(tarinfo.gid, str(tarinfo.gid)) if stat.S_ISREG(exist.st_mode): tarinfo.type = tarfile.REGTYPE - f = open(path) + f = open(encoded_path) try: tar.addfile(tarinfo, f) finally: @@ -1718,20 +1718,20 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje package = package.split(".tbz2")[0] package = remove_entropy_revision(package) package = remove_tag(package) - + # FIXME: deprecated - will be removed soonly if package.split("-")[len(package.split("-"))-1].startswith("t"): package = '-t'.join(package.split("-t")[:-1]) - + package = package.split("-") pkgname = "" pkglen = len(package) if package[pkglen-1].startswith("r"): pkgver = package[pkglen-2]+"-"+package[pkglen-1] - pkglen -= 2 + pkglen -= 2 else: - pkgver = package[len(package)-1] - pkglen -= 1 + pkgver = package[len(package)-1] + pkglen -= 1 for i in range(pkglen): if i == pkglen-1: pkgname += package[i] @@ -1872,7 +1872,7 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje outcontent.sort() for i in outcontent: data['content'][i[0]] = i[1] - + except IOError: if inject: # CONTENTS is not generated when a package is emerged with portage and the option -B # we have to unpack the tbz2 and generate content dict @@ -1882,7 +1882,6 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje shutil.rmtree(mytempdir) if not os.path.isdir(mytempdir): os.makedirs(mytempdir) - mytempdir = mytempdir.encode(sys.getfilesystemencoding()) uncompressTarBz2(filepath, extractPath = mytempdir, catchEmpty = True) for currentdir, subdirs, files in os.walk(mytempdir): @@ -1900,7 +1899,6 @@ def extractPkgData(package, etpBranch = etpConst['branch'], silent = False, inje os.rmdir(mytempdir) except: pass - pass # files size on disk if (data['content']): diff --git a/libraries/reagentTools.py b/libraries/reagentTools.py index f70efbed4..6e0978b4e 100644 --- a/libraries/reagentTools.py +++ b/libraries/reagentTools.py @@ -121,18 +121,18 @@ def update(options): repackageItems = [] _options = [] for opt in options: - if opt.startswith("--seekstore"): - reagentRequestSeekStore = True - elif opt.startswith("--repackage"): - reagentRequestRepackage = True - elif opt.startswith("--noask"): - reagentRequestAsk = False - else: - if (reagentRequestRepackage) and (not opt.startswith("--")): - if not opt in repackageItems: - repackageItems.append(opt) - continue - _options.append(opt) + if opt.startswith("--seekstore"): + reagentRequestSeekStore = True + elif opt.startswith("--repackage"): + reagentRequestRepackage = True + elif opt.startswith("--noask"): + reagentRequestAsk = False + else: + if (reagentRequestRepackage) and (not opt.startswith("--")): + if not opt in repackageItems: + repackageItems.append(opt) + continue + _options.append(opt) options = _options if (not reagentRequestSeekStore):