From 54b864e8512bb8bc278167cac7dce1b599403a25 Mon Sep 17 00:00:00 2001
From: Anas Nashif
Date: Mon, 11 Feb 2013 00:19:59 -0500
Subject: [PATCH] add installation
---
repo/TZUP-2013-001-000.zip | Bin 1013836 -> 1009134 bytes
...27bc854135800de59851030f20d858053a1-updates.xml | 19 ---
repo/data/updatemd.xml | 4 +-
swup.py | 140 +++++++++++++++++++--
4 files changed, 132 insertions(+), 31 deletions(-)
delete mode 100644 repo/data/26bff4f6eecbac4790f4a4dd1eb7b27bc854135800de59851030f20d858053a1-updates.xml
diff --git a/repo/TZUP-2013-001-000.zip b/repo/TZUP-2013-001-000.zip
index cadd5ee49a32ccbb7820e42559370213ec8a1bf2..b358c2b8a782588a0913f9d7a6b6b2aaf8491fbe 100644
GIT binary patch
delta 391
zcmX@}!S>y0Tb2NCW|rv>iuffaALo^2j>r(3SSU4_kF9)O1c
delta 4873
zcmbtYc|25o)E_g(*oPSVlBguIFJsA;p)4Uw*~Sc_vP_I@ag%-DjU;6)N{yX_p0Z}&
zQX(ZOStHrPdr?pIc;CO?`FzfN?z#7T&+puO&hOmwy|Zm9?ei*9hPp6HTFCZqsa#oO
z=iuibHG~I(BM_W@j(Iqln$SRCHW-AFuoEkZ!4}CS5K7ek%Nh<^yE_ov#CJ?Zp{yjF
zEt2n0AW`QpGumHf_BbML*EZ`6YTK3rUiJ_&2Xm9q&QROsBG*Gk_EkPrX?d
zdoA15ChKDxwbp%)qWKtVw$3raD6zv3@$`5w5%`UsA
zuz!^5iXwWrpQq|nXtn!7@tyC@7Wp-4mZtk$$Z*aN>af@X4O5gG9Q)`XyNl_`BLfyL
z79qgV#%k6lq7tL;FvB=cztYF3tAcc*TBa=-r0jh5f|DwIe)dDB;&_Kz^!3BUS>72b
zu)k*3)Nfu+rWZ!qGz*qK%qQ8V#tnEqjFLV3-5)vg-{sEaEFSBc;A~6U3J88R#=Tur
zyUFypprhdwKR#~{CNly|rrBS~l*Z#7?CfQwaOWi@CD8y5Z6_&r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evHkj(Em;8xqq<9DH8MS)Q_{ssMu
z#(`e8S^ahx+`wJ}`KOmSurz-M@Hd_O|FTIijMu8rpK++~B{YA=5k&cC9Di>V(9br#
z*|{Crz4QE^Zd%~GZhlSoAar}O-+@Z)eeeH<&II;>lfb`I0EpY30(KHf>bFG-LGLq=
z$T%b`i4lj?fG+PSTqNgh;)DQ>-0SRjV12y>MGynhq
diff --git a/repo/data/26bff4f6eecbac4790f4a4dd1eb7b27bc854135800de59851030f20d858053a1-updates.xml b/repo/data/26bff4f6eecbac4790f4a4dd1eb7b27bc854135800de59851030f20d858053a1-updates.xml
deleted file mode 100644
index f40143d..0000000
--- a/repo/data/26bff4f6eecbac4790f4a4dd1eb7b27bc854135800de59851030f20d858053a1-updates.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- d1d44afba88cabf44cccd8d9fde2daacba31e09e9b7e46526ba9c1e3b41c0a3b
- incremental
- yes
- no
- no
- Tizen 3.0.1 Update
- 3.0.1
-
- This Update will solve all your problems
- For more information, see http://updates.tizen.org
- ]]>
-
-
-
diff --git a/repo/data/updatemd.xml b/repo/data/updatemd.xml
index 74443e1..647412f 100644
--- a/repo/data/updatemd.xml
+++ b/repo/data/updatemd.xml
@@ -2,8 +2,8 @@
1360101688
-
- 26bff4f6eecbac4790f4a4dd1eb7b27bc854135800de59851030f20d858053a1
+
+ 215b71246acd76913ff734a37ec034978ad86bc599d1ae391c4290bb3c731311
1360101689.12
65544
diff --git a/swup.py b/swup.py
index 094b0da..53ea8c0 100755
--- a/swup.py
+++ b/swup.py
@@ -4,11 +4,14 @@ import ConfigParser
from optparse import OptionParser
import urllib2
from lxml import etree
-from BeautifulSoup import *
+#from BeautifulSoup import *
import hashlib
import os
import tempfile
import shutil
+import sys
+import zipfile
+import rpm
update_repo="file:///home/nashif/system-updates/repo"
update_cache="/tmp/updates"
@@ -81,7 +84,57 @@ def probe_updates():
else:
get_new_update_list(href)
-
+
+def parse_updates():
+
+ updates = {}
+
+ fp = open("%s/data/updates.xml" % update_cache , "r")
+ updates_root = etree.XML(fp.read())
+ updates_el = updates_root.xpath("//update")
+ for update in updates_el:
+ up = {}
+ attr = update.attrib
+ up['id'] = attr['id']
+ up['checksum'] = update.xpath("checksum")[0].text
+ up['title'] = update.xpath("title")[0].text
+ loc = update.xpath("location")[0]
+ up['location'] = "%s" % ( loc.attrib['href'])
+
+ updates[up['id']] = up
+ return updates
+
+
+def download_update(update_data):
+ u = update_data
+ location = u['location']
+ if not os.path.exists("%s/downloads/%s" % (update_cache,location)):
+ update_file = urllib2.urlopen("%s/%s" % (update_repo, location) )
+ location = os.path.basename(location)
+ announced_csum = u['checksum']
+ update_raw = update_file.read()
+ fp = open("%s/downloads/%s" % (update_cache,location) , "w")
+ fp.write(update_raw)
+ fp.close()
+ downloaded_csum = checksum("%s/downloads/%s" % (update_cache,location), "sha256")
+ # Verify Checksum
+ if downloaded_csum != announced_csum:
+ print "Error: Checksum mismatch"
+ os.remove("%s/downloads/%s" % (update_cache,location))
+ else:
+ print "%s already downloaded" % location
+
+def download_all_updates(update_label=None):
+ updates = parse_updates()
+
+ if update_label is not None:
+ u = updates[update_label]
+ download_update(u)
+ else:
+ for k in updates.keys():
+ u = updates[k]
+ download_update(u)
+
def get_new_update_list(location):
up = urllib2.urlopen("%s/%s" % (update_repo, location) )
@@ -91,17 +144,65 @@ def get_new_update_list(location):
fp.close()
-def list_updates():
- fp = open("%s/data/updates.xml" % update_cache , "r")
- updates_root = etree.XML(fp.read())
- updates = updates_root.xpath("//update")
- for update in updates:
- attr = update.attrib
- print " %s:" %attr['id']
- print " %s" %update.xpath("title")[0].text
+def prepare_update(update_data):
+ u = update_data
+ location = u['location']
+ # unzip
+ if os.path.exists("%s/downloads/%s" % (update_cache,location)) and not os.path.exists("%s/downloads/%s" % (update_cache,u['id'])):
+ zfile = zipfile.ZipFile("%s/downloads/%s" % (update_cache,location))
+ for name in zfile.namelist():
+ (dirname, filename) = os.path.split(name)
+ print "Decompressing " + filename + " on " + dirname
+ if not os.path.exists("%s/downloads/%s" % (update_cache, dirname)):
+ os.mkdir("%s/downloads/%s" % (update_cache, dirname))
+ if filename != "":
+ fd = open("%s/downloads/%s" % (update_cache, name),"w")
+ fd.write(zfile.read(name))
+ fd.close()
+ # apply deltas
+ print "Delta Packages:"
+ for delta in os.listdir("%s/downloads/%s/delta" % (update_cache,u['id'])):
+
+
+ ts = rpm.TransactionSet()
+ fdno = os.open("%s/downloads/%s/delta/%s" % (update_cache, u['id'], delta), 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'])
+ version = "_%s.%s.drpm" % (hdr['release'], hdr['arch'])
+
+ original_rpm = "%s.%s.rpm" %( delta.replace(version, ""), hdr['arch'] )
+ print " %s" %original_rpm
+ print " + %s" %delta
+ print " = %s" %target_rpm
+
+ # Verify
+
+ mi = ts.dbMatch("name", hdr['name'])
+ 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
+ if Found:
+ print "Original availale, delta can be applied. Applying now..."
+ # apply delta here
+ else:
+ print "Error: original not available, can't apply delta. We have %s instead of %s" % (installed, original_rpm)
+def apply_update(update_data):
+ pass
+
+def list_updates():
+ updates = parse_updates()
+ for k in updates.keys():
+ u = updates[k]
+ print "%s" %u['id']
+ print " %s" %u['title']
+
parser = OptionParser()
parser.add_option("-V", "--os-version", action="store_true", dest="osver", default=False,
@@ -112,6 +213,8 @@ parser.add_option("-d", "--download-only", action="store_true", dest="downloadon
help="Download only")
parser.add_option("-i", "--install", dest="install", metavar="LABEL",
help="Install update")
+parser.add_option("-a", "--install-all", dest="installall", action="store_true", default=False,
+ help="Install all updates")
parser.add_option("-r", "--recommended", dest="recommended", action="store_true", default=False,
help="Install recommended updates only")
parser.add_option("-q", "--quiet",
@@ -127,3 +230,20 @@ if options.osver:
if options.listupdates:
probe_updates()
list_updates()
+
+if options.downloadonly:
+ probe_updates()
+ download_all_updates()
+
+if options.install is not None:
+ probe_updates()
+ updates = parse_updates()
+ if not updates.has_key(options.install):
+ print "%s is not available for installation. Abort." %options.install
+ sys.exit()
+ u = updates[options.install]
+ download_update(u)
+ prepare_update(u)
+
+
+
--
2.7.4