blob: 82a7b1ff7f1e3a69369244a17a90beda98142025 (
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
|
#!/bin/sh
prog=makepkgmeta
lazysource()
{
awk -v prog="$prog" '
BEGIN { FS = "\n"; RS = ""; OFS = ORS = "\n\n" }
$1 == "pkgver" { ver = $2 }
$1 == "source" {
len = NF - 1
for (i = 2; i <= NF; i++) sources[i - 1] = $i
next
}
1 # print everything but sources
END {
# remember that metas emit no output when they cant match
# a package.
if (NR == 0 || !ver) exit 2
ORS="\n"
# Replace any version strings in the source file with ${pkgver}.
gsub(/[.]/, "\\\\&", ver)
print "source"
for(i = 1; i <= len; i++) {
gsub(ver, "${pkgver}", sources[i])
print sources[i]
}
print ""
}'
return $?
} # end of lazysource()
basicmeta()
{
printf "pkgname\n%s\n\n" "$1"
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
}
case $# in
0) echo "Usage: $prog [pkgname]" 1>&2
exit 1
esac
case "$METABIN" in
'') echo "$prog: set METABIN before calling $prog" 1>&2
exit 2
esac
for flav in "$METABIN"/*
do
[ -f "$flav" -a -x "$flav" ] || continue
PATH="$PATH:$flav.d" "$flav" $1 >PKGMETA.tmp
metaret=$?
case $metaret in
0) basicmeta $1
lazysource <PKGMETA.tmp
rm PKGMETA.tmp
exit 0 ;;
1) echo "makepkgmeta: $flav encountered an error" 1>&2
exit 1 ;;
2) ;; # loop
*) echo "makepkgmeta: $flav returned error code $metaret" 1>&2
exit 1 ;;
esac
done
echo "makepkgmeta: no matching meta generator found for '$1'" 1>&2
exit 1
|