From a8d4ffe20d7dec606761cccfc870320e0a235544 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Wed, 6 Apr 2016 10:50:20 +0100 Subject: [PATCH] fallback to alpine distfiles if upstream source has gone missing, fix #70 Signed-off-by: Justin Cormack --- licensing/license.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/licensing/license.sh b/licensing/license.sh index be4eea27e..a68dfd4f4 100755 --- a/licensing/license.sh +++ b/licensing/license.sh @@ -1,6 +1,15 @@ #!/bin/bash -fail() { +fetch () { + wget $1 + [ $? == 0 ] && exit 0 + # try at archive if original source fails + BASE=$(basename $1) + # distfiles are split as v3.3, not v3.3.3 + # edge is not available but should always be upstream + ALPINE=$(cat /hostetc/alpine-release | sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/') + wget http://distfiles.alpinelinux.org/distfiles/v${ALPINE}/$BASE + [ $? == 0 ] && exit 0 printf "\e[31m$1 \e[0m\n" exit 1 } @@ -46,9 +55,8 @@ do then cp -a $f "$srcdir"/$pkgname-$pkgver/ else - cd "$srcdir"/$pkgname-$pkgver && \ - wget $f || fail "Cannot retrieve $f" && \ - cd - + ( cd "$srcdir"/$pkgname-$pkgver && \ + fetch $f ) fi fi done