summaryrefslogtreecommitdiffstats
path: root/src/ppt-make
blob: eb9a4755b6314d2c715212f9340216105a92c8bc (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
78
79
80
81
#!/bin/sh

set -eu

PPT_VERSION='1.0.0'
PLATFORM=
MAINTAINER_NAME=
MAINTAINER_MAILBOX=

main()
{
	local date=

	prompt 'Platform' PLATFORM
	prompt 'Maintainer name' MAINTAINER_NAME
	prompt 'Maintainer e-mail address' MAINTAINER_MAILBOX

	if [ "x${MAINTAINER_NAME#\"}" = "x${MAINTAINER_NAME}" ]; then
		if [ "x${MAINTAINER_NAME#*[()<>\[\]:;@\\,.]}" != \
				"x${MAINTAINER_NAME}" ]; then
			MAINTAINER_NAME="\"${MAINTAINER_NAME}\""
		fi
	fi
	if [ "x${MAINTAINER_MAILBOX#<}" = "x${MAINTAINER_MAILBOX}" ]; then
		MAINTAINER_MAILBOX="<${MAINTAINER_MAILBOX}>"
	fi

	date="$(LC_ALL='POSIX' date '+%a, %d %b %Y %H:%M:%S %z')"

	printf '2.0\n' >format

	cat >control <<-EOF
		Maintainer: ${MAINTAINER_NAME} ${MAINTAINER_MAILBOX}
		Build-Depends: platconf-pkg-tools (>= ${PPT_VERSION%.*})
		EOF

	cat >changelog <<-EOF
		config-${PLATFORM} (1) trunk

		  * Initial release.

		 -- ${MAINTAINER_NAME} ${MAINTAINER_MAILBOX}  ${date}
		EOF

	mkdir src src/build src/run

	cat >build <<-EOF
		#!/usr/bin/make -f

		include /usr/share/platconf-pkg-tools/build.mk
		EOF
	chmod 0755 build

	printf 'ppt_version=%d\n' ${PPT_VERSION%%.*} >ppt-version

	>copyright

	cat <<-EOF

Package generated.

Put build-time configuration files in src/build/<package>/<upstream-ver>, e.g.:
    src/build/linux-libre/3.10.45~gnu/config

Put run-time configuration files in src/run/<package>, e.g.:
    src/run/lilo/etc/lilo.conf.in

Then run ppt-mkpkgs to generate metadata files for binary packages.
EOF
}

prompt()
{
	local msg="${1}"
	local var="${2}"

	printf '%s:\n> ' "${msg}"
	read -r "${var}"
}

main "${@}"