summaryrefslogtreecommitdiffstats
path: root/config
blob: 9ed25339861b512cd7d9c6c158eb0c873c29a20a (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
#! /bin/sh

set -e

TPL_PKGS='cpp gcc g++'

main()
{
	case "${1}" in
		clean)
			clean
			;;
		*)
			if [ -z "${PKG_TARGETS}" ]; then
				PKG_TARGETS="$(cat targets.in)"
			fi
			>targets
			for arch in ${PKG_TARGETS}; do
				PKG_TARGET_ARCH="${arch}" configure_build
				printf '%s\n' "${arch}" >>targets
			done
			;;
	esac
}

msg()
{
	printf 'gcc-defaults config: '
	printf "${@}"
	printf '\n'
}

configure_build()
{
	# Generate a sed script to edit files.
	_ss=
	for _name in TARGET_ARCH; do
		_ss="${_ss}s&@PKG_${_name}@&$(eval echo \$\{PKG_${_name}\})&g;"
	done

	# Write metadata for <pkgbase>-<target> packages.
	for _pkg in ${TPL_PKGS}; do
		mkdir -p "${_pkg}-${PKG_TARGET_ARCH}.pkg"
		sed "${_ss}" "${_pkg}.pkg.in/control" \
			>"${_pkg}-${PKG_TARGET_ARCH}.pkg/control"
		sed "${_ss}" "${_pkg}.pkg.in/files" \
			>"${_pkg}-${PKG_TARGET_ARCH}.pkg/files"
		sed "${_ss}" "${_pkg}.pkg.in/postinst" \
			>"${_pkg}-${PKG_TARGET_ARCH}.pkg/postinst"
		sed "${_ss}" "${_pkg}.pkg.in/prerm" \
			>"${_pkg}-${PKG_TARGET_ARCH}.pkg/prerm"
		msg 'Metadata for package "%s" generated.' \
			"${_pkg}-${PKG_TARGET_ARCH}"
	done
}

clean()
{
	# Remove generated metadata for <pkgbase>-<target> packages.
	for _pkg in ${TPL_PKGS}; do
		rm -Rf "${_pkg}"-*-*-*.pkg/
	done
}

main "${@}"