[pacman-dev] [PATCH v4 7/8] bacman: add option to specify the number of jobs
Gordian Edenhofer
gordian.edenhofer at gmail.com
Thu Sep 1 13:43:22 UTC 2016
Signed-off-by: Gordian Edenhofer <gordian.edenhofer at gmail.com>
---
contrib/bacman.sh.in | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index fef5e78..6158a2c 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -57,6 +57,7 @@ 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
@@ -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=$2
[[ ! -d "$2" ]] && 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=1 ;;
--nocolor)
@@ -190,7 +199,11 @@ fakebuild() {
cd "$work_dir" || exit 1
# Assemble list of files which belong to the package and tar them
- msg2 "Copying package files..."
+ if [[ $MAX_JOBS -gt 1 ]]; then
+ msg2 "${pkg_name}: Copying package files..."
+ else
+ msg2 "Copying package files..."
+ fi
while read i; do
if [[ -z $i ]]; then
@@ -265,7 +278,11 @@ fakebuild() {
# Reconstruct .PKGINFO from database
# TODO adopt makepkg's write_pkginfo() into this or scripts/library
- msg2 "Generating .PKGINFO metadata..."
+ if [[ $MAX_JOBS -gt 1 ]]; then
+ msg2 "${pkg_name}: Generating .PKGINFO metadata..."
+ else
+ msg2 "Generating .PKGINFO metadata..."
+ fi
echo "# Generated by $myname $myver" > .PKGINFO
if [[ $INFAKEROOT == "1" ]]; then
echo "# Using $(fakeroot -v)" >> .PKGINFO
@@ -353,7 +370,11 @@ fakebuild() {
chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
# Generate the package
- msg2 "Generating the package..."
+ if [[ $MAX_JOBS -gt 1 ]]; then
+ msg2 "${pkg_name}: Generating the package..."
+ else
+ msg2 "Generating the package..."
+ fi
pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}"
ret=0
--
2.9.3
More information about the pacman-dev
mailing list