|
|
@ -41,7 +41,7 @@ Setup_cleanup
|
|
|
|
|
|
|
|
|
|
|
|
. config/functions
|
|
|
|
. config/functions
|
|
|
|
|
|
|
|
|
|
|
|
lb_chroot_remove_packages() {
|
|
|
|
lb_chroot_remove_packages () {
|
|
|
|
# Remove packages from the chroot specific to this layer
|
|
|
|
# Remove packages from the chroot specific to this layer
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# $1: Name of the pass*
|
|
|
|
# $1: Name of the pass*
|
|
|
@ -54,28 +54,28 @@ lb_chroot_remove_packages() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Create the snap list specific to this layer
|
|
|
|
# Create the snap list specific to this layer
|
|
|
|
lb_chroot_snap_lists() {
|
|
|
|
lb_chroot_snap_lists () {
|
|
|
|
local pass=$1
|
|
|
|
local pass=$1
|
|
|
|
local prevpass=$2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# This assumes that the prefix is unique for a given project
|
|
|
|
# This assumes that the prefix is unique for a given project
|
|
|
|
local snap_for_pass=$(ls config/package-lists/*.snaplist.chroot_${pass}.full 2>/dev/null || true)
|
|
|
|
local snap_for_pass=$(ls config/package-lists/*.snaplist.chroot_${pass}.full 2>/dev/null || true)
|
|
|
|
local snap_for_prevpass=$(ls config/package-lists/*.snaplist.chroot_${prevpass}.full 2>/dev/null || true)
|
|
|
|
parent_pass=$(get_parent_pass $pass)
|
|
|
|
|
|
|
|
local snap_for_parent_pass=$(ls config/package-lists/*.snaplist.chroot_${parent_pass}.full 2>/dev/null || true)
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "${snap_for_pass}" ]; then
|
|
|
|
if [ -z "${snap_for_pass}" ]; then
|
|
|
|
return
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "${snap_for_prevpass}" ]; then
|
|
|
|
if [ -z "${snap_for_parent_pass}" ]; then
|
|
|
|
cp ${snap_for_pass} ${snap_for_pass%.full}
|
|
|
|
cp ${snap_for_pass} ${snap_for_pass%.full}
|
|
|
|
return
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Generate a list of snaps added to a layer.
|
|
|
|
# Generate a list of snaps added to a layer.
|
|
|
|
diff -NU0 ${snap_for_prevpass} ${snap_for_pass}|grep -Ev '^(---|\+\+\+|@@)'|cut -c2- > ${snap_for_pass%.full}
|
|
|
|
diff -NU0 ${snap_for_parent_pass} ${snap_for_pass}|grep -Ev '^(---|\+\+\+|@@)'|cut -c2- > ${snap_for_pass%.full}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lb_chroot_install_snaps() {
|
|
|
|
lb_chroot_install_snaps () {
|
|
|
|
# Prepare the snap environment and install snaps into a chroot
|
|
|
|
# Prepare the snap environment and install snaps into a chroot
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# $1: Name of the pass
|
|
|
|
# $1: Name of the pass
|
|
|
@ -93,7 +93,7 @@ lb_chroot_install_snaps() {
|
|
|
|
done < $snaplist_file
|
|
|
|
done < $snaplist_file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lb_chroot_includes() {
|
|
|
|
lb_chroot_includes () {
|
|
|
|
# Copying includes from pass subdirectory
|
|
|
|
# Copying includes from pass subdirectory
|
|
|
|
local pass="$1"
|
|
|
|
local pass="$1"
|
|
|
|
|
|
|
|
|
|
|
@ -106,30 +106,47 @@ lb_chroot_includes() {
|
|
|
|
cd "${OLDPWD}"
|
|
|
|
cd "${OLDPWD}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
create_chroot_pass() {
|
|
|
|
create_chroot_pass () {
|
|
|
|
local pass=$1
|
|
|
|
local pass=$1
|
|
|
|
local prevpass=$2
|
|
|
|
shift 1 # restore ${*}
|
|
|
|
local lowerlayers=$3
|
|
|
|
|
|
|
|
local passtype=$4 # "first"|"last"|"" empty string
|
|
|
|
|
|
|
|
shift 4 # restore ${*}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# We have already treated that pass
|
|
|
|
Echo_message "lb_chroot_layered: treating pass $pass"
|
|
|
|
if [ -d "overlay.${pass}/" ]; then
|
|
|
|
|
|
|
|
|
|
|
|
# We have already treated that pass just return.
|
|
|
|
|
|
|
|
local overlay_dir="overlay.${pass}"
|
|
|
|
|
|
|
|
if [ -d "$overlay_dir/" ]; then
|
|
|
|
return
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
export PASS=${pass}
|
|
|
|
# Only get some function executed on root passes
|
|
|
|
|
|
|
|
# Copy bootstrap on root layers
|
|
|
|
if [ "${passtype}" != "first" ]; then
|
|
|
|
if [ -z "$(get_parent_pass $pass)" ]; then
|
|
|
|
mkdir overlay.${pass}
|
|
|
|
rm -f .build/chroot_linux-image .build/chroot_preseed .build/chroot_hacks
|
|
|
|
mount_overlay ${lowerlayers} "overlay.${pass}/" chroot/
|
|
|
|
cp -a chroot.bootstrap/ "$overlay_dir/"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Others have to be executed on every pass
|
|
|
|
|
|
|
|
rm -f .build/chroot_early_hooks .build/chroot_hooks .build/chroot_interactive
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export PASS=${pass}
|
|
|
|
|
|
|
|
setenv_file PASS "${pass}" config/environment.chroot
|
|
|
|
|
|
|
|
|
|
|
|
# Configuring chroot
|
|
|
|
# Configuring chroot
|
|
|
|
lb chroot_cache restore ${*}
|
|
|
|
|
|
|
|
lb chroot_devpts install ${*}
|
|
|
|
lb chroot_devpts install ${*}
|
|
|
|
lb chroot_proc install ${*}
|
|
|
|
lb chroot_proc install ${*}
|
|
|
|
lb chroot_sysfs install ${*}
|
|
|
|
lb chroot_sysfs install ${*}
|
|
|
|
|
|
|
|
# We run chroot_hacks only on root layers (update-initramfs diverted)
|
|
|
|
|
|
|
|
if [ -z "$(get_parent_pass $pass)" ]; then
|
|
|
|
|
|
|
|
divert_update_initramfs
|
|
|
|
|
|
|
|
fi
|
|
|
|
lb chroot_debianchroot install ${*}
|
|
|
|
lb chroot_debianchroot install ${*}
|
|
|
|
lb chroot_dpkg install ${*}
|
|
|
|
lb chroot_dpkg install ${*}
|
|
|
|
lb chroot_tmpfs install ${*}
|
|
|
|
lb chroot_tmpfs install ${*}
|
|
|
@ -140,10 +157,11 @@ create_chroot_pass() {
|
|
|
|
# Note: this triggers an upgrade + dist-ugprade; which may impact sublayers with more
|
|
|
|
# Note: this triggers an upgrade + dist-ugprade; which may impact sublayers with more
|
|
|
|
# diff content than desired. However, we still need to setup the archive and teardown
|
|
|
|
# diff content than desired. However, we still need to setup the archive and teardown
|
|
|
|
# for each layer.
|
|
|
|
# for each layer.
|
|
|
|
# We could modify livebuild if necessary to have conditional upgrade (first pass only).
|
|
|
|
# We could modify livebuild if necessary to have conditional upgrade (root pass only).
|
|
|
|
lb chroot_archives chroot install ${*}
|
|
|
|
lb chroot_archives chroot install ${*}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${passtype}" = "first" ]; then
|
|
|
|
# Only configure universe on root passes
|
|
|
|
|
|
|
|
if [ -z "$(get_parent_pass $pass)" ]; then
|
|
|
|
configure_universe
|
|
|
|
configure_universe
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
@ -157,23 +175,22 @@ create_chroot_pass() {
|
|
|
|
lb_chroot_remove_packages ${pass} ${*}
|
|
|
|
lb_chroot_remove_packages ${pass} ${*}
|
|
|
|
|
|
|
|
|
|
|
|
# Snap management
|
|
|
|
# Snap management
|
|
|
|
lb_chroot_snap_lists ${pass} ${prevpass}
|
|
|
|
lb_chroot_snap_lists ${pass} ${*}
|
|
|
|
lb_chroot_install_snaps ${pass} ${*}
|
|
|
|
lb_chroot_install_snaps ${pass} ${*}
|
|
|
|
|
|
|
|
|
|
|
|
# Kernel should be in first layer
|
|
|
|
configure_network_manager
|
|
|
|
if [ "${passtype}" = "first" ]; then
|
|
|
|
|
|
|
|
configure_network_manager
|
|
|
|
# Mark kernel headers as autoremovable
|
|
|
|
Chroot chroot "dpkg -l linux-headers-3* linux-headers-4*" 2>/dev/null \
|
|
|
|
Chroot chroot "dpkg -l linux-headers-3* linux-headers-4*" 2>/dev/null \
|
|
|
|
| awk '/^i/ {print $2}' > chroot.headers
|
|
|
|
| awk '/^i/ {print $2}' > chroot.headers
|
|
|
|
for i in $(cat chroot.headers); do
|
|
|
|
for i in $(cat chroot.headers); do
|
|
|
|
Chroot chroot "apt-mark auto $i"
|
|
|
|
Chroot chroot "apt-mark auto $i"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Chroot chroot "apt-get --purge -y autoremove"
|
|
|
|
Chroot chroot "apt-get --purge -y autoremove"
|
|
|
|
|
|
|
|
|
|
|
|
# Add live packages to top layer
|
|
|
|
# Add live packages to live layers
|
|
|
|
if [ "${passtype}" = "last" ]; then
|
|
|
|
if echo $pass | grep -Eq '\.live*'; then
|
|
|
|
lb chroot_live-packages ${*}
|
|
|
|
lb chroot_live-packages ${*}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
@ -181,7 +198,14 @@ create_chroot_pass() {
|
|
|
|
lb_chroot_includes ${pass} ${*}
|
|
|
|
lb_chroot_includes ${pass} ${*}
|
|
|
|
|
|
|
|
|
|
|
|
lb chroot_hooks ${*}
|
|
|
|
lb chroot_hooks ${*}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Run chroot_hacks only on root layers.
|
|
|
|
|
|
|
|
# chroot_hacks changes the mode of boot/initrd*. The side effect in
|
|
|
|
|
|
|
|
# layered mode is to create an initrd on each layer with a significant
|
|
|
|
|
|
|
|
# impact on image size (+30MB per layer). This is an issue even with
|
|
|
|
|
|
|
|
# update-initramfs disabled.
|
|
|
|
lb chroot_hacks ${*}
|
|
|
|
lb chroot_hacks ${*}
|
|
|
|
|
|
|
|
|
|
|
|
lb chroot_interactive ${*}
|
|
|
|
lb chroot_interactive ${*}
|
|
|
|
|
|
|
|
|
|
|
|
# Misc ubuntu cleanup and post-layer configuration
|
|
|
|
# Misc ubuntu cleanup and post-layer configuration
|
|
|
@ -202,45 +226,19 @@ create_chroot_pass() {
|
|
|
|
lb chroot_sysfs remove ${*}
|
|
|
|
lb chroot_sysfs remove ${*}
|
|
|
|
lb chroot_proc remove ${*}
|
|
|
|
lb chroot_proc remove ${*}
|
|
|
|
lb chroot_devpts remove ${*}
|
|
|
|
lb chroot_devpts remove ${*}
|
|
|
|
lb chroot_cache save ${*}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${passtype}" = "first" ]; then
|
|
|
|
if [ -n "$lowerdirs" ]; then
|
|
|
|
mv chroot overlay.${pass}
|
|
|
|
|
|
|
|
mkdir chroot
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
umount chroot
|
|
|
|
umount chroot
|
|
|
|
|
|
|
|
rmdir chroot
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
rm chroot
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Handle direct sublayer of current one
|
|
|
|
|
|
|
|
# Extract the name of the pass corresponding to the sublayer
|
|
|
|
|
|
|
|
for subpass in $(ls config/package-lists/*list.chroot_${pass}_* 2>/dev/null | sed -e "s/.*list\.chroot_\(${pass}_[^_]\+\).*/\1/"); do
|
|
|
|
|
|
|
|
lowerlayers_for_subpass="overlay.${pass}:${lowerlayers}"
|
|
|
|
|
|
|
|
lowerlayers_for_subpass="${lowerlayers_for_subpass%:}"
|
|
|
|
|
|
|
|
create_chroot_pass "${subpass}" "${pass}" "${lowerlayers_for_subpass}" "" ${*}
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PASSES="${PASSES:-install live}"
|
|
|
|
if [ ! -d chroot.bootstrap/ ]; then
|
|
|
|
CURPASS=1
|
|
|
|
mv chroot/ chroot.bootstrap/
|
|
|
|
PREVPASS=""
|
|
|
|
fi
|
|
|
|
LASTPASS=$(echo $PASSES|wc -w)
|
|
|
|
|
|
|
|
LOWER_LAYERS=""
|
|
|
|
|
|
|
|
for _PASS in $PASSES
|
|
|
|
for _PASS in $PASSES
|
|
|
|
do
|
|
|
|
do
|
|
|
|
PASSTYPE=""
|
|
|
|
create_chroot_pass "$_PASS" ${*}
|
|
|
|
if [ $CURPASS -eq 1 ]; then
|
|
|
|
|
|
|
|
PASSTYPE="first"
|
|
|
|
|
|
|
|
elif [ $CURPASS -eq $LASTPASS ]; then
|
|
|
|
|
|
|
|
PASSTYPE="last"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
create_chroot_pass "$_PASS" "$PREVPASS" "$LOWER_LAYERS" "$PASSTYPE" ${*}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOWER_LAYERS="overlay.${_PASS}:$LOWER_LAYERS"
|
|
|
|
|
|
|
|
LOWER_LAYERS="${LOWER_LAYERS%:}"
|
|
|
|
|
|
|
|
PREVPASS=${_PASS}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CURPASS=$(( CURPASS + 1 ))
|
|
|
|
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
rmdir chroot
|
|
|
|
|
|
|
|