tools: add deflated size of the zipfile to the updates.xml 21/3921/1 accepted/tizen/20130611.123253 submit/tizen/20130611.120126
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Wed, 29 May 2013 14:41:11 +0000 (17:41 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 30 May 2013 10:18:25 +0000 (13:18 +0300)
The size returned is the sum of the sizes of all the files in the
zip file.

NOTE: This is not exactly the same as disk usage after decompression.
The size returned here does not take into account the real disk usage of
the files (dependent on the fs block sizes) or disk space taken by
directories.

Change-Id: I8c52aed054c6fe9cf7ec9c3add24c0395cbb5c79
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tools/updateinfo/create-update.py
tools/updateinfo/updateutils.py

index c75feab..605e72c 100755 (executable)
@@ -113,9 +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_sz, zip_checksum = create_update_file(opts.patch, repo_dir, opts.destdir,
-                                          patch_id)
+zip_sz, zip_open_sz, zip_checksum = create_update_file(opts.patch, repo_dir,
+                                                       opts.destdir, patch_id)
 extra_meta = {'size': zip_sz,
+              'open-size': zip_open_sz,
               'checksum': zip_checksum,
               'build-id': opts.new}
 
index 17c164a..18fb517 100755 (executable)
@@ -521,10 +521,14 @@ def create_update_file(patch_path, target_dir, destination, patch_id):
         for file in files:
             fn = os.path.join(base, file)
             zip.write(fn, "%s/%s" % (patch_id, fn[rootlen:]))
+    # Calculate total size of (deflated) files
+    zip_open_sz = 0
+    for info in zip.infolist():
+        zip_open_sz += info.file_size
     zip.close()
     zip_sz = os.stat(zip_path).st_size
     zip_checksum = get_checksum("%s/%s.zip" % (destination, patch_id))
-    return (zip_sz, zip_checksum)
+    return (zip_sz, zip_open_sz, zip_checksum)
 
 def update_metadata(destination, root, patch, extra_metadata):
     # creates updates.xml