From 903ba3b2760ac38e7c47f5bcc6472467fa26ac81 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lallement Date: Thu, 15 Nov 2018 12:12:49 +0100 Subject: [PATCH] Actually install snap for each layer. --- live-build/lb_chroot_layered | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/live-build/lb_chroot_layered b/live-build/lb_chroot_layered index 9a3b3905..a8b152c4 100755 --- a/live-build/lb_chroot_layered +++ b/live-build/lb_chroot_layered @@ -41,8 +41,49 @@ Setup_cleanup . config/functions +# Create the snap list specific to this layer +lb_chroot_snap_lists() { + local pass=$1 + local prevpass=$2 + + # 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_prevpass=$(ls config/package-lists/*.snaplist.chroot_${prevpass}.full 2>/dev/null || true) + + if [ -z "${snap_for_pass}" ]; then + return + fi + + if [ -z "${snap_for_prevpass}" ]; then + cp ${snap_for_pass} ${snap_for_pass%.full} + return + fi + + # 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} +} + +lb_chroot_install_snaps() { + # Prepare the snap environment and install snaps into a chroot + # + # $1: Name of the pass + + local snaplist_file=$(ls config/package-lists/*.snaplist.chroot_${1} 2>/dev/null || true) + + if [ -z "${snaplist_file}" ]; then + return + fi + + snap_prepare chroot + + while read snap; do + snap_preseed chroot "${snap}" + done < $snaplist_file +} + PASSES="${PASSES:-install live}" CURPASS=1 +PREVPASS="" LASTPASS=$(echo $PASSES|wc -w) LOWER_LAYERS="" for _PASS in $PASSES @@ -79,6 +120,10 @@ do lb chroot_package-lists ${_PASS} ${*} lb chroot_install-packages ${_PASS} ${*} + # Snap management + lb_chroot_snap_lists ${_PASS} ${PREVPASS} + lb_chroot_install_snaps ${_PASS} ${*} + # Kernel should be in first layer if [ $CURPASS -eq 1 ]; then Chroot chroot "dpkg -l linux-headers-3* linux-headers-4*" 2>/dev/null \ @@ -128,6 +173,7 @@ do fi LOWER_LAYERS="chroot.${_PASS}:$LOWER_LAYERS" LOWER_LAYERS="${LOWER_LAYERS%:}" + PREVPASS=${_PASS} CURPASS=$(( CURPASS + 1 )) done