tails-custom-apt-sources 1.38 KB
Newer Older
1
#!/bin/bash
2
3

set -e
4
set -u
5

6
7
. "$(dirname $0)/utils.sh"

8
APT_MIRROR_URL="http://deb.tails.boum.org/"
9
DEFAULT_COMPONENTS="main contrib non-free"
10

11
12
13
14
15
16
17
output_apt_binary_source() {
	local suite="$1"
	local components="${2:-$DEFAULT_COMPONENTS}"

	echo "deb $APT_MIRROR_URL $suite $components"
}

18
output_overlay_apt_binary_sources() {
19
20
	cd config/APT_overlays.d/
	for suite in * ; do
21
22
23
		# handle the case when no APT overlay is enabled
		[[ -e "$suite" ]] || break

24
25
		output_apt_binary_source "$suite"
	done
26
	cd ../../
27
28
29
30
}

### Sanity checks

31
32
[ -d config/APT_overlays.d ] || fatal 'config/APT_overlays.d/ does not exist'
[ -e config/base_branch  ]   || fatal 'config/base_branch does not exist'
33
34
35
36

[ "$(cat config/base_branch | wc -l)" -eq 1 ] \
    || fatal 'config/base_branch must contain exactly one line'

37
if on_base_branch && ! [ "$(base_branch)" = "$(git_current_branch)" ] ; then
38
	echo "base_branch: $(base_branch)" >&2
39
	echo "current_branch: $(git_current_branch)" >&2
40
41
42
43
	fatal "In a base branch, config/base_branch must match the current branch."
fi

### Main
44
45

if version_was_released "$(version_in_changelog)"; then
46
47
	if [ -n "$(ls config/APT_overlays.d)" ]; then
		fatal 'config/APT_overlays.d/ must be empty while releasing'
48
	fi
49
	output_apt_binary_source "$(branch_name_to_suite "$(version_in_changelog)")"
50
else
51
52
	output_apt_binary_source "$(branch_name_to_suite "$(base_branch)")"
	output_overlay_apt_binary_sources
53
54
fi