From b0c41b26b9435a3a834bee7cc16a1ae1cb03a5fa Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 26 Jan 2016 15:41:47 -0500 Subject: Add support for --build-type and --version options to configure script. Image version will now be passed in configure option. As a collateral damage, add support for options without default values. --- scripts/build-config | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/build-config b/scripts/build-config index b350f692..685d79f2 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -50,13 +50,18 @@ options = { 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), - 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']) + 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']), + 'version': ('Version number (release builds only)', None, None) } # Create the option parser parser = argparse.ArgumentParser() for k, v in options.items(): - parser.add_argument('--' + k, type=str, help=v[0], default=v[1]()) + help_string, default_value_thunk = v[0], v[1] + if default_value_thunk is None: + parser.add_argument('--' + k, type=str, help=help_string) + else: + parser.add_argument('--' + k, type=str, help=help_string, default=default_value_thunk()) args = vars(parser.parse_args()) @@ -76,6 +81,14 @@ if (args['debian_mirror'] != defaults.DEBIAN_MIRROR) and \ (args['pbuilder_debian_mirror'] == defaults.DEBIAN_MIRROR): args['pbuilder_debian_mirror'] = args['debian-mirror'] +# Version can only be set for release builds, +# for dev builds it hardly makes any sense +if args['build_type'] == 'development': + if args['version'] is not None: + print("Version can only be set for release builds") + print("Use --build-type=release option if you want to set version number") + sys.exit(1) + # Populate some defaults that are not configurable, # but that are handy to have in the options hash args['distribution'] = defaults.DEBIAN_DISTRIBUTION -- cgit v1.2.3