diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 448: Addressing the review comments for the hwpack name changes

Message ID 20111014053314.12404.96502.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Deepti B. Kalakeri Oct. 14, 2011, 5:33 a.m. UTC
Merge authors:
  Deepti B. Kalakeri (deeptik)
Related merge proposals:
  https://code.launchpad.net/~deeptik/linaro-image-tools/linaro-hwpack-name-changes/+merge/79228
  proposed by: Deepti B. Kalakeri (deeptik)
  review: Approve - James Westby (james-w)
------------------------------------------------------------
revno: 448 [merge]
committer: Deepti B. Kalakeri<deepti.kalakeri@linaro.org>
branch nick: linaro-image-tools
timestamp: Fri 2011-10-14 05:28:15 +0000
message:
  Addressing the review comments for the hwpack name changes
modified:
  linaro-hwpack-replace


--
lp:linaro-image-tools
https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk

You are subscribed to branch lp:linaro-image-tools.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'linaro-hwpack-replace'
--- linaro-hwpack-replace	2011-10-12 17:49:06 +0000
+++ linaro-hwpack-replace	2011-10-13 12:11:28 +0000
@@ -45,6 +45,9 @@ 
 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("-n", "--append-build-number", dest="build_number",
+                    help="Specify the build number if any to be used in new "\
+                          "hwpack name (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",
@@ -77,10 +80,19 @@ 
         logger.setLevel(logging.DEBUG)
 
 
-def get_hwpack_name(old_hwpack):
+def get_hwpack_name(old_hwpack, build_number):
+    # The build_number would be the job build number.
+    # Valid value for the build_number would be available for ex 
+    # when l-h-r is used in the jenkins.
     timestamp = [datetime.datetime.utcnow().strftime("%Y%m%d-%H%M")]
     hwpack_name_parts = (old_hwpack.split('_', 3))
-    return('_'.join(hwpack_name_parts[:2] + timestamp + hwpack_name_parts[3:]))
+    new_hwpack_name = [('_'.join(hwpack_name_parts[:2] + timestamp))]
+
+    if build_number is not None:
+        job_build_number = [''.join('b' + build_number)]
+        new_hwpack_name = [('_'.join(new_hwpack_name + job_build_number))]
+    
+    return('_'.join(new_hwpack_name + hwpack_name_parts[3:]))
 
 
 def should_remove(package_name, prefix_pkg_remove):
@@ -171,12 +183,13 @@ 
     old_hwpack = args.hwpack_name
     new_deb_file_to_copy = args.deb_pack
     prefix_pkg_remove = args.prefix_pkg_remove
+    build_number = args.build_number
     status = 0
     tempdir = ""
 
     try:
         # Get the new hardware pack name
-        hwpack_name = get_hwpack_name(old_hwpack)
+        hwpack_name = get_hwpack_name(old_hwpack, build_number)
         if hwpack_name == None:
             logger.error("Did not get a valid hwpack name, exiting")
             return status