diff options
author | Daniil Baturin <daniil@baturin.org> | 2024-11-06 18:55:37 +0000 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2024-11-06 19:03:42 +0000 |
commit | 9ed7a29ebb77c36ee555c2818b728a7e6b160322 (patch) | |
tree | 39a8197682364fdeb008f3047064cb7aea01e89a | |
parent | 5674398d59f76bfcd3b594bfef4e5afb4eb043ca (diff) | |
download | vyos-build-9ed7a29ebb77c36ee555c2818b728a7e6b160322.tar.gz vyos-build-9ed7a29ebb77c36ee555c2818b728a7e6b160322.zip |
build: T6855: make the custom APT entry and key syntax more flexible
-rw-r--r-- | data/architectures/amd64.toml | 13 | ||||
-rw-r--r-- | data/architectures/arm64.toml | 13 | ||||
-rwxr-xr-x | scripts/image-build/build-vyos-image | 44 | ||||
-rw-r--r-- | scripts/image-build/defaults.py | 2 |
4 files changed, 54 insertions, 18 deletions
diff --git a/data/architectures/amd64.toml b/data/architectures/amd64.toml index 8a4ef9d0..9ab1c03b 100644 --- a/data/architectures/amd64.toml +++ b/data/architectures/amd64.toml @@ -1,8 +1,3 @@ -additional_repositories = [ - "deb [arch=amd64] https://packages.vyos.net/saltproject/debian/11/amd64/3005 bullseye main", - "deb https://repo.zabbix.com/zabbix/6.0/debian bookworm main" -] - # Packages added to images for x86 by default packages = [ "grub2", @@ -13,3 +8,11 @@ packages = [ "vyos-intel-ixgbe", "vyos-intel-ixgbevf", ] + +[additional_repositories.salt] + architecture = "amd64" + url = "https://packages.vyos.net/saltproject/debian/11/amd64/3005" + distribution = "bullseye" + +[additional_repositories.zabbix] + url = "https://repo.zabbix.com/zabbix/6.0/debian" diff --git a/data/architectures/arm64.toml b/data/architectures/arm64.toml index bf9ef8ee..ebf14ef4 100644 --- a/data/architectures/arm64.toml +++ b/data/architectures/arm64.toml @@ -1,10 +1,13 @@ -additional_repositories = [ - "deb [arch=arm64] https://packages.vyos.net/saltproject/debian/11/arm64/3005 bullseye main", - "deb https://repo.zabbix.com/zabbix/6.0/debian-arm64 bookworm main" -] - # Packages included in ARM64 images by default packages = [ "grub-efi-arm64", ] bootloaders = "grub-efi" + +[additional_repositories.salt] + architecture = "arm64" + url = "https://packages.vyos.net/saltproject/debian/11/amd64/3005" + distribution = "bullseye" + +[additional_repositories.zabbix] + url = "https://repo.zabbix.com/zabbix/6.0/debian-arm64" diff --git a/scripts/image-build/build-vyos-image b/scripts/image-build/build-vyos-image index a9294f38..044a9055 100755 --- a/scripts/image-build/build-vyos-image +++ b/scripts/image-build/build-vyos-image @@ -25,6 +25,7 @@ import copy import uuid import glob import json +import base64 import shutil import argparse import datetime @@ -503,8 +504,9 @@ DOCUMENTATION_URL="{build_config['documentation_url']}" ## Create live-build configuration files # Add the additional repositories to package lists - print("I: Setting up additional APT entries") + print("I: Setting up VyOS repository APT entries") vyos_repo_entry = "deb {vyos_mirror} {vyos_branch} main\n".format(**build_config) + vyos_repo_entry += "deb-src {vyos_mirror} {vyos_branch} main\n".format(**build_config) apt_file = defaults.VYOS_REPO_FILE @@ -516,10 +518,36 @@ DOCUMENTATION_URL="{build_config['documentation_url']}" f.write(vyos_repo_entry) # Add custom APT entries + print("I: Setting up additional APT entries") if build_config.get('additional_repositories', False): - build_config['custom_apt_entry'] += build_config['additional_repositories'] + for r in build_config['additional_repositories']: + repo_data = build_config['additional_repositories'][r] + + url = repo_data.get('url', None) + arch = repo_data.get('architecture', None) + distro = repo_data.get('distribution', build_config['debian_distribution']) + components = repo_data.get('components', 'main') + + if not url: + print(f'E: repository {r} does not specify URL') + sys.exit(1) + + if arch: + arch_string = f'[arch={arch}]' + else: + arch_string = '' + + entry = f'deb {arch_string} {url} {distro} {components}' + build_config['custom_apt_entry'].append(entry) + + if not repo_data.get('no_source', False): + src_entry = f'deb-src {url} {distro} {components}' + build_config['custom_apt_entry'].append(src_entry) + + if repo_data.get('key', None): + build_config['custom_apt_keys'].append({'name': r, 'key': repo_data['key']}) - if build_config.get('custom_apt_entry', False): + if build_config.get('custom_apt_entry', []): custom_apt_file = defaults.CUSTOM_REPO_FILE entries = "\n".join(build_config['custom_apt_entry']) if debug: @@ -530,11 +558,13 @@ DOCUMENTATION_URL="{build_config['documentation_url']}" f.write("\n") # Add custom APT keys - if has_nonempty_key(build_config, 'custom_apt_key'): + if has_nonempty_key(build_config, 'custom_apt_keys'): key_dir = defaults.ARCHIVES_DIR - for k in build_config['custom_apt_key']: - dst_name = '{0}.key.chroot'.format(os.path.basename(k)) - shutil.copy(k, os.path.join(key_dir, dst_name)) + for k in build_config['custom_apt_keys']: + dst_name = '{0}.key.chroot'.format(k['name']) + with open(os.path.join(key_dir, dst_name), 'bw') as f: + key_data = base64.b64decode(k['key']) + f.write(key_data) # Add custom packages if has_nonempty_key(build_config, 'packages'): diff --git a/scripts/image-build/defaults.py b/scripts/image-build/defaults.py index a0c5c8bf..29a6d59f 100644 --- a/scripts/image-build/defaults.py +++ b/scripts/image-build/defaults.py @@ -35,7 +35,7 @@ boot_settings: dict[str, str] = { # Hardcoded default values HARDCODED_BUILD = { 'custom_apt_entry': [], - 'custom_apt_key': [], + 'custom_apt_keys': [], 'custom_package': [], 'reuse_iso': None, 'disk_size': 10, |