summaryrefslogtreecommitdiffstats
path: root/src/2/ppt-mkpkgs
blob: b114a746ac33d50d177d8c8872e7cdb3d3e9ca0b (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
#!/bin/sh

set -eu

PLAT=

main()
{
	PLAT="$(sed '1{s/^config-\([^ ][^ ]*\) (.*$/\1/;};1!q;' changelog)"

	make_common_pkg
	make_build_time_pkgs
	make_run_time_pkgs
}

info()
{
	local fmt="${1}"
	shift 1

	printf "ppt-mkpkgs: ${fmt}\n" "${@}"
}

make_common_pkg()
{
	# Make "-common" package to provide source package documentation files.
	mkdir -p "config-${PLAT}-common.pkg"
	cat >"config-${PLAT}-common.pkg/control" <<-EOF
		Architecture: all
		Platform: all
		Description: "${PLAT}" platform configuration - common files
		EOF
	>"config-${PLAT}-common.pkg/docs"
	info 'Metadata for package "%s" generated.' "config-${PLAT}-common"
}

make_build_time_pkgs()
{
	local pkg=

	# Make each config-*-* package.
	for pkg in src/build/*; do
		pkg="${pkg#src/build/}"
		mkdir -p "config-${pkg}-${PLAT}.pkg"
		cat >"config-${pkg}-${PLAT}.pkg/control" <<-EOF
			Architecture: all
			Platform: all
			Depends: config-${PLAT}-common (= \${Binary-Version})
			Description: "${PLAT}" platform configuration for ${pkg}
			EOF
		info 'Metadata for package "%s" generated.' \
			"config-${pkg}-${PLAT}"
	done
}

make_run_time_pkgs()
{
	local pkg=

	# Make each config-* package.
	for pkg in src/run/*; do
		pkg="${pkg#src/run/}"
		mkdir -p "config-${pkg}.pkg"
		cat >"config-${pkg}.pkg/control" <<-EOF
			Architecture: all
			Platform: ${PLAT}
			Depends: config-${PLAT}-common (= \${Binary-Version})
			Description: "${PLAT}" platform configuration for ${pkg}
			EOF
		info 'Metadata for package "%s" generated.' \
			"config-${pkg}"
	done
}

main "${@}"