summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-07-01 11:01:09 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2014-07-01 11:01:09 +0200
commita5ad7c4c0a1e649033699a3ba832c3810fb576dc (patch)
treed0e042967c34ebb053d13502be4e128f528ef0ed
parent08809fe4005276fd9ce9424cf5932da02162d5ba (diff)
downloadalpine-conf-a5ad7c4c0a1e649033699a3ba832c3810fb576dc.zip
setup-apkrepos: allow specify the repos from cmdline
ref #2862
-rw-r--r--setup-apkrepos.in60
1 files changed, 33 insertions, 27 deletions
diff --git a/setup-apkrepos.in b/setup-apkrepos.in
index 7744d8b..e29572e 100644
--- a/setup-apkrepos.in
+++ b/setup-apkrepos.in
@@ -137,7 +137,7 @@ edit_repositories() {
usage() {
cat <<__EOF__
-usage: setup-apkrepos [-hr]
+usage: setup-apkrepos [-hr] [REPO...]
Setup apk repositories
@@ -155,7 +155,7 @@ while getopts "hr" opt; do
r) JUSTADDRANDOM=1;;
esac
done
-
+shift $(($OPTIND - 1))
# main
# install alpine-mirrors if its not already there
@@ -175,35 +175,41 @@ if [ -r "$APKREPOS_PATH" ]; then
APKREPOS=`cat "$APKREPOS_PATH"`
fi
-
-
get_alpine_release
default_answer=f
-changed=
-while true; do
- if [ -n "$JUSTADDRANDOM" ]; then
- show_mirror_list > /dev/null
- add_random_mirror && changed=1 && break
- else
- show_mirror_list
- prompt_setup_method $default_answer
-
- default_read answer $default_answer
- case "$answer" in
- "done") break;;
- [0-9]*) add_from_list $answer && changed=1;;
- /*|http://*|ftp://*|https://*) add_from_url "$answer" && changed=1;;
- r) add_random_mirror && changed=1;;
- f) add_fastest_mirror && changed=1;;
- e) edit_repositories && changed=1 && break;;
- esac
- if [ -n "$changed" ]; then
- break
- fi
- fi
+changed=false
+
+if [ $# -gt 0 ]; then
+ # replace the apk repos with the specified ones
+ rm -f "$APKREPOS_PATH"
+ for i; do
+ echo "$i" >> "$APKREPOS_PATH"
+ done
+ changed=true
+fi
+
+if [ -n "$JUSTADDRANDOM" ]; then
+ show_mirror_list > /dev/null
+ add_random_mirror && changed=true
+fi
+
+while ! $changed; do
+ show_mirror_list
+ prompt_setup_method $default_answer
+
+ default_read answer $default_answer
+ case "$answer" in
+ "done") break;;
+ [0-9]*) add_from_list $answer && changed=true;;
+ /*|http://*|ftp://*|https://*) add_from_url "$answer" \
+ && changed=true;;
+ r) add_random_mirror && changed=true;;
+ f) add_fastest_mirror && changed=true;;
+ e) edit_repositories && changed=true;;
+ esac
done
-if [ -n "$changed" ]; then
+if $changed; then
echo -n "Updating repository indexes... "
apk update --quiet $apk_root_opt && echo "done."
fi