90-enable-repo 730 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/bin/sh
# enable online repos if possible, just quit if anything's wrong

repo_source='/etc/apt/sources.list.d/alt.list'
host='http://ftp.altlinux.org'

[ -s "$repo_source" ] || exit 0

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

# architectures
host_arch="$(rpm --eval '%_host_cpu')"
[ "$host_arch" = "x86_64" ] && compat="x86_64-i586" || compat=
16
[ "$host_arch" = 'armh' ] && noarch= || noarch='noarch'
17 18

# turn on unconditionally
19 20
for arch in "$host_arch" "$noarch" "$compat"; do
	[ -n "$arch" ] || continue
21 22
	sed -i "s/^#\($updates_re$arch\)/\1/" "$repo_source"
done