summaryrefslogtreecommitdiffstats
path: root/createprestorepo/packagelist.py
diff options
context:
space:
mode:
authorJonathan Dieter <jdieter@gmail.com>2007-06-19 16:59:35 +0300
committerJonathan Dieter <jdieter@gmail.com>2007-06-19 16:59:35 +0300
commit93b2295180471308e969640472bdc601d1f10015 (patch)
tree15cd1a0d4ed1789984d6d98b5f1cbac4baf529f7 /createprestorepo/packagelist.py
parentd60f28d66709c0c7fed26d19b1b7fb2c55439507 (diff)
downloadpresto-93b2295180471308e969640472bdc601d1f10015.zip
presto-93b2295180471308e969640472bdc601d1f10015.tar.gz
presto-93b2295180471308e969640472bdc601d1f10015.tar.xz
Small changes
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Diffstat (limited to 'createprestorepo/packagelist.py')
-rw-r--r--createprestorepo/packagelist.py51
1 files changed, 37 insertions, 14 deletions
diff --git a/createprestorepo/packagelist.py b/createprestorepo/packagelist.py
index 5482572..c057f3f 100644
--- a/createprestorepo/packagelist.py
+++ b/createprestorepo/packagelist.py
@@ -60,7 +60,7 @@ class DrpmItem:
return (self.dst_name, self.dst_epoch, self.dst_version, self.dst_release, self.dst_arch)
def getSrcDstNevra(self):
- return [getSrcNevra(), getDstNevra()]
+ return [self.getSrcNevra(), self.getDstNevra()]
def __eq__(self, b):
if b == None:
@@ -94,7 +94,13 @@ class PackageList:
rpm_key = "%s.%s" % (rpm.name, rpm.arch)
self.rpm_list.setdefault(rpm_key, {})
self.rpm_list[rpm_key].setdefault("rpms", [])
- self.rpm_list[rpm_key]["rpms"].append(rpm)
+ found = False
+ for found_rpm in self.rpm_list[rpm_key]["rpms"]:
+ if rpm == found_rpm:
+ found = True
+ break
+ if not found:
+ self.rpm_list[rpm_key]["rpms"].append(rpm)
def addDrpm(self, drpm):
"""Add DrpmItem to PackageList"""
@@ -102,7 +108,13 @@ class PackageList:
rpm_key = "%s.%s" % (drpm.src_name, drpm.src_arch)
self.rpm_list.setdefault(rpm_key, {})
self.rpm_list[rpm_key].setdefault("drpms", [])
- self.rpm_list[rpm_key]["drpms"].append(drpm)
+ found = False
+ for found_drpm in self.rpm_list[rpm_key]["drpms"]:
+ if drpm == found_drpm:
+ found = True
+ break
+ if not found:
+ self.rpm_list[rpm_key]["drpms"].append(drpm)
def sort(self):
"""Sort all rpms and deltarpms in reverse order. This is necessary before running any
@@ -186,10 +198,9 @@ class PackageList:
(code, out) = commands.getstatusoutput(deltaCommand)
if code:
- #raise Exception("genDeltaRPM: exitcode was %s - Reported Error: %s" % (code, out))
print "Error genDeltaRPM for %s: exitcode was %s - Reported Error: %s" % (n1, code, out)
return False
- else:
+ else:
# Check whether or not we should keep the drpm
drpmsize = os.path.getsize(deltaRPMName)
if not self.__drpmIsWorthKeeping(drpmsize, f1):
@@ -261,11 +272,12 @@ class PackageList:
return False
- def makeDeltaRpms(self, OnlyLastPackage=True, DrpmsPerPackage=0):
+ def makeDeltaRpms(self, DrpmsPerPackage=0, OnlyLastPackage=True, DoFirst=True):
"""Create deltarpms for packages.
Attributes:
- OnlyLastPackage (Boolean): Only create deltarpms for last package
- DrpmsPerPackage (Int): Number of deltarpms to make for each package (0 = all possible)"""
+ OnlyLastPackage (Boolean): Only create deltarpms to point to last destination package
+ DrpmsPerPackage (Int): Number of deltarpms to make for each package (0 = all possible)
+ DoFirst (Boolean): Create deltarpm for first source package"""
if not self.sorted:
self.sort()
temp_list = []
@@ -341,19 +353,30 @@ class PackageList:
newpkg_list.append(rpm)
for newpkg in newpkg_list:
- start = False
- count = 0
- for build in build_list:
+ start = False
+ count = 0
+ do_last = True
+ for build in build_list[:-1]:
if start:
self.__makeDeltaRpm(build[0], newpkg, package)
if not self.sorted:
self.sort()
count += 1
- if count > DrpmsPerPackage and DrpmsPerPackage != 0:
- break
+ if DrpmsPerPackage != 0:
+ if count >= DrpmsPerPackage and not DoFirst:
+ do_last = False
+ break
+ elif count >= DrpmsPerPackage - 1 and DoFirst:
+ break
if build[0] == newpkg.getNevra():
start = True
-
+
+ if DoFirst == 1 and start and do_last:
+ self.__makeDeltaRpm(build_list[-1][0], newpkg, package)
+ if not self.sorted:
+ self.sort()
+ return
+
def __drpmIsWorthKeeping(self, drpmsize, newrpm):
newsize = os.path.getsize(newrpm)
# Delete the drpm if it's too large