aboutsummaryrefslogtreecommitdiff
path: root/linaro-hwpack-replace
diff options
context:
space:
mode:
authorPaul Larson <paul.larson@canonical.com>2011-10-11 20:58:01 -0500
committerPaul Larson <paul.larson@canonical.com>2011-10-11 20:58:01 -0500
commit236d893112d98393c707cbcc2763a38dde5d545f (patch)
tree7fb29df2eed1596c53d4fae0960beb7f64bfd9d8 /linaro-hwpack-replace
parent53bf73f118a4ac4f0e4945c6f8e9ae3705edb11a (diff)
downloadlinaro-image-tools-236d893112d98393c707cbcc2763a38dde5d545f.tar.gz
* Add a -i, --in-place option to modify the specified hwpack rather than making a new one
* Cleanup the tempdir
Diffstat (limited to 'linaro-hwpack-replace')
-rwxr-xr-xlinaro-hwpack-replace12
1 files changed, 11 insertions, 1 deletions
diff --git a/linaro-hwpack-replace b/linaro-hwpack-replace
index ee92ebb..7a2bf1d 100755
--- a/linaro-hwpack-replace
+++ b/linaro-hwpack-replace
@@ -45,6 +45,8 @@ parser.add_argument("-p", "--deb-pack", dest="deb_pack",
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 @@ def main():
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,14 +209,21 @@ def main():
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()
+ 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'",