From 6395d20dd45489ba82cc9d89ae241ad6d843f042 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Sat, 13 Oct 2007 21:12:02 +0000 Subject: Better scripting --- truecrypt/build/truecrypt.SlackBuild | 52 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'truecrypt') diff --git a/truecrypt/build/truecrypt.SlackBuild b/truecrypt/build/truecrypt.SlackBuild index 3df97827..2f8cccbc 100755 --- a/truecrypt/build/truecrypt.SlackBuild +++ b/truecrypt/build/truecrypt.SlackBuild @@ -60,22 +60,24 @@ VERSION=${VERSION:-4.3a} ARCH=${ARCH:-i486} BUILD=3 -DOCS="README.1st Release/Readme.txt INSTALL License.txt userguide.pdf" +DOCS="README.1st Readme.txt License.txt userguide.pdf" KVER=${KVER:-$(uname -r)} KSRC=${KSRC:-/lib/modules/{KVER}/build} SLACKMAJ=$( cat /etc/slackware-version | cut -f2 -d\ | cut -f1 -d. ) -SOURCE="${PRGNAM}-${VERSION}-source-code.tar.gz" -PATCH0="${PRGNAM}-${VERSION}_ksrc.patch" -PATCH1="${PRGNAM}-${VERSION}_kernel_2.6.23.patch" - # Where do we look for sources? CWD=$(pwd) SRCDIR=$(dirname $0) [ "${SRCDIR:0:1}" == "." ] && SRCDIR=${CWD}/${SRCDIR} +SRCURL="http://www.truecrypt.org/downloads/${PRGNAM}-${VERSION}-source-code.tar.gz" +SOURCE="${SRCDIR}/${PRGNAM}-${VERSION}-source-code.tar.gz" + +PATCH0="${SRCDIR}/${PRGNAM}-${VERSION}_ksrc.patch" +PATCH1="${SRCDIR}/${PRGNAM}-${VERSION}_kernel_2.6.23.patch" + # Place to build (TMP) package (PKG) and output (OUTPUT) the program: TMP=${TMP:-/tmp/build} PKG=$TMP/package-$PRGNAM @@ -125,44 +127,54 @@ case "$ARCH" in ;; esac +# Prepare build environment: mkdir -p $TMP/tmp-$PRGNAM # location to build the source rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build mkdir -p $PKG # place for the package to be built rm -rf $PKG/* # We always erase old package's contents: mkdir -p $OUTPUT # place for the package to be saved -if ! [ -f ${SRCDIR}/${SOURCE} ]; then - echo "File '${SOURCE}' not available... aborting the build." - exit 1 +# Source file availability: +if ! [ -f ${SOURCE} ]; then + if ! [ "x${SRCURL}" == "x" ]; then + # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT + [ -w "$SRCDIR" ] || SOURCE="$OUTPUT/$(basename $SOURCE)" + echo "Source '$(basename ${SOURCE})' not available yet..." + echo "Will download file to $(dirname $SOURCE)" + wget -nv --connect-timeout=30 -O "${SOURCE}" "${SRCURL}" || true + if [ $? -ne 0 -o ! -s "${SOURCE}" ]; then + echo "Downloading '$(basename ${SOURCE})' failed... aborting the build." + mv -f "${SOURCE}" "${SOURCE}".FAIL + exit 1 + fi + else + echo "File '$(basename ${SOURCE})' not available... aborting the build." + exit 1 + fi fi -# --- PACKAGE BUILDING --- - +# Package building: echo "++" echo "|| $PRGNAM-$VERSION" echo "++" cd $TMP/tmp-$PRGNAM - echo "Extracting the program tarball(s) for $PRGNAM..." tar -xzvf $SRCDIR/${SOURCE} mv ${PRGNAM}-${VERSION}-source-code ${PRGNAM}-${VERSION} || true cd ${PRGNAM}-${VERSION} -# Support kernels >= 2.6.23 : chown -R root.root * find . -perm 777 -exec chmod 755 {} \; find . -exec chmod +r {} \; echo "Building ..." -# Small doc filename clash: -mv -f Readme.txt INSTALL - cd Linux # Patches first: -# More compilation error output: -patch -p0 < $SRCDIR/${PATCH0} 2>&1 | tee $OUTPUT/patch-${PRGNAM}.log -patch -p1 < ${SRCDIR}/${PATCH1} 2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log +# Verbose compilation output: +patch -p0 < ${PATCH0} 2>&1 | tee $OUTPUT/patch-${PRGNAM}.log +# Support for kernels >= 2.6.23 : +patch -p1 < ${PATCH1} 2>&1 | tee -a $OUTPUT/patch-${PRGNAM}.log CFLAGS="$SLKCFLAGS" \ KERNEL_VER=$KVER KERNEL_SRC=$KSRC \ @@ -171,9 +183,7 @@ KERNEL_VER=$KVER KERNEL_SRC=$KSRC \ # Run a test ./Cli/truecrypt --test 2>&1 | tee -a $OUTPUT/make-${PRGNAM}.log -# -# Install all the needed stuff to the package dir -# +# Install all the needed stuff to the package dir: mkdir -p $PKG/usr/bin mkdir -p $PKG/usr/man/man1 mkdir -p $PKG/lib/modules/$KVER/extra -- cgit v1.2.3