summaryrefslogtreecommitdiffstats
path: root/presto.py
diff options
context:
space:
mode:
Diffstat (limited to 'presto.py')
-rw-r--r--presto.py104
1 files changed, 33 insertions, 71 deletions
diff --git a/presto.py b/presto.py
index 60e391c..b270212 100644
--- a/presto.py
+++ b/presto.py
@@ -30,6 +30,7 @@ from prestoRepo import PrestoRepository
from prestomdparser import PrestoMDParser
import prestoTransaction
import prestoLog
+import prestoDownload
requires_api_version = '2.1'
LOG_FILE = "/var/log/presto.log"
@@ -37,7 +38,7 @@ plugin_type = (TYPE_INTERACTIVE,)
rpm_size = 0
drpm_size = 0
-was_drpm = False
+drpm_count = 0
# Configuration stuff
def config_hook(conduit):
@@ -75,7 +76,7 @@ def postreposetup_hook(conduit):
def postresolve_hook(conduit):
global rpm_size
global drpm_size
- global was_drpm
+ global drpm_count
opts, commands = conduit.getCmdLine()
if not opts.disablepresto:
@@ -87,31 +88,24 @@ def postresolve_hook(conduit):
# If a drpm was found, change certain package information so it reflects
# the drpm, not the rpm.
if chosen_drpm != None:
- was_drpm = True
- rpm_size += int(newpkg.po.simple['packagesize'])
+ newpkg.po.has_drpm = True
+ conduit.info(2, "Found deltarpm update for %s.%s %s:%s-%s" % (newpkg.name, newpkg.arch, newpkg.epoch, newpkg.version, newpkg.release))
+ # In yum 3.0.x, this doesn't get defined if you run "yum update x" rather than "yum update"
+ rpm_size += int(newpkg.po.size)
drpm_size += int(chosen_drpm['size'])
- newpkg.po.hasdrpm = True
- newpkg.po.simple['basepath'] = chosen_drpm['baseurl']
- newpkg.po.simple['realpackagesize'] = newpkg.po.simple['packagesize']
+ newpkg.po.simple['realpackagesize'] = newpkg.po.size
newpkg.po.simple['packagesize'] = chosen_drpm['size']
- newpkg.po.simple['realrelativepath'] = newpkg.po.simple['relativepath']
- newpkg.po.simple['relativepath'] = chosen_drpm['drpm_filename']
- newpkg.po.reallocalpath = newpkg.po.localpath
- newpkg.po.localpath = newpkg.po.repo.deltasdir + "/" + os.path.basename(chosen_drpm['drpm_filename'])
+ newpkg.po.simple['deltasize'] = chosen_drpm['size']
+ newpkg.po.simple['deltarelativepath'] = chosen_drpm['drpm_filename']
+ newpkg.po.simple['deltachecksumtype'] = chosen_drpm['checksum_type']
+ newpkg.po.simple['deltachecksum'] = chosen_drpm['checksum']
+ newpkg.po.simple['deltalocalpath'] = newpkg.po.repo.deltasdir + "/" + os.path.basename(chosen_drpm['drpm_filename'])
newpkg.po.to = newpkg
newpkg.realpkgtup = newpkg.pkgtup
newpkg.pkgtup = (newpkg.name + " *", newpkg.arch, newpkg.epoch, newpkg.version, newpkg.release)
- for (csum_type, csum, csumid) in newpkg.po._checksums:
- if csumid:
- newpkg.po._realchecksum = (csum_type, csum, csumid)
- newpkg.po._checksums.remove((csum_type, csum, csumid))
- csum_type = chosen_drpm['checksum_type']
- csum = chosen_drpm['checksum']
- newpkg.po._checksums.append((csum_type, csum, csumid))
-
- conduit.info(2, "Found deltarpm update for %s.%s %s:%s.%s" % (newpkg.name, newpkg.arch, newpkg.epoch, newpkg.version, newpkg.release))
+ newpkg.po.hasdrpm = True
+ drpm_count += 1
else:
- newpkg.po.hasdrpm = False
if installed and drpm_enabled and not local:
try:
rpm_size += int(newpkg.po.simple['packagesize'])
@@ -120,59 +114,27 @@ def postresolve_hook(conduit):
pass
return
- # Free up memory used by deleting Presto repositories
- for active_repo in conduit.getRepos().listEnabled():
- if active_repo.p_repo.enabled:
- del active_repo.p_repo
-def postdownload_hook(conduit):
- global was_drpm
+def predownload_hook(conduit):
+ global drpm_count
+
+ pkglist = conduit.getDownloadPackages()
opts, commands = conduit.getCmdLine()
- if not opts.disablepresto and was_drpm:
- failure = False
- # Cycle through packages to see if we've downloaded a deltarpm
- conduit.info(2, "Rebuilding full packages from deltas")
- for pkg in conduit.getDownloadPackages():
- if pkg.hasdrpm and pkg.verifyLocalPkg():
- # Apply deltarpm and save where rpm would have been saved
- drpm = deltarpm.DeltaRpmWrapper(conduit)
- this_failure = False
- try:
- drpm.apply(pkg.reallocalpath, pkg.localpath)
- except:
- conduit.info(2, "Error rebuilding rpm from %s!" % pkg.localpath)
- failure = True
- this_failure = True
- if not this_failure:
- drpm_path = pkg.localpath
-
- # Change package information to reflect original rpm information
- pkg.to.pkgtup = pkg.to.realpkgtup
- pkg.localpath = pkg.reallocalpath
- pkg.simple['packagesize'] = pkg.simple['realpackagesize']
- del pkg.simple['basepath']
- for (csum_type, csum, csumid) in pkg._checksums:
- if csumid:
- pkg._checksums.remove((csum_type, csum, csumid))
- pkg._checksums.append(pkg._realchecksum)
-
- # Check to see whether or not we should keep the drpms
- # FIXME: Is there any way to see whether or not a Boolean option was not set?
- if conduit.confBool('main', 'neverkeepdeltas'):
- delete = True
- elif conduit.confBool('main', 'keepdeltas'):
- delete = False
- elif conduit.getConf().keepcache != 0:
- delete = False
- else:
- delete = True
-
- if delete:
- os.unlink(drpm_path)
-
- if failure:
- raise PluginYumExit("Error rebuilding at least one deltarpm. Please report this error to\nhttp://hosted.fedoraproject.org/projects/presto/newticket. To bypass this problem, run yum \nwith the --disablepresto option")
+ if not opts.disablepresto and drpm_count > 0:
+ # Download deltarpms
+ problems = prestoDownload.downloadPkgs(conduit, pkglist)
+
+ # If 'exitondownloaderror' is on, exit
+ if conduit.confBool('main', 'exitondownloaderror') and len(problems.keys()) > 0:
+ errstring = ''
+ errstring += 'Error Downloading Packages:\n'
+ for key in problems.keys():
+ errors = misc.unique(problems[key])
+ for error in errors:
+ errstring += ' %s: %s\n' % (key, error)
+ raise PluginYumExit(errstring)
+
def posttrans_hook(conduit):
global rpm_size