tools: add zip file size to the updates.xml metadata 20/3920/1
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Wed, 29 May 2013 14:31:32 +0000 (17:31 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 30 May 2013 10:18:25 +0000 (13:18 +0300)
Change-Id: Ic90c1ae761d4d7581c2ccd76684fc4f4bf22b4fd
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tools/updateinfo/create-update.py
tools/updateinfo/updateutils.py

index ffebc43..c75feab 100755 (executable)
@@ -113,8 +113,10 @@ os.system("modifyrepo %s/updateinfo.xml %s/repodata"  % (tmp_dir, repo_dir))
 if not os.path.exists(opts.destdir):
     os.makedirs(opts.destdir)
 
-zip_checksum = create_update_file(opts.patch, repo_dir, opts.destdir, patch_id)
-extra_meta = {'checksum': zip_checksum,
+zip_sz, zip_checksum = create_update_file(opts.patch, repo_dir, opts.destdir,
+                                          patch_id)
+extra_meta = {'size': zip_sz,
+              'checksum': zip_checksum,
               'build-id': opts.new}
 
 update_metadata(opts.destdir, tmp_dir, patch, extra_meta)
index a5a508c..17c164a 100755 (executable)
@@ -511,7 +511,8 @@ def create_updateinfo(base_dir, patch):
 def create_update_file(patch_path, target_dir, destination, patch_id):
     # create zip file
     shutil.copyfile(patch_path, "%s/%s" %(target_dir, patch_id))
-    zip = zipfile.ZipFile("%s/%s.zip" % (destination, patch_id ), 'w', zipfile.ZIP_DEFLATED)
+    zip_path = '%s/%s.zip' % (destination, patch_id)
+    zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
     rootlen = len(target_dir) + 1
     for base, dirs, files in os.walk(target_dir):
         basedir = os.path.basename(base)
@@ -521,8 +522,9 @@ def create_update_file(patch_path, target_dir, destination, patch_id):
             fn = os.path.join(base, file)
             zip.write(fn, "%s/%s" % (patch_id, fn[rootlen:]))
     zip.close()
+    zip_sz = os.stat(zip_path).st_size
     zip_checksum = get_checksum("%s/%s.zip" % (destination, patch_id))
-    return zip_checksum
+    return (zip_sz, zip_checksum)
 
 def update_metadata(destination, root, patch, extra_metadata):
     # creates updates.xml