mirror of
https://git.launchpad.net/livecd-rootfs
synced 2026-04-02 15:11:17 +00:00
04-kernel-bits.binary only handled ubuntu-server; desktop builds (ubuntu, ubuntu-budgie, lubuntu, etc.) had no equivalent and so the kernel never reached the ISO casper directory for MAKE_ISO=yes builds. Centralise the logic in lb_binary_layered, which already knows which passes are live passes and is where the kernel is subsequently removed from the chroot overlay. The flavor is determined by convention: - passes ending in .live (desktop builds) use LB_LINUX_FLAVOURS - other live passes (server installer passes such as "...installer.generic-hwe") encode the flavor as the final dot-separated component of the pass name The netboot sub-passes (e.g. installer.generic.netboot) are never added to LIVE_PASSES, so is_live_layer already guards against them; the explicit exit-0 that 04-kernel-bits.binary needed is not required. MAKE_ISO is always "yes" when lb_binary_layered runs — every code path that sets PASSES_TO_LAYERS=true also sets MAKE_ISO=yes — so no conditional is needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
225 lines
7.0 KiB
Bash
Executable File
225 lines
7.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
## live-build(7) - System Build Scripts
|
|
## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
|
|
##
|
|
## 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
|
|
( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
|
|
|
|
|
|
# Automatically populating config tree
|
|
if [ -x auto/config ] && [ ! -e .build/config ]
|
|
then
|
|
Echo_message "Automatically populating config tree."
|
|
lb config
|
|
fi
|
|
|
|
# Setting static variables
|
|
DESCRIPTION="$(Echo 'build binary images')"
|
|
HELP=""
|
|
USAGE="${PROGRAM} [--force]"
|
|
|
|
Arguments "${@}"
|
|
|
|
# Reading configuration files
|
|
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
|
|
Set_defaults
|
|
|
|
# Setup cleanup function
|
|
Setup_cleanup
|
|
|
|
. config/functions
|
|
|
|
lb_binary_includes () {
|
|
# Copying includes from pass subdirectory
|
|
local pass="$1"
|
|
|
|
if [ ! -d config/includes.binary.${pass} ]; then
|
|
return
|
|
fi
|
|
|
|
cd config/includes.binary.${pass}
|
|
find . | cpio -dmpu --no-preserve-owner "${OLDPWD}"/chroot
|
|
cd "${OLDPWD}"
|
|
}
|
|
|
|
build_layered_squashfs () {
|
|
local pass=$1
|
|
shift 1 # restore ${*}
|
|
|
|
Echo_message "lb_binary_layered: treating pass $pass"
|
|
|
|
# Per convention, we include the subarch name next to the project
|
|
PROJECT_FULL=$PROJECT${SUBARCH:+-$SUBARCH}
|
|
|
|
# Building squashfs filesystem & manifest
|
|
local overlay_dir="overlay.${pass}"
|
|
base="${PWD}/${CASPER_DIR}/${pass}"
|
|
squashfs_f="${base}.squashfs"
|
|
|
|
# We have already treated that pass
|
|
if [ -f "${squashfs_f}" ]; then
|
|
return
|
|
fi
|
|
|
|
rm -f .build/binary_chroot .build/binary_hooks
|
|
|
|
mkdir -p "$overlay_dir/"
|
|
lowerdirs=$(get_lowerdirs_for_pass $pass)
|
|
if [ -n "$lowerdirs" ]; then
|
|
mkdir -p chroot/
|
|
mount_overlay "$lowerdirs" "$overlay_dir" chroot/
|
|
else
|
|
ln -s "$overlay_dir/" chroot
|
|
fi
|
|
|
|
export PASS=${pass}
|
|
setenv_file PASS "${pass}" config/environment.chroot
|
|
|
|
# Cleanup root filesystem
|
|
lb binary_chroot ${*}
|
|
|
|
lb_binary_includes $pass ${*}
|
|
lb binary_hooks ${*}
|
|
|
|
# Copy initrd and vmlinuz outside of chroot and remove them from the layer squashfs
|
|
if $(is_live_layer "$pass"); then
|
|
# For *.live passes (desktop builds), the kernel flavor comes from
|
|
# LB_LINUX_FLAVOURS. For other live passes (server installer passes
|
|
# like "...installer.generic-hwe"), the flavor is encoded as the
|
|
# final dot-separated component of the pass name.
|
|
case "$pass" in
|
|
*.live)
|
|
for flavor in $LB_LINUX_FLAVOURS; do
|
|
iso_install_kernel "$flavor" chroot/boot/vmlinu?-* chroot/boot/initrd.img-*
|
|
done
|
|
;;
|
|
*)
|
|
iso_install_kernel "${pass##*.}" chroot/boot/vmlinu?-* chroot/boot/initrd.img-*
|
|
;;
|
|
esac
|
|
lb binary_linux-image ${*}
|
|
rm -f chroot/boot/initrd.img-* chroot/boot/vmlinu{x,z}-*
|
|
fi
|
|
|
|
make_squashfs=yes
|
|
ppass="${pass}"
|
|
while :; do
|
|
for nsp in ${NO_SQUASHFS_PASSES}; do
|
|
if [ "${ppass}" = "${nsp}" ]; then
|
|
make_squashfs=no
|
|
break 2
|
|
fi
|
|
done
|
|
ppass="$(get_parent_pass "${ppass}")"
|
|
if [ -z "${ppass}" ]; then
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ $make_squashfs = yes ]; then
|
|
# Full manifest until that PASS
|
|
squashfs_f_manifest="${base}.manifest"
|
|
create_manifest "chroot" "${squashfs_f_manifest}.full"
|
|
|
|
# Delta manifest
|
|
diff -NU0 ${PWD}/${CASPER_DIR}/$(get_parent_pass $pass).manifest.full ${squashfs_f_manifest}.full|grep -v ^@ > $squashfs_f_manifest || true
|
|
echo "Delta manifest:"
|
|
cat $squashfs_f_manifest
|
|
|
|
squashfs_f_size="${base}.size"
|
|
du -B 1 -s "overlay.${pass}/" | cut -f1 > "${squashfs_f_size}"
|
|
|
|
if [ -n "$lowerdirs" ]; then
|
|
# Although the current chroot was created as an overlay over
|
|
# the previous layer, many operations can result in redundant
|
|
# files in the upperdir. Rather than trying to minimize the
|
|
# overlay by hand, we rsync the chroot into a fresh overlay,
|
|
# rely on rsyncs ability to avoid redundant file operations,
|
|
# and take _that_ overlay's upperdir as the content of the
|
|
# layer.
|
|
mkdir -p chroot-2 "$overlay_dir-2"
|
|
mount_overlay "$lowerdirs" "$overlay_dir-2" chroot-2
|
|
# rsync takes many, many options. The subset
|
|
# we pass here is quite important:
|
|
# -a is standard to operate in the basic way required here.
|
|
# -X to preserve xattrs
|
|
# -H to preserve hardlinks
|
|
# -A to preserve ACLs
|
|
# -S to preserve sparseness
|
|
# --checksum to skip copies based on the content of the file
|
|
# (rather than the default which is to skip copies based
|
|
# on size + mtime)
|
|
# --no-times to not copy mtimes from source to dest (we
|
|
# do care about mtime in the image but want to
|
|
# deduplicate files that have indentical contents but
|
|
# different mtimes, and mtime will be fixed below)
|
|
# --del because we want to remove files that have been
|
|
# deleted in this layer.
|
|
rsync -aXHAS --checksum --no-times --del chroot/ chroot-2/
|
|
umount chroot-2
|
|
rmdir chroot-2
|
|
overlay_dir="$overlay_dir-2"
|
|
# We use rsync with --no-times rsync (see above)
|
|
# for the absolute best size reduction. But there are
|
|
# cases where we want mtime preservation to match what
|
|
# was found in the original archive packages, such as
|
|
# keeping .py mtime in sync with the matching .pyc.
|
|
# Operate on the upperdir directly, so that we are only
|
|
# modifying mtime on files that are actually changed in
|
|
# this layer. LP: #2107332
|
|
${LIVECD_ROOTFS_ROOT}/sync-mtime chroot "$overlay_dir"
|
|
fi
|
|
|
|
# For the root layer when building with a pool, include
|
|
# cdrom.sources so casper can access the ISO's package repository.
|
|
if [ -n "${POOL_SEED_NAME}" ] && $(is_root_layer $pass); then
|
|
isobuild generate-sources --mountpoint=/cdrom > ${overlay_dir}/etc/apt/sources.list.d/cdrom.sources
|
|
fi
|
|
create_squashfs "${overlay_dir}" ${squashfs_f}
|
|
rm -f ${overlay_dir}/etc/apt/sources.list.d/cdrom.sources
|
|
|
|
if [ -f config/$pass.catalog-in.yaml ]; then
|
|
echo "Expanding catalog entry template for $pass"
|
|
usc_opts="--output ${CASPER_DIR}/install-sources.yaml \
|
|
--template config/$pass.catalog-in.yaml \
|
|
--size $(du -B 1 -s chroot/ | cut -f1) --squashfs ${pass}.squashfs \
|
|
--translations config/catalog-translations"
|
|
if [ -f config/seeded-languages ]; then
|
|
usc_opts="$usc_opts --langs $(cat config/seeded-languages)"
|
|
fi
|
|
${LIVECD_ROOTFS_ROOT}/update-source-catalog source $usc_opts
|
|
else
|
|
echo "No catalog entry template for $pass"
|
|
fi
|
|
fi
|
|
|
|
if [ -n "$lowerdirs" ]; then
|
|
umount chroot
|
|
rmdir chroot
|
|
else
|
|
rm chroot
|
|
fi
|
|
}
|
|
|
|
for _PASS in $PASSES
|
|
do
|
|
build_layered_squashfs "${_PASS}" ${*}
|
|
done
|
|
|
|
if [ -n "$DEFAULT_KERNEL" -a -f ${CASPER_DIR}/install-sources.yaml ]; then
|
|
write_kernel_yaml "$DEFAULT_KERNEL" "$BRIDGE_KERNEL_REASONS"
|
|
${LIVECD_ROOTFS_ROOT}/update-source-catalog merge \
|
|
--output ${CASPER_DIR}/install-sources.yaml \
|
|
--template config/kernel.yaml
|
|
fi
|
|
|
|
chmod 644 ${CASPER_DIR}/*.squashfs ${CASPER_DIR}/*.manifest* ${CASPER_DIR}/*.size
|