diff --git a/live-build/functions b/live-build/functions index 9f910bcb..2bfe3f2d 100644 --- a/live-build/functions +++ b/live-build/functions @@ -556,11 +556,39 @@ snap_from_seed() { fi } +seed_from_task () +{ + # Retrieve the name of the seed from a task name + local task=$1 + local seed + local seedfile + local seedfiles + + seedfile="$(grep -lE "^Task-Key: +${task}\$" config/germinate-output/*seedtext|head -1)" + if [ -n "$seedfile" ]; then + basename $seedfile .seedtext + return + fi + + seedfiles="$(grep -lE "^Task-Per-Derivative: *1\$" config/germinate-output/*seedtext)" + if [ -n "$seedfiles" ]; then + for seed in $(echo $seedfiles | xargs basename -s .seedtext); do + if [ ${PROJECT}-${seed} = $task ]; then + echo ${seed} + return + fi + done + fi +} + add_task () { local pass="$1" shift local task + local snap_list_file + local snap_list_files + local curseed # The removal of direct task installation support from live-build # poses some problems. If the chroot has multiarch configured - for @@ -577,12 +605,32 @@ add_task () # probably a lurking timebomb that we need to fix. In the meantime, # the Architecture restriction at least saves us from abject # failure. + # + # We want as well to grab the snap list for each PASS. Resolve for all + # given task, and deduplicate them to generate snaps for the PASS. for task; do # We need a ridiculous number of backslashes to protect # parentheses from eval. echo "!chroot chroot apt-cache dumpavail | grep-dctrl -nsPackage \\\\\\( -XFArchitecture $ARCH -o -XFArchitecture all \\\\\\) -a -wFTask $task" >> "config/package-lists/livecd-rootfs.list.chroot_$pass" + + curseed=$(seed_from_task ${task}) + if [ -z "${curseed}" ]; then + echo "W: No seed matching task ${task}" + continue + fi + snap_list_file="config/package-lists/seed.${curseed}.snaplist.full" + snap_from_seed "${curseed}" $snap_list_file + if [ -e "$snap_list_file" ]; then + snap_list_files="${snap_list_files} $snap_list_file" + fi done + # The snap list is one line, and could be duplicated between seeds via inheritance. + # Uniquely sort them and store them back in one line. + if [ -n "${snap_list_files}" ]; then + cat ${snap_list_files}|xargs -n1|sort -u > "config/package-lists/livecd-rootfs.snaplist.chroot_${pass}.full" + rm ${snap_list_files} + fi } add_package ()