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.
This commit is contained in:
Daniil Baturin 2015-12-25 18:28:27 -05:00
parent c0cae8b7fe
commit 595d17abea
6 changed files with 93 additions and 0 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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')

35
scripts/pbuilder-config Executable file
View File

@ -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)

34
scripts/pbuilder-setup Executable file
View File

@ -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)

View File

@ -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