summaryrefslogtreecommitdiffstats
path: root/bin/prepkg
blob: 22356fa322cfe489075ca7ff0c94b09da489d4ec (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
#!/bin/sh

prog=prepkg

err()
{
	ret=$1
	shift
	echo "$prog: $*" 1>&2
	exit $ret
}

basicmeta()
{
	printf "pkgname\n%s\n\n" "$pkgname"
	printf "pkgrel\n%d\n\n" "${PKGREL:-1}"
	printf "packager\n%s\n\n" "${PACKAGER:-Anonymous}"
	
	if [ "$MAINTAINER" ]
	then
		printf "maintainer\n%s\n\n" "$MAINTAINER"
	fi

	return 0
}

case $# in
0)	echo "usage: $prog [package name]" 1>&2
	exit 2
esac

case "$PREPSPATH" in
'')	err 2 "set PREPSPATH before calling $prog"
esac

for flav in "$PREPSPATH"/*
do
	pkgname="$1"
	[ -f "$flav" -a -x "$flav" ] || continue
	PATH="$PATH:$flav.d" "$flav" "$pkgname"
	prepret=$?
	
	case "$prepret" in
	100)	;; # loop
	101) exit 101 ;; # tell genpkg to cleanup
	0)	basicmeta
		exit 0 ;;
	1)	err 1 "$flav encountered an error" ;;
	*)	err 1 "$flav returned error code $prepret" ;;
	esac
done

echo "no matching meta generator found for '$1'" 1>&2
exit 101