Put the udebs in a pool type directory structure

Signed-off-by: Neil Williams <codehelp@debian.org>
This commit is contained in:
Neil Williams 2016-07-01 19:21:35 +02:00 committed by Iain R. Learmonth
parent e54cb37851
commit bf7ff4d222
7 changed files with 57 additions and 51 deletions

View file

@ -145,6 +145,8 @@ class LiveWrapper(cliapp.Application):
'(default: %default)', default=False, group="Bootloaders")
def process_args(self, args):
if os.path.exists(self.settings['image_output']):
raise cliapp.AppException("Image '%s' already exists" % self.settings['image_output'])
if not self.settings['isolinux'] and not self.settings['grub']:
raise cliapp.AppException("You must enable at least one bootloader!")
if self.settings['grub'] and self.settings['grub-loopback-only']:
@ -180,9 +182,9 @@ class LiveWrapper(cliapp.Application):
logging.info("Running vmdebootstrap...")
print("Running vmdebootstrap...")
# Run vmdebootstrap
# Run vmdebootstrap, putting files in /live/
vm = VMDebootstrap(self.settings['distribution'],
self.settings['mirror'])
self.settings['mirror'], self.cdroot)
vm.run()
# Fetch D-I helper archive if needed

View file

@ -75,7 +75,15 @@ class AptUdebDownloader(object):
def download_udebs(self, exclude_list):
if not self.cache:
raise RuntimeError('No cache available.')
main_pool = os.path.join(self.destdir, 'pool', 'main')
os.makedirs(main_pool)
for pkg_name in self.cache.keys():
prefix = pkg_name[0]
# destdir is just a base, needs pool/main/[index]/[name]
if pkg_name[:3] == 'lib':
prefix = pkg_name[:4]
pkg_dir = os.path.join(main_pool, prefix, pkg_name)
os.makedirs(pkg_dir)
if pkg_name in exclude_list:
continue
pkg = self.cache[pkg_name]
@ -89,8 +97,9 @@ class AptUdebDownloader(object):
version = pkg.versions[0]
if not version.uri:
continue
# FIXME: still need a Packages file and Release.
try:
version.fetch_binary(destdir=self.destdir)
version.fetch_binary(destdir=pkg_dir)
except TypeError as exc:
continue
except apt.package.FetchError as exc:

View file

@ -28,6 +28,7 @@ class GrubConfig(object):
def generate_cfg(self):
ret = ("if [ ${iso_path} ] ; then\nset loopback=\"" +
"findiso=${iso_path}\"\nfi\n\n")
# FIXME: identify grub module prefix, e.g. boot/grub/x86_64-efi
self.versions.sort(reverse=True)
for version in self.versions:
ret += "menuentry \"Debian GNU/Linux Live (kernel %s)\" {\n" % (version,)

View file

@ -19,12 +19,12 @@ from vmdebootstrap.base import runcmd
class VMDebootstrap:
def __init__(self, distribution, mirror=None):
def __init__(self, distribution, mirror=None, cdroot='/tmp/'):
self.args = ["vmdebootstrap",
"--sudo", "--lock-root-password",
"--enable-dhcp", "--configure-apt", "--verbose",
"--log", "vmdebootstrap.log", "--squash=cdroot/live/",
"--log-level", "debug", "--customize",
"--log", "vmdebootstrap.log", "--squash=%s/live/" % cdroot,
"--log-level", "debug", "--customize", "--use-uefi",
"hooks/customise.sh"]
self.args.extend(["--distribution", distribution])

View file

@ -44,7 +44,6 @@ class Xorriso:
self.args.extend(['-as', 'mkisofs', '-eltorito-alt-boot', '-e',
'boot/grub/efi.img', '-no-emul-boot',
'-isohybrid-gpt-basdat'])
return self.args
def build_image(self):
@ -61,4 +60,5 @@ class Xorriso:
if len(self.args) == 1:
cliapp.AppException("Attempted to run xorriso before building "
"arguments!")
print(self.args)
runcmd(self.args)

View file

@ -0,0 +1,34 @@
# Slow image building tests
In this chapter, we have test scenarios that actually build an image
and test the output. The images are not booted, but that may be added
later. Instead, all the tests on the images are static.
These tests are slow, since building images is slow.
## Build a very basic Debian 8 image
SCENARIO build a basic Debian 8 image
ASSUMING build tests are requested
GIVEN user wants to build an image FOO.img that is 2GiB in size
WHEN the user runs vmdebootstrap --sparse --extlinux
THEN the image has the correct size
AND the partition count of the image is 1
AND partition 1 has the boot flag set
AND partition 1 has an ext4 filesystem
AND partition 1 has file /etc/debian_version matching ^8\..*$
# need a test that xorriso builds a bootable disk.
# Eltorito validation header:
# Hid 1
# Arch 239 (Unknown Arch)
# ID ''
# Key 55 AA
# Eltorito defaultboot header:
# Bootid 88 (bootable)
# Boot media 0 (No Emulation Boot)
# Load segment 0
# Sys type 0
# Nsect 340
# Bootoff 6C 108

View file

@ -73,48 +73,8 @@ The steps in this section do static tests of disk image. These all
operate on the image specified in the step "GIVEN user wants to
build...".
Test the size of an image. This tests the length, not disk usage, of
the image.
# isoinfo -i jessie-live-uefi.iso -ld
# CD-ROM is in ISO 9660 format
# El Torito VD version 1 found, boot catalog is in sector 3031
# Bootid 88 (bootable)
IMPLEMENTS THEN the image has the correct size
actual="$(stat -c %s "$IMAGE")"
[ "$actual" = "$IMAGE_SIZE" ]
Check the partition table on the image.
IMPLEMENTS THEN the partition count of the image is (\d+)
parted --script "$IMAGE" print |
sed '1,/^Number/d' |
grep -c . |
grep -Fx $MATCH_1
Check partition boot flag.
IMPLEMENTS THEN partition (\d+) has the boot flag set
parted --script "$IMAGE" print |
awk -v "PART=$MATCH_1" '/^ [0-9]+ / && $1 == PART && $7 ~ "^boot,?$"' |
grep .
IMPLEMENTS THEN partition (\d+) has the lba flag set
parted --script "$IMAGE" print |
awk -v "PART=$MATCH_1" '/^ [0-9]+ / && $1 == PART && $8 ~ "^lba?$"' |
grep .
Check filesystem on a partition. This checks the actual filesystem,
not a type declared in the partition table.
IMPLEMENTS THEN partition (\d+) has an? (\S+) filesystem
device="$(kpartx_image_partition "$IMAGE" "$MATCH_1")"
trap "unkpartx_image \"$IMAGE\"" EXIT
blkid "$device" | grep "TYPE=\"$MATCH_2\""
Check that the partition contains a file with some content matching a
regular expression.
IMPLEMENTS THEN partition (\d+) has file (\S+) matching (.+)
device="$(kpartx_image_partition "$IMAGE" "$MATCH_1")"
trap "unkpartx_image \"$IMAGE\"" EXIT
mp="$(mktemp -d)"
mount -r "$device" "$mp"
trap "umount \"$mp\"; unkpartx_image \"$IMAGE\"" EXIT
grep -P -e "$MATCH_3" "$mp/$MATCH_2"