From 9a0c6102fdff56da0871bfb1a63cc0349d6317f4 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 23 Feb 2018 00:00:20 +0000 Subject: Fix build with local offline mirrors Commit a15b579652e64 (#775989) dropped an early exit from the chroot_archives remove step in case the parent mirror chroot and binary parameters are the same and introduced a regression, as with the following live-build now fails when the parent mirror is using a file:/ local apt repository (for example when the build worker is offline and uses a pre-built cache of packages). Example config: lb config --mirror-bootstrap "file:/pkgs" \ --mirror-chroot "file:/pkgs/" \ --mirror-binary "file:/pkgs" \ --parent-mirror-bootstrap "file:/pkgs" \ --parent-mirror-chroot "file:/pkgs/" \ --parent-mirror-binary "file:/pkgs" \ ... with /pkgs being a directory with the packages for the installation and the apt metadata (Packages/Sources/Release). The problem is that, with such a setup, the /pkgs directory is bind mounted inside the chroot as an optimisation in the install step, and umounted as one of the first actions in the remove step for chroot_archives. Before that fix, the script terminated immediately. But now it progresses and at the end it tries to run apt update inside the chroot which will fail since the repository directory has been umounted, and thus the packages and the apt metadata are no longer available, while still being listed in /etc/apt/sources.list. The proposed solution is to umount the local directory at the end of the remove step, rather than at the beginning. Closes: #891206 --- scripts/build/chroot_archives | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts/build/chroot_archives') diff --git a/scripts/build/chroot_archives b/scripts/build/chroot_archives index 85ad35b0c..596fafc57 100755 --- a/scripts/build/chroot_archives +++ b/scripts/build/chroot_archives @@ -449,12 +449,6 @@ EOF mv chroot/etc/apt/sources.list.d/zz-sources.list chroot/etc/apt/sources.list fi - # Unmount local repository -if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/' -then - Chroot_unbind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')" -fi - # Configure generic indices # Cleaning apt list cache rm -rf chroot/var/lib/apt/lists @@ -652,6 +646,12 @@ EOF # Updating indices Apt chroot update + # Unmount local repository - after apt update or it will fail due to missing files + if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/' + then + Chroot_unbind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')" + fi + # Cleaning apt package cache rm -rf chroot/var/cache/apt mkdir -p chroot/var/cache/apt/archives/partial -- cgit v1.2.3