diff options
Diffstat (limited to 'shared/prestoTransaction.py')
-rw-r--r-- | shared/prestoTransaction.py | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/shared/prestoTransaction.py b/shared/prestoTransaction.py index bd3bfa1..15ad928 100644 --- a/shared/prestoTransaction.py +++ b/shared/prestoTransaction.py @@ -28,39 +28,48 @@ def find_available_drpms(conduit, newpkg): p_repo = newpkg.po.repo.p_repo chosen_drpm = None - if p_repo.enabled: - # Don't try to download deltarpm if full rpm already exists - if not os.path.exists(newpkg.po.localpath): - # First part of key when matching drpms - key1 = "%s*%s*%i*%s*%s" % (newpkg.name, newpkg.arch, int(newpkg.epoch), newpkg.version, newpkg.release) - - # Find any installed packages that match the ones we want to download - installed = rpmdb.searchNevra(newpkg.name, None, None, None, newpkg.arch) + # First part of key when matching drpms + key1 = "%s*%s*%i*%s*%s" % (newpkg.name, newpkg.arch, int(newpkg.epoch), newpkg.version, newpkg.release) + + # Find any installed packages that match the ones we want to download + installed = rpmdb.searchNevra(newpkg.name, None, None, None, newpkg.arch) - for oldpkg in installed: - # Generate second part of key for matching drpms, then full key - key2 = "%s*%s*%i*%s*%s" % (oldpkg.name, oldpkg.arch, int(oldpkg.epoch), oldpkg.version, oldpkg.release) - key = "%s!!%s" % (key1, key2) + if installed == []: + is_installed = False + else: + is_installed = True + + if os.path.exists(newpkg.po.localpath): + is_local = True + else: + is_local = False + + if is_installed and p_repo.enabled and not is_local: + for oldpkg in installed: + # Generate second part of key for matching drpms, then full key + key2 = "%s*%s*%i*%s*%s" % (oldpkg.name, oldpkg.arch, int(oldpkg.epoch), oldpkg.version, oldpkg.release) + key = "%s!!%s" % (key1, key2) + + # Check whether we have a matching drpm + if p_repo.deltalist.has_key(key): + # Check whether or not we already have a matching drpm, then choose smallest of the two if we do + if chosen_drpm == None or p_repo.deltalist[key]['size'] < chosen_drpm['size']: - # Check whether we have a matching drpm - if p_repo.deltalist.has_key(key): - # Check whether or not we already have a matching drpm, then choose smallest of the two if we do - if chosen_drpm == None or p_repo.deltalist[key]['size'] < chosen_drpm['size']: + # Get sequence code for drpm + sequence = p_repo.deltalist[key]['sequence'] + if int(oldpkg.epoch) == 0: + seq = "%s-%s-%s-%s" % (oldpkg.name, oldpkg.version, oldpkg.release, sequence) + else: + seq = "%s-%i:%s-%s-%s" % (oldpkg.name, int(oldpkg.epoch), oldpkg.version, oldpkg.release, sequence) + drpm = deltarpm.DeltaRpmWrapper(conduit) - # Get sequence code for drpm - sequence = p_repo.deltalist[key]['sequence'] - if int(oldpkg.epoch) == 0: - seq = "%s-%s-%s-%s" % (oldpkg.name, oldpkg.version, oldpkg.release, sequence) - else: - seq = "%s-%i:%s-%s-%s" % (oldpkg.name, int(oldpkg.epoch), oldpkg.version, oldpkg.release, sequence) - drpm = deltarpm.DeltaRpmWrapper(conduit) - - # Attempt to apply sequence code for drpm. If this fails, drpm will not apply cleanly, so - # don't even try to download it. - try: - drpm.verifySequence(seq) - chosen_drpm = p_repo.deltalist[key] - chosen_drpm['baseurl'] = p_repo.baseurl[0] - except: - conduit.info(5, "Verification of %s failed" % seq) - return chosen_drpm + # Attempt to apply sequence code for drpm. If this fails, drpm will not apply cleanly, so + # don't even try to download it. + try: + drpm.verifySequence(seq) + chosen_drpm = p_repo.deltalist[key] + chosen_drpm['baseurl'] = p_repo.baseurl[0] + except: + conduit.info(5, "Verification of %s failed" % seq) + + return (chosen_drpm, installed, is_local) |