Commit a5ad7c4c authored by Natanael Copa's avatar Natanael Copa

setup-apkrepos: allow specify the repos from cmdline

ref #2862
parent 08809fe4
......@@ -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
......
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