From 94abddf58d99c4dd22749d2d646296446d19294c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 10 Jan 2024 21:13:08 +0100 Subject: [PATCH] yolo: attempt to preinstall apt dependencies in the initial lxc snapshot --- lib/lxc.sh | 2 ++ lib/tests.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/lxc.sh b/lib/lxc.sh index 6bdb497..4b2dabd 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -49,6 +49,8 @@ LXC_CREATE () { fi set_witness_files + _PREINSTALL_APT_DEPS + sleep 3 log_info "Creating initial snapshot $LXC_NAME ..." lxc snapshot $LXC_NAME snap0 diff --git a/lib/tests.sh b/lib/tests.sh index 5217d0b..da1e740 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -4,6 +4,20 @@ # "Low-level" logistic helpers #================================================= +_PREINSTALL_APT_DEPS() +{ + [[ -e $package_path/manifest.toml ]] || return + + local apt_deps=$(python3 -c "import toml, sys; t = toml.loads(sys.stdin.read()); p = t['resources'].get('apt', {}).get('packages', ''); print(p.replace(',', ' ')) if isinstance(p, str) else print(' '.join(p));" < $package_path/manifest.toml) + + log_small_title "Preinstalling apt dependencies before creating the initial snapshot..." + RUN_INSIDE_LXC apt install $apt_deps || true + + # Execute the command given in argument in the container and log its results. + lxc exec $LXC_NAME -t -- /bin/bash -c "apt install $apt_deps" | tee -a "$full_log" >/dev/null +} + + _RUN_YUNOHOST_CMD() { log_debug "Running yunohost $1"