summaryrefslogtreecommitdiff
path: root/helpers/lh_setupapt
blob: 37a3dbdfa0d4b6da7d3dd78799d5f4ebd3865667 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/sh

case "${1}" in
	custom)
		# Configure custom sources.list
		case "${LIVE_DISTRIBUTION}" in
			stable|"${CODENAME_STABLE}"|testing|"${CODENAME_TESTING}")
				echo "deb ${LIVE_MIRROR} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list

				if [ "${LIVE_SOURCE}" = "yes" ]
				then
					echo "deb-src ${LIVE_MIRROR} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
				fi

				echo "deb ${LIVE_MIRROR_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list

				if [ "${LIVE_SOURCE}" = "yes" ]
				then
					echo "deb-src ${LIVE_MIRROR_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
				fi
				;;

			unstable|"${CODENAME_UNSTABLE}")
				echo "deb ${LIVE_MIRROR} unstable ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list

				if [ "${LIVE_SOURCE}" = "yes" ]
				then
					echo "deb-src ${LIVE_MIRROR} unstable ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
				fi

				if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ]
				then
					echo "deb ${LIVE_MIRROR} experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list

					if [ "${LIVE_SOURCE}" = "yes" ]
					then
						echo "deb-src ${LIVE_MIRROR} experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
					fi

cat > "${LIVE_CHROOT}"/etc/apt/preferences << EOF
Package: *
Pin: release a=experimental
Pin-Priority: 999
EOF
				fi
				;;
		esac
		;;

	default)
		# Configure default sources.list
		case "${LIVE_DISTRIBUTION}" in
			oldstable|"${CODENAME_OLDSTABLE}"|stable|"${CODENAME_STABLE}"|testing|"${CODENAME_TESTING}")
				echo "deb http://ftp.debian.org/debian/ ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list

				if [ "${LIVE_SOURCE}" = "yes" ]
				then
					echo "deb-src http://ftp.debian.org/debian/ ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
				fi

				echo "deb http://security.debian.org/ ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list

				if [ "${LIVE_SOURCE}" = "yes" ]
				then
					echo "deb-src http://security.debian.org/ ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
				fi
				;;

			unstable|"${CODENAME_UNSTABLE}")
				echo "deb http://ftp.debian.org/debian/ unstable ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list

				if [ "${LIVE_SOURCE}" = "yes" ]
				then
					echo "deb-src http://ftp.debian.org/debian/ unstable ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
				fi

				if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ]
				then
					echo "deb http://ftp.debian.org/debian/ experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list

					if [ "${LIVE_SOURCE}" = "yes" ]
					then
						echo "deb-src http://ftp.debian.org/debian/ experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
					fi
				fi
				;;
		esac
		;;
esac

# Add custom repositories
echo "" >> "${LIVE_CHROOT}"/etc/apt/sources.list
echo "# Custom repositories" >> "${LIVE_CHROOT}"/etc/apt/sources.list

for NAME in ${LIVE_REPOSITORIES}
do
	eval REPOSITORY="$`echo LIVE_REPOSITORY_$NAME`"
	eval REPOSITORY_DISTRIBUTION="$`echo LIVE_REPOSITORY_DISTRIBUTION_$NAME`"
	eval REPOSITORY_SECTIONS="$`echo LIVE_REPOSITORY_SECTIONS_$NAME`"

	# Configure /etc/apt/sources.list
	if [ -n "${REPOSITORY_DISTRIBUTION}" ]
	then
		echo "deb ${REPOSITORY} ${REPOSITORY_DISTRIBUTION} ${REPOSITORY_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
	else
		echo "deb ${REPOSITORY} ${LIVE_DISTRIBUTION} ${REPOSITORY_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
	fi
done

# Update indices
if [ "${2}" = "initial" ]
then
	lh_chroot "apt-get update"
else
	lh_chroot "aptitude update"
fi

if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ]
then
	# experimental is sometimes broken,
	# therefore this is intentionally kept interactive.
	lh_chroot "aptitude upgrade" || return 0
	lh_chroot "aptitude dist-upgrade" || return 0
fi