Signed-off-by: Gordian Edenhofer <gordian.edenho...@gmail.com>
---
 contrib/bacman.sh.in | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 706c6fb..e8e53ea 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -57,11 +57,12 @@ usage() {
            -q, --quiet             silence most of the status reporting
            --nocolor               turn off color in output
            --pacnew                package .pacnew files
+           -j, --jobs <jobs>       build in parallel - you may want to set 
XZ_OPT
            -o, --out  <dir>        write output to <dir>
 
        Examples:   # $myname linux-headers
                    # $myname gzip munge binutils -o ~/Downloads
-                   # $myname --nocolor --pacnew -o /tmp gzip munge binutils
+                   # $myname --nocolor --pacnew -o /tmp -j 5 gzip munge 
binutils
                    # $myname \$(pacman -Qsq)
        EOF
 }
@@ -89,8 +90,8 @@ for option in "$@"; do
 done
 
 # Parse arguments
-OPT_SHORT=':o:qv'
-OPT_LONG=('out:' 'quiet' 'nocolor' 'pacnew' 'version')
+OPT_SHORT=':o:j:qv'
+OPT_LONG=('out:' 'jobs:' 'quiet' 'nocolor' 'pacnew' 'version')
 if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
        usage
        exit 1
@@ -104,6 +105,14 @@ while :; do
                        pkg_dest="$(readlink -e $2)"
                        [[ $? -ne 0 ]] && echo -e "The directory 
\e[39;1m$2\e[0m does not exist!" && exit 3
                        shift ;;
+               -j|--jobs)
+                       if [[ $2 =~ ^-?[0-9]+$ ]]; then
+                               MAX_JOBS=$2
+                       else
+                               echo -e "\e[39;1m$2\e[0m is not a valid 
integer!"
+                               exit -1
+                       fi
+                       shift ;;
                -q|--quiet)
                        QUIET='y' ;;
                --nocolor)
@@ -190,7 +199,9 @@ fakebuild() {
        cd "$work_dir" || exit 1
 
        # Assemble list of files which belong to the package and tar them
-       if [[ "$QUIET" != "y" ]]; then
+       if [[ $MAX_JOBS -gt 1 && "$QUIET" != "y" ]]; then
+               msg2 "${pkg_name}: Copying package files..."
+       elif [[ "$QUIET" != "y" ]]; then
                msg2 "Copying package files..."
        fi
 
@@ -267,7 +278,9 @@ fakebuild() {
 
        # Reconstruct .PKGINFO from database
        # TODO adopt makepkg's write_pkginfo() into this or scripts/library
-       if [[ "$QUIET" != "y" ]]; then
+       if [[ $MAX_JOBS -gt 1 && "$QUIET" != "y" ]]; then
+               msg2 "${pkg_name}: Generating .PKGINFO metadata..."
+       elif [[ "$QUIET" != "y" ]]; then
                msg2 "Generating .PKGINFO metadata..."
        fi
        echo "# Generated by $myname $myver"    > .PKGINFO
@@ -357,7 +370,9 @@ fakebuild() {
        chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
 
        # Generate the package
-       if [[ "$QUIET" != "y" ]]; then
+       if [[ $MAX_JOBS -gt 1 && "$QUIET" != "y" ]]; then
+               msg2 "${pkg_name}: Generating the package..."
+       elif [[ "$QUIET" != "y" ]]; then
                msg2 "Generating the package..."
        fi
 
-- 
2.9.3

Reply via email to