summaryrefslogtreecommitdiff
path: root/common.sh
blob: 53c2558f39f715f523334ee217e5b7104716592c (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
pkgrel=1
arch=(any)
pkgname=$(basename "$BUILDFILE" .PKGBUILD)
case "$pkgname" in
    config-mgmt-*)
	replaces=(${pkgname/-mgmt-/-})
	conflicts=(${pkgname/-mgmt-/-})
	;;
    config-box-*)
	replaces=(${pkgname/-box-/-})
	conflicts=(${pkgname/-box-/-})
	;;
esac

netctl-enable() (
	. "etc/netctl/$1"
	unit=netctl@"$(systemd-escape -- "$1")".service
	install -Dm644 /dev/stdin etc/systemd/system/"${unit}" <<EOF
.include /usr/lib/systemd/system/netctl@.service

[Unit]
Description=${Description}
BindsTo=sys-subsystem-net-devices-${Interface}.device
After=sys-subsystem-net-devices-${Interface}.device
EOF
	add-unit etc/systemd/system/multi-user.target.wants/"$unit"
)

add-unit() (
	install -d "${1%/*}"
	base="$(sed 's/@[^.]*\./@./' <<<"${1##*/}")"
	srcs=(
		"etc/systemd/system/${1##*/}"
		"etc/systemd/system/$base"
		"usr/lib/systemd/system/$base"
	)
	for src in "${srcs[@]}"; do
		if test -f "$src"; then
			break
		fi
		if test -f "/$src"; then
			break
		fi
	done
	ln -s "/$src" "$1"
)

add-file() {
	install -Dm644 /dev/stdin "$@"
}

preamble() {
	cd "$pkgdir"
}

postamble() {
	install -Dm644 "$BUILDFILE" -t "usr/share/doc/config"
	backup=($(find "$pkgdir" -type f -printf '%P\n'))
	local d
	for d in "$pkgdir"/usr/share/holo/*; do
		if [[ -d "$d" ]]; then
			depends+=("holo-${d##*/}")
			install=holo.install
		fi
	done
}