From 9f427b60af348bb7e9f5789275fd03529eb8a0e0 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Wed, 2 Sep 2015 23:47:19 +0100 Subject: Port the task-based scripts from tests with debian-cd --- MANIFEST.in | 2 +- bin/vmdebootstrap | 2 +- common/customise.lib | 23 ++++++++++++++++++++++- common/jessie-amd64-hook.sh | 30 ++++++++++++++++++++++++++++++ common/jessie-amd64.sh | 30 ++++++++++++++++++++++++++++++ common/jessie-arm64-hook.sh | 29 +++++++++++++++++++++++++++++ common/jessie-arm64.sh | 33 +++++++++++++++++++++++++++++++++ vmdebootstrap/uefi.py | 11 +++++++++-- 8 files changed, 155 insertions(+), 5 deletions(-) create mode 100755 common/jessie-amd64-hook.sh create mode 100755 common/jessie-amd64.sh create mode 100755 common/jessie-arm64-hook.sh create mode 100755 common/jessie-arm64.sh diff --git a/MANIFEST.in b/MANIFEST.in index c250038..9dbf08a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,6 @@ include NEWS include vmextract.py include vmdebootstrap.8.in recursive-include examples *.sh *.txt -recursive-include common *.lib +include common/* include doc/* recursive-include man *.rst diff --git a/bin/vmdebootstrap b/bin/vmdebootstrap index 175292e..1c77373 100755 --- a/bin/vmdebootstrap +++ b/bin/vmdebootstrap @@ -473,10 +473,10 @@ class VmDebootstrap(cliapp.Application): # pylint: disable=too-many-public-meth def debootstrap(self, rootdir): base = self.handlers[Base.name] msg = "(%s)" % self.settings['variant'] if self.settings['variant'] else '' + include = self._bootstrap_packages() base.message( 'Debootstrapping %s [%s] %s' % ( self.settings['distribution'], self.settings['arch'], msg)) - include = self._bootstrap_packages() args = ['debootstrap', '--arch=%s' % self.settings['arch']] diff --git a/common/customise.lib b/common/customise.lib index d36d78a..a62c64a 100644 --- a/common/customise.lib +++ b/common/customise.lib @@ -13,6 +13,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +BASE_OPTS=" + --owner ${WHO} --verbose \ + --sudo \ + --lock-root-password \ + --enable-dhcp \ + --configure-apt \ + --log debian-cd-${SUITE}-${ARCH}.log --log-level debug \ +" + +TASK_PACKAGES="task-laptop task-english" + +# packages which are not (yet) part of a task +EXTRA_PACKAGES="dkms locales whois telnet aptitude lsof host \ + bash-completion firmware-linux-free dnsutils time rsync reportbug w3m \ + ethtool ftp host lsof debian-faq debian-installer-launcher doc-debian \ +" cleanup() { umount ${rootdir}/proc umount ${rootdir}/sys @@ -38,10 +54,11 @@ EOF chmod a+x ${rootdir}/usr/sbin/policy-rc.d } +# FIXME: pass the replacement mirror prepare_apt_source() { # handle the apt source mv ${rootdir}/etc/apt/sources.list.d/base.list ${rootdir}/etc/apt/ - echo "deb http://cdbuilder.debian.org/debian/ jessie main contrib non-free" > ${rootdir}/etc/apt/sources.list + echo "deb http://mirror/debian/ ${SUITE} main contrib non-free" > ${rootdir}/etc/apt/sources.list chroot ${rootdir} apt update } @@ -54,3 +71,7 @@ replace_apt_source() { rm ${rootdir}/etc/apt/sources.list mv ${rootdir}/etc/apt/base.list ${rootdir}/etc/apt/sources.list.d/ } + +blacklist_qemu_bochs() { + echo "blacklist bochs-drm" > ${rootdir}/etc/modprobe.d/qemu-blacklist.conf +} diff --git a/common/jessie-amd64-hook.sh b/common/jessie-amd64-hook.sh new file mode 100755 index 0000000..c6a99fd --- /dev/null +++ b/common/jessie-amd64-hook.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +set -e + +rootdir=$1 + +# common needs rootdir to already be defined. +. /usr/share/vmdebootstrap/common/customise.lib + +trap cleanup 0 + +mount_support +disable_daemons +# prepare_apt_source + +chroot ${rootdir} apt-get -q -y install ${TASK_PACKAGES} ${EXTRA_PACKAGES} \ + task-xfce-desktop exim4 mutt info rpcbind pciutils \ + task-ssh-server task-print-server plymouth procmail \ + m4 open-vm-tools apt-listchanges at busybox nfs-common \ + wamerican texinfo plymouth-themes plymouth-x11 uuid-runtime \ + open-vm-tools-dkms open-vm-tools-desktop gettext-base mlocate \ + irqbalance memtest86+ user-setup zerofree + +remove_daemon_block +# replace_apt_source + +# particular to efi builds +blacklist_qemu_bochs + +echo "Customisation complete" diff --git a/common/jessie-amd64.sh b/common/jessie-amd64.sh new file mode 100755 index 0000000..6f0971e --- /dev/null +++ b/common/jessie-amd64.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +set -e + +# define before sourcing common +WHO=`whoami` +USER='user/live' +SUITE='jessie' +SIZE='5G' +ARCH='amd64' +SHARE_PATH='/usr/share/vmdebootstrap/common' +# needs a path for arch and task desktop +IMAGE_PATH='.' + +. ${SHARE_PATH}/customise.lib + +sudo vmdebootstrap \ + ${BASE_OPTS} --user ${USER} \ + --size ${SIZE} \ + --arch ${ARCH} \ + --no-extlinux \ + --grub --use-uefi \ + --distribution ${SUITE} \ + --customize "${SHARE_PATH}/${SUITE}-${ARCH}-hook.sh" \ + --image ${IMAGE_PATH}/${SUITE}.img \ + "$@" + +# report results and check we have something valid. +ls -l ${IMAGE_PATH}/${SUITE}.img +md5sum ${IMAGE_PATH}/${SUITE}.img diff --git a/common/jessie-arm64-hook.sh b/common/jessie-arm64-hook.sh new file mode 100755 index 0000000..c986759 --- /dev/null +++ b/common/jessie-arm64-hook.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +set -e + +rootdir=$1 + +# common needs rootdir to already be defined. +. /usr/share/vmdebootstrap/common/customise.lib + +trap cleanup 0 + +mount_support +disable_daemons +prepare_apt_source + +chroot ${rootdir} apt-get -q -y install ${TASK_PACKAGES} ${EXTRA_PACKAGES} \ + task-xfce-desktop exim4 mutt info rpcbind pciutils \ + task-ssh-server task-print-server plymouth procmail \ + m4 apt-listchanges at busybox nfs-common \ + wamerican texinfo plymouth-themes plymouth-x11 uuid-runtime \ + gettext-base mlocate irqbalance \ + irqbalance user-setup zerofree + +remove_daemon_block +replace_apt_source +# particular to efi builds +blacklist_qemu_bochs + +echo "Customisation complete" diff --git a/common/jessie-arm64.sh b/common/jessie-arm64.sh new file mode 100755 index 0000000..4ac9f8d --- /dev/null +++ b/common/jessie-arm64.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +# define before sourcing common +WHO=`whoami` +USER='user/live' +SUITE='jessie' +SIZE='5G' +ARCH='arm64' +BINFMT='/usr/bin/qemu-aarch64-static' +SHARE_PATH='/usr/share/vmdebootstrap/common' +# needs a path for arch and task desktop +IMAGE_PATH='.' + +. ${SHARE_PATH}/customise.lib + +sudo vmdebootstrap \ + ${BASE_OPTS} --user ${USER} \ + --size ${SIZE} \ + --arch ${ARCH} \ + --foreign ${BINFMT} \ + --no-extlinux \ + --grub --use-uefi \ + --package dosfstools \ + --distribution ${SUITE} \ + --customize "${SHARE_PATH}/${SUITE}-${ARCH}-hook.sh" \ + --image ${IMAGE_PATH}/${SUITE}-${ARCH}.img \ + "$@" + +# report results and check we have something valid. +ls -l ${IMAGE_PATH}/${SUITE}-${ARCH}.img +md5sum ${IMAGE_PATH}/${SUITE}-${ARCH}.img diff --git a/vmdebootstrap/uefi.py b/vmdebootstrap/uefi.py index 50ad842..08da7c7 100644 --- a/vmdebootstrap/uefi.py +++ b/vmdebootstrap/uefi.py @@ -46,10 +46,11 @@ class Uefi(Base): def efi_packages(self): packages = [] - if self.settings['grub'] and not self.settings['use-uefi']: + if not self.settings['use-uefi'] or\ + self.settings['arch'] not in arch_table: return packages pkg = arch_table[self.settings['arch']]['package'] - self.message("Adding %s" % pkg) + self.message("Adding %s to debootstrap" % pkg) packages.append(pkg) extra = arch_table[self.settings['arch']]['extra'] if extra and isinstance(extra, str): @@ -59,6 +60,8 @@ class Uefi(Base): return packages def copy_efi_binary(self, efi_removable, efi_install): + if self.settings['arch'] not in arch_table: + return logging.debug("using bootdir=%s", self.bootdir) if efi_removable.startswith('/'): efi_removable = efi_removable[1:] @@ -83,6 +86,8 @@ class Uefi(Base): Copy the bootloader file from the package into the location so needs to be after grub and kernel already installed. """ + if self.settings['arch'] not in arch_table: + return self.message('Configuring EFI') mount_wrapper(rootdir) efi_removable = str(arch_table[self.settings['arch']]['removable']) @@ -95,6 +100,8 @@ class Uefi(Base): umount_wrapper(rootdir) def configure_extra_efi(self, rootdir): + if self.settings['arch'] not in arch_table: + return extra = arch_table[self.settings['arch']]['extra'] if extra: mount_wrapper(rootdir) -- cgit v1.2.1