From b9979cad2a7d65f6e138749ecd1e1a75d3ab0d7f Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 26 Mar 2019 13:27:34 +1300 Subject: [PATCH] add a big comment --- bin/subiquity-configure-apt | 41 ++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/bin/subiquity-configure-apt b/bin/subiquity-configure-apt index 49fa0fd0..cb7082e1 100755 --- a/bin/subiquity-configure-apt +++ b/bin/subiquity-configure-apt @@ -1,9 +1,38 @@ #!/bin/bash -eux + +# Configure apt so that installs from the pool on the cdrom are preferred +# during installation but not in the installed system. +# +# This has a few steps. +# +# 1. As the remaining steps mean that any changes to apt configuration are do +# not persist into the installed system, we get curtin to configure apt a +# bit earlier than it would by default. +# +# 2. Bind-mount the cdrom into the installed system as /run/cdrom +# +# 3. Set up an overlay over /target/etc/apt. This means that any changes we +# make will not persist into the installed system and we do not have to +# worry about cleaning up after ourselves. +# +# 4. Configure apt in /target to look at the pool on the cdrom. This has two +# subcases: +# +# a. if we expect the network to be working, this basically means +# prepending "deb file:///run/cdrom $(lsb_release -sc) main restricted" +# to the sources.list file. +# +# b. if the network is not expected to be working, we replace the +# sources.list with a file just referencing the cdrom. +# +# 5. If the network is not expected to be working, we also set up an overlay +# over /target/var/lib/apt/lists (if the network is working, we'll run "apt +# update" after the /target/etc/apt overlay has been cleared). + PY=$1 HAS_NETWORK=$2 -mount -t tmpfs tmpfs "$TARGET_MOUNT_POINT/run" -mkdir -p "$TARGET_MOUNT_POINT/run/cdrom" -mount --bind /cdrom "$TARGET_MOUNT_POINT/run/cdrom" + +$PY -m curtin apt-config setup_overlay () { local dir=$1 @@ -12,10 +41,12 @@ setup_overlay () { mount -t overlay overlay -o lowerdir=$dir,workdir=$t/work,upperdir=$t/upper $dir } -$PY -m curtin apt-config - setup_overlay $TARGET_MOUNT_POINT/etc/apt +mount -t tmpfs tmpfs "$TARGET_MOUNT_POINT/run" +mkdir -p "$TARGET_MOUNT_POINT/run/cdrom" +mount --bind /cdrom "$TARGET_MOUNT_POINT/run/cdrom" + cat > "/tmp/sources.list" <