Commit a5ad7c4c authored by Natanael Copa's avatar Natanael Copa
Browse files

setup-apkrepos: allow specify the repos from cmdline

ref #2862
parent 08809fe4
...@@ -137,7 +137,7 @@ edit_repositories() { ...@@ -137,7 +137,7 @@ edit_repositories() {
usage() { usage() {
cat <<__EOF__ cat <<__EOF__
usage: setup-apkrepos [-hr] usage: setup-apkrepos [-hr] [REPO...]
Setup apk repositories Setup apk repositories
...@@ -155,7 +155,7 @@ while getopts "hr" opt; do ...@@ -155,7 +155,7 @@ while getopts "hr" opt; do
r) JUSTADDRANDOM=1;; r) JUSTADDRANDOM=1;;
esac esac
done done
shift $(($OPTIND - 1))
# main # main
# install alpine-mirrors if its not already there # install alpine-mirrors if its not already there
...@@ -175,35 +175,41 @@ if [ -r "$APKREPOS_PATH" ]; then ...@@ -175,35 +175,41 @@ if [ -r "$APKREPOS_PATH" ]; then
APKREPOS=`cat "$APKREPOS_PATH"` APKREPOS=`cat "$APKREPOS_PATH"`
fi fi
get_alpine_release get_alpine_release
default_answer=f default_answer=f
changed= changed=false
while true; do
if [ -n "$JUSTADDRANDOM" ]; then if [ $# -gt 0 ]; then
show_mirror_list > /dev/null # replace the apk repos with the specified ones
add_random_mirror && changed=1 && break rm -f "$APKREPOS_PATH"
else for i; do
show_mirror_list echo "$i" >> "$APKREPOS_PATH"
prompt_setup_method $default_answer done
changed=true
default_read answer $default_answer fi
case "$answer" in
"done") break;; if [ -n "$JUSTADDRANDOM" ]; then
[0-9]*) add_from_list $answer && changed=1;; show_mirror_list > /dev/null
/*|http://*|ftp://*|https://*) add_from_url "$answer" && changed=1;; add_random_mirror && changed=true
r) add_random_mirror && changed=1;; fi
f) add_fastest_mirror && changed=1;;
e) edit_repositories && changed=1 && break;; while ! $changed; do
esac show_mirror_list
if [ -n "$changed" ]; then prompt_setup_method $default_answer
break
fi default_read answer $default_answer
fi 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 done
if [ -n "$changed" ]; then if $changed; then
echo -n "Updating repository indexes... " echo -n "Updating repository indexes... "
apk update --quiet $apk_root_opt && echo "done." apk update --quiet $apk_root_opt && echo "done."
fi fi
......
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