-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparsepkgbuild.sh
More file actions
64 lines (59 loc) · 1.63 KB
/
Copy pathparsepkgbuild.sh
File metadata and controls
64 lines (59 loc) · 1.63 KB
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
#!/usr/bin/env rbash
# shellcheck shell=bash
# shellcheck disable=SC1090
source "$1"
# Ensure $pkgname, $pkgver, and $pkgrel variables were found
if [[ -z "$pkgname" ]] || [[ -z "$pkgver" ]] || [[ -z "$pkgrel" ]]; then
echo "error: invalid package file"
exit 1
fi
function pkginfo() {
# Manually handle keys whose section headers differ from the variable name
if [[ -n "$pkgname" ]]; then
printf "%%NAME%%\n%s\n" "$pkgname"
printf "%%VERSION%%\n%s\n" "$pkgver-$pkgrel"
fi
if [ -n "$pkgdesc" ]; then
echo -e "%DESC%\n$pkgdesc\n"
fi
# The four keys $pkg{name,ver,rel,desc} we just handled manually are excluded
meta_keys=(groups url license arch builddate packager replaces force depends
makedepends optdepends conflicts provides backup options source
validpgpkeys {md5,sha{1,224,256,384,512},b2}sums install)
for key in "${meta_keys[@]}"; do
arr="$key"'[@]'
if [[ -n ${!key} ]]; then
echo "%${key^^}%"
for i in "${!arr}"; do echo "$i"; done
echo ''
fi
done
unset arr key meta_keys i
echo "%SETVARS%"
compgen -A variable
}
# is it a split pkgbuild ?
if [[ "${#pkgname[@]}" -gt 1 ]]; then
pkgbase=${pkgbase:-${pkgname[0]}}
_namcap_pkgnames=("${pkgname[@]}")
unset pkgname
echo -e "%SPLIT%\n1\n"
echo -e "%BASE%\n${pkgbase}\n"
echo "%NAMES%"
for i in "${_namcap_pkgnames[@]}"; do echo "$i"; done
echo ''
pkginfo
# Print per package information
for _namcap_subpkg in "${_namcap_pkgnames[@]}"; do
echo -e '\0'
pkgname=$_namcap_subpkg
package_"$_namcap_subpkg"
pkginfo
# Did the function actually exist?
echo "%PKGFUNCTION%"
type -t package_"$_namcap_subpkg" || echo undefined
echo ''
done
else
pkginfo
fi