diff options
Diffstat (limited to 'contrib/bacman.in')
-rwxr-xr-x | contrib/bacman.in | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/contrib/bacman.in b/contrib/bacman.in index 93145e48..89d7f619 100755 --- a/contrib/bacman.in +++ b/contrib/bacman.in @@ -20,6 +20,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +shopt -s extglob +shopt -s nullglob + readonly progname="bacman" readonly progver="0.2.1" @@ -109,8 +112,8 @@ fi # # Begin # -echo Package: ${pkg_namver} -work_dir=$(mktemp -d -p /tmp) +echo "Package: ${pkg_namver}" +work_dir=$(mktemp -d --tmpdir bacman.XXXXXXXXXX) cd "$work_dir" || exit 1 # @@ -124,12 +127,12 @@ while read i; do continue fi - if [[ "$i" =~ %[A-Z]*% ]]; then + if [[ $i == %+([A-Z])% ]]; then current=$i continue fi - case $current in + case "$current" in %FILES%) ret=0 if [[ -e /$i ]]; then @@ -163,6 +166,7 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}') # # .PKGINFO stuff +# TODO adopt makepkg's write_pkginfo() into this or scripts/library # echo Generating .PKGINFO metadata... echo "# Generated by $progname $progver" > .PKGINFO @@ -174,11 +178,11 @@ echo "#" >> .PKGINFO cat "$pkg_dir"/{desc,files} | while read i; do - if [[ -z "$i" ]]; then + if [[ -z $i ]]; then continue; fi - if [[ "$i" =~ %[A-Z]*% ]]; then + if [[ $i == %+([A-Z])% ]]; then current=$i continue fi @@ -273,9 +277,6 @@ esac pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}" ret=0 -# when fileglobbing, we want * in an empty directory to expand to -# the null string rather than itself -shopt -s nullglob # TODO: Maybe this can be set globally for robustness shopt -s -o pipefail bsdtar -cf - $comp_files * | @@ -284,7 +285,7 @@ case "$PKGEXT" in *tar.bz2) bzip2 -c -f ;; *tar.xz) xz -c -z - ;; *tar) cat ;; -esac > ${pkg_file} || ret=$? +esac > "${pkg_file}"; ret=$? if (( ret )); then echo "ERROR: unable to write package to $pkg_dest" |