90-enable-repo 1.02 KB
Newer Older
1
#!/bin/sh
2
# enable online repos if not use/repo/main
3

4
[ -z "$GLOBAL_REPO_MAIN" ] || exit 0
5

6 7 8
# no public repos for e2k for now, unfortunately
[ `arch` != "e2k" ] || exit 0

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
[ -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
33
	echo "Error: $repo_source does not exist" >&2
34 35
	exit 1
fi
36 37 38

# regexps from alterator-pkg (via installer-feature-online-repo)
prefix_re="[[:space:]]*rpm[[:space:]]\+\([^[:space:]]\+[[:space:]]\+\)\?"
39
host_re="${PROTO:-http}:\/\/\([^[:space:]]\+\)[[:space:]]\+"
40
updates_re="${prefix_re}${host_re}\([^[:space:]]\+\/\)\?"
41

42
sed -i "s/^#\($updates_re\)/\1/" "$repo_source"