mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
bacman: small code cleanup
This includes: - Quoting fixes. - Drop deprecated mktemp option -p. - Set extglob nullglob shell options at the top. - Use extended globbing instead of regex to match %HEADER% in pacman db. Signed-off-by: lolilolicon <lolilolicon@gmail.com>
This commit is contained in:
parent
7e5bbf0387
commit
273cc66a8a
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user