From 52d9bd3eadfb6a6650664922861e2fd1f90489e7 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lallement Date: Thu, 24 Jan 2019 16:21:41 +0100 Subject: [PATCH] Run live specific scripts on non live layers Allow execution of lb_binary_linux-image and lb_chroot_live-packages on any layer by setting LIVE_PASSES. --- live-build/auto/config | 25 +++++++++++++++++++++++++ live-build/lb_binary_layered | 12 ++++++++---- live-build/lb_chroot_layered | 6 ++++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/live-build/auto/config b/live-build/auto/config index 21d173ac..5d464e26 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -260,6 +260,22 @@ _sanitize_passes () echo $passes } +_get_live_passes () +{ + # Returns a list of all passes that ends with .live for automated live passes detection + # $1 list of passes + local passes="$1" + local livepasses="" + [ -z "$passes" ] && return + + for pass in $passes; do + if echo $pass | grep -Eq '\.live*'; then + livepasses="$pass $livepasses" + fi + done + echo $livepasses +} + if [ -z "${IMAGEFORMAT:-}" ]; then case $PROJECT:${SUBPROJECT:-} in ubuntu-cpc:*) @@ -1031,6 +1047,12 @@ lb config noauto \ "$@" PASSES=$(_sanitize_passes "$PASSES") +LIVE_PASSES=${LIVE_PASSES:-$(_get_live_passes "$PASSES")} + +if [ -n "$PASSES" ] && [ -z "$LIVE_PASSES" ]; then + Echo_warning "Multi-layered mode is enabled, but we didn't find any live pass." \ + "Either set \$LIVE_PASSES or add a pass ending with '.live'." +fi echo "LB_CHROOT_HOOKS=\"$CHROOT_HOOKS\"" >> config/chroot echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/chroot @@ -1038,6 +1060,9 @@ echo "LB_DISTRIBUTION=\"$SUITE\"" >> config/chroot if [ -n "$PASSES" ]; then echo "PASSES=\"$PASSES\"" >> config/common fi +if [ -n "$LIVE_PASSES" ]; then + echo "LIVE_PASSES=\"$LIVE_PASSES\"" >> config/common +fi echo "LB_BINARY_HOOKS=\"$BINARY_HOOKS\"" >> config/binary echo "BUILDSTAMP=\"$NOW\"" >> config/binary echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/binary diff --git a/live-build/lb_binary_layered b/live-build/lb_binary_layered index 3b3b0b7c..91c64046 100755 --- a/live-build/lb_binary_layered +++ b/live-build/lb_binary_layered @@ -100,10 +100,14 @@ build_layered_squashfs () { # Prepare initrd + kernel # Main manifest and size files prefix="livecd.$PROJECT${SUBARCH:+-$SUBARCH}" - if echo $pass | grep -Eq '\.live*' && test ! -e "${prefix}.manifest"; then - lb binary_linux-image ${*} - cp ${squashfs_f_size} "${prefix}.size" - cp "${squashfs_f_manifest}.full" "${prefix}.manifest" + if [ ! -e "${prefix}.manifest" ]; then + for livepass in $LIVE_PASSES; do + [ "$livepass" != "$pass" ] && continue + lb binary_linux-image ${*} + cp ${squashfs_f_size} "${prefix}.size" + cp "${squashfs_f_manifest}.full" "${prefix}.manifest" + break + done fi (cd "overlay.${pass}/" && diff --git a/live-build/lb_chroot_layered b/live-build/lb_chroot_layered index 65c81910..b1bf31fe 100755 --- a/live-build/lb_chroot_layered +++ b/live-build/lb_chroot_layered @@ -220,9 +220,11 @@ create_chroot_pass () { Chroot chroot "apt-get --purge -y autoremove" # Add live packages to live layers - if echo $pass | grep -Eq '\.live*'; then + for livepass in $LIVE_PASSES; do + [ "$livepass" != "$pass" ] && continue lb chroot_live-packages ${*} - fi + break + done # Run includes by pass lb_chroot_includes ${pass} ${*}