summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Bilyk <jbilyk@gmail.com>2011-01-01 19:48:05 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-01-03 13:49:49 +0000
commit3ba7e1372693eab058f90f2464f8535346222207 (patch)
tree84b6e5f45d3de01a880a0f1df47cd234a504329d
parentca99d9e3232d621f6764da6643cc3cc3b828ab0c (diff)
downloadalpine-conf-3ba7e1372693eab058f90f2464f8535346222207.zip
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
-rwxr-xr-xsetup-apkrepos.in63
1 files changed, 36 insertions, 27 deletions
diff --git a/setup-apkrepos.in b/setup-apkrepos.in
index 1436292..19344bd 100755
--- a/setup-apkrepos.in
+++ b/setup-apkrepos.in
@@ -5,31 +5,40 @@ PREFIX=
. $PREFIX/lib/libalpine.sh
-while true; do
- printf "Enter repository branch : \n"
- printf "1 1.10 \n"
- printf "2 2.0\n"
- printf "3 2.1\n"
- printf "4 edge\n"
- default_read REPO "3"
- if [ $REPO -gt 0 ] && [ $REPO -lt 5 ]; then
- break
- fi
-done
-if [ $REPO == 1 ]; then
- echo "v1.10 repos selected"
- echo "http://dl-3.alpinelinux.org/alpine/v1.10/packages/main" >> /etc/apk/repositories
- apk update
-elif [ $REPO == 2 ]; then
- echo "v2.0 repos selected";
- echo "http://dl-3.alpinelinux.org/alpine/v2.0/packages/main" >> /etc/apk/repositories
- apk update
-elif [ $REPO == 3 ]; then
- echo "v2.1 repos selected";
- echo "http://dl-3.alpinelinux.org/alpine/v2.1/packages/main" >> /etc/apk/repositories
- apk update
-elif [ $REPO == 4 ]; then
- echo "edge repos selected";
- echo "http://dl-3.alpinelinux.org/alpine/edge/packages/main" >> /etc/apk/repositories
- apk update
+# TODO: change tail command to a random mirror instead of last one in MIRRORS.txt
+MIRROR=`wget -O - http://www.alpinelinux.org/alpine/MIRRORS.txt 2>&1 | grep http | awk -F 'ETA' '{print $NF}' | tail -n 1`
+
+# Retrieve version from alpine-release if available
+if [ -e /etc/alpine-release ]; then
+ release=$(cut -f1 /etc/alpine-release)
+ case "$release" in
+ *_git*) repo="edge";;
+ [0-9]*.[0-9]*.[0-9]*)
+ # release in x.y.z format, cut last digit
+ repo=v${release%.[0-9]*};;
+ esac
+ echo "$repo"
+else
+ while true; do
+ printf "Enter repository branch from list below [v2.2]: \n"
+ # Retrieve list of versions available on mirror 2.0 and above
+ wget "$MIRROR" > /dev/null 2>&1
+ availablerepos=""
+ for version in `links ./index.html -dump | grep "v[2-9]" | awk -F '/' '{print $1}'`; do
+
+ availablerepos="$availablerepos $version"
+ done
+ rm index.html
+ availablerepos="$availablerepos edge"
+ for i in `echo $availablerepos`; do
+ printf "$i\n"
+ done
+ default_read repo "v2.2"
+ if [ $repo ]; then
+ break
+ fi
+ done
fi
+
+echo "${MIRROR}${repo}/main" >> /etc/apk/repositories
+apk update