summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-03-03 17:02:48 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-03-03 17:02:48 +0000
commit002634515bb11dda8e929d4d3d9481a04ef17695 (patch)
treeebcdab8b3672a5b7141e9de6bd7f3b9c36daeb30
parentde967ed0964382a185838a1fa312345c502c6d48 (diff)
downloadalpine-conf-002634515bb11dda8e929d4d3d9481a04ef17695.zip
setup-apkrepos: install alpine-mirrors if needed
-rwxr-xr-xsetup-apkrepos.in41
1 files changed, 27 insertions, 14 deletions
diff --git a/setup-apkrepos.in b/setup-apkrepos.in
index 468e65e..21eb802 100755
--- a/setup-apkrepos.in
+++ b/setup-apkrepos.in
@@ -5,20 +5,6 @@ PREFIX=
. $PREFIX/lib/libalpine.sh
-MIRRORS_PATH=/usr/share/alpine-mirrors/MIRRORS.txt
-if [ -z "$MIRRORS" ] && [ -r "$MIRRORS_PATH" ]; then
- MIRRORS=`cat $MIRRORS_PATH`
-fi
-
-RELEASES_PATH=/usr/share/alpine-mirrors/RELEASES.txt
-if [ -z "$RELEASES" ] && [ -r "$RELEASES_PATH" ]; then
- RELEASES=`cat $RELEASES_PATH`
-fi
-
-APKREPOS_PATH=/etc/apk/repositories
-if [ -r "$APKREPOS_PATH" ]; then
- APKREPOS=`cat "$APKREPOS_PATH"`
-fi
get_hostname_from_url() {
local n=${1#*://}
@@ -135,6 +121,28 @@ edit_repositories() {
}
# main
+# install alpine-mirrors if its not already there
+to_uninstall=
+if ! apk info -q -e alpine-mirrors; then
+ apk add -q alpine-mirrors
+ to_uninstall=alpine-mirrors
+fi
+
+MIRRORS_PATH=/usr/share/alpine-mirrors/MIRRORS.txt
+if [ -z "$MIRRORS" ] && [ -r "$MIRRORS_PATH" ]; then
+ MIRRORS=`cat $MIRRORS_PATH`
+fi
+
+RELEASES_PATH=/usr/share/alpine-mirrors/RELEASES.txt
+if [ -z "$RELEASES" ] && [ -r "$RELEASES_PATH" ]; then
+ RELEASES=`cat $RELEASES_PATH`
+fi
+
+APKREPOS_PATH=/etc/apk/repositories
+if [ -r "$APKREPOS_PATH" ]; then
+ APKREPOS=`cat "$APKREPOS_PATH"`
+fi
+
get_alpine_release
default_answer=f
changed=
@@ -160,3 +168,8 @@ if [ -n "$changed" ]; then
echo -n "Updating repository indexes... "
apk update -q && echo "done."
fi
+
+# clean up
+if [ -n "$to_uninstall" ]; then
+ apk del -q alpine-mirrors
+fi