tails-custom-apt-sources 1.52 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
BASE_BRANCHES="stable testing devel feature/stretch"
11

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

	echo "deb $APT_MIRROR_URL $suite $components"
}

19
output_overlay_apt_binary_sources() {
20
	for suite in $(ls config/APT_overlays.d) ; do
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
		output_apt_binary_source "$suite"
	done
}

on_base_branch() {
	local current_branch=$(current_branch)

	for base_branch in $BASE_BRANCHES ; do
		if [ "$current_branch" = "$base_branch" ] ; then
			return 0
		fi
	done

	return 1
}

### Sanity checks

39
40
[ -d config/APT_overlays.d ] || fatal 'config/APT_overlays.d/ does not exist'
[ -e config/base_branch  ]   || fatal 'config/base_branch does not exist'
41
42
43
44
45
46
47
48
49
50
51

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

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

### Main
52
53

if version_was_released "$(version_in_changelog)"; then
54
55
	if [ -n "$(ls config/APT_overlays.d)" ]; then
		fatal 'config/APT_overlays.d/ must be empty while releasing'
56
	fi
57
	output_apt_binary_source "$(branch_name_to_suite "$(version_in_changelog)")"
58
else
59
60
	output_apt_binary_source "$(branch_name_to_suite "$(base_branch)")"
	output_overlay_apt_binary_sources
61
62
fi