diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-12-25 18:28:27 -0500 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-12-25 18:28:27 -0500 |
commit | 595d17abea232345cf4475206363de7c379c3211 (patch) | |
tree | 7c1d312af13a784db35926670f156720c346ed7b /scripts | |
parent | c0cae8b7fec0d5e8a7c8ff9418397587e967fd15 (diff) | |
download | vyos-build-595d17abea232345cf4475206363de7c379c3211.tar.gz vyos-build-595d17abea232345cf4475206363de7c379c3211.zip |
Initial support for pbuilder.
Note: pbuilder --create does not work well with relative build path,
base.tgz creation fails.
This led to the build_dir path being absolute.
Perhaps we should make it more granular and only use absolute paths for
pbuilder options.
Diffstat (limited to 'scripts')
-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 |
5 files changed, 87 insertions, 0 deletions
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 |