mirror of
https://github.com/sbopkg/sbopkg
synced 2025-01-16 03:41:32 +01:00
Allow multiple instances of sbopkg to run simultaneously.
This patch makes it possible to run multiple sbopkg instances simultaneously in different $SBOPKGTMP prefixes. There are some known (and possibly unknown) caveats the user should be aware before enabling this option -- I documented the ones I could think of. Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
parent
51b52b748d
commit
0cf9aea14a
4 changed files with 78 additions and 3 deletions
|
@ -17,4 +17,7 @@ enhancements:
|
||||||
RHS of [[ commands using the =~ operator which broke the repo file
|
RHS of [[ commands using the =~ operator which broke the repo file
|
||||||
validation, among other things. Thanks to SiegeX, Zmyrgel, and BCarey for
|
validation, among other things. Thanks to SiegeX, Zmyrgel, and BCarey for
|
||||||
the reports and suggestions.
|
the reports and suggestions.
|
||||||
|
* Add the ability to run multiple sbopkg instances simultaneously. This has
|
||||||
|
been suggested many times in the past. Users should read the sbopkg.conf
|
||||||
|
man page before using this option (which is disabled by default).
|
||||||
+--------------------------+
|
+--------------------------+
|
||||||
|
|
|
@ -20,6 +20,11 @@ LOGFILE=$LOGDIR/sbopkg-build-log
|
||||||
DEBUG=0
|
DEBUG=0
|
||||||
CLEANUP=NO
|
CLEANUP=NO
|
||||||
|
|
||||||
|
# Set this to YES to allow multiple instances of sbopkg to run.
|
||||||
|
# Please read the sbopkg.conf(5) man page before doing so
|
||||||
|
# (otherwise, don't even think about submitting a problem report).
|
||||||
|
ALLOW_MULTI=NO
|
||||||
|
|
||||||
# The following variables are used by sbopkg and by the SlackBuild scripts
|
# The following variables are used by sbopkg and by the SlackBuild scripts
|
||||||
# themselves. They are exported for this reason.
|
# themselves. They are exported for this reason.
|
||||||
export TMP=${TMP:-/tmp/SBo}
|
export TMP=${TMP:-/tmp/SBo}
|
||||||
|
|
|
@ -138,6 +138,40 @@ from the environment or from the configuration files is ignored.
|
||||||
|
|
||||||
The default value of CLEANUP is: NO.
|
The default value of CLEANUP is: NO.
|
||||||
|
|
||||||
|
.TP 5
|
||||||
|
.B ALLOW_MULTI
|
||||||
|
.br
|
||||||
|
When set to YES, this option allows the user to run multiple instances
|
||||||
|
of sbopkg.
|
||||||
|
|
||||||
|
Please understand that this option is provided for convenience, but
|
||||||
|
given the number of potential issues you can face when enabling this
|
||||||
|
(and we aren't going to try to work around users doing silly things),
|
||||||
|
you should consider working with ALLOW_MULTI=YES as an EXPERIMENTAL
|
||||||
|
UNSUPPORTED feature. If you encounter problems, please try to make sure
|
||||||
|
these aren't caused by yourself doing improper things.
|
||||||
|
|
||||||
|
For reference, these are some of the things you shouldn't do with this
|
||||||
|
option enabled:
|
||||||
|
.RS 6
|
||||||
|
.IP \[bu] 2
|
||||||
|
run an ALLOW_MULTI=NO instance together with one or more having
|
||||||
|
ALLOW_MULTI=YES
|
||||||
|
.IP \[bu]
|
||||||
|
sync a repository when another instance is using it
|
||||||
|
.IP \[bu]
|
||||||
|
change the branch of a git repository when another instance is using it
|
||||||
|
(you can do this with rsync -- i.e. SlackBuild.org -- repos)
|
||||||
|
.IP \[bu]
|
||||||
|
simultaneously build or install the same package from different instances
|
||||||
|
.IP \[bu]
|
||||||
|
save a queue file while using it from another instance
|
||||||
|
.RE
|
||||||
|
|
||||||
|
.RS 5
|
||||||
|
There can be more unsafe situations we haven't thought about. Take care.
|
||||||
|
.RE
|
||||||
|
|
||||||
.TP 5
|
.TP 5
|
||||||
.B DEBUG
|
.B DEBUG
|
||||||
.br
|
.br
|
||||||
|
|
|
@ -106,7 +106,7 @@ config_check() {
|
||||||
# Some configuration options are mandatory
|
# Some configuration options are mandatory
|
||||||
for VAR in REPO_ROOT LOGDIR QUEUEDIR SRCDIR SBOPKGTMP REPO_NAME \
|
for VAR in REPO_ROOT LOGDIR QUEUEDIR SRCDIR SBOPKGTMP REPO_NAME \
|
||||||
REPO_BRANCH KEEPLOG CLEANUP LOGFILE DEBUG TMP OUTPUT RSYNCFLAGS \
|
REPO_BRANCH KEEPLOG CLEANUP LOGFILE DEBUG TMP OUTPUT RSYNCFLAGS \
|
||||||
WGETFLAGS DIFF DIFFOPTS SBOPKG_REPOS_D; do
|
WGETFLAGS DIFF DIFFOPTS SBOPKG_REPOS_D ALLOW_MULTI; do
|
||||||
if [[ -z "${!VAR}" ]]; then
|
if [[ -z "${!VAR}" ]]; then
|
||||||
MISSING+="$VAR "
|
MISSING+="$VAR "
|
||||||
fi
|
fi
|
||||||
|
@ -141,6 +141,22 @@ EOF
|
||||||
if [[ $CLEANUP == [Nn][Oo] ]]; then
|
if [[ $CLEANUP == [Nn][Oo] ]]; then
|
||||||
unset CLEANUP
|
unset CLEANUP
|
||||||
fi
|
fi
|
||||||
|
if [[ $ALLOW_MULTI == [Nn][Oo] ]]; then
|
||||||
|
unset ALLOW_MULTI
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If multiple instances of sbopkg are allowed, they need their own
|
||||||
|
# private $SBOPKGTMP.
|
||||||
|
# Since simply appending the cookie makes sbopkg to inform the user about
|
||||||
|
# the creation of the new $SBOPKGTMP directory on every startup, we do a
|
||||||
|
# little more setup here.
|
||||||
|
if [[ $ALLOW_MULTI ]]; then
|
||||||
|
# Note: this ck_dir line is copied from directory_checks
|
||||||
|
ck_dir $SBOPKGTMP \
|
||||||
|
"Creating local sbopkg TMP directory $SBOPKGTMP."
|
||||||
|
SBOPKGTMP+=/sbopkg-instance-$(mcookie)
|
||||||
|
mkdir -p $SBOPKGTMP
|
||||||
|
fi
|
||||||
|
|
||||||
# Make sure there are no unexpected files in $SBOPKGTMP
|
# Make sure there are no unexpected files in $SBOPKGTMP
|
||||||
if [[ -n $(find $SBOPKGTMP -mindepth 1 -maxdepth 1 -not -name sbopkg\* \
|
if [[ -n $(find $SBOPKGTMP -mindepth 1 -maxdepth 1 -not -name sbopkg\* \
|
||||||
|
@ -294,7 +310,7 @@ directory_checks() {
|
||||||
ck_dir $SBOPKGTMP \
|
ck_dir $SBOPKGTMP \
|
||||||
"Creating local sbopkg TMP directory $SBOPKGTMP."
|
"Creating local sbopkg TMP directory $SBOPKGTMP."
|
||||||
ck_dir $TMP \
|
ck_dir $TMP \
|
||||||
"Creating local SBo TMP directory $TMP."
|
"Creating local SBo TMP directory $TMP." # Also see config_check()
|
||||||
ck_dir $OUTPUT \
|
ck_dir $OUTPUT \
|
||||||
"Creating local package output directory $OUTPUT."
|
"Creating local package output directory $OUTPUT."
|
||||||
|
|
||||||
|
@ -3873,6 +3889,23 @@ cleanup() {
|
||||||
rm -f $SBOPKGTMP/sbopkg-tmp-*
|
rm -f $SBOPKGTMP/sbopkg-tmp-*
|
||||||
rm -f $PIDFILE
|
rm -f $PIDFILE
|
||||||
|
|
||||||
|
if [[ $ALLOW_MULTI ]]; then
|
||||||
|
if ! rmdir $SBOPKGTMP 2>/dev/null; then
|
||||||
|
cat <<EOF
|
||||||
|
$SCRIPT was unable to remove the temporary folder:
|
||||||
|
|
||||||
|
$SBOPKGTMP
|
||||||
|
|
||||||
|
since it still contains some file or directory.
|
||||||
|
Please file a bug report telling us how you managed to trigger this
|
||||||
|
message and append to it the output of:
|
||||||
|
|
||||||
|
find $SBOPKGTMP
|
||||||
|
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Back to the directory the user started sbopkg in
|
# Back to the directory the user started sbopkg in
|
||||||
cd "$CWD"
|
cd "$CWD"
|
||||||
}
|
}
|
||||||
|
@ -4290,7 +4323,7 @@ fi
|
||||||
directory_checks
|
directory_checks
|
||||||
|
|
||||||
# Check for another instance
|
# Check for another instance
|
||||||
pid_check
|
[[ $ALLOW_MULTI ]] || pid_check
|
||||||
|
|
||||||
if [[ $DIAG ]]; then
|
if [[ $DIAG ]]; then
|
||||||
if [[ $TERM =~ ^rxvt.* || $TERM =~ ^screen.* ]]; then
|
if [[ $TERM =~ ^rxvt.* || $TERM =~ ^screen.* ]]; then
|
||||||
|
|
Loading…
Reference in a new issue