diff options
-rwxr-xr-x | scripts/build-config | 3 | ||||
-rwxr-xr-x | scripts/make-version-file | 40 |
2 files changed, 32 insertions, 11 deletions
diff --git a/scripts/build-config b/scripts/build-config index c613b0e4..356aa340 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -71,7 +71,8 @@ options = { 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: build_defaults['debian_mirror'], None), 'vyos-mirror': ('VyOS package mirror', lambda: build_defaults["vyos_mirror"], None), 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']), - 'version': ('Version number (release builds only)', None, None) + 'version': ('Version number (release builds only)', None, None), + 'build-comment': ('Optional build comment', lambda: '', None) } # Create the option parser diff --git a/scripts/make-version-file b/scripts/make-version-file index fa632eed..a2828434 100755 --- a/scripts/make-version-file +++ b/scripts/make-version-file @@ -46,22 +46,33 @@ build_date = now.strftime("%a %d %b %Y %H:%M UTC") build_uuid = str(uuid.uuid4()) # Initialize Git object from our repository -repo = git.Repo('.') - -# Retrieve the Git commit ID of the repository, 14 charaters will be sufficient -build_git = repo.head.object.hexsha[:14] -# If somone played around with the source tree and the build is "dirty", mark it -if repo.is_dirty(): - build_git += "-dirty" +try: + repo = git.Repo('.') + + # Retrieve the Git commit ID of the repository, 14 charaters will be sufficient + build_git = repo.head.object.hexsha[:14] + # If somone played around with the source tree and the build is "dirty", mark it + if repo.is_dirty(): + build_git += "-dirty" + + # Retrieve git branch name + git_branch = repo.active_branch.name +except Exception as e: + print("Could not retrieve information from git: {0}".format(str(e))) + build_git = "" + git_branch = "" + git_commit = "" # Create a build version if build_config['build_type'] == 'development': try: + if not git_branch: + raise ValueError("git branch could not be determined") + # Load the branch to version mapping file with open('data/versions') as f: version_mapping = json.load(f) - git_branch = repo.active_branch.name branch_version = version_mapping[git_branch] version = "{0}-rolling-{1}".format(branch_version, build_timestamp) @@ -72,12 +83,20 @@ else: # Release build, use the version from ./configure arguments version = build_config['version'] +if build_config['build_type'] == 'development': + lts_build = False +else: + lts_build = True + version_data = { 'version': version, 'built_by': build_config['build_by'], 'built_on': build_date, 'build_uuid': build_uuid, - 'build_git': build_git + 'build_git': build_git, + 'build_branch': git_branch, + 'lts_build': lts_build, + 'build_comment': build_config['build_comment'] } os.makedirs(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/share/vyos'), exist_ok=True) @@ -85,8 +104,9 @@ with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/share/vyos/version.jso json.dump(version_data, f) # For backwards compatibility with 'add system image' script from older versions -# we need a file in old format so that script can find out the version of the image +# we need a file in the old format so that script can find out the version of the image # for upgrade +os.makedirs(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/'), exist_ok=True) with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/version'), 'w') as f: print("Version: {0}".format(version), file=f) |