add deltas
authorAnas Nashif <nashif@planux.com>
Mon, 11 Feb 2013 14:04:51 +0000 (09:04 -0500)
committerAnas Nashif <nashif@planux.com>
Mon, 11 Feb 2013 14:04:51 +0000 (09:04 -0500)
TZUP-2013-001-000/delta/libzypp-11.6.2_11.8.0-2.1.2_2.4.1.x86_64.drpm [new file with mode: 0644]
TZUP-2013-001-000/delta/systemd-44-10.4.1_10.8.1.x86_64.drpm [deleted file]
TZUP-2013-001-000/delta/zypper-1.7.3_1.7.8-1.2.2_1.5.1.x86_64.drpm [new file with mode: 0644]
repo/TZUP-2013-001-000.zip
repo/data/3114f5e83faf5fe76b7ebd6dc274dc2ec68c84181256ac47337a48db6843a713-updates.xml [moved from repo/data/215b71246acd76913ff734a37ec034978ad86bc599d1ae391c4290bb3c731311-updates.xml with 83% similarity]
repo/data/updatemd.xml
swup.py

diff --git a/TZUP-2013-001-000/delta/libzypp-11.6.2_11.8.0-2.1.2_2.4.1.x86_64.drpm b/TZUP-2013-001-000/delta/libzypp-11.6.2_11.8.0-2.1.2_2.4.1.x86_64.drpm
new file mode 100644 (file)
index 0000000..7af29c5
Binary files /dev/null and b/TZUP-2013-001-000/delta/libzypp-11.6.2_11.8.0-2.1.2_2.4.1.x86_64.drpm differ
diff --git a/TZUP-2013-001-000/delta/systemd-44-10.4.1_10.8.1.x86_64.drpm b/TZUP-2013-001-000/delta/systemd-44-10.4.1_10.8.1.x86_64.drpm
deleted file mode 100644 (file)
index 76bcaf1..0000000
Binary files a/TZUP-2013-001-000/delta/systemd-44-10.4.1_10.8.1.x86_64.drpm and /dev/null differ
diff --git a/TZUP-2013-001-000/delta/zypper-1.7.3_1.7.8-1.2.2_1.5.1.x86_64.drpm b/TZUP-2013-001-000/delta/zypper-1.7.3_1.7.8-1.2.2_1.5.1.x86_64.drpm
new file mode 100644 (file)
index 0000000..59adab2
Binary files /dev/null and b/TZUP-2013-001-000/delta/zypper-1.7.3_1.7.8-1.2.2_1.5.1.x86_64.drpm differ
index b358c2b..9149aaa 100644 (file)
Binary files a/repo/TZUP-2013-001-000.zip and b/repo/TZUP-2013-001-000.zip differ
@@ -2,7 +2,7 @@
 <updates >
     <update id="TZUP-2013-001-000">
         <location href="TZUP-2013-001-000.zip" />
-        <checksum type="sha256">3e641b8091ee9cedf9a14a80c51f395fc662e4a4d870cd84206be5b3753e2508</checksum>
+        <checksum type="sha256">8d6e9274b411008e564da76158462fedcf6c56500b3993f8c8a24083dd104b3d</checksum>
         <type>incremental</type>
         <reboot>yes</reboot>
         <security>no</security>
index 647412f..2dc94a7 100644 (file)
@@ -2,8 +2,8 @@
 <updatemd>
   <revision>1360101688</revision>
   <data type="update">
-    <location href="data/215b71246acd76913ff734a37ec034978ad86bc599d1ae391c4290bb3c731311-updates.xml"/>
-    <checksum type="sha256">215b71246acd76913ff734a37ec034978ad86bc599d1ae391c4290bb3c731311</checksum>
+    <location href="data/3114f5e83faf5fe76b7ebd6dc274dc2ec68c84181256ac47337a48db6843a713-updates.xml"/>
+    <checksum type="sha256">3114f5e83faf5fe76b7ebd6dc274dc2ec68c84181256ac47337a48db6843a713</checksum>
     <timestamp>1360101689.12</timestamp>
     <size>65544</size>
   </data>
diff --git a/swup.py b/swup.py
index 53ea8c0..1acc587 100755 (executable)
--- a/swup.py
+++ b/swup.py
@@ -12,6 +12,7 @@ import shutil
 import sys
 import zipfile
 import rpm
+import subprocess as sub
 
 update_repo="file:///home/nashif/system-updates/repo"
 update_cache="/tmp/updates"
@@ -165,13 +166,17 @@ def prepare_update(update_data):
         
 
         ts = rpm.TransactionSet()
-        fdno = os.open("%s/downloads/%s/delta/%s" % (update_cache, u['id'], delta), os.O_RDONLY)
+        delta_location = "%s/downloads/%s/delta/%s" % (update_cache, u['id'], delta)
+        fdno = os.open(delta_location, os.O_RDONLY)
+        
         hdr = ts.hdrFromFdno(fdno)
         os.close(fdno)
         target_rpm =  "%s-%s-%s.%s.rpm" % (hdr['name'], hdr['version'], hdr['release'], hdr['arch'])
+        target_location = "%s/downloads/%s/packages/%s" % (update_cache, u['id'], target_rpm)
         version = "_%s.%s.drpm" % (hdr['release'], hdr['arch'])
-        
+        print version
         original_rpm = "%s.%s.rpm" %( delta.replace(version, ""), hdr['arch'] )
+        original_rpm = original_rpm.replace("_%s" % hdr['version'], "")
         print "   %s" %original_rpm
         print " + %s" %delta
         print " = %s" %target_rpm
@@ -182,12 +187,23 @@ def prepare_update(update_data):
         Found = False
         for r in mi:
             installed = "%s-%s-%s.%s.rpm" % (r.name, r.version, r.release, r.arch)
-            original = "%s-%s-%s.%s" % (hdr['name'], hdr['version'], hdr['release'], hdr['arch'])                
-            if installed == original:
-                found = True
+            #original = "%s-%s-%s.%s" % (hdr['name'], hdr['version'], hdr['release'], hdr['arch'])        
+            print installed
+
+            if installed == original_rpm:
+                Found = True
         if Found:
             print "Original availale, delta can be applied. Applying now..."
             # apply delta here
+            if os.path.exists("/usr/bin/applydeltarpm"):
+                if not os.path.exists(target_location):
+                    cmd = '/usr/bin/applydeltarpm %s %s' % (delta_location, target_location) 
+                    print cmd
+                    p = sub.Popen(["/usr/bin/applydeltarpm", delta_location, target_location] ,stdout=sub.PIPE,stderr=sub.PIPE)
+                    output, errors = p.communicate()
+                    print output
+                else:
+                    print "Target already exists"
         else:
             print "Error: original not available, can't apply delta. We have %s instead of %s" % (installed, original_rpm)