~ubuntu-branches/ubuntu/quantal/apt-setup/quantal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
set -e

. /usr/share/debconf/confmodule

file="$1"

db_get apt-setup/services-select-ubuntu
if ! echo "$RET" | grep -q security; then
	exit
fi

db_get apt-setup/security_host
host="$RET"
[ "$host" ] || exit

db_get apt-setup/security_path
directory="$RET"
[ "$directory" ] || exit

if ! db_get mirror/codename || [ -z "$RET" ]; then
	db_get cdrom/codename
fi
codename="$RET"

# Awful Ubuntu-specific hack. *-security suites for ports architectures
# aren't available on security.ubuntu.com, only on ports.ubuntu.com.
if [ "$host" = security.ubuntu.com ]; then
	db_get mirror/protocol
	protocol="$RET"
	db_get mirror/$protocol/hostname
	if [ "$RET" = ports.ubuntu.com ]; then
		host="$RET"
		db_get mirror/$protocol/directory
		directory="$RET"
	fi
fi

# To determine if restricted should be included, grep the file to see if it
# is listed in it.
dists="main"
for dist in restricted; do
	if grep -v 'cdrom:' $ROOT/etc/apt/sources.list.new | grep -q '^[^#]* '$dist; then
		dists="$dists $dist"
	fi
done

# Don't test mirror if no network selected in netcfg
echo "deb http://$host$directory $codename-security $dists" >> $file
echo "deb-src http://$host$directory $codename-security $dists" >> $file

# Security sources for Ubuntu universe; not used much, but e.g. unsupported
# binary packages from a supported source package will end up here.
if db_get apt-setup/universe && [ "$RET" = true ]; then
	COMMENT=
else
	COMMENT='# '
fi
cat >> $file <<EOF
${COMMENT}deb http://$host$directory $codename-security universe
${COMMENT}deb-src http://$host$directory $codename-security universe
EOF

# Security sources for Ubuntu multiverse, with the same caveats as for
# universe.
if db_get apt-setup/multiverse && [ "$RET" = true ]; then
	COMMENT=
else
	COMMENT='# '
fi
cat >> $file <<EOF
${COMMENT}deb http://$host$directory $codename-security multiverse
${COMMENT}deb-src http://$host$directory $codename-security multiverse
EOF

apt-setup-signed-release security.ubuntu.com "$file"

exit 0