sqg: Set alternative output.

Fixed #13.

Signed-off-by: Willy Sudiarto Raharjo <willysr@sbopkg.org>
This commit is contained in:
Willy Sudiarto Raharjo 2017-06-17 21:15:47 +07:00
parent afddeb52f6
commit fe264c391e
No known key found for this signature in database
GPG key ID: 887B8374D7333381
4 changed files with 40 additions and 12 deletions

View file

@ -62,13 +62,15 @@ Options are:
Multiple packages can be passed with quotes,
e.g. -p "pkg1 pkg2".
Packages with an empty REQUIRES= line will be skipped unless
SKIP_EMPTY is uncommented at the top of the script.
SKIP_EMPTY is uncommented in sqg script.
Package names are case-sensitive.
-a Builds queuefiles for all packages.
-j Number of concurrent queuefile generation processes.
This could heavily raise disk I/O so use with care.
Requires: GNU parallel
Default: 1
-o Save QUEUE(s) to custom.sqf.
This could be useful to create custom queue file.
This script will overwrite existing queuefiles in \$QUEUEDIR so back up any
existing queuefile(s) or local modifications. Check the top of the script for
@ -166,6 +168,7 @@ build_queuefile () {
local REPO_DIR="$1"
local QUEUEDIR="$2"
local PRGNAM="$3"
local CUSTOM_QUEUE="$4"
local OLDFILE=$QUEUEDIR/$PRGNAM.sqf
local QUEUEFILE=$QUEUEDIR/$PRGNAM.sqf.tmp
local CATFILE=$QUEUEDIR/$PRGNAM.tmp.sqf
@ -175,9 +178,17 @@ build_queuefile () {
parse_queuefile_requires "$REPO_DIR" "$PRGNAM" "$QUEUEFILE"
tac $QUEUEFILE > $CATFILE
if cmp -s "$CATFILE" "$OLDFILE"; then
if [ ! -z $CUSTOM_QUEUE ]; then
cat $CATFILE >> $QUEUEDIR/$CUSTOM_QUEUE.sqf
fi
rm $QUEUEFILE $CATFILE
else
mv $CATFILE $OLDFILE
if [ ! -z $CUSTOM_QUEUE ]; then
cat $CATFILE >> $QUEUEDIR/$CUSTOM_QUEUE.sqf
rm $CATFILE
else
mv $CATFILE $OLDFILE
fi
rm $QUEUEFILE
fi
}
@ -189,12 +200,16 @@ execute_build () {
local REPO_DIR="$1"
local QUEUEDIR="$2"
local PKGS="$3"
local ALL=${4:-"no"}
local JOBS=${5:-1}
local ALL="${4:-no}"
local JOBS="${5:-1}"
local CUSTOM_QUEUE="${6:-}"
local PKGSNEW=()
local VERBOSE="no"
local PKG INFOPATH
# make sure the custom queue is empty
rm -f $QUEUEDIR/custom.sqf
if [ "$ALL" == "yes" ]; then
printf "Processing all SlackBuilds in the $REPO_SUBPATH repository..."
PKGSNEW=($(find "$REPO_DIR" -name *.info -print0 | xargs -r0))
@ -218,11 +233,13 @@ execute_build () {
printf '%s\n' "${PKGSNEW[@]}" | \
parallel --eta --will-cite --jobs $JOBS \
/usr/libexec/sbopkg/sqg/sqg-build-queuefile \
"$REPO_DIR" "$QUEUEDIR" {} "$SKIP_EMPTY" $VERBOSE
"$REPO_DIR" "$QUEUEDIR" {} "$SKIP_EMPTY" "$VERBOSE" \
"$CUSTOM_QUEUE" "custom"
else
for PKG in "${PKGSNEW[@]}"; do
/usr/libexec/sbopkg/sqg/sqg-build-queuefile \
"$REPO_DIR" "$QUEUEDIR" "$PKG" "$SKIP_EMPTY" $VERBOSE
"$REPO_DIR" "$QUEUEDIR" "$PKG" "$SKIP_EMPTY" "$VERBOSE" \
"$CUSTOM_QUEUE" "custom"
done
fi
}

View file

@ -6,8 +6,9 @@
REPO_DIR="$1"
QUEUEDIR="$2"
INFO="$3"
SKIP_EMPTY=${4:-""}
VERBOSE=${5:-"no"}
SKIP_EMPTY="${4:-}"
VERBOSE="${5:-no}"
CUSTOM_QUEUE="${6}"
. $INFO
@ -24,5 +25,5 @@ if [ "$VERBOSE" == "yes" ]; then
fi
if [[ ! -z $REQUIRES || $SKIP_EMPTY == "NO" ]]; then
build_queuefile "$REPO_DIR" "$QUEUEDIR" "$PRGNAM"
build_queuefile "$REPO_DIR" "$QUEUEDIR" "$PRGNAM" "$CUSTOM_QUEUE"
fi

View file

@ -54,14 +54,16 @@ SCRIPT=${0##*/}
OPT_JOBS=1
OPT_ALL="no"
OPT_PACKAGES=""
OPT_OUTPUT=""
sanity_checks
while getopts "ap:j:h" OPT; do
while getopts "ap:j:ho" OPT; do
case $OPT in
a ) OPT_ALL="yes" ;;
p ) OPT_PACKAGES=$OPTARG ;;
j ) get_jobs "$OPTARG"; OPT_JOBS=$?; ;;
o ) OPT_OUTPUT=1 ;;
h ) usage $SCRIPT; exit 0; ;;
? ) exit 1; ;;
esac
@ -73,7 +75,11 @@ if [ $OPTIND -eq 1 ]; then
exit 1
fi
execute_build "$REPO_DIR" "$QUEUEDIR" "$OPT_PACKAGES" "$OPT_ALL" $OPT_JOBS
if [ -z $OPT_OUTPUT ]; then
execute_build "$REPO_DIR" "$QUEUEDIR" "$OPT_PACKAGES" "$OPT_ALL" $OPT_JOBS
else
execute_build "$REPO_DIR" "$QUEUEDIR" "$OPT_PACKAGES" "$OPT_ALL" $OPT_JOBS "$OPT_OUTPUT"
fi
echo "Done."
exit 0

View file

@ -1,6 +1,6 @@
SBOPKG NEWS
sbopkg-dev (2017-06-15 09:13:00 UTC)
sbopkg-dev (2017-06-18 01:40:00 UTC)
FEATURES
* sqg: Parallelize building of single and all packages by option -j.
Requires GNU Parallel.
@ -9,6 +9,10 @@ sbopkg-dev (2017-06-15 09:13:00 UTC)
This will reduce queue generation time significantly when
invoked with -j N+1 (N: Number of cores)
Patch by Marcel Saegebarth.
* sqg: Generate one queue file for multiple programs by option -o.
The output is fixed as custom.sqf.
You can then run sbopkg -i custom to install all packages+deps.
Feature Request by Jeremy/bassmadrigal (Fixed #13).
MODIFICATIONS
* bash-completion: Complete -i and -b when git repo is used