Fix PKGBUILD
[archnosh.git] / scriptletbuilder.sh
blob54c589b777a86f9f5b25e21ad623ea61f6acbf07
1 #!/bin/sh -e
2 # builds the Archlinux .install script for a package, argument $1 is the package name
3 # if a <package>.p file exists, use the corresponding utility .funcs
4 # if a <package>.(pre_|post_)(install|upgrade|remove).extra exists, add it or use it standalone
6 _buildinstall() {
8 local pkgpath="${srcdir}"/package/debian
10 for j in install upgrade remove
12 for k in pre_ post_
14 s="$k$j"
15 if test -r $pkgpath/"$1".p # bundle-based install
16 then
17 printf "$s() {\n"
18 if >/dev/null expr "$1" : "nosh-run-"
19 then
20 printf " nosh_run_package=YES\n"
22 sed -e 's/^/ /' $pkgpath/"$s".funcs # all combinations are present
23 echo
24 sed -e 's/^/ /' $pkgpath/"$1".p
25 if test -r $pkgpath/"$1"."$s".extra # additional instructions
26 then
27 sed -e 's/^/ /' $pkgpath/"$1"."$s".extra
29 printf "\n}\n"
30 else # no bundle, only extra scripting
31 if test -r $pkgpath/"$1"."$s".extra
32 then
33 printf "$s() {\n"
34 sed -e 's/^/ /' $pkgpath/"$1"."$s".extra
35 printf "\n}\n"
38 done
39 done