summaryrefslogtreecommitdiffstats
path: root/createprestorepo/gendeltarpms.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/gendeltarpms.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/gendeltarpms.py')
-rwxr-xr-xcreateprestorepo/gendeltarpms.py59
1 files changed, 43 insertions, 16 deletions
diff --git a/createprestorepo/gendeltarpms.py b/createprestorepo/gendeltarpms.py
index fc4a9ca..26d795b 100755
--- a/createprestorepo/gendeltarpms.py
+++ b/createprestorepo/gendeltarpms.py
@@ -105,7 +105,7 @@ def getFileList(path, ext, filelist):
return filelist
-def createPrestoRepo(base_dir, drpm_dir):
+def createPrestoRepo(base_dir, drpm_dir, dst_dir=None):
ts = rpmUtils.transaction.initReadOnlyTransaction()
changed = False
@@ -115,11 +115,18 @@ def createPrestoRepo(base_dir, drpm_dir):
print 'Using destination dir: %s' % drpm_dir
rpm_files = getFileList(base_dir, ".rpm", [])
- drpm_files = getFileList(base_dir, ".drpm", [])
+ if dst_dir != None:
+ dst_rpm_files = getFileList(dst_dir, ".rpm", [])
+ drpm_files = getFileList(drpm_dir, ".drpm", [])
+
if not len(rpm_files):
print ' Nothing found.'
return changed
+ if dst_dir != None and not len(dst_rpm_files):
+ print ' No new rpms found.'
+ return changed
+
# Check whether rel_dir exists, and if it doesn't, create it
if not os.access(drpm_dir, os.F_OK):
os.makedirs(drpm_dir, 0755)
@@ -144,6 +151,24 @@ def createPrestoRepo(base_dir, drpm_dir):
rpm = RpmItem(nevra, f)
rpm_list.addRpm(rpm)
+ # If we have a new distro, add its rpms with epoch bumped +5
+ if dst_dir != None:
+ for f in dst_rpm_files:
+ try:
+ hdr = rpmUtils.miscutils.hdrFromPackage(ts, f)
+ except:
+ print "Unable to open %s" % f
+ else:
+ nm = hdr['name'] + "." + hdr['arch']
+ e = hdr['epoch']
+ if e is None:
+ e = "0"
+ e = str(int(e) + 5)
+
+ nevra = (hdr['name'], e, hdr['version'], hdr['release'], hdr['arch'])
+ rpm = RpmItem(nevra, f)
+ rpm_list.addRpm(rpm)
+
# Add all deltarpms to PackageList
for f in drpm_files:
try:
@@ -167,23 +192,25 @@ def createPrestoRepo(base_dir, drpm_dir):
rpm_list.dump()
# Build deltarpms
- rpm_list.makeDeltaRpms()
-
-def main(bin_rpm_path, delta_rpm_path):
- assert rpmUtils.miscutils.compareEVR((1,2,3),(1,2,0)) > 0
- assert rpmUtils.miscutils.compareEVR((0,1,2),(0,1,2)) == 0
- assert rpmUtils.miscutils.compareEVR((1,2,3),(4,0,99)) < 0
-
- return createPrestoRepo(bin_rpm_path, delta_rpm_path)
-
+ if dst_dir != None:
+ rpm_list.makeDeltaRpms(DrpmsPerPackage=1, DoFirst=False)
+ else:
+ rpm_list.makeDeltaRpms(DrpmsPerPackage=5)
if __name__ == '__main__':
- if len(sys.argv) < 2:
- print 'Usage: %s <bin_rpm_dir> <delta_rpm_dir> \n' % os.path.basename(sys.argv[0])
+ if len(sys.argv) < 2 or (sys.argv[1] == "-d" and len(sys.argv) < 4):
+ print 'Usage: %s <bin_rpm_dir> <delta_rpm_dir>' % os.path.basename(sys.argv[0])
+ print ' %s -d <old_dist_dir> <new_dist_dir> <delta_rpm_dir>' % os.path.basename(sys.argv[0])
sys.exit(errno.EINVAL)
- bin_rpm_path = sys.argv[1]
- delta_rpm_path = sys.argv[2]
+ if sys.argv[1] != "-d":
+ bin_rpm_path = sys.argv[1]
+ delta_rpm_path = sys.argv[2]
+ createPrestoRepo(bin_rpm_path, delta_rpm_path)
+ else:
+ src_bin_rpm_path = sys.argv[2]
+ dst_bin_rpm_path = sys.argv[3]
+ delta_rpm_path = sys.argv[4]
+ createPrestoRepo(src_bin_rpm_path, delta_rpm_path, dst_bin_rpm_path)
- main(bin_rpm_path, delta_rpm_path)
sys.exit(0)