Allow configuring debootstrap implementation, add mmdebstrap support
Adds mmdebstrap-specific code to bootstrap_debootstrap, and allows the user to set whether they want to use debootstrap or mmdebstrap to bootstrap the chroot. Other debootstrap alternatives could be supported fairly easily by adding the appropriate logic for those frontends to bootstrap_debootstrap. Closes: #1031929
This commit is contained in:
parent
9ae2c0105c
commit
0a8559b9d4
@ -489,6 +489,8 @@ Prepare_config ()
|
||||
LB_BOOTSTRAP_QEMU_ARCHITECTURE="${LB_BOOTSTRAP_QEMU_ARCHITECTURE:-}"
|
||||
LB_BOOTSTRAP_QEMU_EXCLUDE="${LB_BOOTSTRAP_QEMU_EXCLUDE:-}"
|
||||
LB_BOOTSTRAP_QEMU_STATIC="${LB_BOOTSTRAP_QEMU_STATIC:-}"
|
||||
|
||||
DEBOOTSTRAP_ENGINE="${DEBOOTSTRAP_ENGINE:-debootstrap}"
|
||||
}
|
||||
|
||||
Validate_config ()
|
||||
@ -768,6 +770,11 @@ Validate_config_permitted_values ()
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! In_list "${DEBOOTSTRAP_ENGINE}" debootstrap mmdebstrap; then
|
||||
Echo_error "You have specified an invalid value for DEBOOTSTRAP_ENGINE (--debootstrap-engine)."
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
# Check option combinations and other extra stuff
|
||||
@ -800,6 +807,18 @@ Validate_config_dependencies ()
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${DEBOOTSTRAP_ENGINE}" = 'mmdebstrap' ]; then
|
||||
if [ -n "${DEBOOTSTRAP_SCRIPT}" ]; then
|
||||
Echo_error "mmdebstrap is not compatible with a non-empty DEBOOTSTRAP_SCRIPT option (--debootstrap-script)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${LB_APT_SECURE}" = 'false' ]; then
|
||||
Echo_error "mmdebstrap is not compatible with an LB_APT_SECURE (--apt-secure) option that is set to 'false'."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
Validate_http_proxy
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,8 @@
|
||||
[\fB\-\-debian\-installer\-gui\fR true|false]
|
||||
.br
|
||||
[\fB\-\-debian\-installer\-preseedfile\fR \fIFILE\fR|\fIURL\fR]
|
||||
.br
|
||||
[\fB\-\-debootstrap\-engine\fR \fIdebootstrap\fR|\fImmdebstrap\fR]
|
||||
.br
|
||||
[\fB\-\-debootstrap\-options\fR \fIOPTION\fR|"\fIOPTIONS\fR"]
|
||||
.br
|
||||
@ -324,6 +326,8 @@ defines the distribution where the debian\-installer files should be taken out f
|
||||
defines whether the graphical version of the debian\-installer should be provided alongside the text based one. This defaults to true.
|
||||
.IP "\fB\-\-debian\-installer\-preseedfile\fR \fIFILE\fR|\fIURL\fR" 4
|
||||
sets the filename or URL for an optionally used and included preseeding file for debian\-installer. If config/binary_debian\-installer/preseed.cfg exists, it will be used by default.
|
||||
.IP "\fB\-\-debootstrap\-engine\fR \fIdebootstrap\fR|\fImmdebstrap\fR" 4
|
||||
sets the debootstrap implementation to use. Currently debootstrap and mmdebstrap are supported.
|
||||
.IP "\fB\-\-debootstrap\-options\fR \fIOPTION\fR|""\fIOPTIONS\fR""" 4
|
||||
passes the given options to debootstrap when setting up the base system.
|
||||
.IP "\fB\-\-debootstrap\-script\fR \fISCRIPT\fR" 4
|
||||
|
@ -15,16 +15,25 @@ set -e
|
||||
[ -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 debootstrap(8)"
|
||||
DESCRIPTION="Bootstrap a Debian system with debootstrap(8) or mmdebstrap(1)"
|
||||
USAGE="${PROGRAM} [--force]"
|
||||
|
||||
# Processing arguments and configuration files
|
||||
Init_config_data "${@}"
|
||||
|
||||
if ! command -v debootstrap >/dev/null
|
||||
if [ "${DEBOOTSTRAP_ENGINE}" = 'debootstrap' ]
|
||||
then
|
||||
Echo_error "debootstrap - command not found"
|
||||
exit 1
|
||||
if ! command -v debootstrap >/dev/null
|
||||
then
|
||||
Echo_error "debootstrap - command not found"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if ! command -v mmdebstrap >/dev/null
|
||||
then
|
||||
Echo_error "mmdebstrap - command not found"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
Echo_message "Begin bootstrapping system..."
|
||||
@ -75,26 +84,37 @@ fi
|
||||
|
||||
if [ "${LB_CACHE_PACKAGES}" = "true" ]
|
||||
then
|
||||
if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1
|
||||
if [ "${DEBOOTSTRAP_ENGINE}" = 'debootstrap' ]
|
||||
then
|
||||
mkdir -p chroot/var/cache/apt/archives
|
||||
cp cache/packages.bootstrap/*.deb chroot/var/cache/apt/archives
|
||||
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 debootstrap (download-only)..."
|
||||
debootstrap ${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
|
||||
else
|
||||
Echo_message "Using mmdebstrap, skipping caching of bootstrap packages."
|
||||
fi
|
||||
|
||||
Print_breakage
|
||||
Echo_message "Running debootstrap (download-only)..."
|
||||
debootstrap ${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 debootstrap..."
|
||||
if [ "${DEBOOTSTRAP_ENGINE}" = 'debootstrap' ]
|
||||
then
|
||||
Echo_message "Running debootstrap..."
|
||||
else
|
||||
Echo_message "Running mmdebstrap..."
|
||||
fi
|
||||
|
||||
# Run appropriate bootstrap, i.e. foreign or regular bootstrap
|
||||
if [ -n "${LB_BOOTSTRAP_QEMU_ARCHITECTURE}" ]; then
|
||||
@ -105,12 +125,22 @@ if [ -n "${LB_BOOTSTRAP_QEMU_ARCHITECTURE}" ]; then
|
||||
fi
|
||||
|
||||
Echo_message "Bootstrap will be foreign"
|
||||
debootstrap ${DEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" ${DEBOOTSTRAP_SCRIPT}
|
||||
if [ "${DEBOOTSTRAP_ENGINE}" = 'debootstrap' ]
|
||||
then
|
||||
debootstrap ${DEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" ${DEBOOTSTRAP_SCRIPT}
|
||||
|
||||
Echo_message "Running debootstrap second stage under QEMU"
|
||||
Chroot chroot /bin/sh /debootstrap/debootstrap --second-stage ${FOREIGN_DEBOOTSTRAP_OPTIONS}
|
||||
Echo_message "Running debootstrap second stage under QEMU"
|
||||
Chroot chroot /bin/sh /debootstrap/debootstrap --second-stage ${FOREIGN_DEBOOTSTRAP_OPTIONS}
|
||||
else
|
||||
mmdebstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIGBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
|
||||
fi
|
||||
else
|
||||
debootstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" ${DEBOOTSTRAP_SCRIPT}
|
||||
if [ "${DEBOOTSTRAP_ENGINE}" = 'debootstrap' ]
|
||||
then
|
||||
debootstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" ${DEBOOTSTRAP_SCRIPT}
|
||||
else
|
||||
mmdebstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION_CHROOT}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If there's an os-release file, copy it to /etc/ and add some extra fields that identify the live image
|
||||
|
@ -58,6 +58,7 @@ USAGE="${PROGRAM} [--apt apt|apt-get|aptitude]\n\
|
||||
\t [--debian-installer-distribution daily|CODENAME]\n\
|
||||
\t [--debian-installer-gui true|false]\n\
|
||||
\t [--debian-installer-preseedfile FILE|URL]\n\
|
||||
\t [--debootstrap-engine debootstrap|mmdebstrap]\n\
|
||||
\t [--debootstrap-options OPTION|\"OPTIONS\"]\n\
|
||||
\t [--debootstrap-script SCRIPT]\n\
|
||||
\t [--debug]\n\
|
||||
@ -147,7 +148,8 @@ Local_arguments ()
|
||||
chroot-squashfs-compression-type:,clean,color,compression:,conffile:,
|
||||
config:,debconf-frontend:,debconf-priority:,debian-installer:,
|
||||
debian-installer-distribution:,debian-installer-gui:,
|
||||
debian-installer-preseedfile:,debootstrap-options:,debootstrap-script:,
|
||||
debian-installer-preseedfile:,debootstrap-engine:,
|
||||
debootstrap-options:,debootstrap-script:,
|
||||
debug,dm-verity,dm-verity-fec:,dm-verity-sign:,
|
||||
distribution:,distribution-binary:,distribution-chroot:,dump,
|
||||
fdisk:,firmware-binary:,firmware-chroot:,force,
|
||||
@ -467,6 +469,11 @@ Local_arguments ()
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--debootstrap-engine)
|
||||
DEBOOTSTRAP_ENGINE="${2}"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--debootstrap-options)
|
||||
DEBOOTSTRAP_OPTIONS="${2}"
|
||||
shift 2
|
||||
@ -1040,6 +1047,9 @@ APT_OPTIONS="${APT_OPTIONS}"
|
||||
# Set options to use with aptitude
|
||||
APTITUDE_OPTIONS="${APTITUDE_OPTIONS}"
|
||||
|
||||
# Set debootstrap implementation to use
|
||||
DEBOOTSTRAP_ENGINE="${DEBOOTSTRAP_ENGINE}"
|
||||
|
||||
# Set options to use with debootstrap
|
||||
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user