summaryrefslogtreecommitdiff
path: root/common.sh
blob: 93d19ed2b18739421ef42d363a7d20781978c871 (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
#!/hint/bash
pkgrel=1
options=('!debug')
arch=(any)
pkgname=$(basename "$BUILDFILE" .PKGBUILD)

netctl-enable() (
	. "etc/netctl/$1"
	unit=netctl@"$(systemd-escape -- "$1")".service
	install -Dm644 /dev/stdin etc/systemd/system/"${unit}.d"/profile.conf <<-EOF
		[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##*/}")"
	case "$1" in
	    /*)
		error 'add-unit: path is absolute, not relative to $pkgdir: %s' "$1"
		exit 1;;
	    etc/systemd/system/*)
		srcs=(
			"etc/systemd/system/${1##*/}"
			"etc/systemd/system/$base"
			"usr/lib/systemd/system/$base"
		);;
	    etc/systemd/user/*)
		srcs=(
			"etc/systemd/user/${1##*/}"
			"etc/systemd/user/$base"
			"usr/lib/systemd/user/$base"
		);;
	    *)
		error 'add-unit: unknown directory: %s' "$1"
		exit 1;;
	esac
	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() {
	case "$pkgname" in
		config-parabola-*)
			replaces+=(${pkgname/-parabola-/-})
			conflicts+=(${pkgname/-parabola-/-})
			;;
	esac
	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
}