Add sbopkg.conf option to delete build residuals.

This patch adds a sbopkg.conf option that, when enabled,
tells sbopkg to automatically delete the sources and all
the other files generated during the SlackBuild execution
right after running it.
Addresses issue #21. Thanks to Marco Bonetti and Gregory
Tourte for the report and the nice discussion.

Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
mauro.giachero 2009-07-09 14:05:44 +00:00
parent cc6ddd5457
commit 104ad3804f
4 changed files with 45 additions and 5 deletions

View file

@ -118,4 +118,8 @@ enhancements:
are preparing for the Slackware 13.0 release.
* Add option to retry a failed build. Thanks to Zordrak for suggesting this
feature.
* Add CLEANUP configuration variable, which when set to YES tells sbopkg to
delete the extracted sources, and all the associated "residuals" of the
build, as soon as the build is finished. Thanks to Marco Bonetti and
Gregory Tourte for the suggestion and the nice discussion.
+--------------------------+

View file

@ -18,6 +18,7 @@ REPO_BRANCH=${REPO_BRANCH:-13.0}
KEEPLOG=YES
LOGFILE=$LOGDIR/sbopkg-build-log
DEBUG=0
CLEANUP=NO
# The following variables are used by sbopkg and by the SlackBuild scripts
# themselves. They are exported for this reason.

View file

@ -126,6 +126,17 @@ The default value of LOGDIR is:
.br
LOGDIR=${LOGDIR:-/var/log/sbopkg}.
.TP 5
.B CLEANUP
.br
This option should be set to YES or NO. When set to YES, the source
files and the various residuals from the process of building a package
are deleted right after the build.
A side effect of setting CLEANUP to YES is that the TMP setting got
from the environment or from the configuration files is ignored.
The default value of CLEANUP is: NO.
.TP 5
.B DEBUG
.br
@ -207,6 +218,9 @@ would then set $TMP to /home/sbo/tmp for building SBo
packages. OUTPUT can also be changed to save compiled packages in a
location other than the default of /tmp.
Please note that if the CLEANUP variable is set to YES, the TMP setting
is ignored.
You can also export variables in sbopkg.conf that are not used by
sbopkg at all.

View file

@ -30,9 +30,10 @@
# Antoine, ktabic, Ken Roberts, samac, Bert Babington, Murat D. Kadirov,
# The-spiki, David Somero, LukenShiro, Drew Ames, nille, acidchild, mancha,
# macavity, Zordrak, João Felipe Santos, cotterochan, necropresto, Pierre
# Cazenave, Mauro Giachero, The-Croupier, Wade Grant, TSquaredF, and
# alkos333. This script would not be where it is without the help of these
# folks. If I left anyone out, I apologize. Thank you!
# Cazenave, Mauro Giachero, The-Croupier, Wade Grant, TSquaredF, alkos333,
# Marco Bonetti and Gregory Tourte.
# This script would not be where it is without the help of these folks.
# If I left anyone out, I apologize. Thank you!
#
#set -x
@ -119,9 +120,14 @@ config_check() {
else
unset KEEPLOG
fi
if [[ $CLEANUP == [Yy][Ee][Ss] ]]; then
CLEANUP=1
else
unset CLEANUP
fi
# Some configuration options are mandatory
for VAR in REPO_ROOT LOGDIR QUEUEDIR SRCDIR SBOPKGTMP REPO_NAME \
REPO_BRANCH KEEPLOG LOGFILE DEBUG TMP OUTPUT RSYNCFLAGS \
REPO_BRANCH KEEPLOG CLEANUP LOGFILE DEBUG TMP OUTPUT RSYNCFLAGS \
WGETFLAGS DIFF DIFFOPTS SBOPKG_REPOS_D; do
if [[ -z "${!VAR}" ]]; then
MISSING+="$VAR "
@ -2889,7 +2895,19 @@ build_package() {
[[ $BUILDOPTIONS ]] && eval "export $BUILDOPTIONS"
fi
export OUTPUT=$SB_OUTPUT
nice sh $PKGNAME.SlackBuild.build
if [[ $CLEANUP ]]; then
# We want to remove all the build residuals after running the
# SlackBuild script. To do that reliably (i.e. without
# deleting too much or leaving garbage behind us), a nice
# approach is to use a dedicated build directory.
export TMP=$SBOPKGTMP/sbopkg-build-directory
rm -rf $TMP # Just in case
nice sh $PKGNAME.SlackBuild.build
echo "Cleaning up..."
rm -rf $TMP
else
nice sh $PKGNAME.SlackBuild.build
fi
)
# Let's see the result
@ -3723,6 +3741,7 @@ cleanup() {
rm -f $SBOPKGTMP/sbopkg_*
rm -f $SBOPKGTMP/sbopkgpidlist
rm -rf $SBOPKGTMP/sbopkg-sbooutputdir
rm -rf $SBOPKGTMP/sbopkg-build-directory
rm -f $SBOPKGTMP/sbopkg-*-queue
rm -f $SBOPKGTMP/sbopkg-tmp-*
rm -f $PIDFILE
@ -3933,6 +3952,8 @@ unset REPO_TOOL # Active branch's fetch tool
unset REPO_LINK # Active branch's fetch link
unset REPO_DIR # Active branch's directory
unset REPO_GPG # Active branch's GPG checking
unset CLEANUP # If set, delete the sources & c. after the build
unset KEEPLOG # If set, keep a permanent build log
unset BUILD BFLAG IFLAG CHK_UPDATES GENSEARCH CHANGELOG OBSOLETESRC GETPKGS
unset RSYNC SEARCH UPDATE VERSION CUSTOMVER