bacman: fix issue with symlink early copy

test -e tries to resolve the link before testing, so if the link is copied
before the actual file, the script exited. This fixes the issue.

[Dan: also add some improved quoting in the script]

Signed-off-by: Carlo Bersani <carlocci@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Carlo Bersani 2008-06-22 21:21:05 -05:00 committed by Dan McGee
parent 74eb2f5c61
commit b15fb504a1

View file

@ -111,7 +111,7 @@ fi
# #
echo Package: ${pkg_namver} echo Package: ${pkg_namver}
work_dir=$(mktemp -d -p /tmp) work_dir=$(mktemp -d -p /tmp)
cd $work_dir || exit 1 cd "$work_dir" || exit 1
# #
# File copying # File copying
@ -136,12 +136,12 @@ while read i; do
bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf - bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf -
# Workaround to bsdtar not reporting a missing file as an error # Workaround to bsdtar not reporting a missing file as an error
if [ ! -e "$work_dir"/"$i" ]; then if [ ! -e "$work_dir/$i" ] && [ -L "$work_dir/$i"]; then
echo "" echo ""
echo "ERROR: unable to add /$i to the package" echo "ERROR: unable to add /$i to the package"
echo " If your user does not have permssion to read this file then" echo " If your user does not have permssion to read this file then"
echo " you will need to run $progname as root" echo " you will need to run $progname as root"
rm -rf $work_dir rm -rf "$work_dir"
exit 1 exit 1
fi fi
else else
@ -157,7 +157,7 @@ done
ret=$? ret=$?
if [ $ret -ne 0 ]; then if [ $ret -ne 0 ]; then
rm -rf $work_dir rm -rf "$work_dir"
exit 1 exit 1
fi fi
@ -256,8 +256,8 @@ done
# #
# Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL # Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL
# #
chown root:root $work_dir/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null chown root:root "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
chmod 644 $work_dir/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
# #
# Generate the package # Generate the package
@ -269,14 +269,15 @@ bsdtar -czf "$pkg_dest/$pkg_namver-$pkg_arch.tar.gz" $(ls -A) || ret=$?
if [ $ret -ne 0 ]; then if [ $ret -ne 0 ]; then
echo "ERROR: unable to write package to $pkg_dest" echo "ERROR: unable to write package to $pkg_dest"
echo " Maybe the disk is full or you do not have write access" echo " Maybe the disk is full or you do not have write access"
rm -rf $work_dir rm -rf "$work_dir"
exit 1 exit 1
fi fi
rm -rf $work_dir rm -rf "$work_dir"
echo Done echo Done
exit 0 exit 0
# vim: set ts=2 sw=2 noet: # vim: set ts=2 sw=2 noet: