update_repo="http://www.planux.com/updates"
update_cache="/var/cache/updatemanager"
-
+# zypper return values that are acceptable when running the patch command
+patch_okay_codes = [0, 102, 103]
class FakeSecHead(object):
def __init__(self, fp):
if downloaded_csum != announced_csum:
print "Error: Checksum mismatch"
os.remove("%s/download/%s" % (update_cache,location))
+ raise Exception("Checksum failed")
else:
print "%s already downloaded" % location
repodir = "%s/repos.d" %update_cache
repourl = "file://%s/download/%s/content" % (update_cache, update_id)
if not os.path.exists("%s/%s.repo" % (repourl, update_id)):
- os.system("zypper --quiet --reposd-dir %s ar --no-gpgcheck --no-keep-packages %s %s" %(repodir, repourl, update_id))
+ r = os.system("zypper --quiet --reposd-dir %s ar --no-gpgcheck --no-keep-packages %s %s" %(repodir, repourl, update_id))
+ if r != 0:
+ raise Exception("zypper add repo error: %s" % r)
if not download:
- os.system("zypper --quiet --non-interactive --reposd-dir %s patch --repo %s -d" % (repodir, update_id) )
+ r = os.system("zypper --quiet --non-interactive --reposd-dir %s patch --repo %s -d" % (repodir, update_id) )
+ if r not in patch_okay_codes:
+ raise Exception("zypper patch error: %s" % r)
def install_update(update_data):
u = update_data
repodir = "%s/repos.d" %update_cache
repourl = "file://%s/download/%s/content" % (update_cache, update_id)
if not os.path.exists("%s/%s.repo" % (repodir, update_id)):
- os.system("zypper --quiet --reposd-dir %s ar --no-gpgcheck --no-keep-packages %s %s" %(repodir, repourl, update_id))
+ r = os.system("zypper --quiet --reposd-dir %s ar --no-gpgcheck --no-keep-packages %s %s" %(repodir, repourl, update_id))
+ if r != 0:
+ raise Exception("zypper add repo error: %s" % r)
print "zypper -n --reposd-dir %s patch --with-interactive --repo %s " % (repodir, update_id)
os.system("plymouth message --text='%s'" % u['title'])
- os.system("zypper -n --reposd-dir %s patch --with-interactive --repo %s " % (repodir, update_id) )
+ r = os.system("zypper -n --reposd-dir %s patch --with-interactive --repo %s " % (repodir, update_id) )
+ if r not in patch_okay_codes:
+ raise Exception("zypper patch error: %s" % r)
if not os.path.exists("%s/installed" % (update_cache)):
os.mkdir("%s/installed" % (update_cache))
shutil.copyfile("%s/download/%s/content/%s" %(update_cache, update_id, update_id), "%s/installed/%s" % (update_cache, update_id))