From c13b695498cb60e338a4a815fbd64f2631d330c0 Mon Sep 17 00:00:00 2001 From: lxnay Date: Sun, 6 Apr 2008 23:48:40 +0000 Subject: [PATCH] - updated TODO Entropy/Server Interface: - more work on activator code migration git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1562 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- TODO | 24 ++-------- libraries/activatorTools.py | 39 --------------- libraries/entropy.py | 96 ++++++++++++++++++++++++++++++++++++- 3 files changed, 100 insertions(+), 59 deletions(-) diff --git a/TODO b/TODO index bd6b8e914..2d674bb32 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,8 @@ TODO list - Server-side code refactoring: - 1st: - [] calculate extra deps from NEEDED, server side? - NEEDED + ldconfig -p - [] write a tool that helps keeping packages updated (also supporting injected ones) - [] complete reagent spm interface - [] write a tool that will rebuild kernel dependant packages - [] GLSA interface, interfaced between packages in repo and the portage tree - 2nd: - [] write a ncurses interface to manage entropy database - - split RDEPEND and PDEPEND ( + && and || ) (*) + [] children repo management + [] write a ncurses interface to manage entropy database + spm interface + GLSA + - split RDEPEND and PDEPEND ( + && and || ??? ) (*) - add i18n support (*) - log messages from portage doebuild() calls @@ -22,9 +16,8 @@ TODO list - find a way to better handle real smartapps deps (need split PDEPEND?) Spritz: - - handle entropy exceptions (*) - - apackage masking menu (*) - - bug reporting interface (*) + - handle entropy exceptions/bug reporting interface (*) + - package masking menu (*) - GLSA interface (*) - applet ignores masks - applet from critical to up to date @@ -33,10 +26,3 @@ TODO list - Skip Mirror buttons - button to stop the queue - show the number of packages found in a list - - -Project Status: -- reagent: complete. -- activator: complete. -============ -- equo - beta stage: 60% \ No newline at end of file diff --git a/libraries/activatorTools.py b/libraries/activatorTools.py index 896cd4265..dbba45c51 100644 --- a/libraries/activatorTools.py +++ b/libraries/activatorTools.py @@ -1263,42 +1263,3 @@ def getEtpRemoteDatabaseStatus(): ftp.closeConnection() return uriDbInfo - -def downloadPackageFromMirror(uri,pkgfile,branch): - - tries = 0 - maxtries = 5 - for i in range(maxtries): - - print_info(red(" * Connecting to ")+bold(Entropy.entropyTools.extractFTPHostFromUri(uri)), back = True) - # connect - ftp = FtpInterface(uri, Entropy) - ftp.setCWD(etpConst['binaryurirelativepath']+"/"+branch) - # get the files - print_info(red(" * Downloading ")+brown(pkgfile)+red(" from ")+bold(Entropy.entropyTools.extractFTPHostFromUri(uri))) - rc = ftp.downloadFile(pkgfile,etpConst['packagesbindir']+"/"+branch) - if (rc is None): - # file does not exist - print_warning(red(" * File ")+brown(pkgfile)+red(" does not exist remotely on ")+bold(Entropy.entropyTools.extractFTPHostFromUri(uri))) - ftp.closeConnection() - return None - # check md5 - dbconn = Entropy.databaseTools.openServerDatabase(readOnly = True, noUpload = True) - idpackage = dbconn.getIDPackageFromDownload(pkgfile,branch) - storedmd5 = dbconn.retrieveDigest(idpackage) - dbconn.closeDB() - print_info(red(" * Checking MD5 of ")+brown(pkgfile)+red(": should be ")+bold(storedmd5), back = True) - md5check = Entropy.entropyTools.compareMd5(etpConst['packagesbindir']+"/"+branch+"/"+pkgfile,storedmd5) - if (md5check): - print_info(red(" * Package ")+brown(pkgfile)+red("downloaded successfully.")) - return True - else: - if (tries == maxtries): - print_warning(red(" * Package ")+brown(pkgfile)+red(" checksum does not match. Please consider to download or repackage again. Giving up.")) - return False - else: - print_warning(red(" * Package ")+brown(pkgfile)+red(" checksum does not match. Trying to download it again...")) - tries += 1 - if os.path.isfile(etpConst['packagesbindir']+"/"+branch+"/"+pkgfile): - os.remove(etpConst['packagesbindir']+"/"+branch+"/"+pkgfile) - diff --git a/libraries/entropy.py b/libraries/entropy.py index d6fa1c4ee..7873630fa 100644 --- a/libraries/entropy.py +++ b/libraries/entropy.py @@ -10770,6 +10770,7 @@ class ServerInterface(TextInterface): etpSys['serverside'] = True self.indexing = False self.xcache = False + self.MirrorsService = None self.FtpInterface = FtpInterface self.serverDbCache = {} self.settings_to_backup = [] @@ -10799,6 +10800,7 @@ class ServerInterface(TextInterface): self.databaseTools = self.ClientService.databaseTools self.entropyTools = self.ClientService.entropyTools self.SpmService = self.ClientService.Spm() + self.MirrorsService = ServerMirrorsInterface(self) def setup_entropy_settings(self): self.settings_to_backup.extend([ @@ -11717,7 +11719,7 @@ class ServerInterface(TextInterface): not_downloaded = set() for pkg in to_download: - rc = activatorTools.downloadPackageFromMirror(uri,pkg[1],pkg[2]) + rc = self.MirrorsService.download_package(uri,pkg[1],pkg[2]) if rc == None: not_downloaded.add((pkg[1],pkg[2])) elif not rc: @@ -12206,3 +12208,95 @@ class ServerMirrorsInterface: lock_file = self.get_database_download_lockfile() if os.path.isfile(lock_file): os.remove(lock_file) + + # was downloadPackageFromMirror + def download_package(self, uri, pkgfile, branch): + + crippled_uri = self.Entropy.entropyTools.extractFTPHostFromUri(uri) + + tries = 0 + while tries < 5: + tries += 1 + + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] connecting to download package: %s" % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "info", + header = darkgreen(" * "), + back = True + ) + + ftp = self.FtpInterface(uri, self.Entropy) + dirpath = os.path.join(etpConst['binaryurirelativepath'],branch) + ftp.setCWD(dirpath) + + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] downloading package: %s" % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "info", + header = darkgreen(" * ") + ) + + download_path = os.path.join(etpConst['packagesserverbindir'],branch) + rc = ftp.downloadFile(pkgfile,download_path) + if not rc: + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] package: %s does not exist" % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "error", + header = darkred(" !!! ") + ) + ftp.closeConnection() + return rc + + dbconn = self.Entropy.openServerDatabase(read_only = True, no_upload = True) + idpackage = dbconn.getIDPackageFromDownload(pkgfile,branch) + if idpackage == -1: + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] package: %s is not listed in the current repository database!!" % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "error", + header = darkred(" !!! ") + ) + ftp.closeConnection() + return 0 + + storedmd5 = dbconn.retrieveDigest(idpackage) + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] verifying checksum of package: %s" % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "info", + header = darkgreen(" * "), + back = True + ) + + pkg_path = os.path.join(download_path,pkgfile) + md5check = self.Entropy.entropyTools.compareMd5(pkg_path,storedmd5) + if md5check: + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] package: %s downloaded successfully" % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "info", + header = darkgreen(" * ") + ) + return True + else: + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] package: %s checksum does not match. re-downloading..." % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "warning", + header = darkred(" * ") + ) + if os.path.isfile(pkg_path): + os.remove(pkg_path) + + continue + + # if we get here it means the files hasn't been downloaded properly + self.Entropy.updateProgress( + red("[repo:%s|mirror:%s|#%s] package: %s seems broken. Consider to re-package it. Giving up!" % (etpConst['officialrepositoryid'],crippled_uri,tries,pkgfile,)), + importance = 1, + type = "error", + header = darkred(" !!! ") + ) + return False \ No newline at end of file