diff options
-rw-r--r-- | Makefile | 6 | ||||
-rwxr-xr-x | scripts/build-config | 7 | ||||
-rw-r--r-- | scripts/defaults.py | 5 | ||||
-rwxr-xr-x | scripts/pbuilder-config | 35 | ||||
-rwxr-xr-x | scripts/pbuilder-setup | 34 | ||||
-rwxr-xr-x | scripts/pbuilder/hooks/C10shell | 6 |
6 files changed, 93 insertions, 0 deletions
@@ -24,6 +24,12 @@ iso: prepare lb build 2>&1 | tee build.log @echo "VyOS ISO build successful" +.PHONY: prepare-package-env +.ONESHELL: +prepare-package-env: + @scripts/pbuilder-config + @scripts/pbuilder-setup + .PHONY: clean .ONESHELL: clean: diff --git a/scripts/build-config b/scripts/build-config index f04dcb3f..e001ef3d 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -51,6 +51,13 @@ if (args['debian_mirror'] != defaults.DEBIAN_MIRROR) and \ (args['pbuilder_debian_mirror'] == defaults.DEBIAN_MIRROR): args['pbuilder_debian_mirror'] = args['debian-mirror'] +# Populate some defaults that are not configurable, +# but that are handy to have in the options hash +args['distribution'] = defaults.DEBIAN_DISTRIBUTION +args['build_dir'] = os.path.join(os.getcwd(), defaults.BUILD_DIR) +args['pbuilder_config'] = defaults.PBUILDER_CONFIG + + # Save to file distutils.dir_util.mkpath(defaults.BUILD_DIR) diff --git a/scripts/defaults.py b/scripts/defaults.py index 05f05973..2dbaeb0c 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -5,3 +5,8 @@ BUILD_CONFIG = os.path.join(BUILD_DIR, 'build-config.json') # The default mirror was chosen entirely at random DEBIAN_MIRROR = 'http://ftp.nl.debian.org/debian/' + +DEBIAN_DISTRIBUTION = 'jessie' + +PBUILDER_CONFIG = os.path.join(BUILD_DIR, 'pbuilderrc') +PBUILDER_DIR = os.path.join(BUILD_DIR, 'pbuilder') diff --git a/scripts/pbuilder-config b/scripts/pbuilder-config new file mode 100755 index 00000000..5cda7b13 --- /dev/null +++ b/scripts/pbuilder-config @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import sys +import os +import json + +import pystache + +import defaults +import util + +util.check_build_config() + +pbuilder_config_tmpl = """ + +BASETGZ={{build_dir}}/base.tgz +BUILDPLACE={{build_dir}}/pbuilder/ +MIRRORSITE={{pbuilder_debian_mirror}} +BUILDRESULT={{build_dir}}/pbuilder/result/ + +DISTRIBUTION={{distribution}} + +ARCHITECTURE={{architecture}} + +""" + +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +pbuilder_config = pystache.render(pbuilder_config_tmpl, build_config) + +print("Configuring pbuilder") + +with open(defaults.PBUILDER_CONFIG, 'w+') as f: + f.write(pbuilder_config) diff --git a/scripts/pbuilder-setup b/scripts/pbuilder-setup new file mode 100755 index 00000000..264db0b2 --- /dev/null +++ b/scripts/pbuilder-setup @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import sys +import os +import json +import distutils.dir_util + +import pystache + +import defaults +import util + +util.check_build_config() + +pbuilder_create_cmd_tmpl= """ + sudo pbuilder --create \ + --configfile {{pbuilder_config}} +""" + +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +pbuilder_create_command = pystache.render(pbuilder_create_cmd_tmpl, build_config) + +print("Creating a pbuilder environment") +#os.chdir(defaults.BUILD_DIR) + +distutils.dir_util.mkpath(defaults.PBUILDER_DIR) + +result = os.system(pbuilder_create_command) +if result > 0: + print("pbuilder environment bootstrap failed") + sys.exit(1) + diff --git a/scripts/pbuilder/hooks/C10shell b/scripts/pbuilder/hooks/C10shell new file mode 100755 index 00000000..f56f9f7f --- /dev/null +++ b/scripts/pbuilder/hooks/C10shell @@ -0,0 +1,6 @@ +#!/bin/sh +# invoke shell if build fails. + +apt-get install -y --force-yes vim nano less bash +cd /tmp/buildd/*/debian/.. +/bin/bash < /dev/tty > /dev/tty 2> /dev/tty |