summaryrefslogtreecommitdiff
path: root/functions/sourcelist.sh
blob: 69d1570331af7c5ff2987d69fd4fe0e50b5b076b (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/sh

## live-build(7) - System Build Scripts
## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


Create_apt_sources_list ()
{
	local PARENT_MIRROR
	local MIRROR
	local PARENT_MIRROR_SECURITY
	local MIRROR_SECURITY
	local PARENT_DISTRIBUTION
	local DISTRIBUTION

	case "${1}" in
		chroot)
			PARENT_MIRROR=${LB_PARENT_MIRROR_CHROOT}
			MIRROR=${LB_MIRROR_CHROOT}
			PARENT_MIRROR_SECURITY=${LB_PARENT_MIRROR_CHROOT_SECURITY}
			MIRROR_SECURITY=${LB_MIRROR_CHROOT_SECURITY}
			PARENT_DISTRIBUTION=${LB_PARENT_DISTRIBUTION_CHROOT}
			DISTRIBUTION=${LB_DISTRIBUTION_CHROOT}
			;;
		binary)
			PARENT_MIRROR=${LB_PARENT_MIRROR_BINARY}
			MIRROR=${LB_MIRROR_BINARY}
			PARENT_MIRROR_SECURITY=${LB_PARENT_MIRROR_BINARY_SECURITY}
			MIRROR_SECURITY=${LB_MIRROR_BINARY_SECURITY}
			PARENT_DISTRIBUTION=${LB_PARENT_DISTRIBUTION_BINARY}
			DISTRIBUTION=${LB_DISTRIBUTION_BINARY}
			;;
		*)
			Echo_error "Invalid mode '${1}' specified for source list creation!"
			exit 1
			;;
	esac

	local ADD_SOURCES=false
	if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]; then
		ADD_SOURCES=true
	fi

	local PARENT_FILE
	case "${LB_DERIVATIVE}" in
		true)
			PARENT_FILE="sources.list.d/debian.list"
			;;

		false)
			PARENT_FILE="sources.list"
			;;
	esac

	local LIST_FILE="chroot/etc/apt/sources.list.d/${LB_MODE}.list"
	local PARENT_LIST_FILE="chroot/etc/apt/${PARENT_FILE}"

	local _DISTRIBUTION
	if [ "${LB_DERIVATIVE}" = "true" ]; then
		_DISTRIBUTION="$(echo ${DISTRIBUTION} | sed -e 's|-backports||')"
	fi

	# Clear out existing lists
	rm -f ${PARENT_LIST_FILE} ${LIST_FILE}

	# Set general repo
	echo "deb ${PARENT_MIRROR} ${PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> ${PARENT_LIST_FILE}

	if $ADD_SOURCES; then
		echo "deb-src ${PARENT_MIRROR} ${PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> "${PARENT_LIST_FILE}"
	fi

	if [ "${LB_DERIVATIVE}" = "true" ]; then
		echo "deb ${MIRROR} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"

		if $ADD_SOURCES; then
			echo "deb-src ${MIRROR} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"
		fi
	fi

	# Set security repo
	if [ "${LB_SECURITY}" = "true" ]; then
		case "${LB_MODE}" in
			debian|progress-linux)
				case "${PARENT_DISTRIBUTION}" in
					sid)
						# do nothing
						;;

					*)
						echo "deb ${PARENT_MIRROR_SECURITY} ${PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> "${PARENT_LIST_FILE}"

						if $ADD_SOURCES; then
							echo "deb-src ${PARENT_MIRROR_SECURITY} ${PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> "${PARENT_LIST_FILE}"
						fi
						;;
				esac

				if [ "${LB_MODE}" = progress-linux ]; then
					echo "deb ${MIRROR_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"

					if $ADD_SOURCES; then
						echo "deb-src ${MIRROR_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"
					fi
				else
					if [ "${LB_DERIVATIVE}" = "true" ]; then
						echo "deb ${MIRROR_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"

						if $ADD_SOURCES; then
							echo "deb-src ${MIRROR_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"
						fi
					fi
				fi
				;;
		esac
	fi

	# Set updates repo
	if [ "${LB_UPDATES}" = "true" ]; then
		echo "deb ${PARENT_MIRROR} ${PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> "${PARENT_LIST_FILE}"

		if $ADD_SOURCES; then
			echo "deb-src ${PARENT_MIRROR} ${PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> "${PARENT_LIST_FILE}"
		fi

		if [ "${LB_DERIVATIVE}" = "true" ]; then
			echo "deb ${MIRROR} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"

			if $ADD_SOURCES; then
				echo "deb-src ${MIRROR} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"
			fi
		fi
	fi

	# Set backports repo
	if [ "${LB_BACKPORTS}" = "true" ]; then
		case "${LB_MODE}" in
			debian)
				if [ "${PARENT_DISTRIBUTION}" != "sid" ]; then
					echo "deb ${PARENT_MIRROR} ${PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> "${PARENT_LIST_FILE}"

					if $ADD_SOURCES; then
						echo "deb-src ${PARENT_MIRROR} ${PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> "${PARENT_LIST_FILE}"
					fi
				fi
				;;
		esac

		if [ "${LB_DERIVATIVE}" = "true" ]; then
			echo "deb ${MIRROR} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"

			if $ADD_SOURCES; then
				echo "deb-src ${MIRROR} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> "${LIST_FILE}"
			fi
		fi
	fi
}