From 7be6795c631d310a4811a297d1f5d1bc648fe8d7 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Fri, 1 Mar 2024 21:41:22 +0100 Subject: T3664: remove leading whitespaces from generated /usr/lib/os-release (cherry picked from commit 195c13022de0b022e054347f0170fb536f4e9b9b) --- scripts/build-vyos-image | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image index 0ec77bde..3d6238a4 100755 --- a/scripts/build-vyos-image +++ b/scripts/build-vyos-image @@ -31,13 +31,12 @@ import functools import json - try: import toml import jinja2 import git except ModuleNotFoundError as e: - print("Cannot load a required library: {}".format(e)) + print(f"Cannot load a required library: {e}") print("Please make sure the following Python3 modules are installed: toml jinja2 git") import vyos_build_utils as utils @@ -318,16 +317,19 @@ if __name__ == "__main__": 'build_comment': build_config['build_comment'] } + # Multi line strings needs to be un-indented to not have leading + # whitespaces in the resulting file os_release = f""" - PRETTY_NAME="VyOS {version} ({build_config['release_train']})" - NAME="VyOS" - VERSION_ID="{version}" - VERSION="{version} ({build_config['release_train']})" - VERSION_CODENAME={build_defaults['debian_distribution']} - ID=vyos - HOME_URL="{build_defaults['website_url']}" - SUPPORT_URL="{build_defaults['support_url']}" - BUG_REPORT_URL="{build_defaults['bugtracker_url']}" +PRETTY_NAME="VyOS {version} ({build_config['release_train']})" +NAME="VyOS" +VERSION_ID="{version}" +VERSION="{version} ({build_config['release_train']})" +VERSION_CODENAME={build_defaults['debian_distribution']} +ID=vyos +BUILD_ID="{build_git}" +HOME_URL="{build_defaults['website_url']}" +SUPPORT_URL="{build_defaults['support_url']}" +BUG_REPORT_URL="{build_defaults['bugtracker_url']}" """ # Switch to the build directory, this is crucial for the live-build work @@ -353,7 +355,7 @@ if __name__ == "__main__": # Define variables that influence to welcome message on boot os.makedirs(os.path.join(chroot_includes_dir, 'usr/lib/'), exist_ok=True) - with open(os.path.join(chroot_includes_dir, 'usr/lib//os-release'), 'w') as f: + with open(os.path.join(chroot_includes_dir, 'usr/lib/os-release'), 'w') as f: print(os_release, file=f) @@ -371,12 +373,12 @@ if __name__ == "__main__": # Add the additional repositories to package lists print("I: Setting up additional APT entries") - vyos_repo_entry = "deb {0} {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) + vyos_repo_entry = "deb {vyos_mirror} {vyos_branch} main\n".format(**build_config) apt_file = defaults.VYOS_REPO_FILE if debug: - print("D: Adding these entries to {0}:".format(apt_file)) + print(f"D: Adding these entries to {apt_file}:") print("\t", vyos_repo_entry) with open(apt_file, 'w') as f: -- cgit v1.2.3