You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

3 years ago
#!/bin/sh
# enable online repos if not use/repo/main
3 years ago
[ -z "$GLOBAL_REPO_MAIN" ] || exit 0
3 years ago
# no public repos for e2k for now, unfortunately
[ `arch` != "e2k" ] || exit 0
3 years ago
[ -n "$GLOBAL_REPO" ] || exit 0
PROTO="${GLOBAL_REPO%/*}" # http, ftp, rsync
case "$PROTO" in
http|ftp|rsync)
;;
*)
echo "Error: protocol $PROTO not supported" >&2
exit 1
;;
esac
MIRROR="${GLOBAL_REPO#*/}" # alt, heanet, kiev, yandex, ...
if [ -z "$MIRROR" ]; then
echo "Error: variable MIRROR is not set!!!" >&2
echo "Set REPO variable in the format: PROTO/MIRROR" >&2
echo "Example: http/yandex" >&2
exit 1
fi
repo_source="/etc/apt/sources.list.d/$MIRROR.list"
if [ ! -s "$repo_source" ]; then
echo "Error: $repo_source is not exist" >&2
exit 1
fi
3 years ago
# regexps from alterator-pkg (via installer-feature-online-repo)
prefix_re="[[:space:]]*rpm[[:space:]]\+\([^[:space:]]\+[[:space:]]\+\)\?"
host_re="${PROTO:-http}:\/\/\([^[:space:]]\+\)[[:space:]]\+"
3 years ago
updates_re="${prefix_re}${host_re}\([^[:space:]]\+\/\)\?"
sed -i "s/^#\($updates_re\)/\1/" "$repo_source"