Allow specifying sources.list info for each local repository

This commit is contained in:
Aaron Rainbolt 2024-10-20 20:54:05 -05:00
parent e745cbb6ac
commit eb1813e7bd
No known key found for this signature in database
GPG Key ID: A709160D73C79109
4 changed files with 51 additions and 27 deletions

View File

@ -800,6 +800,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

@ -66,7 +66,9 @@
.br
[\fB\-\-chroot\-filesystem\fR ext2|ext3|ext4|squashfs|jffs2|none|plain]
.br
[\fB\-\-chroot\-localrepos\fR \fIPARAMETER\fR|"\fIPARAMETERS\fR"]
[\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
@ -300,8 +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\-localrepos\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
.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

@ -28,31 +28,36 @@ Echo_message "Begin enabling use of temporary local deb repository"
Require_stagefiles config bootstrap
if [ -z "${LB_LOCALREPOS}" ]
if [ -z "${LB_LOCALREPO_LOCATIONS}" ]
then
exit 0
fi
for _LOCALREPO_PATH in ${LB_LOCALREPOS}
_LOCALREPO_COUNT="$(printf '%s\n' "${LB_LOCALREPO_LOCATIONS}" | tr ' ' '\n' | wc -l)"
_LOCALREPO_IDX=1
while [ "${_LOCALREPO_IDX}" -le "${_LOCALREPO_COUNT}" ]
do
case "${_ACTION}" in
configure)
_LOCALREPO_FILE="$(basename "${_LOCALREPO_PATH}")"
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} ./" > chroot/etc/apt/sources.list.d/"${_LOCALREPO_FILE}".list
;;
_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)
_LOCALREPO_FILE="$(basename "${_LOCALREPO_PATH}")"
rm chroot/etc/apt/sources.list.d/"${_LOCALREPO_FILE}".list
umount chroot/root/localrepos/"${_LOCALREPO_FILE}"
rm -rf chroot/root/localrepos/"${_LOCALREPO_FILE}"
;;
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
*)
Echo_error "Invalid action parameter: '${_ACTION}'"
Usage --fail
;;
esac
_LOCALREPO_IDX=$(( _LOCALREPO_IDX + 1 ))
done

View File

@ -45,7 +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-localrepos PARAMETER|\"PARAMETERS\"]\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\
@ -144,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-localrepos:,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:,
@ -423,8 +425,13 @@ Local_arguments ()
shift 2
;;
--chroot-localrepos)
LB_LOCALREPOS="${2}"
--chroot-localrepo-locations)
LB_LOCALREPO_LOCATIONS="${2}"
shift 2
;;
--chroot-localrepo-lists)
LB_LOCALREPO_LISTS="${2}"
shift 2
;;
@ -1206,7 +1213,10 @@ LB_BACKPORTS="${LB_BACKPORTS}"
LB_PROPOSED_UPDATES="${LB_PROPOSED_UPDATES}"
# Set path to one or more local deb repositories
LB_LOCALREPOS="${LB_LOCALREPOS}"
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