diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-04-05 14:59:44 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-04-05 14:59:44 +0200 |
commit | d2e4f63f03ef5628ab94be34bf368e8c8458a2d0 (patch) | |
tree | 38c2f3a44d1a2c246b667ad1fd7e504097c1d7c1 | |
parent | 7c8769b7518d1396ab0ffb255a4dcb0e17c0da9a (diff) | |
download | vyos-build-d2e4f63f03ef5628ab94be34bf368e8c8458a2d0.tar.gz vyos-build-d2e4f63f03ef5628ab94be34bf368e8c8458a2d0.zip |
T596: use a more descriptive dev build version format.
-rw-r--r-- | data/versions | 3 | ||||
-rwxr-xr-x | scripts/check-build-env | 3 | ||||
-rwxr-xr-x | scripts/make-version-file | 24 |
3 files changed, 25 insertions, 5 deletions
diff --git a/data/versions b/data/versions new file mode 100644 index 00000000..3d0c2871 --- /dev/null +++ b/data/versions @@ -0,0 +1,3 @@ +{ + "current": "1.2.0" +} diff --git a/scripts/check-build-env b/scripts/check-build-env index 7f02c02a..7377be64 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -32,7 +32,8 @@ deps = { 'live-build', 'pbuilder', 'devscripts', - 'python3-pystache' + 'python3-pystache', + 'python3-git' ], 'binaries': [] } diff --git a/scripts/make-version-file b/scripts/make-version-file index 3bb33319..0459b8bf 100755 --- a/scripts/make-version-file +++ b/scripts/make-version-file @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -# Copyright (C) 2016 VyOS maintainers and contributors +# Copyright (C) 2018 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -25,16 +25,18 @@ import datetime import json import uuid +import git + import defaults import util +# Load the build config util.check_build_config() with open(defaults.BUILD_CONFIG, 'r') as f: build_config = json.load(f) - +# Create a build timestamp now = datetime.datetime.today() - build_timestamp = now.strftime("%Y%m%d%H%M") # FIXME: use aware rather than naive object @@ -43,9 +45,23 @@ build_date = now.strftime("%a %d %b %Y %H:%M UTC") # Assign a (hopefully) unique identifier to the build (UUID) build_id = str(uuid.uuid4()) +# Create a build version if build_config['build_type'] == 'development': - version = "999.{0}".format(build_timestamp) + try: + # Load the branch to version mapping file + with open('data/versions') as f: + version_mapping = json.load(f) + + repo = git.Repo('.') + git_branch = repo.active_branch.name + branch_version = version_mapping[git_branch] + + version = "{0}-rolling+{1}".format(branch_version, build_timestamp) + except Exception as e: + print("Could not build a version string specific to git branch, falling back to default: {0}".format(str(e))) + version = "999.{0}".format(build_timestamp) else: + # Release build, use the version from ./configure arguments version = build_config['version'] version_data = { |