|
|
@ -81,18 +81,23 @@ lb_chroot_install_snaps() {
|
|
|
|
done < $snaplist_file
|
|
|
|
done < $snaplist_file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PASSES="${PASSES:-install live}"
|
|
|
|
create_chroot_pass() {
|
|
|
|
CURPASS=1
|
|
|
|
local pass=$1
|
|
|
|
PREVPASS=""
|
|
|
|
local prevpass=$2
|
|
|
|
LASTPASS=$(echo $PASSES|wc -w)
|
|
|
|
local lowerlayers=$3
|
|
|
|
LOWER_LAYERS=""
|
|
|
|
local passtype=$4 # "first"|"last"|"" empty string
|
|
|
|
for _PASS in $PASSES
|
|
|
|
shift 4 # restore ${*}
|
|
|
|
do
|
|
|
|
|
|
|
|
export PASS=${_PASS}
|
|
|
|
# We have already treated that pass
|
|
|
|
|
|
|
|
if [ -d "chroot.${pass}/" ]; then
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ $CURPASS -gt 1 ]; then
|
|
|
|
export PASS=${pass}
|
|
|
|
mkdir chroot.${_PASS}
|
|
|
|
|
|
|
|
mount_overlay $LOWER_LAYERS "chroot.${_PASS}/" chroot/
|
|
|
|
if [ "${passtype}" != "first" ]; then
|
|
|
|
|
|
|
|
mkdir chroot.${pass}
|
|
|
|
|
|
|
|
mount_overlay ${lowerlayers} "chroot.${pass}/" chroot/
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Configuring chroot
|
|
|
|
# Configuring chroot
|
|
|
@ -117,15 +122,15 @@ do
|
|
|
|
lb chroot_preseed ${*}
|
|
|
|
lb chroot_preseed ${*}
|
|
|
|
lb chroot_early_hooks ${*}
|
|
|
|
lb chroot_early_hooks ${*}
|
|
|
|
|
|
|
|
|
|
|
|
lb chroot_package-lists ${_PASS} ${*}
|
|
|
|
lb chroot_package-lists ${pass} ${*}
|
|
|
|
lb chroot_install-packages ${_PASS} ${*}
|
|
|
|
lb chroot_install-packages ${pass} ${*}
|
|
|
|
|
|
|
|
|
|
|
|
# Snap management
|
|
|
|
# Snap management
|
|
|
|
lb_chroot_snap_lists ${_PASS} ${PREVPASS}
|
|
|
|
lb_chroot_snap_lists ${pass} ${prevpass}
|
|
|
|
lb_chroot_install_snaps ${_PASS} ${*}
|
|
|
|
lb_chroot_install_snaps ${pass} ${*}
|
|
|
|
|
|
|
|
|
|
|
|
# Kernel should be in first layer
|
|
|
|
# Kernel should be in first layer
|
|
|
|
if [ $CURPASS -eq 1 ]; then
|
|
|
|
if [ "${passtype}" = "first" ]; then
|
|
|
|
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
|
|
|
@ -136,7 +141,7 @@ do
|
|
|
|
Chroot chroot "apt-get --purge -y autoremove"
|
|
|
|
Chroot chroot "apt-get --purge -y autoremove"
|
|
|
|
|
|
|
|
|
|
|
|
# Add live packages to top layer
|
|
|
|
# Add live packages to top layer
|
|
|
|
if [ $CURPASS -eq $LASTPASS ]; then
|
|
|
|
if [ "${passtype}" = "last" ]; then
|
|
|
|
lb chroot_live-packages ${*}
|
|
|
|
lb chroot_live-packages ${*}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
@ -145,7 +150,7 @@ do
|
|
|
|
lb chroot_hacks ${*}
|
|
|
|
lb chroot_hacks ${*}
|
|
|
|
lb chroot_interactive ${*}
|
|
|
|
lb chroot_interactive ${*}
|
|
|
|
|
|
|
|
|
|
|
|
Chroot chroot "dpkg-query -W" > chroot.packages.${_PASS}
|
|
|
|
Chroot chroot "dpkg-query -W" > chroot.packages.${pass}
|
|
|
|
|
|
|
|
|
|
|
|
# Deconfiguring chroot
|
|
|
|
# Deconfiguring chroot
|
|
|
|
lb chroot_archives chroot remove ${*}
|
|
|
|
lb chroot_archives chroot remove ${*}
|
|
|
@ -164,13 +169,38 @@ do
|
|
|
|
lb chroot_devpts remove ${*}
|
|
|
|
lb chroot_devpts remove ${*}
|
|
|
|
lb chroot_cache save ${*}
|
|
|
|
lb chroot_cache save ${*}
|
|
|
|
|
|
|
|
|
|
|
|
if [ $CURPASS -eq 1 ]; then
|
|
|
|
if [ "${passtype}" = "first" ]; then
|
|
|
|
mv chroot chroot.${_PASS}
|
|
|
|
mv chroot chroot.${pass}
|
|
|
|
mkdir chroot
|
|
|
|
mkdir chroot
|
|
|
|
elif [ $CURPASS -ne $LASTPASS ]; then
|
|
|
|
else
|
|
|
|
# we will unmount chroot/ at teardown for upper layer
|
|
|
|
|
|
|
|
umount chroot
|
|
|
|
umount 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="chroot.${pass}:${lowerlayers}"
|
|
|
|
|
|
|
|
lowerlayers_for_subpass="${lowerlayers_for_subpass%:}"
|
|
|
|
|
|
|
|
create_chroot_pass "${subpass}" "${pass}" "${lowerlayers_for_subpass}" "" ${*}
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PASSES="${PASSES:-install live}"
|
|
|
|
|
|
|
|
CURPASS=1
|
|
|
|
|
|
|
|
PREVPASS=""
|
|
|
|
|
|
|
|
LASTPASS=$(echo $PASSES|wc -w)
|
|
|
|
|
|
|
|
LOWER_LAYERS=""
|
|
|
|
|
|
|
|
for _PASS in $PASSES
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
PASSTYPE=""
|
|
|
|
|
|
|
|
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="chroot.${_PASS}:$LOWER_LAYERS"
|
|
|
|
LOWER_LAYERS="chroot.${_PASS}:$LOWER_LAYERS"
|
|
|
|
LOWER_LAYERS="${LOWER_LAYERS%:}"
|
|
|
|
LOWER_LAYERS="${LOWER_LAYERS%:}"
|
|
|
|
PREVPASS=${_PASS}
|
|
|
|
PREVPASS=${_PASS}
|
|
|
@ -178,8 +208,10 @@ do
|
|
|
|
CURPASS=$(( CURPASS + 1 ))
|
|
|
|
CURPASS=$(( CURPASS + 1 ))
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# Remove unused chroot binary corresponding to bottom layer (once everything is unmount)
|
|
|
|
# remount last pass on chroot for lb binary
|
|
|
|
|
|
|
|
mount_overlay "${LOWER_LAYERS}" "chroot.${_PASS}/" chroot/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Remove unused chroot binary corresponding to bottom layer (once everything is unmount)
|
|
|
|
TEARDOWNPATH="config/teardown_chroot_layered"
|
|
|
|
TEARDOWNPATH="config/teardown_chroot_layered"
|
|
|
|
cat > $TEARDOWNPATH << EOF
|
|
|
|
cat > $TEARDOWNPATH << EOF
|
|
|
|
#!/bin/sh
|
|
|
|
#!/bin/sh
|
|
|
|