=== modified file 'linaro-hwpack-replace'
@@ -45,6 +45,8 @@
parser.add_argument("-r", "--prefix-pkg-remove", dest="prefix_pkg_remove",
help="Specify the prefix of the old debian package to "\
"replace (default: None).")
+parser.add_argument("-i", "--in-place", action="store_true", dest="inplace",
+ help="Modify the hwpack rather than creating a new one")
parser.add_argument("-d", "--debug-output", action="store_true", dest="debug",
help="Verbose messages are displayed when specified")
@@ -182,6 +184,7 @@
tar = tarfile.open(old_hwpack, "r:gz")
tempdir = tempfile.mkdtemp()
tar.extractall(tempdir)
+ tar.close()
# Search if a similar package with the same name exists, if yes then
# replace it. IF the old and new debian have the same name then we
@@ -206,15 +209,26 @@
modify_Packages_info(debpack_dirname, new_debpack_info, prefix_pkg_remove)
#tar the hardware pack with the new debian file included in it
- tar = tarfile.open( hwpack_name , "w:gz")
+ tar = tarfile.open(hwpack_name , "w:gz")
+ origdir = os.getcwd()
os.chdir(tempdir)
for file_name in glob.glob('*'):
tar.add(file_name, recursive=True)
tar.close()
+
+ # Retain old hwpack name instead of using a new name
+ os.chdir(origdir)
+ if args.inplace:
+ os.rename(hwpack_name, old_hwpack)
+ hwpack_name = old_hwpack
+
except Exception, details:
logger.error("Error Details: %s", details)
status = 1
+ finally:
+ shutil.rmtree(tempdir)
+
if status == 0:
logger.info("The debian package '%s' has been been included in '%s'",
new_deb_file_to_copy, hwpack_name)