diff options
-rwxr-xr-x | contrib/bacman.in | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/contrib/bacman.in b/contrib/bacman.in index cb1aa10b..93145e48 100755 --- a/contrib/bacman.in +++ b/contrib/bacman.in @@ -26,23 +26,23 @@ readonly progver="0.2.1" # # User Friendliness # -function usage(){ +usage() { echo "This program recreates a package using pacman's db and system files" echo "Usage: $progname <installed package name>" echo "Example: $progname kernel26" } -if [ $# -ne 1 ] ; then +if (( $# != 1 )); then usage exit 1 fi -if [ "$1" = "--help" -o "$1" = "-h" ] ; then +if [[ $1 == "--help" || $1 == "-h" ]]; then usage exit 0 fi -if [ "$1" = "--version" -o "$1" = "-v" ]; then +if [[ $1 == "--version" || $1 == "-v" ]]; then echo "$progname version $progver" echo "Copyright (C) 2008 locci" exit 0 @@ -51,11 +51,11 @@ fi # # Fakeroot support # -if [ $EUID -gt 0 ]; then - if [ -f /usr/bin/fakeroot ]; then +if (( EUID )); then + if [[ -f /usr/bin/fakeroot ]]; then echo "Entering fakeroot environment" export INFAKEROOT="1" - /usr/bin/fakeroot -u -- $0 $1 + /usr/bin/fakeroot -u -- "$0" "$@" exit $? else echo "WARNING: installing fakeroot or running ${progname} as root is required to" @@ -67,7 +67,7 @@ fi # # Setting environmental variables # -if [ ! -r @sysconfdir@/pacman.conf ]; then +if [[ ! -r @sysconfdir@/pacman.conf ]]; then echo "ERROR: unable to read @sysconfdir@/pacman.conf" exit 1 fi @@ -75,13 +75,13 @@ fi eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf) pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local" -if [ ! -r @sysconfdir@/makepkg.conf ]; then +if [[ ! -r @sysconfdir@/makepkg.conf ]]; then echo "ERROR: unable to read @sysconfdir@/makepkg.conf" exit 1 fi source "@sysconfdir@/makepkg.conf" -if [ -r ~/.makepkg.conf ]; then +if [[ -r ~/.makepkg.conf ]]; then source ~/.makepkg.conf fi @@ -96,12 +96,12 @@ pkg_namver="${pkg_dir##*/}" # # Checks everything is in place # -if [ ! -d "$pac_db" ] ; then +if [[ ! -d $pac_db ]]; then echo "ERROR: pacman database directory ${pac_db} not found" exit 1 fi -if [ ! -d "$pkg_dir" ] ; then +if [[ ! -d $pkg_dir ]]; then echo "ERROR: package ${pkg_name} not found in pacman database" exit 1 fi @@ -120,11 +120,11 @@ echo "Copying package files..." cat "$pkg_dir"/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 @@ -132,11 +132,11 @@ while read i; do case $current in %FILES%) ret=0 - if [ -e "/$i" ]; then + if [[ -e /$i ]]; then bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf - # Workaround to bsdtar not reporting a missing file as an error - if [ ! -e "$work_dir/$i" -a ! -L "$work_dir/$i" ]; then + if ! [[ -e $work_dir/$i || -L $work_dir/$i ]]; then echo "" echo "ERROR: unable to add /$i to the package" echo " If your user does not have permssion to read this file then" @@ -154,7 +154,7 @@ while read i; do done ret=$? -if [ $ret -ne 0 ]; then +if (( ret )); then rm -rf "$work_dir" exit 1 fi @@ -166,7 +166,7 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}') # echo Generating .PKGINFO metadata... echo "# Generated by $progname $progver" > .PKGINFO -if [ "$INFAKEROOT" = "1" ]; then +if [[ $INFAKEROOT == "1" ]]; then echo "# Using $(fakeroot -v)" >> .PKGINFO fi echo "# $(LC_ALL=C date)" >> .PKGINFO @@ -178,7 +178,7 @@ while read i; do continue; fi - if [[ "$i" =~ %[A-Z]*% ]] ; then + if [[ "$i" =~ %[A-Z]*% ]]; then current=$i continue fi @@ -241,11 +241,11 @@ done comp_files=".PKGINFO" -if [ -f "$pkg_dir/install" ] ; then +if [[ -f $pkg_dir/install ]]; then cp "$pkg_dir/install" "$work_dir/.INSTALL" comp_files+=" .INSTALL" fi -if [ -f $pkg_dir/changelog ] ; then +if [[ -f $pkg_dir/changelog ]]; then cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG" comp_files+=" .CHANGELOG" fi @@ -286,7 +286,7 @@ case "$PKGEXT" in *tar) cat ;; esac > ${pkg_file} || ret=$? -if [ $ret -ne 0 ]; then +if (( ret )); then echo "ERROR: unable to write package to $pkg_dest" echo " Maybe the disk is full or you do not have write access" rm -rf "$work_dir" |