From 9945e65701f1c5b8143e97dd445e86f1495be107 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Mon, 16 Jan 2023 07:39:15 +0100 Subject: [PATCH] skip running apt-get update if we are very sure that it was already run --- mmdebstrap | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mmdebstrap b/mmdebstrap index 4d87b48..74449ad 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -2275,8 +2275,19 @@ sub run_update() { CHDIR => $options->{root}, }; - info "running apt-get update..."; - run_apt_progress($aptopts); + # Maybe "apt-get update" was already run in the setup hook? If yes, skip + # running it here. We are overly strict on purpose because better to run it + # twice on accident than not at all. + if ( !-d "$options->{root}/var/lib/apt/lists/auxfiles" + || !-d "$options->{root}/var/lib/apt/lists/partial" + || !-e "$options->{root}/var/lib/apt/lists/lock" + || !-e "$options->{root}/var/cache/apt/pkgcache.bin" + || !-e "$options->{root}/var/cache/apt/srcpkgcache.bin") { + info "running apt-get update..."; + run_apt_progress($aptopts); + } else { + info "skipping apt-get update because it was already run"; + } # check if anything was downloaded at all {