Merge branch 'arraybolt3/chroot_local-repos' into 'master'

Add support for local package repositories

See merge request live-team/live-build!369
This commit is contained in:
Aaron Rainbolt 2024-12-22 23:00:10 +00:00
commit d0ee621bd8
5 changed files with 100 additions and 1 deletions

View File

@ -843,6 +843,11 @@ Validate_config_dependencies ()
fi
fi
if [ "$(printf '%s\n' "${LB_LOCALREPO_LOCATIONS}" | tr ' ' '\n' | wc -l)" -ne "$(printf '%s\n' "${LB_LOCALREPO_LISTS}" | tr ',' '\n' | wc -l)" ]; then
Echo_error "LB_LOCALREPO_LOCATIONS (--chroot-localrepo-locations) and LB_LOCALREPO_LISTS (--chroot-localrepo-lists) must have the same number of parameters. Note that local repo locations are space-separated while local repo lists are comma-separated."
exit 1
fi
Validate_http_proxy
}

View File

@ -65,6 +65,10 @@
[\fB\-\-checksums\fR md5|sha1|sha224|sha256|sha384|sha512|none]
.br
[\fB\-\-chroot\-filesystem\fR ext2|ext3|ext4|squashfs|jffs2|none|plain]
.br
[\fB\-\-chroot\-localrepo\-locations\fR \fIPARAMETER\fR|"\fIPARAMETERS\fR"]
.br
[\fB\-\-chroot\-localrepo\-lists\fR \fIPARAMETER\fR|"\fIPARAMETERS\fR"]
.br
[\fB\-\-chroot\-squashfs\-compression\-level\fR LEVEL]
.br
@ -298,6 +302,10 @@ sets which stages should be cached (a comma or space separated list). By default
defines if the binary image should contain a file called XXXsums.txt, where XXX is one of the mentioned checksum types. This file lists all files on the image together with their checksums. This in turn can be used by \fIlive\-boot\fR(7)'s built\-in integrity\-check to verify the medium if specified at boot prompt. In general, this should not be 'none' and is an important feature of live system released to the public. However, during development of very big images it can save some time by not calculating the checksums.
.IP "\fB\-\-chroot\-filesystem\fR ext2|ext3|ext4|squashfs|jffs2|none|plain" 4
defines which filesystem type should be used for the root filesystem image. If you use 'none' or 'plain', then no filesystem image is created and the root filesystem content is copied on the binary image filesystem as flat files. Depending on what binary filesystem you have chosen, it may not be possible to build with such a plain root filesystem, e.g. fat16/fat32 will not work as linux does not support running directly on them.
.IP "\fB\-\-chroot\-localrepo\-locations\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
specifies one more more space-separated paths to use as local apt repositories. The repositories will be treated the same as remote apt repositories. This is mainly useful if you have a number of local packages you wish to install onto the live ISO, but want to ensure dependency packages are properly marked as automatically installed so they can be autoremoved later if needed.
.IP "\fB\-\-chroot\-localrepo\-lists\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
specifies the repo metadata to place into the sources.list file for each local repo. For instance, if the local repo is "flat" (consisting of a directory full of .deb files and a Contents file), you might specify './' for that repo. For a "full" local repo containing a 'debian' dist with 'main', 'contrib', and 'non-free' components, you might use 'debian main contrib non-free' for that repo. Note that you MUST specify the same number of parameters here as you specified for \-\-chroot\-localrepo\-lists. Furthermore, if passing multiple arguments here, you MUST separate them with a comma (this is because the arguments themselves contain spaces).
.IP "\fB\-\-chroot\-squashfs\-compression\-level\fR LEVEL" 4
defines the compression level that is used for the root filesystem image if squashfs is used. Each compression algorithm supports different levels (or none). You can look them up in the \fImksquashfs\fR help. Defaults to the default setting in \fImksquashfs\fR.
.IP "\fB\-\-chroot\-squashfs\-compression\-type\fR gzip|lzma|lzo|lz4|xz|zstd" 4

View File

@ -30,6 +30,9 @@ Setup_clean_exit
# Restoring cached live OS chroot from cache
lb chroot_cache restore "${@}"
# Enable use of a local package repo if it is present
lb chroot_local-repos configure "${@}"
# Configuring chroot
lb chroot_prep install all mode-archives-chroot "${@}"
@ -56,6 +59,7 @@ lb chroot_interactive "${@}"
Chroot chroot "dpkg-query -W" > chroot.packages.live
# Deconfiguring chroot
lb chroot_local-repos deconfigure "${@}"
lb chroot_prep remove all mode-archives-chroot "${@}"
# Saving live OS chroot to cache

View File

@ -0,0 +1,63 @@
#!/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="Enable use of local deb repository"
USAGE="${PROGRAM} {configure|deconfigure} [--force]"
# Processing arguments and configuration files
Init_config_data "${@}"
_ACTION="${1}"
shift
Echo_message "Begin enabling use of temporary local deb repository"
Require_stagefiles config bootstrap
if [ -z "${LB_LOCALREPO_LOCATIONS}" ]
then
exit 0
fi
_LOCALREPO_COUNT="$(printf '%s\n' "${LB_LOCALREPO_LOCATIONS}" | tr ' ' '\n' | wc -l)"
_LOCALREPO_IDX=1
while [ "${_LOCALREPO_IDX}" -le "${_LOCALREPO_COUNT}" ]
do
_LOCALREPO_PATH="$(printf '%s\n' "${LB_LOCALREPO_LOCATIONS}" | cut -d' ' -f"${_LOCALREPO_IDX}")"
_LOCALREPO_LIST="$(printf '%s\n' "${LB_LOCALREPO_LISTS}" | cut -d',' -f"${_LOCALREPO_IDX}")"
_LOCALREPO_FILE="$(basename "${_LOCALREPO_PATH}")"
case "${_ACTION}" in
configure)
mkdir -p chroot/root/localrepos/"${_LOCALREPO_FILE}"
mount --bind "${_LOCALREPO_PATH}" chroot/root/localrepos/"${_LOCALREPO_FILE}"
echo "deb [trusted=yes] file:/root/localrepos/${_LOCALREPO_FILE} ${_LOCALREPO_LIST}" > chroot/etc/apt/sources.list.d/"${_LOCALREPO_FILE}".list
;;
deconfigure)
rm chroot/etc/apt/sources.list.d/"${_LOCALREPO_FILE}".list
umount chroot/root/localrepos/"${_LOCALREPO_FILE}"
rm -rf chroot/root/localrepos/"${_LOCALREPO_FILE}"
;;
*)
Echo_error "Invalid action parameter: '${_ACTION}'"
Usage --fail
;;
esac
_LOCALREPO_IDX=$(( _LOCALREPO_IDX + 1 ))
done

View File

@ -45,6 +45,8 @@ USAGE="${PROGRAM} [--apt apt|apt-get|aptitude]\n\
\t [--cache-stages STAGE|\"STAGES\"]\n\
\t [--checksums md5|sha1|sha224|sha256|sha384|sha512|none]\n\
\t [--chroot-filesystem ext2|ext3|ext4|squashfs|jffs2|none]\n\
\t [--chroot-localrepo-locations PARAMETER|\"PARAMETERS\"]\n\
\t [--chroot-localrepo-lists PARAMETER|\"PARAMETERS\"]\n\
\t [--chroot-squashfs-compression-level LEVEL]\n\
\t [--chroot-squashfs-compression-type gzip|lzma|lzo|lz4|xz|zstd]\n\
\t [--clean]\n\
@ -143,7 +145,8 @@ Local_arguments ()
bootloader:,bootloaders:,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:,
chroot-filesystem:,chroot-localrepo-locations:,
chroot-localrepo-lists:,chroot-squashfs-compression-level:,
chroot-squashfs-compression-type:,clean,color,compression:,conffile:,
config:,debconf-frontend:,debconf-priority:,debian-installer:,
debian-installer-distribution:,debian-installer-gui:,
@ -422,6 +425,16 @@ Local_arguments ()
shift 2
;;
--chroot-localrepo-locations)
LB_LOCALREPO_LOCATIONS="${2}"
shift 2
;;
--chroot-localrepo-lists)
LB_LOCALREPO_LISTS="${2}"
shift 2
;;
--chroot-squashfs-compression-level)
LB_CHROOT_SQUASHFS_COMPRESSION_LEVEL="${2}"
shift 2
@ -1198,6 +1211,12 @@ LB_BACKPORTS="${LB_BACKPORTS}"
# Enable proposed updates
LB_PROPOSED_UPDATES="${LB_PROPOSED_UPDATES}"
# Set path to one or more local deb repositories
LB_LOCALREPO_LOCATIONS="${LB_LOCALREPO_LOCATIONS}"
# Set list components for one or more local deb repositories
LB_LOCALREPO_LISTS="${LB_LOCALREPO_LISTS}"
EOF
# Creating lb_binary_* configuration