Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-27 09:24:28 -0500
committerDan McGee <dan@archlinux.org>2010-09-27 09:24:28 -0500
commitf7895cc188e221c064aac475908a09d2f50b8d38 (patch)
treecf185c923a062ec50ba0129c762ef204296c992b
parentdff06a817016996f414b547fa8db011436bbc63f (diff)
parentfd38319106789e2239d2d31208e463aad8e11a8e (diff)
Merge branch 'maint'
-rwxr-xr-xcontrib/bacman44
1 files changed, 35 insertions, 9 deletions
diff --git a/contrib/bacman b/contrib/bacman
index dfd53e8b..6dd78394 100755
--- a/contrib/bacman
+++ b/contrib/bacman
@@ -87,7 +87,6 @@ fi
pkg_arch=${CARCH:-'unknown'}
pkg_dest="${PKGDEST:-$PWD}"
-pkg_ext=${PKGEXT:-'.pkg.tar.gz'}
pkg_pkger=${PACKAGER:-'Unknown Packager'}
pkg_name="$1"
@@ -164,13 +163,6 @@ fi
pkg_size=$(du -sk | awk '{print $1 * 1024}')
-if [ -f "$pkg_dir/install" ] ; then
- cp "$pkg_dir/install" "$work_dir/.INSTALL"
-fi
-if [ -f $pkg_dir/changelog ] ; then
- cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG"
-fi
-
#
# .PKGINFO stuff
#
@@ -254,6 +246,17 @@ while read i; do
esac
done
+comp_files=".PKGINFO"
+
+if [ -f "$pkg_dir/install" ] ; then
+ cp "$pkg_dir/install" "$work_dir/.INSTALL"
+ comp_files+=" .INSTALL"
+fi
+if [ -f $pkg_dir/changelog ] ; then
+ cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG"
+ comp_files+=" .CHANGELOG"
+fi
+
#
# Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL
#
@@ -265,8 +268,31 @@ chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
#
echo "Generating the package..."
+case "$PKGEXT" in
+ *tar.gz) EXT=${PKGEXT%.gz} ;;
+ *tar.bz2) EXT=${PKGEXT%.bz2} ;;
+ *tar.xz) EXT=${PKGEXT%.xz} ;;
+ *tar) EXT=${PKGEXT} ;;
+ *) echo "WARNING: '%s' is not a valid archive extension." \
+ "$PKGEXT" ; EXT=$PKGEXT ;;
+esac
+
+pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}"
ret=0
-bsdtar -czf "$pkg_dest/$pkg_namver-$pkg_arch$pkg_ext" $(ls -A) || ret=$?
+
+# 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 * |
+case "$PKGEXT" in
+ *tar.gz) gzip -c -f -n ;;
+ *tar.bz2) bzip2 -c -f ;;
+ *tar.xz) xz -c -z - ;;
+ *tar) cat ;;
+esac > ${pkg_file} || ret=$?
+
if [ $ret -ne 0 ]; then
echo "ERROR: unable to write package to $pkg_dest"
echo " Maybe the disk is full or you do not have write access"