Allow setting 'apt update'-specific options

The '--apt-options' setting can only be used for setting options that
are understood by all apt features (install, update, etc.) used by
live-build. Attempting to enable a feature specific to 'apt update',
such as '--error-on=any', will result in a build failure. To allow
these options to be set as well, add an '--apt-update-options' setting
to 'lb config'.
This commit is contained in:
Aaron Rainbolt 2024-10-18 00:16:53 -05:00
parent 9ae2c0105c
commit 838062abcd
No known key found for this signature in database
GPG Key ID: A709160D73C79109
5 changed files with 28 additions and 8 deletions

View File

@ -12,15 +12,21 @@
Apt ()
{
local CHROOT="${1}"
shift
local MODE="${2}"
shift 2
case "${LB_APT}" in
apt|apt-get)
Chroot ${CHROOT} apt-get ${APT_OPTIONS} "${@}"
if [ "${MODE}" = "update" ]
then
Chroot ${CHROOT} apt-get ${APT_OPTIONS} ${APT_UPDATE_OPTIONS} ${MODE} "${@}"
else
Chroot ${CHROOT} apt-get ${APT_OPTIONS} ${MODE} "${@}"
fi
;;
aptitude)
Chroot ${CHROOT} aptitude ${APTITUDE_OPTIONS} "${@}"
Chroot ${CHROOT} aptitude ${APTITUDE_OPTIONS} ${MODE} "${@}"
;;
esac
}

View File

@ -23,6 +23,8 @@
[\fB\-\-apt\-secure\fR true|false]
.br
[\fB\-\-apt\-source\-archives\fR true|false]
.br
[\fB\-\-apt\-update\-options\fR \fIOPTION\fR|"\fIOPTIONS\fR"]
.br
[\fB\-\-aptitude\-options\fR \fIOPTION\fR|"\fIOPTIONS\fR"]
.br
@ -256,6 +258,8 @@ defines if apt should install recommended packages automatically. By default, th
defines if apt should check repository signatures. This is true by default.
.IP "\fB\-\-apt\-source\-archives\fR true|false" 4
defines if deb-src entries should be included in the resulting live image's apt sources.list or not, defaults to true.
.IP "\fB\-\-apt\-update\-options\fR \fIOPTION\fR|""\fIOPTIONS\fR""" 4
defines the default options that will be appended to 'apt update' calls that are made inside of the chroot during building of the image. Empty by default. Useful if you want to set options such as '\-\-error\-on=any'. Note that this option does not apply to aptitude calls.
.IP "\fB\-\-aptitude\-options\fR \fIOPTION\fR|""\fIOPTIONS\fR""" 4
defines the default options that will be appended to every aptitude call that is made inside chroot during building of the image. By default, this is set to '\-\-assume\-yes' to allow non-interactive installation of packages.
.IP "\fB\-a\fR|\fB\-\-architecture\fR \fIARCHITECTURE\fR" 4

View File

@ -128,7 +128,7 @@ fi
# Installing aptitude
if [ "${LB_APT}" = "aptitude" ] && [ ! -x chroot/usr/bin/aptitude ]
then
Chroot chroot "apt-get ${APT_OPTIONS} update"
Chroot chroot "apt-get ${APT_OPTIONS} ${APT_UPDATE_OPTIONS} update"
Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
fi
@ -143,7 +143,7 @@ Apt chroot update
# Installing keyring packages
if [ -n "${LB_KEYRING_PACKAGES}" ]
then
Apt chroot "install ${LB_KEYRING_PACKAGES}"
Apt chroot install "${LB_KEYRING_PACKAGES}"
fi
rm -rf chroot/var/cache/apt/*.bin

View File

@ -259,7 +259,7 @@ case "${_ACTION}" in
if [ "${LB_APT}" = "aptitude" ] && ! command -v aptitude >/dev/null
then
Chroot chroot "apt-get ${APT_OPTIONS} update"
Chroot chroot "apt-get ${APT_OPTIONS} ${APT_UPDATE_OPTIONS} update"
Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
fi
else # Get fresh indices
@ -277,7 +277,7 @@ case "${_ACTION}" in
# Installing aptitude
if [ "${LB_APT}" = "aptitude" ] && [ ! $(Chroot chroot "which aptitude") ]
then
Chroot chroot "apt-get ${APT_OPTIONS} update"
Chroot chroot "apt-get ${APT_OPTIONS} ${APT_UPDATE_OPTIONS} update"
Chroot chroot "apt-get ${APT_OPTIONS} install aptitude"
fi

View File

@ -24,6 +24,7 @@ USAGE="${PROGRAM} [--apt apt|apt-get|aptitude]\n\
\t [--apt-recommends true|false]\n\
\t [--apt-secure true|false]\n\
\t [--apt-source-archives true|false]\n\
\t [--apt-update-options OPTION|\"OPTIONS\"]\n\
\t [--aptitude-options OPTION|\"OPTIONS\"]\n\
\t [-a|--architecture ARCHITECTURE]\n\
\t [--archive-areas ARCHIVE_AREA|\"ARCHIVE_AREAS\"]\n\
@ -137,7 +138,8 @@ Local_arguments ()
LONG_OPTIONS="
apt:,apt-http-proxy:,apt-indices:,aptitude-options:,
apt-options:,apt-pipeline:,apt-recommends:,apt-secure:,
apt-source-archives:,architecture:,architectures:,archive-areas:,
apt-source-archives:,apt-update-options:,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:,
@ -321,6 +323,11 @@ Local_arguments ()
shift 2
;;
--apt-update-options)
APT_UPDATE_OPTIONS="${2}"
shift 2
;;
--aptitude-options)
APTITUDE_OPTIONS="${2}"
shift 2
@ -998,6 +1005,9 @@ LB_APT_SECURE="${LB_APT_SECURE}"
# Set apt/aptitude source entries in sources.list
LB_APT_SOURCE_ARCHIVES="${LB_APT_SOURCE_ARCHIVES}"
# Set options that should only be used during apt updates
APT_UPDATE_OPTIONS="${APT_UPDATE_OPTIONS}"
# Control cache
LB_CACHE="${LB_CACHE}"