Merge branch 'add-mmdebstrap' into 'master'

Support another boostrap tool: mmdebstrap

See merge request live-team/live-build!343
This commit is contained in:
Steven Shiau 2024-12-22 23:00:08 +00:00
commit 470580e7ba
8 changed files with 155 additions and 2 deletions

2
debian/control vendored
View File

@ -18,7 +18,7 @@ Package: live-build
Architecture: all
Depends:
cpio,
debootstrap,
debootstrap | mmdebstrap,
${misc:Depends},
Recommends:
apt-utils,

View File

@ -491,6 +491,8 @@ Prepare_config ()
LB_SOURCE_IMAGES="${LB_SOURCE_IMAGES:-tar}"
LB_SOURCE_IMAGES="$(echo "${LB_SOURCE_IMAGES}" | tr "," " ")"
LB_BOOTSTRAP="${LB_BOOTSTRAP:-debootstrap}"
# Foreign/port bootstrapping
if [ -n "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" ]; then
LB_BOOTSTRAP_QEMU_ARCHITECTURE="${LB_BOOTSTRAP_QEMU_ARCHITECTURES}"

View File

@ -43,6 +43,8 @@
[\fB\-\-bootappend\-live\-failsafe\fR \fIPARAMETER\fR|"\fIPARAMETERS\fR"]
.br
[\fB\-\-bootloaders\fR grub-legacy|grub-pc|syslinux|grub-efi|"\fIBOOTLOADERS\fR"]
.br
[\fB\-\-bootstrap\fR debootstrap|mmdebstrap\fR]
.br
[\fB\-\-bootstrap\-qemu\-arch\fR \fIARCH\fR]
.br

View File

@ -84,6 +84,8 @@ applies apt archive configuration
in save mode, saves to cache a copy of the generated bootstrap directory, and in restore mode, restores from cache a previously generated copy
.IP "\fBlb bootstrap_debootstrap\fR(1)" 4
creates (bootstraps) a basic Debian root filesystem using debootstrap(8)
.IP "\fBlb bootstrap_mmdebstrap\fR(1)" 4
creates (bootstraps) a basic Debian root filesystem using mmdebstrap(8)
.SS Chroot stage specific commands
.PP
Note: The following chroot_ prefixed commands are used in building the live OS filesystem. Another set of similarly prefixed files are listed separately (see further down).

View File

@ -29,6 +29,7 @@ Setup_clean_exit
# Bootstrapping system
lb bootstrap_cache restore "${@}"
lb bootstrap_mmdebstrap "${@}"
lb bootstrap_debootstrap "${@}"
lb bootstrap_cache save "${@}"

View File

@ -21,6 +21,11 @@ USAGE="${PROGRAM} [--force]"
# Processing arguments and configuration files
Init_config_data "${@}"
if [ "${LB_BOOTSTRAP}" != "debootstrap" ]
then
exit 0
fi
if ! command -v debootstrap >/dev/null
then
Echo_error "debootstrap - command not found"

View File

@ -0,0 +1,132 @@
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2016-2020 The Debian Live team
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
set -e
# Including common functions
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
# Setting static variables
DESCRIPTION="Bootstrap a Debian system with mmdebstrap(8)"
USAGE="${PROGRAM} [--force]"
# Processing arguments and configuration files
Init_config_data "${@}"
if [ "${LB_BOOTSTRAP}" != "mmdebstrap" ]
then
exit 0
fi
if ! command -v mmdebstrap >/dev/null
then
Echo_error "mmdebstrap - command not found"
exit 1
fi
# Check architecture
Check_crossarchitectures
Echo_message "Begin bootstrapping system..."
Check_package host /usr/bin/mmdebstrap mmdebstrap
# Checking stage file
Check_stagefile "bootstrap"
# Note, this must match that used in `bootstrap_cache`
Check_stagefile "bootstrap_cache.restore"
# Acquire lock file
Acquire_lockfile
Print_breakage ()
{
Echo_message "If the following stage fails, the most likely cause of the problem is with your mirror configuration or a caching proxy."
}
# Creating chroot directory
mkdir -p chroot
# Setting mmdebstrap options
if [ -n "${LB_ARCHITECTURE}" ]
then
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --arch=${LB_ARCHITECTURE}"
fi
if [ "${LB_ARCHIVE_AREAS}" != "main" ]
then
# Modify archive areas to remove leading/trailing whitespaces and replace other whitepspace with commas
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --components=$(echo ${LB_ARCHIVE_AREAS} | sed -e 's| |,|g')"
FOREIGN_DEBOOTSTRAP_OPTIONS="--components=$(echo ${LB_ARCHIVE_AREAS} | sed -e 's| |,|g')"
fi
if [ "${_VERBOSE}" = "true" ]
then
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --verbose"
fi
# If LB_APT_SECURE is false, do not check signatures of the Release file
if [ "${LB_APT_SECURE}" = "false" ]
then
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --no-check-gpg"
else
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --force-check-gpg"
fi
if [ "${LB_CACHE_PACKAGES}" = "true" ]
then
if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1
then
mkdir -p chroot/var/cache/apt/archives
cp cache/packages.bootstrap/*.deb chroot/var/cache/apt/archives
fi
Print_breakage
Echo_message "Running mmdebstrap (download-only)..."
mmdebstrap ${DEBOOTSTRAP_OPTIONS} --download-only "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" ${DEBOOTSTRAP_SCRIPT}
# Removing old cache
rm -f cache/packages.bootstrap/*.deb
# Saving new cache
mkdir -p cache/packages.bootstrap
cp chroot/var/cache/apt/archives/*.deb cache/packages.bootstrap
fi
Print_breakage
Echo_message "Running mmdebstrap..."
# Run appropriate bootstrap, i.e. foreign or regular bootstrap
if [ "${LB_BOOTSTRAP_QEMU_ARCHITECTURE}" = "${LB_ARCHITECTURE}" ]; then
if [ -n "${LB_BOOTSTRAP_QEMU_EXCLUDE}" ]
then
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_QEMU_EXCLUDE} | sed 's| *|,|g')"
fi
Echo_message "Bootstrap will be foreign"
mmdebstrap ${DEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" ${DEBOOTSTRAP_SCRIPT}
Echo_message "Running mmdebstrap second stage under QEMU"
cp ${LB_BOOTSTRAP_QEMU_STATIC} chroot/usr/bin
Chroot chroot /bin/sh /mmdebstrap/mmdebstrap --second-stage ${FOREIGN_DEBOOTSTRAP_OPTIONS}
else
mmdebstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" ${DEBOOTSTRAP_SCRIPT}
fi
# Deconfiguring mmdebstrap configurations
rm -f chroot/etc/hosts
# Removing bootstrap cache
rm -f chroot/var/cache/apt/archives/*.deb
# Creating stage file
Create_stagefile "bootstrap"

View File

@ -34,6 +34,7 @@ USAGE="${PROGRAM} [--apt apt|apt-get|aptitude]\n\
\t [--bootappend-live PARAMETER|\"PARAMETERS\"]\n\
\t [--bootappend-live-failsafe PARAMETER|\"PARAMETERS\"]\n\
\t [--bootloaders grub-legacy|grub-pc|syslinux|grub-efi|\"BOOTLOADERS\"]\n\
\t [--bootstrap debootstrap|mmdebstrap]\n\
\t [--bootstrap-qemu-arch ARCH]\n\
\t [--bootstrap-qemu-exclude PACKAGE|\"PACKAGES\"]\n\
\t [--bootstrap-qemu-static PATH]\n\
@ -140,7 +141,7 @@ Local_arguments ()
apt-source-archives:,architecture:,architectures:,archive-areas:,
backports:,binary-filesystem:,binary-image:,binary-images:,
bootappend-install:,bootappend-live:,bootappend-live-failsafe:,
bootloader:,bootloaders:,bootstrap-qemu-arch:,bootstrap-qemu-exclude:,
bootloader:,bootloaders:,bootstrap:,bootstrap-qemu-arch:,bootstrap-qemu-exclude:,
bootstrap-qemu-static:,breakpoints,build-with-chroot:,
cache:,cache-indices:,cache-packages:,cache-stages:,checksums:,
chroot-filesystem:,chroot-squashfs-compression-level:,
@ -372,6 +373,11 @@ Local_arguments ()
shift 2
;;
--bootstrap)
LB_BOOTSTRAP="${2}"
shift 2
;;
--bootstrap-qemu-arch)
LB_BOOTSTRAP_QEMU_ARCHITECTURE="${2}"
shift 2
@ -998,6 +1004,9 @@ LB_APT_SECURE="${LB_APT_SECURE}"
# Set apt/aptitude source entries in sources.list
LB_APT_SOURCE_ARCHIVES="${LB_APT_SOURCE_ARCHIVES}"
# Set bootstrap program
LB_BOOTSTRAP="${LB_BOOTSTRAP}"
# Control cache
LB_CACHE="${LB_CACHE}"