mirror of
https://github.com/sbopkg/sbopkg
synced 2024-12-26 09:58:14 +01:00
make assigning to TMPDIR in sbopkg.conf work
Move the assignment to SBOPKGTMP (via mktemp and its TMPDIR) to after sourcing the config file. Thanks to Ken Roberts for reporting the issue and providing a preliminary fix. Also modify config_check() to check for obsolete variables as it does for required variables. Also modify cleanup() to only try to remove SBOPKGTMP if it exists.
This commit is contained in:
parent
74306e5424
commit
c2590f6aca
1 changed files with 41 additions and 24 deletions
|
@ -90,7 +90,7 @@ config_check() {
|
|||
# Check if config file is there and if so check that it has all
|
||||
# needed variables with any value, and set them.
|
||||
|
||||
local MISSING VAR
|
||||
local MISSING VAR OBS OBSVAR
|
||||
|
||||
if [[ ! -d $SBOPKG_REPOS_D ]]; then
|
||||
echo "$SCRIPT: No $SBOPKG_REPOS_D was found." 1>&2
|
||||
|
@ -111,6 +111,25 @@ config_check() {
|
|||
[[ -e $SBOPKG_CONF ]] && . $SBOPKG_CONF
|
||||
[[ -e $HOME/.sbopkg.conf ]] && . $HOME/.sbopkg.conf
|
||||
|
||||
# Some configuration options are obsolete
|
||||
for OBSVAR in SBOPKGTMP; do
|
||||
if [[ ${!OBSVAR} ]]; then
|
||||
OBS+="$OBSVAR "
|
||||
fi
|
||||
done
|
||||
if [[ $OBS ]]; then
|
||||
cat << EOF
|
||||
$SCRIPT: obsolete configuration variable(s) found:
|
||||
|
||||
$OBS
|
||||
|
||||
Please remove or update any obsolete variables. See the sbopkg.conf(5) man
|
||||
page for more details.
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Some configuration options are mandatory
|
||||
for VAR in REPO_ROOT QUEUEDIR SRCDIR REPO_NAME REPO_BRANCH \
|
||||
KEEPLOG CLEANUP LOGFILE DEBUG_UPDATES TMP OUTPUT RSYNCFLAGS \
|
||||
|
@ -121,19 +140,15 @@ config_check() {
|
|||
done
|
||||
if [[ "$MISSING" ]]; then
|
||||
cat << EOF
|
||||
$SCRIPT: required configuration variable(s) not found:
|
||||
|
||||
ERROR
|
||||
$SCRIPT: Can't find a value for variable(s):
|
||||
$MISSING
|
||||
|
||||
If you have recently upgraded sbopkg there may be
|
||||
new variables in the sbopkg.conf file. Please
|
||||
merge the sbopkg.conf.new file with your existing
|
||||
sbopkg.conf file. Please see the sbopkg.conf(5)
|
||||
man page for more details.
|
||||
If you have recently upgraded sbopkg there may be new variables in the
|
||||
sbopkg.conf file. Please merge the sbopkg.conf.new file with your existing
|
||||
sbopkg.conf file. See the sbopkg.conf(5) man page for more details.
|
||||
|
||||
Please correct this error and run $SCRIPT again.
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
@ -4113,7 +4128,9 @@ cleanup() {
|
|||
if [[ $HAS_NCURSES ]]; then
|
||||
tput cnorm # Restore cursor
|
||||
fi
|
||||
rm -r $SBOPKGTMP
|
||||
if [[ -d $SBOPKGTMP ]]; then
|
||||
rm -r $SBOPKGTMP
|
||||
fi
|
||||
rm -f $PIDFILE
|
||||
}
|
||||
|
||||
|
@ -4396,20 +4413,6 @@ DIAG=1
|
|||
ON_ERROR=ask
|
||||
REPOS_FIELDS=7
|
||||
|
||||
SBOPKGTMP=$(mktemp -td sbopkg.XXXXXX) ||
|
||||
{ echo "$SCRIPT: failed to create sbopkg's temporary directory"; exit 1; }
|
||||
STARTQUEUE=$SBOPKGTMP/sbopkg-start-queue
|
||||
USERQUEUE_LOCK=$SBOPKGTMP/sbopkg_user_queue.lck
|
||||
MISSING_LIST_FILE=$SBOPKGTMP/sbopkg_addall_missing
|
||||
MISSING_SINGLE_FILE=$SBOPKGTMP/sbopkg_add_item_missing
|
||||
TMPLOG=$SBOPKGTMP/sbopkg_tmplog
|
||||
TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue
|
||||
FINALQUEUE=$SBOPKGTMP/sbopkg-final-queue
|
||||
SB_OUTPUT=$SBOPKGTMP/sbopkg-sbooutputdir
|
||||
SBOPKGOUTPUT=$SBOPKGTMP/sbopkg_output
|
||||
TMPBUILDLOG=$SBOPKGTMP/sbopkg-tmp-buildlog
|
||||
TMPSUMMARYLOG=$SBOPKGTMP/sbopkg-tmp-summarylog
|
||||
|
||||
# Make sure we are root.
|
||||
if [[ $(id -u) != 0 ]]; then
|
||||
echo "$SCRIPT: $SCRIPT must be run by the root user. Exiting." >&2
|
||||
|
@ -4587,6 +4590,20 @@ fi
|
|||
# Check for a good config file and set initial variables
|
||||
config_check
|
||||
|
||||
SBOPKGTMP=$(mktemp -td sbopkg.XXXXXX) ||
|
||||
{ echo "$SCRIPT: failed to create sbopkg's temporary directory"; exit 1; }
|
||||
STARTQUEUE=$SBOPKGTMP/sbopkg-start-queue
|
||||
USERQUEUE_LOCK=$SBOPKGTMP/sbopkg_user_queue.lck
|
||||
MISSING_LIST_FILE=$SBOPKGTMP/sbopkg_addall_missing
|
||||
MISSING_SINGLE_FILE=$SBOPKGTMP/sbopkg_add_item_missing
|
||||
TMPLOG=$SBOPKGTMP/sbopkg_tmplog
|
||||
TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue
|
||||
FINALQUEUE=$SBOPKGTMP/sbopkg-final-queue
|
||||
SB_OUTPUT=$SBOPKGTMP/sbopkg-sbooutputdir
|
||||
SBOPKGOUTPUT=$SBOPKGTMP/sbopkg_output
|
||||
TMPBUILDLOG=$SBOPKGTMP/sbopkg-tmp-buildlog
|
||||
TMPSUMMARYLOG=$SBOPKGTMP/sbopkg-tmp-summarylog
|
||||
|
||||
# Change $REPO_BRANCH (and optionally REPO_NAME) if set manually using cli -v
|
||||
if [[ $VERSION ]]; then
|
||||
if [[ $CUSTOMVER == ? ]]; then
|
||||
|
|
Loading…
Reference in a new issue