summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-06-26 14:21:32 +0200
committerDaniil Baturin <daniil@baturin.org>2018-06-26 14:21:32 +0200
commitaa91197422cee8dda2e79cd307cfaf0194044eb4 (patch)
tree6bc1ff7ecde1c1b9d3c615aa9680ce2512ad176a /scripts
parent7f14d89db276262884dbb6b291fcbd396b007850 (diff)
downloadvyos-build-aa91197422cee8dda2e79cd307cfaf0194044eb4.tar.gz
vyos-build-aa91197422cee8dda2e79cd307cfaf0194044eb4.zip
T712: add configure options to simplify building images with custom packages.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-config12
-rw-r--r--scripts/defaults.py4
-rwxr-xr-xscripts/live-build-config25
3 files changed, 41 insertions, 0 deletions
diff --git a/scripts/build-config b/scripts/build-config
index 27a6c7ba..008311ad 100755
--- a/scripts/build-config
+++ b/scripts/build-config
@@ -59,6 +59,7 @@ options = {
'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None),
'vyos-mirror': ('VyOS package mirror', lambda: defaults.VYOS_MIRROR, None),
'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']),
+ 'custom-packages': ('Custom packages to install from repositories', lambda: '', None),
'version': ('Version number (release builds only)', None, None)
}
@@ -74,6 +75,10 @@ for k, v in options.items():
# The debug option is a bit special since it's different type
parser.add_argument('--debug', help="Enable debug output", action='store_true')
+# Custom APT entry and APT key options can be used multiple times
+parser.add_argument('--custom-apt-entry', help="Custom APT entry", action='append')
+parser.add_argument('--custom-apt-key', help="Custom APT key file", action='append')
+
args = vars(parser.parse_args())
# Validate options
@@ -107,6 +112,13 @@ args['build_dir'] = os.path.join(os.getcwd(), defaults.BUILD_DIR)
args['pbuilder_config'] = defaults.PBUILDER_CONFIG
args['vyos_branch'] = defaults.VYOS_BRANCH
+# Convert a whitespace-separated string of custom packages to a list
+if args['custom_packages']:
+ args['custom_packages'] = re.split(r'\s+', args['custom_packages'])
+else:
+ args['custom_packages'] = []
+
+
# Check the build environment and dependencies
env_check_retval = os.system("scripts/check-build-env")
if env_check_retval > 0:
diff --git a/scripts/defaults.py b/scripts/defaults.py
index 93eadc30..392af475 100644
--- a/scripts/defaults.py
+++ b/scripts/defaults.py
@@ -37,4 +37,8 @@ VYOS_MIRROR = 'http://dev.packages.vyos.net/repositories/current'
VYOS_BRANCH = 'current'
+ARCHIVES_DIR = 'config/archives/'
+
VYOS_REPO_FILE = 'config/archives/vyos.list.chroot'
+CUSTOM_REPO_FILE = 'config/archives/custom.list.chroot'
+CUSTOM_PACKAGE_LIST_FILE = 'config/package-lists/custom.list.chroot'
diff --git a/scripts/live-build-config b/scripts/live-build-config
index b1a77b4c..6933a475 100755
--- a/scripts/live-build-config
+++ b/scripts/live-build-config
@@ -22,6 +22,7 @@
import sys
import os
+import shutil
import json
import pystache
@@ -79,6 +80,30 @@ with open(apt_file, 'w') as f:
f.write(vyos_repo_entry)
f.write(vyos_debian_repo_entry)
+# Add custom APT entries
+if build_config['custom_apt_entry']:
+ custom_apt_file = os.path.join(build_config['build_dir'], defaults.CUSTOM_REPO_FILE)
+ entries = "\n".join(build_config['custom_apt_entry'])
+ if debug:
+ print("Adding custom APT entries:")
+ print(entries)
+ with open(custom_apt_file, 'w') as f:
+ f.write(entries)
+
+# Add custom APT keys
+if build_config['custom_apt_key']:
+ key_dir = os.path.join(build_config['build_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))
+
+# Add custom packages
+if build_config['custom_packages']:
+ package_list_file = os.path.join(build_config['build_dir'], defaults.CUSTOM_PACKAGE_LIST_FILE)
+ packages = "\n".join(build_config['custom_packages'])
+ with open (package_list_file, 'w') as f:
+ f.write(packages)
+
# Configure live-build
lb_config_command = pystache.render(lb_config_tmpl, build_config)