updates to support new content layout
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@674 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
+46
-18
@@ -582,13 +582,26 @@ class etpDatabase:
|
||||
|
||||
# content, a list
|
||||
for file in etpData['content']:
|
||||
self.cursor.execute(
|
||||
'INSERT into content VALUES '
|
||||
'(?,?)'
|
||||
, ( idpackage,
|
||||
file,
|
||||
)
|
||||
)
|
||||
contenttype = etpData['content'][file]
|
||||
try:
|
||||
self.cursor.execute(
|
||||
'INSERT into content VALUES '
|
||||
'(?,?,?)'
|
||||
, ( idpackage,
|
||||
file,
|
||||
contenttype,
|
||||
)
|
||||
)
|
||||
except:
|
||||
self.createContentTypeColumn()
|
||||
self.cursor.execute(
|
||||
'INSERT into content VALUES '
|
||||
'(?,?,?)'
|
||||
, ( idpackage,
|
||||
file,
|
||||
contenttype,
|
||||
)
|
||||
)
|
||||
|
||||
# counter, if != -1
|
||||
try:
|
||||
@@ -1504,7 +1517,10 @@ class etpDatabase:
|
||||
data['mirrorlinks'].append([mirror,mirrorlinks])
|
||||
|
||||
data['slot'] = mydata[14]
|
||||
data['content'] = self.retrieveContent(idpackage)
|
||||
mycontent = self.retrieveContent(idpackage, extended = True)
|
||||
data['content'] = {}
|
||||
for cdata in mycontent:
|
||||
data['content'][cdata[0]] = cdata[1]
|
||||
|
||||
data['dependencies'] = self.retrieveDependencies(idpackage)
|
||||
data['provide'] = self.retrieveProvide(idpackage)
|
||||
@@ -1949,20 +1965,26 @@ class etpDatabase:
|
||||
'''
|
||||
return sources
|
||||
|
||||
def retrieveContent(self, idpackage):
|
||||
def retrieveContent(self, idpackage, extended = False):
|
||||
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"retrieveContent: retrieving Content for package ID "+str(idpackage))
|
||||
|
||||
''' caching
|
||||
cache = self.fetchInfoCache(idpackage,'retrieveContent')
|
||||
if cache != None: return cache
|
||||
'''
|
||||
extstring = ''
|
||||
if extended:
|
||||
extstring = ",type"
|
||||
|
||||
self.cursor.execute('SELECT "file" FROM content WHERE idpackage = "'+str(idpackage)+'"')
|
||||
fl = self.fetchall2set(self.cursor.fetchall())
|
||||
try:
|
||||
self.cursor.execute('SELECT "file'+extstring+'" FROM content WHERE idpackage = "'+str(idpackage)+'"')
|
||||
except:
|
||||
if extended:
|
||||
self.createContentTypeColumn()
|
||||
self.cursor.execute('SELECT "file'+extstring+'" FROM content WHERE idpackage = "'+str(idpackage)+'"')
|
||||
else:
|
||||
raise
|
||||
if extended:
|
||||
fl = self.cursor.fetchall()
|
||||
else:
|
||||
fl = self.fetchall2set(self.cursor.fetchall())
|
||||
|
||||
''' caching
|
||||
self.storeInfoCache(idpackage,'retrieveContent',fl)
|
||||
'''
|
||||
return fl
|
||||
|
||||
def retrieveSlot(self, idpackage):
|
||||
@@ -2711,6 +2733,12 @@ class etpDatabase:
|
||||
self.cursor.execute('CREATE TABLE sizes ( idpackage INTEGER, size INTEGER );')
|
||||
self.commitChanges()
|
||||
|
||||
def createContentTypeColumn(self):
|
||||
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"createContentTypeColumn: called.")
|
||||
self.cursor.execute('ALTER TABLE content ADD COLUMN type VARCHAR;')
|
||||
self.cursor.execute('UPDATE content SET type = "0"')
|
||||
self.commitChanges()
|
||||
|
||||
def createTriggerTable(self):
|
||||
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"createTriggerTable: called.")
|
||||
self.cursor.execute('CREATE TABLE triggers ( idpackage INTEGER PRIMARY KEY, data BLOB );')
|
||||
|
||||
@@ -73,6 +73,8 @@ DROP TABLE IF EXISTS etpData;
|
||||
DROP TABLE IF EXISTS baseinfo;
|
||||
DROP TABLE IF EXISTS extrainfo;
|
||||
DROP TABLE IF EXISTS content;
|
||||
DROP TABLE IF EXISTS contentreference;
|
||||
DROP TABLE IF EXISTS contenttypes;
|
||||
DROP TABLE IF EXISTS dependencies;
|
||||
DROP TABLE IF EXISTS rundependencies;
|
||||
DROP TABLE IF EXISTS rundependenciesxt;
|
||||
@@ -138,7 +140,8 @@ CREATE TABLE extrainfo (
|
||||
|
||||
CREATE TABLE content (
|
||||
idpackage INTEGER,
|
||||
file VARCHAR
|
||||
file VARCHAR,
|
||||
type VARCHAR
|
||||
);
|
||||
|
||||
CREATE TABLE provide (
|
||||
|
||||
@@ -1224,7 +1224,7 @@ def quickpkg(pkgdata,dirpath):
|
||||
lpath = path
|
||||
arcname = path[1:] # remove trailing /
|
||||
ftype = pkgdata['content'][path]
|
||||
if ftype == '0': ftype = 'dir' # force match below, '0' means databases without ftype
|
||||
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
|
||||
|
||||
+10
-14
@@ -450,27 +450,23 @@ def extractPkgData(package, etpBranch = etpConst['branch']):
|
||||
datafile = datafile[:-3]
|
||||
datafile = ' '.join(datafile)
|
||||
else:
|
||||
print "unhandled",datafile
|
||||
datafile = datafile[0]
|
||||
print "unhandled !!!!!!!",datafile
|
||||
raise Exception
|
||||
outcontent.add((datafile,datatype))
|
||||
except:
|
||||
pass
|
||||
|
||||
# filter bad utf-8 chars
|
||||
# convert to plain str() since it's that's used by portage
|
||||
# when portage will use utf, test utf-8 encoding
|
||||
_outcontent = set()
|
||||
for i in outcontent:
|
||||
try:
|
||||
datatype = i[1]
|
||||
datafile = i[0]
|
||||
datafile = datafile.encode(getfilesystemencoding())
|
||||
_outcontent.add(i)
|
||||
except:
|
||||
pass
|
||||
outcontent = _outcontent
|
||||
outcontent = list(outcontent)
|
||||
datatype = i[1]
|
||||
datafile = str(i[0])
|
||||
_outcontent.add((i[0],i[1]))
|
||||
outcontent = list(_outcontent)
|
||||
outcontent.sort()
|
||||
for i in outcontent:
|
||||
etpData['content'][i[0].encode(getfilesystemencoding())] = i[1]
|
||||
etpData['content'][str(i[0])] = i[1]
|
||||
|
||||
except IOError:
|
||||
pass
|
||||
@@ -892,7 +888,7 @@ def database(options):
|
||||
# initialize the database
|
||||
dbconn = databaseTools.openServerDatabase(readOnly = False, noUpload = True)
|
||||
dbconn.initializeDatabase()
|
||||
|
||||
|
||||
# sync packages directory
|
||||
if revisionsMatch:
|
||||
print_info(green(" * ")+red("Dumping current revisions to file ")+"/entropy-revisions-dump.txt")
|
||||
|
||||
Reference in New Issue
Block a user