From 402cdd15bed5f2dfb6442a77d6aa943178d91d87 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lallement Date: Thu, 24 Jan 2019 16:13:41 +0100 Subject: [PATCH] Adds is_root_layer Factored the code to detect if a layer is a root layer in function is_root_layer and execute lb_chroot_archives only on root layers. --- live-build/functions | 8 ++++++++ live-build/lb_chroot_layered | 18 +++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/live-build/functions b/live-build/functions index 64984e35..30aaadff 100644 --- a/live-build/functions +++ b/live-build/functions @@ -759,3 +759,11 @@ rm -f /usr/sbin/update-initramfs dpkg-divert --quiet --remove --rename /usr/sbin/update-initramfs EOF } + +is_root_layer () { + local pass=$1 + if [ -z "$(get_parent_pass $pass)" ]; then + return 0 + fi + return 1 +} diff --git a/live-build/lb_chroot_layered b/live-build/lb_chroot_layered index c65a6af4..c81bec5f 100755 --- a/live-build/lb_chroot_layered +++ b/live-build/lb_chroot_layered @@ -120,7 +120,7 @@ create_chroot_pass () { # Only get some function executed on root passes # Copy bootstrap on root layers - if [ -z "$(get_parent_pass $pass)" ]; then + if $(is_root_layer $pass); then rm -f .build/chroot_linux-image .build/chroot_preseed .build/chroot_hacks cp -a chroot.bootstrap/ "$overlay_dir/" fi @@ -144,7 +144,7 @@ create_chroot_pass () { lb chroot_proc install ${*} lb chroot_sysfs install ${*} # We run chroot_hacks only on root layers (update-initramfs diverted) - if [ -z "$(get_parent_pass $pass)" ]; then + if $(is_root_layer $pass); then divert_update_initramfs fi lb chroot_debianchroot install ${*} @@ -155,13 +155,11 @@ create_chroot_pass () { lb chroot_hostname install ${*} lb chroot_apt install ${*} # 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 - # for each layer. - # We could modify livebuild if necessary to have conditional upgrade (root pass only). - lb chroot_archives chroot install ${*} - + # diff content than desired. So only running this on root pass. + # Also configure universe # Only configure universe on root passes - if [ -z "$(get_parent_pass $pass)" ]; then + if $(is_root_layer $pass); then + lb chroot_archives chroot install ${*} configure_universe fi @@ -215,7 +213,9 @@ create_chroot_pass () { Chroot chroot "dpkg-query -W" > chroot.packages.${pass} # Deconfiguring chroot - lb chroot_archives chroot remove ${*} + if $(is_root_layer $pass); then + lb chroot_archives chroot remove ${*} + fi lb chroot_apt remove ${*} lb chroot_hostname remove ${*} lb chroot_resolv remove ${*}