diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | data/live-build-config/archives/trixie.pref.chroot | 4 | ||||
-rwxr-xr-x | data/live-build-config/hooks/live/18-enable-disable_services.chroot | 1 | ||||
-rw-r--r-- | docker/Dockerfile | 17 | ||||
-rw-r--r-- | packages/frr/Jenkinsfile | 2 | ||||
-rwxr-xr-x | packages/frr/build-frr.sh | 2 | ||||
-rw-r--r-- | packages/frr/patches/0001-bgpd-fix-no-set-as-path-prepend-ASNUM.patch | 70 | ||||
-rw-r--r-- | packages/frr/patches/0002-bgpd-allow-using-optional-table-id-for-negative.patch | 29 | ||||
-rw-r--r-- | packages/linux-kernel/arch/x86/configs/vyos_defconfig | 6 | ||||
m--------- | packages/vyos-1x | 0 | ||||
-rwxr-xr-x | scripts/image-build/build-vyos-image | 198 | ||||
-rw-r--r-- | scripts/image-build/raw_image.py | 11 |
13 files changed, 235 insertions, 110 deletions
diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7d26010c..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "packages/vyos-1x"] - path = packages/vyos-1x - url = https://github.com/vyos/vyos-1x @@ -8,7 +8,7 @@ all: @echo "The most common target is 'iso'" %: - VYOS_TEMPLATE_DIR=`pwd`/packages/vyos-1x/data/templates/ ./build-vyos-image $* + ./build-vyos-image $* .PHONY: checkiso .ONESHELL: diff --git a/data/live-build-config/archives/trixie.pref.chroot b/data/live-build-config/archives/trixie.pref.chroot index a7d8b0ea..a976413d 100644 --- a/data/live-build-config/archives/trixie.pref.chroot +++ b/data/live-build-config/archives/trixie.pref.chroot @@ -6,6 +6,10 @@ Package: netavark Pin: release n=trixie Pin-Priority: 900 +Package: libgpgme11t64 +Pin: release n=trixie +Pin-Priority: 900 + Package: * Pin: release n=trixie Pin-Priority: -10 diff --git a/data/live-build-config/hooks/live/18-enable-disable_services.chroot b/data/live-build-config/hooks/live/18-enable-disable_services.chroot index aa02a7c1..0732e597 100755 --- a/data/live-build-config/hooks/live/18-enable-disable_services.chroot +++ b/data/live-build-config/hooks/live/18-enable-disable_services.chroot @@ -60,7 +60,6 @@ systemctl disable atop-rotate.timer systemctl disable ModemManager.service systemctl disable dnsdist.service systemctl disable haproxy.service -systemctl disable miniupnpd.service systemctl disable owamp-server.service systemctl disable twamp-server.service systemctl disable podman-auto-update.service diff --git a/docker/Dockerfile b/docker/Dockerfile index de6b147f..595f0909 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -222,18 +222,6 @@ RUN apt-get update && apt-get install -y \ build-essential RUN gem install --no-document fpm -# Build rtrlib release 0.8.0 -RUN export RTRLIB_VERSION="0.8.0" export ARCH=$(dpkg-architecture -qDEB_HOST_ARCH) && \ - git clone https://github.com/rtrlib/rtrlib.git /tmp/rtrlib && cd /tmp/rtrlib && \ - mk-build-deps --install --tool "apt-get --yes --no-install-recommends" && \ - dpkg-buildpackage -uc -us -tc -b && \ - dpkg -i ../librtr0*_${ARCH}.deb ../librtr-dev*_${ARCH}.deb ../rtr-tools*_${ARCH}.deb - -RUN export LIBYANG_VERSION="v2.1.128" export ARCH=$(dpkg-architecture -qDEB_HOST_ARCH) && \ - git clone https://github.com/CESNET/libyang.git /tmp/libyang && cd /tmp/libyang && \ - pipx run apkg build -i && find pkg/pkgs -type f -name *.deb -exec mv -t .. {} + && \ - dpkg -i ../libyang*.deb - # Packages needed for vyos-1x RUN pip install --break-system-packages \ git+https://github.com/aristanetworks/j2lint.git@341b5d5db86 \ @@ -243,6 +231,7 @@ RUN pip install --break-system-packages \ fakeroot \ iproute2 \ libzmq3-dev \ + procps \ python3 \ python3-setuptools \ python3-inotify \ @@ -362,6 +351,10 @@ RUN apt-get update && apt-get install -y \ libnl-genl-3-dev \ libxtables-dev +# Packages needed for nftables +RUN apt-get update && apt-get install -y \ + asciidoc-base + # Allow password-less 'sudo' for all users in group 'sudo' RUN sed "s/^%sudo.*/%sudo\tALL=(ALL) NOPASSWD:ALL/g" -i /etc/sudoers && \ echo "vyos_bld\tALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ diff --git a/packages/frr/Jenkinsfile b/packages/frr/Jenkinsfile index 2c309443..441b1681 100644 --- a/packages/frr/Jenkinsfile +++ b/packages/frr/Jenkinsfile @@ -32,7 +32,7 @@ def pkgList = [ ['name': 'frr', 'scmCommit': 'stable/9.1', 'scmUrl': 'https://github.com/FRRouting/frr.git', - 'buildCmd': 'sudo mk-build-deps --install --tool "apt-get --yes --no-install-recommends"; cd ..; ./build-frr.sh'], + 'buildCmd': 'sudo dpkg -i ../*.deb; sudo mk-build-deps --install --tool "apt-get --yes --no-install-recommends"; cd ..; ./build-frr.sh'], ] // Start package build using library function from https://github.com/vyos/vyos-build diff --git a/packages/frr/build-frr.sh b/packages/frr/build-frr.sh index 8be3cb4b..7171a883 100755 --- a/packages/frr/build-frr.sh +++ b/packages/frr/build-frr.sh @@ -31,7 +31,7 @@ fi echo "I: Ensure Debian build dependencies are met" sudo apt-get -y install chrpath gawk install-info libcap-dev libjson-c-dev librtr-dev -sudo apt-get -y install libpam-dev libprotobuf-c-dev libpython3-dev:native libsnmp-dev protobuf-c-compiler python3-dev:native texinfo lua5.3 +sudo apt-get -y install libpam-dev libprotobuf-c-dev libpython3-dev:native python3-sphinx:native libsnmp-dev protobuf-c-compiler python3-dev:native texinfo lua5.3 # Build Debian FRR package echo "I: Build Debian FRR Package" diff --git a/packages/frr/patches/0001-bgpd-fix-no-set-as-path-prepend-ASNUM.patch b/packages/frr/patches/0001-bgpd-fix-no-set-as-path-prepend-ASNUM.patch new file mode 100644 index 00000000..9b87e302 --- /dev/null +++ b/packages/frr/patches/0001-bgpd-fix-no-set-as-path-prepend-ASNUM.patch @@ -0,0 +1,70 @@ +From e069a1c8d52bb6e7808303df488d7ce912e4f652 Mon Sep 17 00:00:00 2001 +From: Donatas Abraitis <donatas@opensourcerouting.org> +Date: Thu, 2 May 2024 23:07:19 +0300 +Subject: [PATCH 1/2] bgpd: Fix `no set as-path prepend ASNUM...` + +If entering `no set as-path prepend 1 2 3`, it's warned as unknown command. + +Now fixed, and the following combinations work fine: + +``` +no set as-path prepend +no set as-path prepend last-as +no set as-path prepend last-as 1 +no set as-path prepend 1 +no set as-path prepend 1 2 +``` + +Fixes: https://github.com/FRRouting/frr/issues/15912 + +Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> +--- + bgpd/bgp_routemap.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c +index 4875697aa106..7eb97dae4d24 100644 +--- a/bgpd/bgp_routemap.c ++++ b/bgpd/bgp_routemap.c +@@ -6288,13 +6288,12 @@ DEFPY_YANG( + } + + DEFUN_YANG (no_set_aspath_prepend, +- no_set_aspath_prepend_cmd, +- "no set as-path prepend [ASNUM] [last-as [(1-10)]]", ++ no_set_aspath_prepend_last_as_cmd, ++ "no set as-path prepend [last-as [(1-10)]]", + NO_STR + SET_STR + "Transform BGP AS_PATH attribute\n" + "Prepend to the as-path\n" +- AS_STR + "Use the peers AS-number\n" + "Number of times to insert\n") + { +@@ -6305,6 +6304,15 @@ DEFUN_YANG (no_set_aspath_prepend, + return nb_cli_apply_changes(vty, NULL); + } + ++ALIAS_YANG (no_set_aspath_prepend, ++ no_set_aspath_prepend_as_cmd, ++ "no set as-path prepend ASNUM...", ++ NO_STR ++ SET_STR ++ "Transform BGP AS_PATH attribute\n" ++ "Prepend to the as-path\n" ++ AS_STR) ++ + DEFUN_YANG (set_aspath_exclude, + set_aspath_exclude_cmd, + "set as-path exclude ASNUM...", +@@ -7981,7 +7989,8 @@ void bgp_route_map_init(void) + install_element(RMAP_NODE, &set_aspath_exclude_access_list_cmd); + install_element(RMAP_NODE, &set_aspath_replace_asn_cmd); + install_element(RMAP_NODE, &set_aspath_replace_access_list_cmd); +- install_element(RMAP_NODE, &no_set_aspath_prepend_cmd); ++ install_element(RMAP_NODE, &no_set_aspath_prepend_last_as_cmd); ++ install_element(RMAP_NODE, &no_set_aspath_prepend_as_cmd); + install_element(RMAP_NODE, &no_set_aspath_exclude_cmd); + install_element(RMAP_NODE, &no_set_aspath_exclude_all_cmd); + install_element(RMAP_NODE, &no_set_aspath_exclude_access_list_cmd); diff --git a/packages/frr/patches/0002-bgpd-allow-using-optional-table-id-for-negative.patch b/packages/frr/patches/0002-bgpd-allow-using-optional-table-id-for-negative.patch new file mode 100644 index 00000000..c414490e --- /dev/null +++ b/packages/frr/patches/0002-bgpd-allow-using-optional-table-id-for-negative.patch @@ -0,0 +1,29 @@ +From e411988a86f1b719fb16ec4c30499bfc650b4ea7 Mon Sep 17 00:00:00 2001 +From: Donatas Abraitis <donatas@opensourcerouting.org> +Date: Fri, 3 May 2024 08:58:21 +0300 +Subject: [PATCH 2/2] bgpd: Allow using optional table id for negative `no set + table X` command + +Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> +--- + bgpd/bgp_routemap.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c +index 7eb97dae4d24..df5c2557bd26 100644 +--- a/bgpd/bgp_routemap.c ++++ b/bgpd/bgp_routemap.c +@@ -5897,10 +5897,11 @@ DEFUN_YANG (set_table_id, + + DEFUN_YANG (no_set_table_id, + no_set_table_id_cmd, +- "no set table", ++ "no set table [(1-4294967295)]", + NO_STR + SET_STR +- "export route to non-main kernel table\n") ++ "export route to non-main kernel table\n" ++ "Kernel routing table id\n") + { + const char *xpath = "./set-action[action='frr-bgp-route-map:table']"; + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); diff --git a/packages/linux-kernel/arch/x86/configs/vyos_defconfig b/packages/linux-kernel/arch/x86/configs/vyos_defconfig index 64bf4964..dce06ec8 100644 --- a/packages/linux-kernel/arch/x86/configs/vyos_defconfig +++ b/packages/linux-kernel/arch/x86/configs/vyos_defconfig @@ -2986,9 +2986,9 @@ CONFIG_MT7663_USB_SDIO_COMMON=m CONFIG_MT7663U=m CONFIG_MT7663S=m CONFIG_MT7915E=m -# CONFIG_MT7921E is not set -# CONFIG_MT7921S is not set -# CONFIG_MT7921U is not set +CONFIG_MT7921E=m +CONFIG_MT7921S=m +CONFIG_MT7921U=m # CONFIG_MT7996E is not set CONFIG_WLAN_VENDOR_MICROCHIP=y # CONFIG_WILC1000_SDIO is not set diff --git a/packages/vyos-1x b/packages/vyos-1x deleted file mode 160000 -Subproject b5d3d36d1f70e53ef6a8a6634ab863d94d791bf diff --git a/scripts/image-build/build-vyos-image b/scripts/image-build/build-vyos-image index c6e76208..5bf5803d 100755 --- a/scripts/image-build/build-vyos-image +++ b/scripts/image-build/build-vyos-image @@ -21,6 +21,7 @@ import re import os import sys +import copy import uuid import glob import json @@ -32,6 +33,13 @@ import datetime import functools import string +## Check if the script is running wirh root permissions +## Since live-build requires privileged calls such as chroot(), +## there's no real way around it. +if os.getuid() != 0: + print("E: this script requires root privileges") + sys.exit(1) + # Import third-party modules try: import tomli @@ -41,45 +49,82 @@ try: except ModuleNotFoundError as e: print(f"E: Cannot load required library {e}") print("E: Please make sure the following Python3 modules are installed: tomli jinja2 git psutil") + sys.exit(1) + +# Import local defaults +import defaults -# Initialize Git object from our repository +## Load the file with default build configuration options try: - repo = git.Repo('.', search_parent_directories=True) - repo.git.submodule('update', '--init') - - # 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 or current tag - # Building a tagged release might leave us checking out a git tag that is not the tip of a named branch (detached HEAD) - # Check if the current HEAD is associated with a tag and use its name instead of an unavailable branch name. - git_branch = next((tag.name for tag in repo.tags if tag.commit == repo.head.commit), None) - if git_branch is None: - git_branch = repo.active_branch.name + with open(defaults.DEFAULTS_FILE, 'rb') as f: + build_defaults = tomli.load(f) except Exception as e: - print(f'W: Could not retrieve information from git: {repr(e)}') - build_git = "" - git_branch = "" + print("E: Failed to open the defaults file {0}: {1}".format(defaults.DEFAULTS_FILE, e)) + sys.exit(1) -# Add the vyos-1x submodule directory to the Python path -# so that we can import modules from it. -VYOS1X_DIR = os.path.join(os.getcwd(), 'packages/vyos-1x/python') +# Checkout vyos-1x under build directory +try: + branch_name = build_defaults['vyos_branch'] + url_vyos_1x = 'https://github.com/vyos/vyos-1x' + path_vyos_1x = os.path.join(defaults.BUILD_DIR, 'vyos-1x') + try: + repo_vyos_1x = git.Repo.clone_from(url_vyos_1x, path_vyos_1x, no_checkout=True) + except git.GitCommandError: + if os.path.exists(path_vyos_1x): + try: + repo_vyos_1x = git.Repo(path_vyos_1x) + except git.GitError: + print(f'E: Corrupted vyos-1x git repo: {path_vyos_1x}; remove') + sys.exit(1) + else: + raise + # alternatively, pass commit hash or tag as arg: + repo_vyos_1x.git.checkout(branch_name) +except Exception as e: + print(f'E: Could not retrieve vyos-1x from branch {branch_name}: {repr(e)}') + sys.exit(1) + +# Add the vyos-1x directory to the Python path so that +# we can import modules from it. +VYOS1X_DIR = os.path.join(os.getcwd(), defaults.BUILD_DIR, 'vyos-1x/python') if not os.path.exists(VYOS1X_DIR): - print("E: packages/vyos-1x subdirectory does not exist, did git submodules fail to initialize?") + print("E: vyos-1x subdirectory does not exist, did git checkout fail?") + sys.exit(1) else: sys.path.append(VYOS1X_DIR) # Import local modules from scripts/image-build # They rely on modules from vyos-1x import utils -import defaults import raw_image from utils import cmd +## Check if there are missing build dependencies +deps = { + 'packages': [ + 'sudo', + 'make', + 'live-build', + 'pbuilder', + 'devscripts', + 'python3-pystache', + 'python3-git', + 'qemu-utils', + 'gdisk', + 'kpartx', + 'dosfstools' + ], + 'binaries': [] +} + +print("I: Checking if packages required for VyOS image build are installed") +try: + utils.check_system_dependencies(deps) +except OSError as e: + print(f"E: {e}") + sys.exit(1) + # argparse converts hyphens to underscores, # so for lookups in the original options hash we have to convert them back def field_to_option(s): @@ -94,21 +139,22 @@ def get_validator(optdict, name): except KeyError: return None -def merge_dicts(source, destination, skip_none=False): - """ Merge two dictionaries and return a new dict which has the merged key/value pairs. +def merge_defaults(source, defaults={}, skip_none=False): + """ Merge a dict with values from a defaults dict. Merging logic is as follows: Sub-dicts are merged. List values are combined. - Scalar values are set to those from the source dict. + Scalar values are set to those from the source dict, + if they exist there. """ from copy import deepcopy - tmp = deepcopy(destination) + tmp = deepcopy(defaults) for key, value in source.items(): if key not in tmp: tmp[key] = value elif isinstance(source[key], dict): - tmp[key] = merge_dicts(source[key], tmp[key]) + tmp[key] = merge_defaults(source[key], tmp[key]) elif isinstance(source[key], list): tmp[key] = source[key] + tmp[key] elif not skip_none or source[key] is not None: @@ -127,46 +173,6 @@ def make_toml_path(dir, file_basename): if __name__ == "__main__": - ## Check if the script is running wirh root permissions - ## Since live-build requires privileged calls such as chroot(), - ## there's no real way around it. - if os.getuid() != 0: - print("E: this script requires root privileges") - sys.exit(1) - - ## Check if there are missing build dependencies - deps = { - 'packages': [ - 'sudo', - 'make', - 'live-build', - 'pbuilder', - 'devscripts', - 'python3-pystache', - 'python3-git', - 'qemu-utils', - 'gdisk', - 'kpartx', - 'dosfstools' - ], - 'binaries': [] - } - - print("I: Checking if packages required for VyOS image build are installed") - try: - checker = utils.check_system_dependencies(deps) - except OSError as e: - print(f"E: {e}") - sys.exit(1) - - ## Load the file with default build configuration options - try: - with open(defaults.DEFAULTS_FILE, 'rb') as f: - build_defaults = tomli.load(f) - except Exception as e: - print("E: Failed to open the defaults file {0}: {1}".format(defaults.DEFAULTS_FILE, e)) - sys.exit(1) - ## Get a list of available build flavors flavor_dir_env = os.getenv("VYOS_BUILD_FLAVORS_DIR") if flavor_dir_env: @@ -241,7 +247,7 @@ if __name__ == "__main__": sys.exit(1) ## Try to get correct architecture and build type from build flavor and CLI arguments - pre_build_config = merge_dicts({}, build_defaults) + pre_build_config = copy.deepcopy(build_defaults) flavor_config = {} build_flavor = args["build_flavor"] @@ -249,7 +255,7 @@ if __name__ == "__main__": toml_flavor_file = make_toml_path(flavor_dir, args["build_flavor"]) with open(toml_flavor_file, 'rb') as f: flavor_config = tomli.load(f) - pre_build_config = merge_dicts(flavor_config, pre_build_config) + pre_build_config = merge_defaults(flavor_config, defaults=pre_build_config) except FileNotFoundError: print(f"E: Flavor '{build_flavor}' does not exist") sys.exit(1) @@ -258,7 +264,7 @@ if __name__ == "__main__": sys.exit(1) ## Combine configs args > flavor > defaults - pre_build_config = merge_dicts(args, pre_build_config, skip_none=True) + pre_build_config = merge_defaults(args, defaults=pre_build_config, skip_none=True) # Some fixup for mirror settings. # The idea is: if --debian-mirror is specified but --pbuilder-debian-mirror is not, @@ -290,20 +296,20 @@ if __name__ == "__main__": args['pbuilder_config'] = os.path.join(defaults.BUILD_DIR, defaults.PBUILDER_CONFIG) ## Combine the arguments with non-configurable defaults - build_config = merge_dicts({}, build_defaults) + build_config = copy.deepcopy(build_defaults) ## Load correct mix-ins with open(make_toml_path(defaults.BUILD_TYPES_DIR, pre_build_config["build_type"]), 'rb') as f: build_type_config = tomli.load(f) - build_config = merge_dicts(build_type_config, build_config) + build_config = merge_defaults(build_type_config, defaults=build_config) with open(make_toml_path(defaults.BUILD_ARCHES_DIR, pre_build_config["architecture"]), 'rb') as f: build_arch_config = tomli.load(f) - build_config = merge_dicts(build_arch_config, build_config) + build_config = merge_defaults(build_arch_config, defaults=build_config) ## Override with flavor and then CLI arguments - build_config = merge_dicts(flavor_config, build_config) - build_config = merge_dicts(args, build_config, skip_none=True) + build_config = merge_defaults(flavor_config, defaults=build_config) + build_config = merge_defaults(args, defaults=build_config, skip_none=True) ## Rename and merge some fields for simplicity ## E.g. --custom-packages is for the user, but internally @@ -316,7 +322,7 @@ if __name__ == "__main__": if has_nonempty_key(build_config, "architectures"): arch = build_config["architecture"] if arch in build_config["architectures"]: - if has_nonempty_key(build_config["architectures"], "packages"): + if has_nonempty_key(build_config["architectures"][arch], "packages"): build_config["packages"] += build_config["architectures"][arch]["packages"] ## Check if image format is specified, @@ -329,7 +335,7 @@ if __name__ == "__main__": if "boot_settings" not in build_config: build_config["boot_settings"] = defaults.boot_settings else: - build_config["boot_settings"] = merge_dicts(defaults.boot_settings, build_config["boot_settings"]) + build_config["boot_settings"] = merge_defaults(build_config["boot_settings"], defaults=defaults.boot_settings) ## Convert the image_format field to a single-item list if it's a scalar ## (like `image_format = "iso"`) @@ -372,6 +378,26 @@ if __name__ == "__main__": # Assign a (hopefully) unique identifier to the build (UUID) build_uuid = str(uuid.uuid4()) + # Initialize Git object from our repository + try: + repo = git.Repo('.', search_parent_directories=True) + # 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 or current tag + # Building a tagged release might leave us checking out a git tag that is not the tip of a named branch (detached HEAD) + # Check if the current HEAD is associated with a tag and use its name instead of an unavailable branch name. + git_branch = next((tag.name for tag in repo.tags if tag.commit == repo.head.commit), None) + if git_branch is None: + git_branch = repo.active_branch.name + except Exception as e: + print(f'W: Could not retrieve information from git: {repr(e)}') + build_git = "" + git_branch = "" + # Create the build version string if build_config['build_type'] == 'development': try: @@ -399,12 +425,14 @@ if __name__ == "__main__": version_data = { 'version': version, + 'flavor': build_config["build_flavor"], 'built_by': build_config['build_by'], 'built_on': build_date, 'build_uuid': build_uuid, 'build_git': build_git, 'build_branch': git_branch, 'release_train': build_config['release_train'], + 'architecture': build_config['architecture'], 'lts_build': lts_build, 'build_comment': build_config['build_comment'], 'bugtracker_url': build_config['bugtracker_url'], @@ -564,9 +592,9 @@ if __name__ == "__main__": ## Pin release for VyOS packages apt_pin = f"""Package: * - Pin: release n={build_config['release_train']} - Pin-Priority: 600 - """ +Pin: release n={build_config['release_train']} +Pin-Priority: 600 +""" with open(defaults.VYOS_PIN_FILE, 'w') as f: f.write(apt_pin) @@ -615,6 +643,8 @@ if __name__ == "__main__": # Most other formats, thankfully, can be produced with just `qemu-img convert` other_formats = filter(lambda x: x not in ["iso", "raw"], build_config["image_format"]) for f in other_formats: - target = f"{os.path.splitext(raw_image)[0]}.{f}" + image_ext = build_config.get("image_ext", f) + image_opts = build_config.get("image_opts", "") + target = f"{os.path.splitext(raw_image)[0]}-{build_config['build_flavor']}.{image_ext}" print(f"I: Building {f} file {target}") - cmd(f"qemu-img convert -f raw -O {f} {raw_image} {target}") + cmd(f"qemu-img convert -f raw -O {f} {image_opts} {raw_image} {target}") diff --git a/scripts/image-build/raw_image.py b/scripts/image-build/raw_image.py index ae061990..27fb27ab 100644 --- a/scripts/image-build/raw_image.py +++ b/scripts/image-build/raw_image.py @@ -22,6 +22,10 @@ import traceback import vyos.utils.process +import vyos.template + +vyos.template.DEFAULT_TEMPLATE_DIR = os.path.join(os.getcwd(), 'build/vyos-1x/data/templates') + SQUASHFS_FILE = 'live/filesystem.squashfs' VERSION_FILE = 'version.json' @@ -138,7 +142,6 @@ def setup_grub_configuration(build_config, root_dir) -> None: Args: root_dir (str): a path to the root of target filesystem """ - from vyos.template import render from vyos.system import grub print('I: Installing GRUB configuration files') @@ -149,13 +152,13 @@ def setup_grub_configuration(build_config, root_dir) -> None: grub_cfg_options = f'{root_dir}/{grub.CFG_VYOS_OPTIONS}' # create new files - render(grub_cfg_main, grub.TMPL_GRUB_MAIN, {}) + vyos.template.render(grub_cfg_main, grub.TMPL_GRUB_MAIN, {}) grub.common_write(root_dir) grub.vars_write(grub_cfg_vars, build_config["boot_settings"]) grub.modules_write(grub_cfg_modules, []) grub.write_cfg_ver(1, root_dir) - render(grub_cfg_menu, grub.TMPL_GRUB_MENU, {}) - render(grub_cfg_options, grub.TMPL_GRUB_OPTS, {}) + vyos.template.render(grub_cfg_menu, grub.TMPL_GRUB_MENU, {}) + vyos.template.render(grub_cfg_options, grub.TMPL_GRUB_OPTS, {}) def install_grub(con, version): from re import match |