diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-config | 11 | ||||
-rwxr-xr-x | scripts/live-build-config | 12 |
2 files changed, 20 insertions, 3 deletions
diff --git a/scripts/build-config b/scripts/build-config index 56fc7a88..a18e95ee 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -43,6 +43,12 @@ def field_to_option(s): def get_default_build_by(): return "{user}@{host}".format(user= getpass.getuser(), host=platform.node()) +def get_validator(optdict, name): + try: + return optdict[name][2] + except KeyError: + return None + # Options dict format: # '$option_name_without_leading_dashes': { ('$help_string', $default_value_generator_thunk, $value_checker_thunk) } @@ -66,12 +72,15 @@ for k, v in options.items(): else: parser.add_argument('--' + k, type=str, help=help_string, default=default_value_thunk()) +# The debug option is a bit special since it's different type +parser.add_argument('--debug', help="Enable debug output", action='store_true') + args = vars(parser.parse_args()) # Validate options for k, v in args.items(): key = field_to_option(k) - func = options[key][2] + func = get_validator(options, k) if func is not None: if not func(v): print("{v} is not a valid value for --{o} option".format(o=key, v=v)) diff --git a/scripts/live-build-config b/scripts/live-build-config index 1880be39..544c67e8 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -60,11 +60,19 @@ lb config noauto \ with open(defaults.BUILD_CONFIG, 'r') as f: build_config = json.load(f) +debug = build_config['debug'] + # Add the additional repositories to package lists print("Setting up additional APT entries") vyos_repo_entry = "deb {0} {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) -with open(os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE), 'w') as f: +apt_file = os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE) + +if debug: + print("Adding these entries to {0}:".format(apt_file)) + print("\t", vyos_repo_entry) + +with open(apt_file, 'w') as f: f.write(vyos_repo_entry) # Configure live-build @@ -72,8 +80,8 @@ with open(os.path.join(defaults.BUILD_DIR, defaults.VYOS_REPO_FILE), 'w') as f: lb_config_command = pystache.render(lb_config_tmpl, build_config) print("Configuring live-build") -os.chdir(defaults.BUILD_DIR) +os.chdir(defaults.BUILD_DIR) result = os.system(lb_config_command) if result > 0: print("live-build config failed") |