From 72487bb5f12f8d4582b42ee76a0be905601fcd86 Mon Sep 17 00:00:00 2001 From: lxnay Date: Thu, 29 Mar 2007 21:36:08 +0000 Subject: [PATCH] add back revision support to the new database git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@229 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/activatorTools.py | 22 ++++------------------ libraries/databaseTools.py | 21 +++++++++++++++++++-- libraries/entropyConstants.py | 1 + 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/libraries/activatorTools.py b/libraries/activatorTools.py index 33300b0a9..f9c387590 100644 --- a/libraries/activatorTools.py +++ b/libraries/activatorTools.py @@ -33,23 +33,11 @@ import string def sync(options): - # For each URI do the same thing - for uri in etpConst['activatoruploaduris']: - ftp = activatorFTP(uri) - print "Listing the content of: "+ftp.getFTPHost() - print "at port: "+str(ftp.getFTPPort()) - print "in dir: "+ftp.getFTPDir() - #print ftp.getFileSize("index.htm") - list = ftp.getRoughList() - - #print ftp.spawnFTPCommand("mdtm index.htm") - ftp.closeFTPConnection() - - sys.exit(0) - # sync the local repository with the remote ones syncRemoteDatabases() + sys.exit(0) + print_info(green(" * ")+red("Collecting local binary packages..."),back = True) localtbz2counter = 0 localTbz2Files = [] @@ -195,7 +183,7 @@ def packages(options): uploadQueue = list(set(uploadQueue)) if (len(uploadQueue) == 0) and (len(downloadQueue) == 0) and (len(removalQueue) == 0): - print_info(green(" * ")+red("Nothing to syncronize for ")+bold(extractFTPHostFromUri(uri)+red(". Queues empty."))) + print_info(green(" * ")+red("Nothing to syncronize for ")+bold(extractFTPHostFromUri(uri)+red(". Queue empty."))) continue @@ -267,8 +255,6 @@ def packages(options): counterInfo = bold(" (")+blue(str(currentCounter))+"/"+red(uploadCounter)+bold(")") print_info(counterInfo+red(" Uploading file ")+bold(item[0]) + red(" [")+blue(bytesIntoHuman(item[1]))+red("] to ")+ bold(extractFTPHostFromUri(uri)) +red(" ..."),back = True) ftp.uploadFile(etpConst['packagessuploaddir']+"/"+item[0]) - # now move the file into etpConst['packagesbindir'] - os.system("mv "+etpConst['packagessuploaddir']+"/"+item[0]+" "+etpConst['packagesbindir']+"/") print_info(red(" * Upload completed for ")+bold(extractFTPHostFromUri(uri))) ftp.closeFTPConnection() @@ -296,7 +282,7 @@ def packages(options): print "Now it should be time for some tidy...?" # now we can store the files in upload/%ARCH% in packages/%ARCH% - os.system("mv "+etpConst['packagessuploaddir']+"/* "+etpConst['packagesbindir']+"/") + os.system("mv -f "+etpConst['packagessuploaddir']+"/* "+etpConst['packagesbindir']+"/ &> /dev/null") def database(options): diff --git a/libraries/databaseTools.py b/libraries/databaseTools.py index 52891c5b5..2345f4f0c 100644 --- a/libraries/databaseTools.py +++ b/libraries/databaseTools.py @@ -97,7 +97,8 @@ def database(options): print_info(red("\t CXXFLAGS: ")+darkred(result[7])) if (result[8]): print_info(red("\t Website: ")+result[8]) - print_info(red("\t USE Flags: ")+blue(result[9])) + if (result[9]): + print_info(red("\t USE Flags: ")+blue(result[9])) print_info(red("\t License: ")+bold(result[10])) print_info(red("\t Source keywords: ")+darkblue(result[11])) print_info(red("\t Binary keywords: ")+green(result[12])) @@ -225,12 +226,15 @@ class etpDatabase: self.cursor = self.connection.cursor() def closeDB(self): + if (self.isDatabaseTainted()): + # bump revision + self.revisionBump() self.cursor.close() self.connection.close() def commitChanges(self): - self.taintDatabase() self.connection.commit() + self.taintDatabase() def taintDatabase(self): # taint the database status @@ -243,6 +247,19 @@ class etpDatabase: # untaint the database status os.system("rm -f "+etpConst['etpdatabasedir']+"/"+etpConst['etpdatabasetaintfile']) + def revisionBump(self): + if (not os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaserevisionfile'])): + revision = 0 + else: + f = open(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaserevisionfile'],"r") + revision = int(f.readline().strip()) + revision += 1 + f.close() + f = open(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaserevisionfile'],"w") + f.write(str(revision)+"\n") + f.flush() + f.close() + def isDatabaseTainted(self): if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabasetaintfile']): return True diff --git a/libraries/entropyConstants.py b/libraries/entropyConstants.py index b2f872a58..adbfd91d9 100644 --- a/libraries/entropyConstants.py +++ b/libraries/entropyConstants.py @@ -136,6 +136,7 @@ etpConst = { 'binaryurirelativepath': "packages/"+ETP_ARCH_CONST+"/", # Relative remote path for the binary repository. 'etpurirelativepath': "database/"+ETP_ARCH_CONST+"/", # Relative remote path for the .etp repository. # TO BE REMOVED? CHECK + 'etpdatabaserevisionfile': "packages.db.revision", # the local/remote database revision file 'etpdatabaselockfile': "packages.db.lock", # the remote database lock file 'etpdatabasedownloadlockfile': "packages.db.download.lock", # the remote database download lock file 'etpdatabasetaintfile': "packages.db.tainted", # when this file exists, the database is not synced anymore with the online one