summaryrefslogtreecommitdiff
path: root/jenkins/schroot-config.sh
blob: 8b8b1856209c82987fcc8124972c4ca80724052f (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
#!/bin/sh

# union-type=overlay needs Linux 4.x and schroot >= 1.6.10-2~.

# ./schroot-config.sh | sudo tee /etc/schroot/chroot.d/sbuild.conf

set -eu

# seed PG_SUPPORTED_DISTS if pgapt.conf is not yet installed
PG_SUPPORTED_DISTS="sid"

# read pgapt config
for dir in . .. $HOME/apt.postgresql.org; do
  test -f $dir/pgapt.conf || continue
  . $dir/pgapt.conf
  break
done

arch="$(dpkg --print-architecture)"

for dist in $PG_SUPPORTED_DISTS; do
		# if arguments are given, execute as command in environment
		# ./schroot-config.sh ./sbuild-update.sh
		if [ "$*" ]; then
			echo "### distribution=$dist architecture=$arch ###"
			export distribution=$dist architecture=$arch
			"$@"
			continue
		fi

		body="$(cat <<-EOF
			type=directory
			groups=sbuild
			root-groups=sbuild
			source-groups=sbuild
			source-root-groups=sbuild
			directory=/home/chroot/$dist-$arch
			union-type=overlay
			union-overlay-directory=/var/run
			
			EOF
		)"

		echo "[$dist-$arch]"
		aliases="$dist-pgdg-$arch,$dist"
		[ $dist = sid ] && aliases="$aliases,default"
		echo "aliases=$aliases"
		echo "$body"
		echo

		echo "[$dist-$arch-sbuild]"
		aliases="$dist-pgdg-$arch-sbuild"
		[ $dist = sid ] && aliases="$aliases,unstable-$arch-sbuild,experimental-$arch-sbuild"
		echo "aliases=$aliases"
		echo "profile=sbuild"
		echo "$body"
		echo
done