Commit 3ba7e137 authored by Jeff Bilyk's avatar Jeff Bilyk Committed by Natanael Copa

alpine-conf: modify setup-apkrepos to grab different mirror and automatically retrieve release

Retrieve MIRRORS.txt and get mirror from there, automatically choose release if possible, and if not prompt for desired release
parent ca99d9e3
...@@ -5,31 +5,40 @@ PREFIX= ...@@ -5,31 +5,40 @@ PREFIX=
. $PREFIX/lib/libalpine.sh . $PREFIX/lib/libalpine.sh
while true; do # TODO: change tail command to a random mirror instead of last one in MIRRORS.txt
printf "Enter repository branch : \n" MIRROR=`wget -O - http://www.alpinelinux.org/alpine/MIRRORS.txt 2>&1 | grep http | awk -F 'ETA' '{print $NF}' | tail -n 1`
printf "1 1.10 \n"
printf "2 2.0\n" # Retrieve version from alpine-release if available
printf "3 2.1\n" if [ -e /etc/alpine-release ]; then
printf "4 edge\n" release=$(cut -f1 /etc/alpine-release)
default_read REPO "3" case "$release" in
if [ $REPO -gt 0 ] && [ $REPO -lt 5 ]; then *_git*) repo="edge";;
break [0-9]*.[0-9]*.[0-9]*)
fi # release in x.y.z format, cut last digit
done repo=v${release%.[0-9]*};;
if [ $REPO == 1 ]; then esac
echo "v1.10 repos selected" echo "$repo"
echo "http://dl-3.alpinelinux.org/alpine/v1.10/packages/main" >> /etc/apk/repositories else
apk update while true; do
elif [ $REPO == 2 ]; then printf "Enter repository branch from list below [v2.2]: \n"
echo "v2.0 repos selected"; # Retrieve list of versions available on mirror 2.0 and above
echo "http://dl-3.alpinelinux.org/alpine/v2.0/packages/main" >> /etc/apk/repositories wget "$MIRROR" > /dev/null 2>&1
apk update availablerepos=""
elif [ $REPO == 3 ]; then for version in `links ./index.html -dump | grep "v[2-9]" | awk -F '/' '{print $1}'`; do
echo "v2.1 repos selected";
echo "http://dl-3.alpinelinux.org/alpine/v2.1/packages/main" >> /etc/apk/repositories availablerepos="$availablerepos $version"
apk update done
elif [ $REPO == 4 ]; then rm index.html
echo "edge repos selected"; availablerepos="$availablerepos edge"
echo "http://dl-3.alpinelinux.org/alpine/edge/packages/main" >> /etc/apk/repositories for i in `echo $availablerepos`; do
apk update printf "$i\n"
done
default_read repo "v2.2"
if [ $repo ]; then
break
fi
done
fi fi
echo "${MIRROR}${repo}/main" >> /etc/apk/repositories
apk update
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment