]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-debian: don't hardcode valid releases
authorAntonio Terceiro <terceiro@debian.org>
Sat, 28 Oct 2017 11:20:35 +0000 (09:20 -0200)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 16 Nov 2017 21:46:49 +0000 (16:46 -0500)
This avoids the dance of updating the list of valid releases every time
Debian makes a new release.

It also fixes the following bug: even though lxc-debian will default to
creating containers of the latest stable by querying the archive, it
won't allow you to explicitly request `stable` because the current list
of valid releases don't include it.

Last, but not least, avoid hitting the mirror in the case the desired
release is one of the ones we know will always be there, i.e. stable,
testing, sid, and unstable.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
templates/lxc-debian.in

index 95099e1e9604671a8450d7c8c5202a0fa6463e43..20c2679107e62febbbd2010c0e42daef96cecba4 100644 (file)
@@ -587,12 +587,13 @@ if [ "$(id -u)" != "0" ]; then
     exit 1
 fi
 
-current_release=`wget ${MIRROR}/dists/stable/Release -O - 2> /dev/null | head |awk '/^Codename: (.*)$/ { print $2; }'`
-release=${release:-${current_release}}
-valid_releases=('wheezy' 'jessie' 'stretch' 'buster' 'testing' 'sid' 'unstable')
-if [[ ! "${valid_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
-    echo "Invalid release ${release}, valid ones are: ${valid_releases[*]}"
-    exit 1
+release=${release:-stable}
+permanent_releases=('stable' 'testing' 'sid' 'unstable')
+if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
+    if ! wget "${MIRROR}/dists/${release}/Release" -O /dev/null 2> /dev/null; then
+       echo "Invalid release ${release} (not found in mirror)"
+       exit 1
+    fi
 fi
 
 # detect rootfs