Skip to content

Commit 1b12eeb

Browse files
committed
build: T6904: allow development builds to have version strings
1 parent 2efc869 commit 1b12eeb

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

scripts/image-build/build-vyos-image

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ if __name__ == "__main__":
192192
'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', None),
193193
'vyos-mirror': ('VyOS package mirror', None),
194194
'build-type': ('Build type, release or development', lambda x: x in ['release', 'development']),
195-
'version': ('Version number (release builds only)', None),
195+
'version': ('Version string', None),
196196
'build-comment': ('Optional build comment', None),
197197
'build-hook-opts': ('Custom options for the post-build hook', None)
198198
}
@@ -269,19 +269,11 @@ if __name__ == "__main__":
269269
if pre_build_config['pbuilder_debian_mirror'] is None:
270270
args['pbuilder_debian_mirror'] = pre_build_config['pbuilder_debian_mirror'] = pre_build_config['debian_mirror']
271271

272-
# Version can only be set for release builds,
273-
# for dev builds it hardly makes any sense
274-
if pre_build_config['build_type'] == 'development':
275-
if args['version'] is not None:
276-
print("E: Version can only be set for release builds")
277-
print("Use --build-type=release option if you want to set version number")
278-
sys.exit(1)
279-
280272
# Validate characters in version name
281-
if 'version' in args and args['version'] != None:
273+
if args.get('version'):
282274
allowed = string.ascii_letters + string.digits + '.' + '-' + '+'
283275
if not set(args['version']) <= set(allowed):
284-
print(f'Version contained illegal character(s), allowed: {allowed}')
276+
print(f'Version string contains illegal character(s), allowed: {allowed}')
285277
sys.exit(1)
286278

287279
## Inject some useful hardcoded options
@@ -413,8 +405,10 @@ if __name__ == "__main__":
413405
build_git = ""
414406
git_branch = ""
415407

416-
# Create the build version string
417-
if build_config['build_type'] == 'development':
408+
# Create the build version string, if it's not explicitly given
409+
if build_config.get('version'):
410+
version = build_config['version']
411+
else:
418412
try:
419413
if not git_branch:
420414
raise ValueError("git branch could not be determined")
@@ -429,9 +423,6 @@ if __name__ == "__main__":
429423
except Exception as e:
430424
print("W: Could not build a version string specific to git branch, falling back to default: {0}".format(str(e)))
431425
version = "999.{0}".format(build_timestamp)
432-
else:
433-
# Release build, use the version from ./configure arguments
434-
version = build_config['version']
435426

436427
version_data = {
437428
'version': version,
@@ -674,7 +665,7 @@ Pin-Priority: 600
674665
# If not, build additional flavors from the ISO.
675666
if build_config["image_format"] != ["iso"]:
676667
# For all non-iso formats, we always build a raw image first
677-
raw_image = raw_image.create_raw_image(build_config, iso_file, "tmp/")
668+
version_data, raw_image = raw_image.create_raw_image(build_config, iso_file, "tmp/")
678669
manifest['artifacts'].append(raw_image)
679670

680671
# If there are other formats in the flavor, the assumptions is that
@@ -704,8 +695,10 @@ Pin-Priority: 600
704695
hook_opts = build_config["build_hook_opts"]
705696
else:
706697
hook_opts = ""
707-
custom_image = rc_cmd(f"./build_hook {raw_image} {build_config['version']} \
708-
{build_config['architecture']} {hook_opts}")
698+
build_hook_command = f"./build_hook {raw_image} {version_data['version']} \
699+
{build_config['architecture']} {hook_opts}"
700+
print(f'I: executing build hook command: {build_hook_command}')
701+
custom_image = rc_cmd(build_hook_command)
709702
manifest['artifacts'].append(custom_image)
710703

711704
# Filter out unwanted files from the artifact list

scripts/image-build/raw_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,4 @@ def create_raw_image(build_config, iso_file, work_dir):
210210
install_image(con, version)
211211
install_grub(con, version)
212212

213-
return raw_file
213+
return (version_data, raw_file)

0 commit comments

Comments
 (0)