From 4810a3be14017772d731b79ae4b6e3f281112ad5 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 9 May 2019 12:58:08 +0000 Subject: [PATCH] Add --timestamp and --sha1 to specify these explicitly. Useful for setting up a build tree populated by packages from a previous build. --- tools/make-versions.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/make-versions.py b/tools/make-versions.py index 28084e9a..adda82f3 100755 --- a/tools/make-versions.py +++ b/tools/make-versions.py @@ -22,11 +22,17 @@ class OnlVersionsGenerator(object): self.ops = ops - cmd = ('git', 'rev-list', 'HEAD', '-1',) - self.build_sha1 = subprocess.check_output(cmd).strip() + if ops.sha1: + self.build_sha1 = ops.sha1 + else: + cmd = ('git', 'rev-list', 'HEAD', '-1',) + self.build_sha1 = subprocess.check_output(cmd).strip() - fmt = "%Y-%m-%d.%H:%M" - self.build_timestamp = time.strftime(fmt, time.localtime()) + if ops.timestamp: + self.build_timestamp = ops.timestamp + else: + fmt = "%Y-%m-%d.%H:%M" + self.build_timestamp = time.strftime(fmt, time.localtime()) def generate_all(self): for product in self.implementation.PRODUCTS: @@ -97,11 +103,10 @@ if __name__ == '__main__': ap.add_argument("--force", action='store_true', help="Force regeneration.") ap.add_argument("--export", action='store_true', help="Include export keyword in .sh and .mk versions.") ap.add_argument("--print", action='store_true', help="Print version data.", dest='print_') + ap.add_argument("--sha1", help="Use the given sha1.") + ap.add_argument("--timestamp", help="Use the given timestamp.") + ops = ap.parse_args() o = OnlVersionsGenerator(ops) o.generate_all() - - - -