mirror of
https://github.com/sbopkg/sbopkg
synced 2024-11-10 03:50:33 +03:00
Alternative custom queue file implementation
Signed-off-by: Marcel Saegebarth <marc@mos6581.de> Signed-off-by: Willy Sudiarto Raharjo <willysr@sbopkg.org>
This commit is contained in:
parent
2b93790463
commit
23696b383b
@ -61,16 +61,16 @@ Options are:
|
|||||||
-p package(s) Creates queuefile(s) for individual package(s).
|
-p package(s) Creates queuefile(s) for individual package(s).
|
||||||
Multiple packages can be passed with quotes,
|
Multiple packages can be passed with quotes,
|
||||||
e.g. -p "pkg1 pkg2".
|
e.g. -p "pkg1 pkg2".
|
||||||
Packages with an empty REQUIRES= line will be skipped unless
|
|
||||||
SKIP_EMPTY is uncommented in sqg script.
|
|
||||||
Package names are case-sensitive.
|
Package names are case-sensitive.
|
||||||
-a Builds queuefiles for all packages.
|
-a Builds queuefiles for all packages.
|
||||||
-j Number of concurrent queuefile generation processes.
|
-j Number of concurrent queuefile generation processes.
|
||||||
This could heavily raise disk I/O so use with care.
|
This could heavily raise disk I/O so use with care.
|
||||||
Requires: GNU parallel
|
Requires: GNU parallel
|
||||||
Default: 1
|
Default: 1
|
||||||
-o Save QUEUE(s) to custom.sqf.
|
-o User-defined queue output filename (without .sqf extension).
|
||||||
This could be useful to create custom queue file.
|
This could be useful to create custom queue file.
|
||||||
|
Multiple packages can be passed with quotes,
|
||||||
|
eg. -p "qt5-webkit sshblock letsencrypt" -o myqueue
|
||||||
|
|
||||||
This script will overwrite existing queuefiles in \$QUEUEDIR so back up any
|
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
|
existing queuefile(s) or local modifications. Check the top of the script for
|
||||||
@ -153,7 +153,7 @@ parse_queuefile_requires () {
|
|||||||
read -s -p ' Do you want to continue? [y/N]' RESPONSE
|
read -s -p ' Do you want to continue? [y/N]' RESPONSE
|
||||||
RESPONSE=$(echo "$RESPONSE" | awk '{print tolower($0)}')
|
RESPONSE=$(echo "$RESPONSE" | awk '{print tolower($0)}')
|
||||||
|
|
||||||
if [ "$RESPONSE" =~ ^\(yes|y\)$ ]; then
|
if [[ "$RESPONSE" =~ ^\(yes|y\)$ ]]; then
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
@ -168,7 +168,7 @@ build_queuefile () {
|
|||||||
local REPO_DIR="$1"
|
local REPO_DIR="$1"
|
||||||
local QUEUEDIR="$2"
|
local QUEUEDIR="$2"
|
||||||
local PRGNAM="$3"
|
local PRGNAM="$3"
|
||||||
local CUSTOM_QUEUE="$4"
|
|
||||||
local OLDFILE=$QUEUEDIR/$PRGNAM.sqf
|
local OLDFILE=$QUEUEDIR/$PRGNAM.sqf
|
||||||
local QUEUEFILE=$QUEUEDIR/$PRGNAM.sqf.tmp
|
local QUEUEFILE=$QUEUEDIR/$PRGNAM.sqf.tmp
|
||||||
local CATFILE=$QUEUEDIR/$PRGNAM.tmp.sqf
|
local CATFILE=$QUEUEDIR/$PRGNAM.tmp.sqf
|
||||||
@ -178,21 +178,31 @@ build_queuefile () {
|
|||||||
parse_queuefile_requires "$REPO_DIR" "$PRGNAM" "$QUEUEFILE"
|
parse_queuefile_requires "$REPO_DIR" "$PRGNAM" "$QUEUEFILE"
|
||||||
tac $QUEUEFILE > $CATFILE
|
tac $QUEUEFILE > $CATFILE
|
||||||
if cmp -s "$CATFILE" "$OLDFILE"; then
|
if cmp -s "$CATFILE" "$OLDFILE"; then
|
||||||
if [ ! -z $CUSTOM_QUEUE ]; then
|
|
||||||
cat $CATFILE >> $QUEUEDIR/$CUSTOM_QUEUE.sqf
|
|
||||||
fi
|
|
||||||
rm $QUEUEFILE $CATFILE
|
rm $QUEUEFILE $CATFILE
|
||||||
else
|
|
||||||
if [ ! -z $CUSTOM_QUEUE ]; then
|
|
||||||
cat $CATFILE >> $QUEUEDIR/$CUSTOM_QUEUE.sqf
|
|
||||||
rm $CATFILE
|
|
||||||
else
|
else
|
||||||
mv $CATFILE $OLDFILE
|
mv $CATFILE $OLDFILE
|
||||||
fi
|
|
||||||
rm $QUEUEFILE
|
rm $QUEUEFILE
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# `cat` all given packages into one custom queue file.
|
||||||
|
#
|
||||||
|
build_queuefile_custom () {
|
||||||
|
local QUEUEDIR=$1
|
||||||
|
local QUEUENAME=$2
|
||||||
|
local PACKAGES=$3
|
||||||
|
|
||||||
|
$(
|
||||||
|
cd "$QUEUEDIR"
|
||||||
|
rm -f "$QUEUEDIR/$QUEUENAME.sqf"
|
||||||
|
|
||||||
|
for PKG in ${PACKAGES[@]}; do
|
||||||
|
cat "$PKG.sqf" >> "$QUEUENAME.sqf"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Processes all or given packages depending on option.
|
# Processes all or given packages depending on option.
|
||||||
#
|
#
|
||||||
@ -207,9 +217,6 @@ execute_build () {
|
|||||||
local VERBOSE="no"
|
local VERBOSE="no"
|
||||||
local PKG INFOPATH
|
local PKG INFOPATH
|
||||||
|
|
||||||
# make sure the custom queue is empty
|
|
||||||
rm -f $QUEUEDIR/custom.sqf
|
|
||||||
|
|
||||||
if [ "$ALL" == "yes" ]; then
|
if [ "$ALL" == "yes" ]; then
|
||||||
printf "Processing all SlackBuilds in the $REPO_SUBPATH repository..."
|
printf "Processing all SlackBuilds in the $REPO_SUBPATH repository..."
|
||||||
PKGSNEW=($(find "$REPO_DIR" -name *.info -print0 | xargs -r0))
|
PKGSNEW=($(find "$REPO_DIR" -name *.info -print0 | xargs -r0))
|
||||||
@ -233,13 +240,15 @@ execute_build () {
|
|||||||
printf '%s\n' "${PKGSNEW[@]}" | \
|
printf '%s\n' "${PKGSNEW[@]}" | \
|
||||||
parallel --eta --will-cite --jobs $JOBS \
|
parallel --eta --will-cite --jobs $JOBS \
|
||||||
/usr/libexec/sbopkg/sqg/sqg-build-queuefile \
|
/usr/libexec/sbopkg/sqg/sqg-build-queuefile \
|
||||||
"$REPO_DIR" "$QUEUEDIR" {} "$SKIP_EMPTY" "$VERBOSE" \
|
"$REPO_DIR" "$QUEUEDIR" {} "$SKIP_EMPTY" "$VERBOSE"
|
||||||
"$CUSTOM_QUEUE" "custom"
|
|
||||||
else
|
else
|
||||||
for PKG in "${PKGSNEW[@]}"; do
|
for PKG in "${PKGSNEW[@]}"; do
|
||||||
/usr/libexec/sbopkg/sqg/sqg-build-queuefile \
|
/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
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -z $CUSTOM_QUEUE ]; then
|
||||||
|
build_queuefile_custom "$QUEUEDIR" "$CUSTOM_QUEUE" "$PKGS"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@ QUEUEDIR="$2"
|
|||||||
INFO="$3"
|
INFO="$3"
|
||||||
SKIP_EMPTY="${4:-}"
|
SKIP_EMPTY="${4:-}"
|
||||||
VERBOSE="${5:-no}"
|
VERBOSE="${5:-no}"
|
||||||
CUSTOM_QUEUE="${6}"
|
CUSTOM_QUEUE="${6:-}"
|
||||||
|
|
||||||
. $INFO
|
. $INFO
|
||||||
|
|
||||||
if [ "$VERBOSE" == "yes" ]; then
|
if [ "$VERBOSE" == "yes" ]; then
|
||||||
INFO_BASENAME=$(basename $INFO .info)
|
INFO_BASENAME=$(basename $INFO .info)
|
||||||
|
|
||||||
if [[ -z $REQUIRES && $SKIP_EMPTY == "" ]]; then
|
if [[ -z $REQUIRES && $SKIP_EMPTY == "yes" ]]; then
|
||||||
echo "$INFO_BASENAME: No dep(s) defined for this package."
|
echo "$INFO_BASENAME: No dep(s) defined for this package."
|
||||||
echo "No queuefile generated."
|
echo "No queuefile generated."
|
||||||
echo "Uncomment SKIP_EMPTY variable in sqg to change this behavior."
|
echo "Uncomment SKIP_EMPTY variable in sqg to change this behavior."
|
||||||
@ -24,6 +24,6 @@ if [ "$VERBOSE" == "yes" ]; then
|
|||||||
echo "Processing $INFO_BASENAME."
|
echo "Processing $INFO_BASENAME."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z $REQUIRES || $SKIP_EMPTY == "NO" ]]; then
|
if [[ ! -z $REQUIRES || $SKIP_EMPTY == "no" ]]; then
|
||||||
build_queuefile "$REPO_DIR" "$QUEUEDIR" "$PRGNAM" "$CUSTOM_QUEUE"
|
build_queuefile "$REPO_DIR" "$QUEUEDIR" "$PRGNAM" "$CUSTOM_QUEUE"
|
||||||
fi
|
fi
|
||||||
|
@ -43,7 +43,7 @@ SBOPKG_CONF=${SBOPKG_CONF:-/etc/sbopkg/sbopkg.conf}
|
|||||||
|
|
||||||
#QUEUEDIR=${QUEUEDIR:-/var/lib/sbopkg/queues}
|
#QUEUEDIR=${QUEUEDIR:-/var/lib/sbopkg/queues}
|
||||||
REPO_BRANCH=${REPO_BRANCH:-$(cat /etc/slackware-version | awk '{print $2}')}
|
REPO_BRANCH=${REPO_BRANCH:-$(cat /etc/slackware-version | awk '{print $2}')}
|
||||||
#SKIP_EMPTY=${SKIP_EMPTY:-NO}
|
SKIP_EMPTY=${SKIP_EMPTY:-yes}
|
||||||
|
|
||||||
### NO CHANGES SHOULD BE NECESSARY BELOW THIS LINE ###
|
### NO CHANGES SHOULD BE NECESSARY BELOW THIS LINE ###
|
||||||
|
|
||||||
@ -58,12 +58,12 @@ OPT_OUTPUT=""
|
|||||||
|
|
||||||
sanity_checks
|
sanity_checks
|
||||||
|
|
||||||
while getopts "ap:j:ho" OPT; do
|
while getopts "ap:j:ho:" OPT; do
|
||||||
case $OPT in
|
case $OPT in
|
||||||
a ) OPT_ALL="yes" ;;
|
a ) OPT_ALL="yes" ;;
|
||||||
p ) OPT_PACKAGES=$OPTARG ;;
|
p ) OPT_PACKAGES=$OPTARG ;;
|
||||||
j ) get_jobs "$OPTARG"; OPT_JOBS=$?; ;;
|
j ) get_jobs "$OPTARG"; OPT_JOBS=$?; ;;
|
||||||
o ) OPT_OUTPUT=1 ;;
|
o ) OPT_OUTPUT="$OPTARG" ;;
|
||||||
h ) usage $SCRIPT; exit 0; ;;
|
h ) usage $SCRIPT; exit 0; ;;
|
||||||
? ) exit 1; ;;
|
? ) exit 1; ;;
|
||||||
esac
|
esac
|
||||||
@ -75,11 +75,7 @@ if [ $OPTIND -eq 1 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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"
|
execute_build "$REPO_DIR" "$QUEUEDIR" "$OPT_PACKAGES" "$OPT_ALL" $OPT_JOBS "$OPT_OUTPUT"
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -10,9 +10,10 @@ sbopkg-dev (2017-06-18 01:40:00 UTC)
|
|||||||
invoked with -j N+1 (N: Number of cores)
|
invoked with -j N+1 (N: Number of cores)
|
||||||
Patch by Marcel Saegebarth.
|
Patch by Marcel Saegebarth.
|
||||||
* sqg: Generate one queue file for multiple programs by option -o.
|
* sqg: Generate one queue file for multiple programs by option -o.
|
||||||
The output is fixed as custom.sqf.
|
The output queue filename is user-defined.
|
||||||
You can then run sbopkg -i custom to install all packages+deps.
|
You can then run sbopkg -i <queue-name> to install all packages+deps.
|
||||||
Feature Request by Jeremy/bassmadrigal (Fixed #13).
|
Feature Request by Jeremy/bassmadrigal (Fixed #13).
|
||||||
|
Implement contributions from Marcel Saegebarth.
|
||||||
|
|
||||||
MODIFICATIONS
|
MODIFICATIONS
|
||||||
* bash-completion: Complete -i and -b when git repo is used
|
* bash-completion: Complete -i and -b when git repo is used
|
||||||
|
Loading…
Reference in New Issue
Block a user