From 659e6cdc408f9987337394152175d84606019c72 Mon Sep 17 00:00:00 2001 From: PktSurf Date: Tue, 27 Sep 2022 10:25:07 +0530 Subject: [PATCH] Added Tadgy's GNOME autobuilding scripts which --- gsb/buildgsb | 547 +++++++++++++++++++++++++++++++++ gsb/functions.sh | 426 +++++++++++++++++++++++++ gsb/gsb.SlackBuild-1.3 | 191 ++++++++++++ gsb/gsb.section.SlackBuild-1.3 | 359 ++++++++++++++++++++++ gsb/link | 1 + gsb/section.SlackBuild-1.6 | 407 ++++++++++++++++++++++++ gsb/section.SlackBuild-1.7 | 422 +++++++++++++++++++++++++ 7 files changed, 2353 insertions(+) create mode 100644 gsb/buildgsb create mode 100644 gsb/functions.sh create mode 100644 gsb/gsb.SlackBuild-1.3 create mode 100644 gsb/gsb.section.SlackBuild-1.3 create mode 100644 gsb/link create mode 100644 gsb/section.SlackBuild-1.6 create mode 100644 gsb/section.SlackBuild-1.7 diff --git a/gsb/buildgsb b/gsb/buildgsb new file mode 100644 index 0000000..9ea3acb --- /dev/null +++ b/gsb/buildgsb @@ -0,0 +1,547 @@ +#!/bin/bash +# Version: 1.9.3 GNOME SlackBuild Build Script +# Copyright (c) 2007, 2008, 2009 +# Darren 'Tadgy' Austin , Coventry, UK. +# Steve Kennedy +# Chip Cuccio , Byron, MN USA +# All rights reserved. +# +# Licenced under the terms of the GNU General Public Licence version 3. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +# OF SUCH DAMAGE. + +# GNOME SlackBuild Version +GSB_VERSION=2_32 + +#======================================================================== +# FUNCTIONS +. ${BASH_SOURCE%/*}/functions.sh || { + echo "Can't find functions.sh." + exit 1; +} + +# Trap keyboard interrupt +trap error_out SIGINT + +#======================================================================== +# ENVIRONMENT + +# If the user created an options file, read it. +[ -r ./gsb.options ] && { + . ./gsb.options + export OPTIONSREAD=1 +} + +# Basic settings +TMP=${TMP:-/tmp} +ARCH=${ARCH:-"$(arch)"} +GSB_ARCH=${GSB_ARCH:-""} +if [ "$ARCH" = "x86_64" ]; then + GSB_ARCH=64 +fi +GSBDIR=${GSBDIR:-gsb${GSB_ARCH}} +TAG=${TAG:-gsb} +PKGDEST=${PKGDEST:-$TMP/gsb${GSB_ARCH}-tree} +LOGSDIR=${LOGSDIR:-$TMP/gsb${GSB_ARCH}-buildlogs} + +# Location of our build source +BUILDSOURCE=${BUILDSOURCE:-"${BASH_SOURCE%/*}/../src"} + +# GPG-KEY +GPGKEY=${GPGKEY:-"${BUILDSOURCE}/../GPG-KEY"} +[ ! -f ${GPGKEY} ] && { + echo ; header "WARNING: Can't find GPG-KEY for verification." + exit 1; +} + +# We will mimic Slackware's tree +SOURCEDIR=${SOURCEDIR:-source} +CHANGELOG=${CHANGELOG:-$LOGSDIR/ChangeLog.txt} +TESTINGDIR=${TESTINGDIR:-testing} +EXTRADIR=${EXTRADIR:-extra} +PASTUREDIR=${PASTUREDIR:-pasture} +PATCHESDIR=${PATCHESDIR:-patches} + +# Option defaults. +WITH_TEST_PACKAGES=0 +AUTO_DOWNLOAD=0 +ONLY_DOWNLOAD=0 +CONFIRM_INSTALLS=0 +NOPATCHESDIR=0 +NOSKIP=0 +SKIP_REBUILDS=0 +NOPRUNE=0 +PUBLISH=0 + +# Download settings +DOWNLOAD_ATTEMPTS=${DOWNLOAD_ATTEMPTS:-3} +WGET_OPTIONS="-4" + +#======================================================================== +# COMMAND LINE PARSING +# +while [ -n "$1" ] ; do + case $1 in + -force|--force) + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--force" + shift + ;; + -no-cleanup|--no-cleanup) + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--no-cleanup" + shift + ;; + -no-patchesdir|--no-patchesdir) + NOPATCHESDIR=1 + shift + ;; + -no-skip|--no-skip) + NOSKIP=1 + NOPATCHESDIR=1 + shift + ;; + -no-prune|--no-prune) + NOPRUNE=1 + shift + ;; + -publish|--publish) + PUBLISH=1 + SKIP_REBUILDS=1 + shift + ;; + -with-testing|--with-testing) + WITH_TEST_PACKAGES=1 + shift + ;; + -confirm-installs|--confirm-installs) + CONFIRM_INSTALLS=1 + shift + ;; + -set=*|--set=*) + SETS=$(echo $1 | cut -f2 -d=) + shift + ;; + -package=*|--package=*) + PKG_ONLY=$(echo $1 | cut -f2 -d=) + shift + ;; + -download-only|--download-only) + ONLY_DOWNLOAD=1 + shift + ;; + -download|--download) + AUTO_DOWNLOAD=1 + shift + ;; + -skip-rebuilds|--skip-rebuilds) + SKIP_REBUILDS=1 + shift + ;; + -help|--help) + usage + exit 1 + ;; + *) + usage ; + echo ; + echo "Invalid option: $1" + exit 1 + ;; + esac +done + +#======================================================================== +# STARTUP +echo ; header "* Building GSB " +if [ "$(id -u)" != "0" ]; then + echo "* Error: Only root can build, install, upgrade, or remove packages." + exit 1 +fi + +# Temporary space, package and log file storage. +mkdir -p $TMP && +mkdir -p $PKGDEST && +mkdir -p $LOGSDIR && +mkdir -p $PKGDEST/${EXTRADIR} && +mkdir -p $PKGDEST/${PASTUREDIR} && +mkdir -p $PKGDEST/${TESTINGDIR} || exit +[ "$NOPATCHESDIR" = "0" ] && { + mkdir -p $PKGDEST/${PATCHESDIR}/packages || exit 1 +} + +# Clear away all tagfiles from build tree to prevent some applications +# from being skipped when upgradepkg is called. +find $PKGDEST/ -name tagfile -exec rm {} \; + +#======================================================================== +# MAIN LIST +# +# The set list is read in from buildlist.txt, with any comments and blank +# lines removed. +# +cd ${BUILDSOURCE} +BUILDLIST=${BUILDLIST:-""} +[ -f buildlist.txt ] && { +BUILDLIST="$(egrep -v "^#|^$" buildlist.txt | \ + # Remove our testing packages if not specified. + if [ "$WITH_TEST_PACKAGES" = "1" ]; then cat ; else egrep -v testing; fi | \ + # Perhaps the user only wants a certain set of packages. + if [ -z "$SETS" ]; then cat ; else egrep ^${SETS}; fi | \ + # Perhaps the user only wants a specific package. + if [ -z "$PKG_ONLY" ]; then cat ; else egrep ${PKG_ONLY}$; fi;)" +} + +[ -z "$BUILDLIST" ] && { + echo "Nothing to build." + exit 1; +} + +#======================================================================== +# CLEAN SYSTEM OF TESTING/ PACKAGES +# +# Clear the system of any packages from testing/ which might be lying around. +# This ensures that we don't accidently build against a package we don't want. +# +if [ "$WITH_TEST_PACKAGES" = "0" -a "${ONLY_DOWNLOAD}" = "0" ]; then + echo; header "Removing any test packages." +( cd ${BUILDSOURCE}/../testing && + for testpkg in $(find . -type d -mindepth 1 -maxdepth 1); do + removepkg $testpkg 1>/dev/null 2>/dev/null + done; +) +fi; + +#======================================================================== +# MAIN BUILD LOOP +# +# Do the build. + +echo; header "* Starting build."; echo; + +# LOOP THROUGH ALL PACKAGES IN $BUILDLIST +for listitem in $BUILDLIST ; +do + +( + +BUILD_OPTION="$(echo $listitem | cut -f1 -d:)" +SET="$(echo $listitem | cut -f2 -d: | cut -f1 -d/)" +PACKAGE="$(echo $listitem | cut -f2 -d: | cut -f2 -d/)" +SKIP_BUILD=0 +DISALLOW_PATCHES=0 +SOURCE=$BUILDSOURCE + +# Create our tree according to Slackware defaults +case $SET in + extra) + SUBDIR=$GSBDIR/../${EXTRADIR}/${PACKAGE} + SOURCE=$BUILDSOURCE/../ + DISALLOW_PATCHES=1 + ;; + pasture) + SUBDIR=$GSBDIR/../${PASTUREDIR} + SOURCE=$BUILDSOURCE/../ + DISALLOW_PATCHES=1 + ;; + testing) + SUBDIR=$GSBDIR/../${TESTINGDIR}/packages + SOURCE=$BUILDSOURCE/../ + DISALLOW_PATCHES=1 + ;; + *) + SUBDIR=$GSBDIR/$SET + ;; +esac + +if [ -d $SOURCE/$SET ]; then + cd $SOURCE/$SET +else + echo "Can't find set directory $SOURCE/$SET." + exit 1 +fi + +# Look for package +[ ! -d $PACKAGE ] && { + header "Error: Can't find package $PACKAGE." ; + exit 1 ; +} + +# Make sure we can run our SlackBuild +[ ! -x "$PACKAGE/$PACKAGE.SlackBuild" ] && { + header "'$PACKAGE.SlackBuild' is not executable." ; + exit 1 +} + +# Get package version and build numbers from the package SlackBuild. +declare PACKAGE_$( egrep -m 1 "^VERSION=.*" $PACKAGE/$PACKAGE.SlackBuild ) +declare PACKAGE_$( egrep -m 1 "^BUILD=.*" $PACKAGE/$PACKAGE.SlackBuild ) +# Check that we got a version and build. +[ -z "$PACKAGE_VERSION" ] || [ -z "$PACKAGE_BUILD" ] && { + header "Failed to get VERSION or BUILD from '$PACKAGE.SlackBuild' " ; exit 1 +} + +# Check if the package should be rebuilt, and where it should be put. +# The assumption is to always rebuild and put packages in the main +# directory, unless modified by the checks below. +if [ "${ONLY_DOWNLOAD}" = "0" ]; then + if find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "" "" "" "\.txz" >/dev/null && [ "$NOSKIP" = "0" ] + then + if find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "${PACKAGE_BUILD}${TAG}" "\.txz" >/dev/null + then + # Package with same version/build was found in the main directory. + SKIP_BUILD=1 + else + # Not in the main directory, check patches. + if [ "$NOPATCHESDIR" = "0" -a "$DISALLOW_PATCHES" = "0" ]; then + [ -d $PKGDEST/$PATCHESDIR/packages ] && { + if find_package_files "$PKGDEST/$PATCHESDIR/packages" \ + "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" "${PACKAGE_BUILD}${TAG}" \ + "\.txz" >/dev/null + then + # Found in patches dir. + SKIP_BUILD=1 + SUBDIR=$PATCHESDIR/packages + else + # No package in patches with the same version/build. + SUBDIR=$PATCHESDIR/packages + fi + } + fi + fi + fi +fi; + +#======================================================================== +# BUILD PACKAGES +# +# Build package if required. +# +SUCCESSFUL_NEW_BUILD=0 +if [ "${ONLY_DOWNLOAD}" = "1" ]; then + cd $PACKAGE && + download_package $PACKAGE || exit $? +elif [ "$SKIP_BUILD" = "0" -o "$BUILD_OPTION" = "rebuild" -a "$SKIP_REBUILDS" = "0" ]; then + rm -f $( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "${PACKAGE_BUILD}${TAG}" "\.txz|\.txt|\.txz\.asc" \ + | tr '\n' ' ' ) >/dev/null 2>&1 + find_package_files "/var/log/packages" "${PACKAGE//+/\+}" "" "" "" "" \ + >/dev/null && { + echogreen "* "; echo "Removing old $PACKAGE and cleaning up files." + removepkg $( basename $( find_package_files "/var/log/packages" \ + "${PACKAGE//+/\+}" "" "" "" "" ) ) || exit 1 + } + + echo ; echogreen "* "; echo "Building package '$PACKAGE'" + mkdir -p $PKGDEST/$SUBDIR + mkdir -p $LOGSDIR/$SET + + # Run the SlackBuild + ( + cd $PACKAGE && + export PKGDEST=$PKGDEST/$SUBDIR || exit 1 + if [ "$AUTO_DOWNLOAD" = "1" ]; then + [ "$BUILD_OPTION" = "nofetch" ] || { + download_package $PACKAGE || exit $? + } + fi; + ./$PACKAGE.SlackBuild $SLACKBUILD_ARGS 2>&1 + ) | tee $LOGSDIR/$SET/$PACKAGE-$( date +%Y%m%d-%H%M%S ).log + + ERR=${PIPESTATUS[0]} + [ "$ERR" != "0" ] && { + exit $ERR + } + SUCCESSFUL_NEW_BUILD=1 +else + echo "* Found: $PACKAGE-${PACKAGE_VERSION//-/_}-${ARCH}-${PACKAGE_BUILD}${TAG}.txz" +fi + +#======================================================================== +# PRUNE OLD FILES +# +# Remove any old packages lying around +# +if [ "${NOPRUNE}" = "0" -a "${ONLY_DOWNLOAD}" = "0" ]; then + PRUNE_FILES="$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "" "" "" "\.txz|\.txt|\.txz\.asc" | grep -v "$( find_package_files \ + "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" \ + "${PACKAGE_BUILD}${TAG}" "\.txz|\.txz\.asc" )" | tr '\n' ' ' )" + [ ! -z "$PRUNE_FILES" ] && { + rm -f $PRUNE_FILES + } +fi; + +#======================================================================== +# MAKE CHECKSUMS AND DESCRIPTIONS +# +# Make a txt description of the package +if [ "$PUBLISH" = "1" -a "${ONLY_DOWNLOAD}" = "0" ]; then + make_pkg_txt "$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "${PACKAGE_BUILD}${TAG}" "\.txz" )" || { + header "Failed to create txt description for '$PACKAGE'." ; exit 1 + } + # Sign the package + SIGN_PACKAGE="$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "${PACKAGE_BUILD}${TAG}" "\.txz" )" + if [ -f ${SIGN_PACKAGE}.asc ]; then + gpg --verify ${SIGN_PACKAGE}.asc ${SIGN_PACKAGE} 1>/dev/null 2>/dev/null || { + echo ;echo ; header "$SIGN_PACKAGE failed to pass asc verification." + echo "Has the package been corrupted?" ; + exit 1 + } + echo " (ASC Signature passed.) " + else + echo ; echogreen "* " ; echo "Please sign for ${PACKAGE}:" + make_pkg_asc "$SIGN_PACKAGE" || { + header "Failed to create asc signature for '$PACKAGE'." ; exit 1 + } + fi; +fi; + +#======================================================================== +# INSTALL NEW PACKAGE +# +# Install our new package if necessary +# +if [ "${ONLY_DOWNLOAD}" = "0" ]; then + INSTALLED=$(find_package_files "/var/log/packages" "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" \ + "" "${PACKAGE_BUILD}${TAG}" "") + if [ "$SKIP_BUILD" = "0" -o "${INSTALLED}" = "" ]; then + # Should we pause for before installing package? + [ "${CONFIRM_INSTALLS}" = "1" ] && { + echo ;echo "Press enter to install new package." ; + read goop; + } + upgradepkg --install-new $( find_package_files "$PKGDEST/$SUBDIR" \ + "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" "${PACKAGE_BUILD}${TAG}" "\.txz" ) || { + header "Failed to install '$PACKAGE'." ; exit 1 + } + # Update changelog on success install and build of changed packages. + if [ "${SUCCESSFUL_NEW_BUILD}" = "1" ]; then +changelog "${SET}/${PACKAGE}-${PACKAGE_VERSION//-/_}-${ARCH}-${PACKAGE_BUILD}${TAG}.txz: Built." ; + fi; + fi; +fi; +# BUILDING PACKAGE +) || { + echo "Check the build logs in: $LOGSDIR" + exit 1 +} + +# Done our PACKAGES loop +done + +# Break out if there has been an error. +[ "$?" != "0" ] && { + exit 1 +} + +#======================================================================== +# COPY DOCUMENTATION AND TAGFILES +# +if [ "${PUBLISH}" = "1" -a "${ONLY_DOWNLOAD}" = "0" ]; then +( +cd $BUILDSOURCE ; +# Copy tagfiles +for tagfile in $(find . -type f -name tagfile); +do + cp $tagfile $PKGDEST/$GSBDIR/$(echo $tagfile | cut -f2 -d/) || exit 1 +done; + +# Copy our main documentation +cd $BUILDSOURCE/.. ; +if [ "$ARCH" = "x86_64" ]; then + cat README.TXT | sed 's,@BINARY_EDITION@,64-bit x86_64 edition,g' > \ + $PKGDEST/README.TXT ; +else + cat README.TXT | sed 's,@BINARY_EDITION@,32-bit x86 edition,g' > \ + $PKGDEST/README.TXT ; +fi; +for i in COPYING COPYING3 CREDITS INSTALL.TXT UPGRADE.TXT \ + CHANGES_AND_HINTS.TXT GPG-KEY COPYRIGHT.TXT MIRRORS.TXT CURRENT.WARNING \ + SLACKWARE_REPLACED_PACKAGES.TXT FAQ.TXT ANNOUNCE.$GSB_VERSION; +do + if [ -f $i ]; then + cp $i $PKGDEST || exit 1; + fi; +done; + +cat << EOF > $PKGDEST/$GSBDIR/README.TXT + +This directory contains the primary GNOME SlackBuild packages -- the ones that +actually install files to your hard drive. You can install these packages with +"pkgtool", or "installpkg". See the man pages (man installpkg) for details. + +Have fun! + +EOF + +# Copy extra documentation +cp extra/README.TXT $PKGDEST/$EXTRADIR || exit 1 +[ "$WITH_TEST_PACKAGES" = "1" ] && { + cp testing/README.TXT $PKGDEST/$TESTINGDIR || exit 1 +} +if [ "$ARCH" = "x86_64" ]; then + cp ChangeLog.slackware64 $PKGDEST/ChangeLog.txt && + cp VERSIONS.slackware64 $PKGDEST/VERSIONS || exit 1 +else + cp ChangeLog.slackware $PKGDEST/ChangeLog.txt && + cp VERSIONS.slackware $PKGDEST/VERSIONS || exit 1 +fi +echo; +header "* Published documentation." +echo; +) +fi; + +#======================================================================== +# CREATE MD5 CHECKSUMS, FILELIST AND MANIFEST +# +if [ "${PUBLISH}" = "1" ]; then + echo ; header "* Generating package file lists and checksums." + ( + cd $PKGDEST || exit 1 + PUBLISH_DIRS="$GSBDIR $PATCHESDIR $EXTRADIR $SOURCEDIR $PASTUREDIR" + if [ "${WITH_TEST_PACKAGES}" = "1" ]; then + PUBLISH_DIRS="${PUBLISH_DIRS} $TESTINGDIR" + fi; + for DIR in ${PUBLISH_DIRS} + do + if [ -d "${DIR}" ]; then + # Skip making packages for our source/ + if [ "${DIR}" != "source" ]; then + make_packages_txt ${DIR} ${DIR} || exit 1 + fi; + make_manifest ${DIR} ${DIR} || exit 1 + make_filelist_txt "${DIR}" "${DIR}" "FILE_LIST" || exit 1 + make_checksums_md5 ${DIR} ${DIR} || exit 1 + fi; + done + ( cd $PKGDEST ; mv $GSBDIR/PACKAGES.TXT . ) + ( cd $GSBDIR ; ln -sf ../PACKAGES.TXT ) + # Make a date stamped file list of our full set of files. + make_filelist_txt "." "" "" "1" || exit 1 + make_checksums_md5 . + ) +fi; + +echo "* Finished building GSB!" +echo "* The complete GSB binary tree can be found in: $PKGDEST" +echo "* Build logs can be found in: $LOGSDIR" +echo ; diff --git a/gsb/functions.sh b/gsb/functions.sh new file mode 100644 index 0000000..2e3e419 --- /dev/null +++ b/gsb/functions.sh @@ -0,0 +1,426 @@ +#!/bin/bash + +# Functions library :: for the GNOME SlackBuild build script +# + +# echogreen will echo $@ in green color +# $1 = text +echogreen() +{ + echo -ne """$@""" +} + +error_out() +{ + echo + echo "* Exiting buildgsb." + exit $? +} + +# header +# $1 = text to show +header() +{ + echo """$@""" +} + +# Send info to changelog +changelog() +{ + CHANGELOG=${CHANGELOG:-/tmp/Changelog.txt} + touch $CHANGELOG + # Stamp changelog if no date previously declared + if [ -z "$(grep "$(date +"%a %b %_d")" $CHANGELOG )" ]; then + echo "+--------------------------+" >> $CHANGELOG + echo "$(date)" >> $CHANGELOG + fi; + echo "$@" 2>/dev/null >> $CHANGELOG + echogreen "* " ; echo "Updated ChangeLog." + +} +# Check for installed package +function check_installed() { + ls -1 /var/log/packages | grep "^${1}-[^-]*-[^-]*-[^-]*$" >/dev/null 2>&1 + return $? +} + +# Make a .txt after a package is built +function make_pkg_txt() { + # $1 = Package file to process [required]. + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + tar xOf $1 install/slack-desc 2>/dev/null | \ + grep -v "^#" | egrep "[[:alnum:]\+]+\:" >${1%.txz}.txt + return $? +} + +# Make an asc checksum of a package, requires input +function make_pkg_asc() { + # $1 = Package file to process [required]. + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + ( cd $( dirname $1 ) && gpg -b -a $( basename $1 ) ) + return $? +} + +# See if we have a package in our build tree +function find_package_files() { + # $1 = Directory to look for files in [required] + # $2 = Package name or regex to match. An empty string matches all. + # $3 = Package version or regex to match. An empty string matches all. + # $4 = Package architecture or regex to match. An empty string matches all. + # $5 = Package build tag or regex to match. An empty string matches all. + # $6 = File extension or regex to match. An empty string means no extension. + # Note: Remember to escape any regex characters used in fixed strings. + [ -z "$1" ] || [ ! -d "$1" ] && return 1 + find $1 -maxdepth 1 -mindepth 1 2>/dev/null | \ + egrep "^.*/(${2:-.*})(-${3:-[^-]*})(-${4:-[^-]*})(-${5:-[^-.]*})($6)$" 2>/dev/null + return $? +} + +# Generate a PACKAGES.TXT for a package tree +function make_packages_txt() { + # $1 = Sub-directory to process [required] + # $2 = Sub-directory to put PACKAGES.TXT in, or empty for current directory + [ -z "$1" ] && return 1 + + echo ; + rm -fr ${2:-.}/PACKAGES.TXT* + local TOTAL_SIZE=0 + local TOTAL_USIZE=0 + local COUNT=1 + local PACKAGE_FILES=$( find ./$1 -name \*.txz \( -type f -o -type l \) -printf "%f %p\n" | sort -k1 -f | cut -d' ' -f2 ) + local TOTAL_PACKAGE_FILES=$(echo $PACKAGE_FILES | wc -w ) + echo -ne "\rCreating PACKAGES.TXT for ${1}: $COUNT / $TOTAL_PACKAGE_FILES " + for FILE in $PACKAGE_FILES ; + do + echo -ne "\rCreating PACKAGES.TXT for ${1}: $COUNT / $TOTAL_PACKAGE_FILES " + COUNT=$(expr $COUNT + 1) + SIZE=$(du -bk $FILE | awk '{print $1}') + USIZE=$(expr $(cat $FILE | xz -dc | wc -c) / 1024) + # Keep a running total for our PACKAGES.TXT + TOTAL_SIZE=$(expr $TOTAL_SIZE + $SIZE ) + TOTAL_USIZE=$(expr $TOTAL_USIZE + $USIZE ) + # Grab package information + rm -fr $TMP/install + tar -C $TMP -xf $FILE install || exit 1 + (echo "PACKAGE NAME: $( echo $FILE | rev | cut -d/ -f1 | rev )" ; + echo "PACKAGE LOCATION: $( echo $FILE | rev | cut -d/ -f2- | rev )" ; + echo "PACKAGE SIZE (compressed): $SIZE K" ; + echo "PACKAGE SIZE (uncompressed): $USIZE K" ; + echo "PACKAGE REQUIRED: $( if [ -f $TMP/install/slack-required ]; then \ + cat $TMP/install/slack-required | tr '\n' ',' | sed -e 's/,$//' ; fi)" ; + echo "PACKAGE CONFLICTS: $( if [ -f $TMP/install/slack-conflicts ]; then \ + cat $TMP/install/slack-conflicts | tr '\n' ',' | sed -e 's/,$//' ; fi)" ; + echo "PACKAGE SUGGESTS: $( if [ -f $TMP/install/slack-suggests ]; then \ + cat $TMP/install/slack-suggests | tr '\n' ' ' ; fi )" ; + echo "PACKAGE DESCRIPTION:" ; + cat $TMP/install/slack-desc | grep -v "^#" | egrep "[[:alnum:]\+]+\:" ; + echo) >>${2:-.}/PACKAGES.TXT.$$ 2>/dev/null + done + echo -e "\rCreating PACKAGES.TXT for ${1}: done. " + + # Create a PACKAGES.TXT header with totals. + { + echo + echo "PACKAGES.TXT; $( date )" + echo + echo "This file provides details on the GNOME SlackBuild packages found" + echo "in the ./$(basename $1)/ directory." + echo + echo "Total size of all packages (compressed): $(expr $TOTAL_SIZE / 1024) MB" + echo "Total size of all packages (uncompressed): $(expr $TOTAL_USIZE / 1024) MB" + echo + echo + } >${2:-.}/PACKAGES.TXT 2>/dev/null + cat ${2:-.}/PACKAGES.TXT.$$ >> ${2:-.}/PACKAGES.TXT 2>/dev/null + rm -fr ${2:-.}/PACKAGES.TXT.$$ +} + +# Generate a FILELIST.TXT for a package tree +function make_filelist_txt() { + # $1 = Sub-directory to process [required] + # $2 = Sub-directory to put FILELIST.TXT in, or empty for current directory + # $3 = Different file name for FILELIST.TXT if desired, defaults to FILELIST.TXT + # $4 = if $4 = "1", then at time stamp is made. + [ -z "$1" ] && return 1 + local FILELIST=${3:-FILELIST.TXT} + local DATED=${4:-0} + echo -n "Creating $FILELIST for $(basename ${1}): " + + rm -fr ${2:-.}/${FILELIST}* + { ( cd $1 + if [ "$DATED" = "1" ]; then + echo "$( date )" + fi; + echo ; + echo "Here is the file list for this directory. If you are using a" + echo "mirror site and find missing or extra files in the disk" + echo "subdirectories, please have the archive administrator refresh" + echo "the mirror." + echo "" + find . ! -wholename ./FILELIST.TXT ! -wholename ./FILELIST.TXT.gz \ + ! -wholename ./CHECKSUMS.md5 ! -wholename ./CHECKSUMS.md5.gz | \ + sort | xargs ls -ld )} >${2:-.}/$FILELIST 2>/dev/null + + echo "done." +} + +function make_checksums_md5() { + # $1 = Sub-directory to process [required] + # $2 = Sub-directory to put CHECKSUMS.md5 in, or empty for current directory + [ -z "$1" ] && return 1 + echo -n "Creating CHECKSUMS.md5 for $(basename ${1}): " + rm -fr ${2:-.}/CHECKSUMS.md5* + + # Our header + cat < ${2:-.}/CHECKSUMS.md5 +If you want to test your files, use 'md5sum' and compare the values to +the ones listed here. + +To test all these files, use this command: + +md5sum -c CHECKSUMS.md5 | less + +'md5sum' can be found in the GNU coreutils package on ftp.gnu.org in +/pub/gnu, or at any GNU mirror site. + +MD5 message digest Filename +EOT + + # Make checkums + ( cd $1 + find . ! -wholename ./CHECKSUMS.md5 ! -wholename ./CHECKSUMS.md5.gz \ + \( -type f -o -type l \) -exec md5sum {} \; | \ + sort -k2 -f ) >>${2:-.}/CHECKSUMS.md5 2>/dev/null + echo "done." + echo "Please sign $(basename $1)/CHECKSUMS.md5: "; echo + gpg -b -a ${2:-.}/CHECKSUMS.md5 || exit 1 +} + +function make_manifest() { + # This handy little piece is from http://www.inreto.de/slacker/, (c) tp(at)fonz.de. + # We use it to produce the MANIFEST.bz2 file in imitation of Slackware. + # $1 = Sub-directory to process [required] + # $2 = Sub-directory to put MANIFEST.bz2 in, or empty for current directory + + [ -z "$1" ] && return 1 + + echo -n "Creating MANIFEST.bz2 for ${1}: " + rm -fr ${2:-.}/MANIFEST.bz2* + manifest=.manifest + rm -f $manifest + pkglist=($(find ${1} -name \*.txz -type f | sort)) + for x in ${pkglist[*]}; do + xx=${x#./} + echo '++========================================' >>$manifest + echo '||' >>$manifest + echo "|| Package: $x" >>$manifest + echo '||' >>$manifest + echo '++========================================' >>$manifest + tar tvf $xx 2>/dev/null >>$manifest + done + if [ -s $manifest ] ; then + bzip2 -c $manifest > ${2:-.}/MANIFEST.bz2 ; + fi; + rm -f $manifest ; + echo "done." +} + +function download_package() { + # $1 is the $PKG name to download + [ -z "$1" ] && return 1; + [ ! -f ./$1.info ] && { + echo "* Error: Can't find $1.info." ; return 1 + } + # Read in package info file, quit if not found. + . ./$1.info || return 1 + # Skip the package if no DOWNLOAD is present in the .info file. + if [ -z "$DOWNLOAD" ] ; then + header "* Skipping the download of $1." + return 0 + fi; + # Check for source file. + FILENAME="$(echo $DOWNLOAD | awk -F/ '{print $NF}')" + echo "${MD5SUM} ${FILENAME}" > $TMP/md5sum.$1.$$ + [ -z $FILENAME ] && { + echo "* Error: No source file defined in $1.info file." ; return 1 + } + + local DOWNLOAD_ATTEMPT=0 + local VALID_MD5=0 + until [ $DOWNLOAD_ATTEMPT -eq 3 -o $VALID_MD5 -eq 1 ]; do + # MD5SUM Comparison + if [ -f $FILENAME ]; then + md5sum -c $TMP/md5sum.$1.$$ 2>/dev/null 1>/dev/null && VALID_MD5=1; + fi; + if [ "${VALID_MD5}" = "0" ]; then + # Download the source file + wget ${WGET_OPTIONS} -c $DOWNLOAD || { + echo ; echo "* Error: Failed to complete download." + return 1 + } + fi + DOWNLOAD_ATTEMPT=$[$DOWNLOAD_ATTEMPT+1]; + done; + rm $TMP/md5sum.$1.$$ + # We couldn't get a decent copy of the source file + if [ "$VALID_MD5" = "0" ]; then + header "* WARNING: $FILENAME has invalid md5sum!" + return 1; + else + echo "* $FILENAME has valid md5sum." + return 0 + fi; +} + +# Usage function +function usage() { + cat << EOF +Usage: ${0##*/} [options] + +Options: + --help Show this help screen. + + --list List the packages which will be built in this section. + + --no-cleanup By default, any source, temporary build and package + directories will be deleted once the package is built. + This option prevents those files from being removed. + + --no-patchesdir When rebuilding packages which already exist in the + main package directory, the default is to put the new + packages in the patches directory. Using this option + completely disables the use of a patches directory. + + --no-skip During the build process, packages that are up to date + (ie, the package version and build numbers match the + coresponding SlackBuild) will not be rebuilt. This + option forces packages to be rebuilt regardless of the + version and build numbers. This option doesn't affect + the pre-build checks for installed packages (see the + --force option). This option implies --no-patchesdir. + + --no-prune Normally, when a package is built and copied to the + destination directory (whether it be the main package + directory or the patches directory), any previous + package(s) of the same name in that directory are + deleted - it is assumed the new package is to replace + any which are already present. This option prevents + previous packages being deleted, possibly leaving more + than one package of the same name (but with different + version or build numbers) laying around. + + --publish Create the package's .txt and .asc meta files, and + create the FILELIST, CHECKSUMS, and MANIFEST, as well + as export the SlackBuild source into a publishable + tree. You will need to create a valid GPG-KEY. + + --with-testing Normally the build script will remove all packages + found in the testing/ directory in order to prevent + unwanted dependencies, and skip building any + testing/ packages.. Use this switch to prevent the + build script from removing these packages, as well + as building the testing/ packages. + + --confirm-installs Wait for an enter press before installing any packages. + + --download As the build progresses, fetch tarballs that aren't + found in the src/ tree. + + --download-only Fetch tarballs that aren't found in the src/ tree, + but don't run a build. This option is exclusive. + + --set= Specifiy a particular set to build, like a,ap,d,c, + etc. This option can be used in coordination with + --download-only to download only a selection of + packages. + + --package= Specifiy a particular package to build. This option + can also be used with the --download or + --download-only options to build a specific package. + + --skip-rebuilds Do not rebuild packages when asked to do so in the + buildlist.txt. + + Options are passed down to the next level SlackBuild where appropriate. +EOF +} + +# This function shamelessly stolen from /sbin/installpkg +pkgbase() { + PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev) + case $PKGEXT in + 'tgz' ) + PKGRETURN=$(basename $1 .tgz) + ;; + 'tbz' ) + PKGRETURN=$(basename $1 .tbz) + ;; + 'tlz' ) + PKGRETURN=$(basename $1 .tlz) + ;; + 'txz' ) + PKGRETURN=$(basename $1 .txz) + ;; + *) + PKGRETURN=$(basename $1) + ;; + esac + echo $PKGRETURN +} + +# This function shamelessly stolen from /sbin/installpkg +package_name() { + STRING=$(pkgbase $1) + # Check for old style package name with one segment: + if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then + echo $STRING + else # has more than one dash delimited segment + # Count number of segments: + INDEX=1 + while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do + INDEX=$(expr $INDEX + 1) + done + INDEX=$(expr $INDEX - 1) # don't include the null value + # If we don't have four segments, return the old-style (or out of spec) package name: + if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then + echo $STRING + else # we have four or more segments, so we'll consider this a new-style name: + NAME=$(expr $INDEX - 3) + NAME="$(echo $STRING | cut -f 1-$NAME -d -)" + echo $NAME + fi + fi +} + +# Export source through svn to directory +export_source() { + # $1 is svn source directory + # $2 is exported destination + [ -z "$1" -o -z "$2" ] && return 1; + local EXPORTDEST=$2 + echo -n "Exporting source for "; echogreen "$(basename $EXPORTDEST)" ; echo -n ": " ; + mkdir -p $EXPORTDEST || return 1 + + if [ -x /usr/bin/rsync ]; then + rsync -C -r $1/ $EXPORTDEST/source/ || { + echo ; echo "* Error: Failed to export source." + return 1 + } + echo "Done export." + + # Clean up the export a bit + find $EXPORTDEST/source \( -name ".buildlist" \ + -o -name ".setlist" \ + -o -name ".ignore" \ + -o -name "tagfile" \ + -o -name "rebuild.list" \ + -o -name "*.info" \) \ + -exec rm -rf {} \; || return 1 + else + echo "You need rsync in order to export the source." + return 1 + fi; + + make_filelist_txt $EXPORTDEST/source $EXPORTDEST/source "FILE_LIST" && + make_checksums_md5 $EXPORTDEST/source $EXPORTDEST/source || return 1 +} diff --git a/gsb/gsb.SlackBuild-1.3 b/gsb/gsb.SlackBuild-1.3 new file mode 100644 index 0000000..5d786eb --- /dev/null +++ b/gsb/gsb.SlackBuild-1.3 @@ -0,0 +1,191 @@ +#!/bin/bash +# Version: 1.3 GSB SlackBuild. +# Copyright (c) 2007 Darren 'Tadgy' Austin +# +# Licenced under the terms of the GNU General Public Licence version 3. +# + +# The default list of GSB sections, in the order they should be processed. +SECTIONS="${SECTIONS:- tools + libraries + platform + desktop + applications + accessibility + bindings + office + mono + extras + themes + compiz }" + +# Usage. +function usage() { + cat << EOF +Usage: ${0##*/} [options] + +Options: + -help Show this help screen. + + -list For each of the GSB sections, list the packages which + will be built. When the SECTIONS environment variable + is set (see README) only those sections are displayed. + + -force A package will not be built if a package of the same + name is already installed, or any of the pre-requisite + packages are not installed. This option over-rides + the checks and attempts a build (which will probably + fail) anyway. + + -no-skip During the build process, packages that are up to date + (ie, the package version and build numbers match the + coresponding SlackBuild) will not be rebuilt. This + option forces packages to be rebuilt regardless of the + version and build numbers. This does not affect the + pre-build checks for installed packages (see -force). + + -no-metafiles Do not create the .txt and .md5 files for each package + which would usually be produced during a build. + + -no-prune Normally, when a package is built and copied to the + destination directory, any previous package(s) of the + same name are deleted - it is assumed the new package + is to replace any which were built previously. + This option prevents previous packages being deleted + from the destination directory, possibly leaving more + than one package of the same name (but with different + version or build numbers) laying around. + + -no-cleanup By default, any source, temporary build and package + directories will be deleted once the package is built. + This option prevents those files from being removed. + + -no-install Build packages but don't install them. This should + only be used for testing individual SlackBuilds as it + WILL cause serious problems - some package builds may + rely on another package being auto installed first. + + Options are passed down to the next level SlackBuild where appropriate. +EOF +} + +function list_packages() { + echo "The sections and packages below (listed in processing order) will be built." + for SECTION in $SECTIONS + do + echo + echo " $SECTION:" + echo "$( $SECTION/gsb.$SECTION.SlackBuild --list | cut -d$'\n' -f2- )" + done +} + +function runtime() { + # $1 = Number of seconds to convert to readable text + + local D=$(( $1 / 86400 )) + local H=$(( ($1 - ($D * 86400)) / 3600 )) + local M=$(( ($1 - ($D * 86400) - ($H * 3600)) / 60 )) + local S=$(( $1 - ($D * 86400) - ($H * 3600) - ($M * 60) )) + + if [ $D -gt 0 ]; then + echo -n "${D}d, ${H}h ${M}m ${S}s" + else + echo -n "${H}h, ${M}m ${S}s" + fi + return 0 +} + +# Make sure we are in the right directory (you can never trust users..) +cd $( cd ${BASH_SOURCE%/*} ; pwd ) + +# If the user created an options file, read it. +[ -r ./gsb.options ] && { + . ./gsb.options + export OPTIONSREAD=1 +} + +# Environment. +export TMP=${TMP:-/tmp} +export PKGDEST=${PKGDEST:-$TMP/gsb-tree/packages} +export LOGSDIR=${LOGSDIR:-$TMP/gsb-buildlogs} + +# Parse command line arguments. +while [ $# -gt 0 ]; do + if [ "$1" = "-help" ] || [ "$1" = "--help" ]; then + usage + exit 0 + elif [ "$1" = "-list" ] || [ "$1" = "--list" ]; then + list_packages + exit 0 + elif [ "$1" = "-force" ] || [ "$1" = "--force" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}-force" + shift + elif [ "$1" = "-no-skip" ] || [ "$1" = "--no-skip" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}-no-skip" + shift + elif [ "$1" = "-no-metafiles" ] || [ "$1" = "--no-metafiles" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}-no-metafiles" + shift + elif [ "$1" = "-no-prune" ] || [ "$1" = "--no-prune" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}-no-prune" + shift + elif [ "$1" = "-no-cleanup" ] || [ "$1" = "--no-cleanup" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}-no-cleanup" + shift + elif [ "$1" = "-no-install" ] || [ "$1" = "--no-install" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}-no-install" + shift + else + echo "${0##*/}: Unknown option: $1" + echo "Try: $0 -help" + exit 1 + fi +done + +# Temporary space, package and log file storage. +mkdir -p $TMP +mkdir -p $PKGDEST +mkdir -p $LOGSDIR + +# Make sure /usr/include/db.h points to the db4 header. +( cd /usr/include ; rm -f db.h ; ln -s db4/db.h db.h ) || { + echo "${0##*/}: Could not set db.h header" + exit 1 +} + +# Do the build. +( echo + echo "*********************************************************************" + echo "* Building GSB - this may take a while..." + echo "*********************************************************************" + + for SECTION in $SECTIONS + do + ( cd $SECTION && ./gsb.$SECTION.SlackBuild $SLACKBUILD_ARGS 2>&1 ) || { + echo + echo "*********************************************************************" + echo "* Build aborted: error building in section '$SECTION'." + echo "* Check the build logs in '$LOGSDIR' and try again." + echo "*********************************************************************" + echo "* Build failed after $( runtime $SECONDS )." + echo "*********************************************************************" + exit 1 + } + done + + echo + echo "*********************************************************************" + echo "* Finished building GSB!" + echo "* GSB was sucessfully built and installed on the system." + echo "* See the README file for details on how to start GNOME." + echo "*********************************************************************" + echo "* A copy of all GSB packages can be found in '$PKGDEST'." + echo "* Build logs can be found in '$LOGSDIR'." + echo "* Package files and build logs can be deleted if not required." + echo "*********************************************************************" + echo "* Complete build time was $( runtime $SECONDS )." + echo "*********************************************************************" +) 2>&1 | tee $LOGSDIR/$( basename $0 .SlackBuild )-$( date +%Y%m%d-%H%M%S ).log + +# Return the exit status from the sub-shell, not the tee command. +exit ${PIPESTATUS[0]} diff --git a/gsb/gsb.section.SlackBuild-1.3 b/gsb/gsb.section.SlackBuild-1.3 new file mode 100644 index 0000000..ff577d7 --- /dev/null +++ b/gsb/gsb.section.SlackBuild-1.3 @@ -0,0 +1,359 @@ +#!/bin/bash +# Version: 1.3 GSB Section SlackBuild. +# Copyright (c) 2007 Darren 'Tadgy' Austin +# +# Licenced under the terms of the GNU General Public Licence version 3. +# + +# The list of packages in this section, in the order they should be built. +PACKAGES=" xxx + xxx + xxx " + +# Section name. +# This should not need to be changed unless the auto detection fails. +SECTION="$( echo $0 | cut -d. -f2 )" + +# Usage. +function usage() { + cat << EOF +Usage: ${0##*/} [options] + +Options: + --help Show this help screen. + + --list List the packages which will be built in this section. + + --force A package will not be built if a package of the same + name is already installed, or any of the pre-requisite + packages are not installed. This option over-rides + the checks and attempts a build (which will probably + fail) anyway. + + --no-skip During the build process, packages that are up to date + (ie, the package version and build numbers match the + coresponding SlackBuild) will not be rebuilt. This + option forces packages to be rebuilt regardless of the + version and build numbers. This does not affect the + pre-build checks for installed packages (see --force). + + --no-metafiles Do not create the .txt and .md5 files for each package + which would usually be produced during a build. + + --no-prune Normally, when a package is built and copied to the + destination directory, any previous package(s) of the + same name are deleted - it is assumed the new package + is to replace any which were built previously. + This option prevents previous packages being deleted + from the destination directory, possibly leaving more + than one package of the same name (but with different + version or build numbers) laying around. + + --no-cleanup By default, any source, temporary build and package + directories will be deleted once the package is built. + This option prevents those files from being removed. + + --no-install Build packages but don't install them. This should + only be used for testing individual SlackBuilds as it + WILL cause serious problems - some package builds may + rely on another package being auto installed first. + + Options are passed down to the next level SlackBuild where appropriate. +EOF +} + +function list_packages() { + local PACKAGE + echo "The following packages are built in this section, listed in processing order:" + ( for PACKAGE in $PACKAGES + do + echo -n "$PACKAGE, " + done ) | sed -e 's/, $//' | fmt -w 74 | sed -e 's/^/ /g' +} + +function find_package_files() { + # $1 = Directory to look for files in [required] + # $2 = Package name or regex to match. An empty string matches all. + # $3 = Package version or regex to match. An empty string matches all. + # $4 = Package architecture or regex to match. An empty string matches all. + # $5 = Package build tag or regex to match. An empty string matches all. + # $6 = File extension or regex to match. An empty string means no extension. + # Note: Remember to escape any regex characters used in fixed strings. + + [ -z "$1" ] || [ ! -d "$1" ] && return 1 + ls -1 $1 2>/dev/null | \ + egrep "^(${2:-.*})(-${3:-[^-]*})(-${4:-[^-]*})(-${5:-[^-.]*})($6)$" 2>/dev/null + return $? +} + +function runtime() { + # $1 = Number of seconds to convert to readable text + + local D=$(( $1 / 86400 )) + local H=$(( ($1 - ($D * 86400)) / 3600 )) + local M=$(( ($1 - ($D * 86400) - ($H * 3600)) / 60 )) + local S=$(( $1 - ($D * 86400) - ($H * 3600) - ($M * 60) )) + + if [ $D -gt 0 ]; then + echo -n "${D}d, ${H}h ${M}m ${S}s" + else + echo -n "${H}h, ${M}m ${S}s" + fi + return 0 +} + +function gen_pkg_txt() { + # $1 = Package file to process [required]. + + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + local METAFILE=${1%.tgz}.txt + local SIZES="$( gunzip -l $1 | tail -n 1 | tr -s '[:blank:]' )" + echo "PACKAGE NAME: $( echo $1 | rev | cut -d/ -f1 | rev )" >$METAFILE + echo "PACKAGE LOCATION: $( echo $1 | rev | cut -d/ -f2- | rev )" >>$METAFILE + echo "PACKAGE SIZE (compressed): $(( $( echo \"$SIZES\" | cut -d' ' -f2 ) / 1024 )) K" >>$METAFILE + echo "PACKAGE SIZE (uncompressed): $(( $( echo \"$SIZES\" | cut -d' ' -f3 ) / 1024 )) K" >>$METAFILE + echo "PACKAGE REQUIRED: $( tar zxOf $1 install/slack-required 2>/dev/null | tr '\n' ',' | sed -e 's/,$//' )" >>$METAFILE + echo "PACKAGE CONFLICTS: $( tar zxOf $1 install/slack-conflicts 2>/dev/null | tr '\n' ',' | sed -e 's/,$//' )" >>$METAFILE + echo "PACKAGE SUGGESTS: $( tar zxOf $1 install/slack-suggests 2>/dev/null | tr '\n' ' ' )" >>$METAFILE + echo "PACKAGE DESCRIPTION:" >>$METAFILE + tar xzOf $1 install/slack-desc 2>/dev/null | grep -v "^#" | egrep "[[:alnum:]\+]+\:" >>$METAFILE + return 0 +} + +function gen_pkg_md5() { + # $1 = Package file to process [required]. + + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + local METAFILE=${1%.tgz}.md5 + md5sum $1 >$METAFILE + return 0 +} + +# Make sure we are in the right directory (you can never trust users..) +cd $( cd ${BASH_SOURCE%/*} ; pwd ) + +# If the user created an options file, read it. +[ "$OPTIONSREAD" != "1" -a -r ../gsb.options ] && { + . ../gsb.options + export OPTIONSREAD=1 +} + +# Environment. +export TMP=${TMP:-/tmp} +export PKGDEST=${PKGDEST:-$TMP/gsb-tree/packages} +export LOGSDIR=${LOGSDIR:-$TMP/gsb-buildlogs} + +# Option defaults. +NOSKIP=0 +NOMETAFILES=0 +NOPRUNE=0 +NOINSTALL=0 + +# Sanity check (in case Steve forgets to add packages again :P). +[ $( echo "$PACKAGES" | wc -w ) != \ + $( find . -type d ! -name .svn -maxdepth 1 -mindepth 1 | wc -w ) ] && { + echo + echo "*********************************************************************" + echo "** Error: the number of packages in the PACKAGES list is different + echo "** to the number of package directories in this section. + echo "** Some packages may not have been added to the PACKAGES list. + echo "*********************************************************************" + exit 1 +} + +# Parse command line arguments. +while [ $# -gt 0 ]; do + if [ "$1" = "-help" ] || [ "$1" = "--help" ]; then + usage + exit 0 + elif [ "$1" = "-list" ] || [ "$1" = "--list" ]; then + list_packages + exit 0 + elif [ "$1" = "-force" ] || [ "$1" = "--force" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--force" + shift + elif [ "$1" = "-no-cleanup" ] || [ "$1" = "--no-cleanup" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--no-cleanup" + shift + elif [ "$1" = "-no-skip" ] || [ "$1" = "--no-skip" ]; then + NOSKIP=1 + shift + elif [ "$1" = "-no-metafiles" ] || [ "$1" = "--no-metafiles" ]; then + NOMETAFILES=1 + shift + elif [ "$1" = "-no-prune" ] || [ "$1" = "--no-prune" ]; then + NOPRUNE=1 + shift + elif [ "$1" = "-no-install" ] || [ "$1" = "--no-install" ]; then + NOINSTALL=1 + shift + else + echo "${0##*/}: Unknown option: $1" + echo "Try: $0 --help" + exit 1 + fi +done + +# Temporary space, package and log file storage. +mkdir -p $TMP +mkdir -p $PKGDEST +mkdir -p $LOGSDIR +mkdir -p $PKGDEST/$SECTION +mkdir -p $LOGSDIR/$SECTION + +echo +echo "*********************************************************************" +echo "** Building section '$SECTION'..." +echo "*********************************************************************" + +# Process packages. +( for PACKAGE in $PACKAGES + do + echo + echo "*********************************************************************" + echo "*** Processing package '$PACKAGE'..." + echo "*********************************************************************" + + # Sanity checks. + [ ! -e "$PACKAGE/$PACKAGE.SlackBuild" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE.SlackBuild' not found." + echo "*********************************************************************" + exit 1 + } + [ ! -x "$PACKAGE/$PACKAGE.SlackBuild" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE.SlackBuild' is not executable." + echo "*********************************************************************" + exit 1 + } + + # Get package version and build numbers from the package SlackBuild. + declare PACKAGE_$( egrep -m 1 "^VERSION=.*" $PACKAGE/$PACKAGE.SlackBuild ) + declare PACKAGE_$( egrep -m 1 "^BUILD=.*" $PACKAGE/$PACKAGE.SlackBuild ) + + # Check that we got a version and build. + [ -z "$PACKAGE_VERSION" ] || [ -z "$PACKAGE_BUILD" ] && { + echo + echo "*********************************************************************" + echo "*** Error: failed to get VERSION or BUILD from '$PACKAGE.SlackBuild'" + echo "*********************************************************************" + exit 1 + } + + # Check if the package has been built previously. + SKIP_BUILD=0 + find_package_files "$PKGDEST/$SECTION" "$PACKAGE" "$PACKAGE_VERSION" '' \ + "$PACKAGE_BUILD" "\.tgz" >/dev/null && { + if [ "$NOSKIP" = "0" ]; then + # The package is up to date, no need to rebuild it. + SKIP_BUILD=1 + else + echo + echo "*********************************************************************" + echo "*** Removing '$PACKAGE' package files from tree..." + echo "*********************************************************************" + rm -f $( find_package_files "$PKGDEST/$SECTION" "$PACKAGE" \ + "$PACKAGE_VERSION" '' "$PACKAGE_BUILD" "\.tgz|\.txt|\.md5" | \ + tr '\n' ' ' ) + fi + } + + # Remove the package if it's installed. + # Note: this is done even with an "update" build so that the system is + # refreshed from the package in the tree. + find_package_files "/var/log/packages" "$PACKAGE" '' '' '' '' >/dev/null && { + echo + echo "*********************************************************************" + echo "*** Removing installed package '$PACKAGE'..." + echo "*********************************************************************" + removepkg $PACKAGE + } + + # Build package if required. + if [ "$SKIP_BUILD" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Building package '$PACKAGE'..." + echo "*********************************************************************" + ( cd $PACKAGE && export PKGDEST=$PKGDEST/$SECTION && + ./$PACKAGE.SlackBuild $SLACKBUILD_ARGS 2>&1 ) | \ + tee $LOGSDIR/$SECTION/$PACKAGE-$( date +%Y%m%d-%H%M%S ).log + ERR=${PIPESTATUS[0]} + [ "$ERR" != "0" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE' build failed." + echo "*********************************************************************" + exit $ERR + } + else + echo + echo "*********************************************************************" + echo "*** Skipping build of '$PACKAGE' - package up to date." + echo "*********************************************************************" + fi + + if [ "$NOPRUNE" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Pruning old '$PACKAGE' package files from tree..." + echo "*********************************************************************" + rm -f $( find_package_files "$PKGDEST/$SECTION" "$PACKAGE" '' '' '' '' | \ + grep -v "$( find_package_files "$PKGDEST/$SECTION" "$PACKAGE" \ + "$PACKAGE_VERSION" '' "$PACKAGE_BUILD" "\.tgz" )" | tr '\n' ' ' ) + else + echo + echo "*********************************************************************" + echo "*** Warning: not pruning any old '$PACKAGE' files." + echo "*********************************************************************" + fi + + if [ "$NOMETAFILES" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Creating metafiles for '$PACKAGE'..." + echo "*********************************************************************" + gen_pkg_txt "$( find_package_files "$PKGDEST/$SECTION" "$PACKAGE" \ + "$PACKAGE_VERSION" '' "$PACKAGE_BUILD" "\.tgz" )" && + gen_pkg_md5 "$( find_package_files "$PKGDEST/$SECTION" "$PACKAGE" \ + "$PACKAGE_VERSION" '' "$PACKAGE_BUILD" "\.tgz" )" || { + echo + echo "*********************************************************************" + echo "*** Error: failed to create metafiles for '$PACKAGE'." + echo "*********************************************************************" + exit 1 + } + else + echo + echo "*********************************************************************" + echo "*** Warning: not creating metafiles for '$PACKAGE'." + echo "*********************************************************************" + fi + + if [ "$NOINSTALL" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Installing '$PACKAGE'..." + echo "*********************************************************************" + upgradepkg --install-new $( find_package_files $PKGDEST/$SECTION \ + "$PACKAGE" "$PACKAGE_VERSION" '' "$PACKAGE_BUILD" "\.tgz" ) || { + echo + echo "*********************************************************************" + echo "*** Error: failed to install '$PACKAGE'." + echo "*********************************************************************" + exit 1 + } + else + echo + echo "*********************************************************************" + echo "*** Warning: not installing '$PACKAGE'." + echo "*********************************************************************" + fi + done +) 2>&1 | tee $LOGSDIR/$SECTION-$(date +%Y%m%d-%H%M%S).log + +# Return the exit status from the sub-shell, not the tee command. +exit ${PIPESTATUS[0]} diff --git a/gsb/link b/gsb/link new file mode 100644 index 0000000..b715d29 --- /dev/null +++ b/gsb/link @@ -0,0 +1 @@ +https://github.com/mmwanga/gsb-build-system/ diff --git a/gsb/section.SlackBuild-1.6 b/gsb/section.SlackBuild-1.6 new file mode 100644 index 0000000..c2b8edb --- /dev/null +++ b/gsb/section.SlackBuild-1.6 @@ -0,0 +1,407 @@ +#!/bin/bash +# Version: 1.6 GSB Section SlackBuild. +# Copyright (c) 2007 Darren 'Tadgy' Austin +# +# Licenced under the terms of the GNU General Public Licence version 3. +# + +# Make sure we are in the right directory (you can never trust users..) +cd $( cd ${BASH_SOURCE%/*} ; pwd ) + +# Section name. +# This should not need to be changed unless the auto detection fails. +SECTION="$( basename $( pwd ) )" + +# Packages to build. +# Package list is read in from .buildlist in the current directory, with any +# comments and blank lines removed. +PACKAGES="$( egrep -v "^#|^$" .buildlist | cut -d'#' -f1 )" + +# Usage. +function usage() { + cat << EOF +Usage: ${0##*/} [options] + +Options: + --help Show this help screen. + + --list List the packages which will be built in this section. + + --force A package will not be built if a package of the same + name is already installed, or any of the pre-requisite + packages are not installed. This option over-rides + the checks and attempts a build (which will probably + fail) anyway. + + --no-cleanup By default, any source, temporary build and package + directories will be deleted once the package is built. + This option prevents those files from being removed. + + --no-patchesdir When rebuilding packages which already exist in the + main package directory, the default is to put the new + packages in the patches directory. Using this option + completely disables the use of a patches directory. + + --no-skip During the build process, packages that are up to date + (ie, the package version and build numbers match the + coresponding SlackBuild) will not be rebuilt. This + option forces packages to be rebuilt regardless of the + version and build numbers. This option doesn't affect + the pre-build checks for installed packages (see the + --force option). This option implies --no-patchesdir. + + --no-prune Normally, when a package is built and copied to the + destination directory (whether it be the main package + directory or the patches directory), any previous + package(s) of the same name in that directory are + deleted - it is assumed the new package is to replace + any which are already present. This option prevents + previous packages being deleted, possibly leaving more + than one package of the same name (but with different + version or build numbers) laying around. + + --no-install Build the packages but don't install them afterwards. + This should only be used for testing as it WILL cause + serious problems - most builds rely on other GSB + packages being automatically installed first. + + --no-metafiles Do not create the package's .txt and .md5 meta files + which would usually be produced during a build. + + Options are passed down to the next level SlackBuild where appropriate. +EOF +} + +function list_packages() { + local PACKAGE + echo "The following packages are built in this section, listed in processing order:" + ( for PACKAGE in $PACKAGES + do + echo -n "$PACKAGE, " + done ) | sed -e 's/, $//' | fmt -w 74 | sed -e 's/^/ /g' +} + +function find_package_files() { + # $1 = Directory to look for files in [required] + # $2 = Package name or regex to match. An empty string matches all. + # $3 = Package version or regex to match. An empty string matches all. + # $4 = Package architecture or regex to match. An empty string matches all. + # $5 = Package build tag or regex to match. An empty string matches all. + # $6 = File extension or regex to match. An empty string means no extension. + # Note: Remember to escape any regex characters used in fixed strings. + + [ -z "$1" ] || [ ! -d "$1" ] && return 1 + find $1 -maxdepth 1 -mindepth 1 2>/dev/null | \ + egrep "^.*/(${2:-.*})(-${3:-[^-]*})(-${4:-[^-]*})(-${5:-[^-.]*})($6)$" 2>/dev/null + return $? +} + +function runtime() { + # $1 = Number of seconds to convert to readable text [required] + + [ -z "$1" ] && return 1 + + local D=$(( $1 / 86400 )) + local H=$(( ($1 - ($D * 86400)) / 3600 )) + local M=$(( ($1 - ($D * 86400) - ($H * 3600)) / 60 )) + local S=$(( $1 - ($D * 86400) - ($H * 3600) - ($M * 60) )) + + if [ $D -gt 0 ]; then + echo -n "${D}d, ${H}h ${M}m ${S}s" + else + echo -n "${H}h, ${M}m ${S}s" + fi + return 0 +} + +function gen_pkg_txt() { + # $1 = Package file to process [required]. + + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + tar xzOf $1 install/slack-desc 2>/dev/null | \ + grep -v "^#" | egrep "[[:alnum:]\+]+\:" >${1%.tgz}.txt + return $? +} + +function gen_pkg_md5() { + # $1 = Package file to process [required]. + + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + ( cd $( dirname $1 ) && md5sum $( basename $1 ) >$1.md5 ) + return $? +} + +# If the user created an options file, read it. +[ "$OPTIONSREAD" != "1" -a -r ../gsb.options ] && { + . ../gsb.options + export OPTIONSREAD=1 +} + +# Environment. +export TMP=${TMP:-/tmp} +if [ "$ARCH" = "x86_64" ]; then + export PKGDEST=${PKGDEST:-$TMP/gsb64-tree} + export LOGSDIR=${LOGSDIR:-$TMP/gsb64-buildlogs} +else + export PKGDEST=${PKGDEST:-$TMP/gsb-tree} + export LOGSDIR=${LOGSDIR:-$TMP/gsb-buildlogs} +fi +export GSBDIR=${GSBDIR:-gsb} +export PATCHESDIR=${PATCHESDIR:-patches} +export TESTINGDIR=${TESTINGDIR:-testing} +export PACKAGESDIR=${PACKAGESDIR:-packages} +export SOURCEDIR=${SOURCEDIR:-source} + +# Option defaults. +NOPATCHESDIR=0 +NOSKIP=0 +NOPRUNE=0 +NOINSTALL=0 +NOMETAFILES=0 + +# Sanity check (in case Steve forgets to add packages again :P). +[ $( echo "$PACKAGES" | wc -w ) != \ + $( find . -type d ! -name .svn -maxdepth 1 -mindepth 1 | wc -w ) ] && { + echo + echo "*********************************************************************" + echo "** Error: the number of packages in the PACKAGES list is different" + echo "** to the number of package directories in this section." + echo "** Some packages may not have been added to the PACKAGES list." + echo "*********************************************************************" + exit 1 +} + +# Parse command line arguments. +while [ $# -gt 0 ]; do + if [ "$1" = "-help" ] || [ "$1" = "--help" ]; then + usage + exit 0 + elif [ "$1" = "-list" ] || [ "$1" = "--list" ]; then + list_packages + exit 0 + elif [ "$1" = "-force" ] || [ "$1" = "--force" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--force" + shift + elif [ "$1" = "-no-cleanup" ] || [ "$1" = "--no-cleanup" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--no-cleanup" + shift + elif [ "$1" = "-no-patchesdir" ] || [ "$1" = "--no-patchesdir" ]; then + NOPATCHESDIR=1 + shift + elif [ "$1" = "-no-skip" ] || [ "$1" = "--no-skip" ]; then + NOSKIP=1 + NOPATCHESDIR=1 + shift + elif [ "$1" = "-no-prune" ] || [ "$1" = "--no-prune" ]; then + NOPRUNE=1 + shift + elif [ "$1" = "-no-install" ] || [ "$1" = "--no-install" ]; then + NOINSTALL=1 + shift + elif [ "$1" = "-no-metafiles" ] || [ "$1" = "--no-metafiles" ]; then + NOMETAFILES=1 + shift + else + echo "${0##*/}: Unknown option: $1" + echo "Try: $0 --help" + exit 1 + fi +done + +# Temporary space, package and log file storage. +mkdir -p $TMP +mkdir -p $PKGDEST +mkdir -p $LOGSDIR +mkdir -p $LOGSDIR/$SECTION + +echo +echo "*********************************************************************" +echo "** Building section '$SECTION'..." +echo "*********************************************************************" + +# Process packages. +( for PACKAGE in $PACKAGES + do + # Build defaults. + SKIP_BUILD=0 + SUBDIR=$GSBDIR/$PACKAGESDIR/$SECTION + + echo + echo "*********************************************************************" + echo "*** Processing package '$PACKAGE'..." + echo "*********************************************************************" + + # Sanity checks. + [ ! -e "$PACKAGE/$PACKAGE.SlackBuild" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE.SlackBuild' not found." + echo "*********************************************************************" + exit 1 + } + [ ! -x "$PACKAGE/$PACKAGE.SlackBuild" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE.SlackBuild' is not executable." + echo "*********************************************************************" + exit 1 + } + + # Get package version and build numbers from the package SlackBuild. + declare PACKAGE_$( egrep -m 1 "^VERSION=.*" $PACKAGE/$PACKAGE.SlackBuild ) + declare PACKAGE_$( egrep -m 1 "^BUILD=.*" $PACKAGE/$PACKAGE.SlackBuild ) + + # Check that we got a version and build. + [ -z "$PACKAGE_VERSION" ] || [ -z "$PACKAGE_BUILD" ] && { + echo + echo "*********************************************************************" + echo "*** Error: failed to get VERSION or BUILD from '$PACKAGE.SlackBuild'" + echo "*********************************************************************" + exit 1 + } + + # Check if the package should be rebuilt, and where it should be put. + # The assumption is to always rebuild and put packages in the main + # directory, unless modified by the checks below. + if find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "" "" "" "\.tgz" >/dev/null && [ "$NOSKIP" = "0" ] + then + if find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" >/dev/null + then + # Package with same version/build was found in the main directory. + SKIP_BUILD=1 + else + # Not in the main directory, check patches. + if [ "$NOPATCHESDIR" = "0" ]; then + if find_package_files "$PKGDEST/$PATCHESDIR/$PACKAGESDIR/$SECTION" \ + "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" \ + "\.tgz" >/dev/null + then + # Found in patches dir. + SKIP_BUILD=1 + SUBDIR=$PATCHESDIR/$PACKAGESDIR/$SECTION + else + # No package in patches with the same version/build. + SUBDIR=$PATCHESDIR/$PACKAGESDIR/$SECTION + fi + fi + fi + fi + + # Build package if required. + if [ "$SKIP_BUILD" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Removing installed package (if required) and cleaning up files" + echo "*********************************************************************" + rm -f $( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz|\.txt|\.tgz\.md5" \ + | tr '\n' ' ' ) >/dev/null 2>&1 + find_package_files "/var/log/packages" "${PACKAGE//+/\+}" "" "" "" "" \ + >/dev/null && { + removepkg $( basename $( find_package_files "/var/log/packages" \ + "${PACKAGE//+/\+}" "" "" "" "" ) ) + } + + echo + echo "*********************************************************************" + echo "*** Building package '$PACKAGE'..." + echo "*********************************************************************" + mkdir -p $PKGDEST/$SUBDIR + ( cd $PACKAGE && export PKGDEST=$PKGDEST/$SUBDIR && + ./$PACKAGE.SlackBuild $SLACKBUILD_ARGS 2>&1 ) | \ + tee $LOGSDIR/$SECTION/$PACKAGE-$( date +%Y%m%d-%H%M%S ).log + ERR=${PIPESTATUS[0]} + [ "$ERR" != "0" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE' build failed." + echo "*********************************************************************" + exit $ERR + } + else + echo + echo "*********************************************************************" + echo "*** Skipping build of '$PACKAGE' - package up to date." + echo "*********************************************************************" + fi + + PRUNE_FILES="$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "" "" "" "\.tgz|\.txt|\.tgz\.md5" | grep -v "$( find_package_files \ + "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" \ + "$PACKAGE_BUILD" "\.tgz" )" | tr '\n' ' ' )" + [ ! -z "$PRUNE_FILES" ] && { + if [ "$NOPRUNE" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Pruning old '$PACKAGE' package files from tree..." + echo "*********************************************************************" + rm -f $PRUNE_FILES + else + echo + echo "*********************************************************************" + echo "*** Warning: not pruning any old '$PACKAGE' files." + echo "*********************************************************************" + fi + } + + if [ "$NOMETAFILES" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Creating meta files for '$PACKAGE'..." + echo "*********************************************************************" + gen_pkg_txt "$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" )" && + gen_pkg_md5 "$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" )" || { + echo + echo "*********************************************************************" + echo "*** Error: failed to create meta files for '$PACKAGE'." + echo "*********************************************************************" + exit 1 + } + else + echo + echo "*********************************************************************" + echo "*** Warning: not creating meta files for '$PACKAGE'." + echo "*********************************************************************" + fi + + if [ "$NOINSTALL" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Installing '$PACKAGE'..." + echo "*********************************************************************" + upgradepkg --install-new $( find_package_files "$PKGDEST/$SUBDIR" \ + "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" ) || { + echo + echo "*********************************************************************" + echo "*** Error: failed to install '$PACKAGE'." + echo "*********************************************************************" + exit 1 + } + else + echo + echo "*********************************************************************" + echo "*** Warning: not installing '$PACKAGE'." + echo "*********************************************************************" + fi + done + + echo + echo "*********************************************************************" + echo "** Finished building section '$SECTION'." + echo "*********************************************************************" + echo "** Binary packages can be found in sub directories of:" + echo "** $PKGDEST" + echo "** Individual build logs can be found in:" + echo "** $LOGSDIR/$SECTION" + echo "** Package files and build logs can be deleted if not required." + echo "*********************************************************************" + echo "** Section build time was $( runtime $SECONDS )." + echo "*********************************************************************" +) 2>&1 | tee $LOGSDIR/$SECTION-$(date +%Y%m%d-%H%M%S).log + +# Return the exit status from the sub-shell, not the tee command. +exit ${PIPESTATUS[0]} diff --git a/gsb/section.SlackBuild-1.7 b/gsb/section.SlackBuild-1.7 new file mode 100644 index 0000000..2be2b1c --- /dev/null +++ b/gsb/section.SlackBuild-1.7 @@ -0,0 +1,422 @@ +#!/bin/bash +# Version: 1.7 GSB Section SlackBuild - Do not remove this line! +# Copyright (c) 2007, 2008: +# Darren 'Tadgy' Austin , Coventry, UK. +# Licenced under the terms of the GNU General Public Licence version 3. +# + +# Make sure we are in the right directory (you can never trust users..) +cd $( cd ${BASH_SOURCE%/*} ; pwd ) + +# Section name. +# This should not need to be changed unless the auto detection fails. +SECTION="$( basename $( pwd ) )" + +# Packages to build. +# The package list is read in from .buildlist in the current directory, with +# any comments and blank lines removed. +PACKAGES="$( egrep -v "^#|^$" .buildlist | cut -d'#' -f1 )" + +# The meta package(s) for this section, in the order they should be processed. +METAPACKAGES="gsb-$SECTION" + + +# Usage. +function usage() { + cat << EOF +Usage: ${0##*/} [options] + +Options: + --help Show this help screen. + + --list List the packages which will be built in this section. + + --force A package will not be built if a package of the same + name is already installed, or any of the pre-requisite + packages are not installed. This option over-rides + the checks and attempts a build (which will probably + fail) anyway. + + --no-cleanup By default, any source, temporary build and package + directories will be deleted once the package is built. + This option prevents those files from being removed. + + --no-patchesdir When rebuilding packages which already exist in the + main package directory, the default is to put the new + packages in the patches directory. Using this option + completely disables the use of a patches directory. + + --no-skip During the build process, packages that are up to date + (ie, the package version and build numbers match the + coresponding SlackBuild) will not be rebuilt. This + option forces packages to be rebuilt regardless of the + version and build numbers. This option doesn't affect + the pre-build checks for installed packages (see the + --force option). This option implies --no-patchesdir. + + --no-prune Normally, when a package is built and copied to the + destination directory (whether it be the main package + directory or the patches directory), any previous + package(s) of the same name in that directory are + deleted - it is assumed the new package is to replace + any which are already present. This option prevents + previous packages being deleted, possibly leaving more + than one package of the same name (but with different + version or build numbers) laying around. + + --no-install Build the packages but don't install them afterwards. + This should only be used for testing as it WILL cause + serious problems - most builds rely on other GSB + packages being automatically installed first. + + --no-metapackages Do not create the slapt-get meta packages for each of + the GSB sections, or the general purpose meta packages + used for installation (eg, gsb-complete, gsb-libs). + + --no-metafiles Do not create the package's .txt and .md5 meta files + which would usually be produced during a build. + + Options are passed down to the next level SlackBuild where appropriate. +EOF +} + +function list_packages() { + local PACKAGE + echo "The following packages are built in this section, listed in processing order:" + + ( for PACKAGE in $PACKAGES $( if [ "$NOMETAPACKAGES" = "0" ]; then \ + echo "$METAPACKAGES"; fi ) + do + echo -n "$PACKAGE, " + done ) | sed -e 's/, $//' | fmt -w 74 | sed -e 's/^/ /g' +} + +function find_package_files() { + # $1 = Directory to look for files in [required] + # $2 = Package name or regex to match. An empty string matches all. + # $3 = Package version or regex to match. An empty string matches all. + # $4 = Package architecture or regex to match. An empty string matches all. + # $5 = Package build tag or regex to match. An empty string matches all. + # $6 = File extension or regex to match. An empty string means no extension. + # Note: Remember to escape any regex characters used in fixed strings. + + [ -z "$1" ] || [ ! -d "$1" ] && return 1 + find $1 -maxdepth 1 -mindepth 1 2>/dev/null | \ + egrep "^.*/(${2:-.*})(-${3:-[^-]*})(-${4:-[^-]*})(-${5:-[^-.]*})($6)$" 2>/dev/null + return $? +} + +function runtime() { + # $1 = Number of seconds to convert to readable text [required] + + [ -z "$1" ] && return 1 + + local D=$(( $1 / 86400 )) + local H=$(( ($1 - ($D * 86400)) / 3600 )) + local M=$(( ($1 - ($D * 86400) - ($H * 3600)) / 60 )) + local S=$(( $1 - ($D * 86400) - ($H * 3600) - ($M * 60) )) + + if [ $D -gt 0 ]; then + echo -n "${D}d, ${H}h ${M}m ${S}s" + else + echo -n "${H}h, ${M}m ${S}s" + fi + return 0 +} + +function gen_pkg_txt() { + # $1 = Package file to process [required]. + + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + tar xzOf $1 install/slack-desc 2>/dev/null | \ + grep -v "^#" | egrep "[[:alnum:]\+]+\:" >${1%.tgz}.txt + return $? +} + +function gen_pkg_md5() { + # $1 = Package file to process [required]. + + [ -z "$1" ] || [ ! -e "$1" ] && return 1 + ( cd $( dirname $1 ) && md5sum $( basename $1 ) >$1.md5 ) + return $? +} + +# If the user created an options file, read it. +[ "$OPTIONSREAD" != "1" -a -r ../gsb.options ] && { + . ../gsb.options + export OPTIONSREAD=1 +} + +# Environment. +export TMP=${TMP:-/tmp} +if [ "$ARCH" = "x86_64" ]; then + export PKGDEST=${PKGDEST:-$TMP/gsb64-tree} + export LOGSDIR=${LOGSDIR:-$TMP/gsb64-buildlogs} +else + export PKGDEST=${PKGDEST:-$TMP/gsb-tree} + export LOGSDIR=${LOGSDIR:-$TMP/gsb-buildlogs} +fi +export GSBDIR=${GSBDIR:-gsb} +export PATCHESDIR=${PATCHESDIR:-patches} +export TESTINGDIR=${TESTINGDIR:-testing} +export PACKAGESDIR=${PACKAGESDIR:-packages} +export SOURCEDIR=${SOURCEDIR:-source} + +# Option defaults. +NOPATCHESDIR=0 +NOSKIP=0 +NOPRUNE=0 +NOINSTALL=0 +NOMETAPACKAGES=0 +NOMETAFILES=0 + +# Sanity check (in case Steve forgets to add packages again :P). +[ $( echo "$PACKAGES $METAPACKAGES" | wc -w ) != \ + $( find . -type d ! -name .svn -maxdepth 1 -mindepth 1 | wc -w ) ] && { + echo + echo "*********************************************************************" + echo "** Error: the number of packages in the .buildlist is different" + echo "** to the number of package directories in this section." + echo "** Some packages may not have been added to the .buildlist." + echo "*********************************************************************" + exit 1 +} + +# Parse command line arguments. +while [ $# -gt 0 ]; do + if [ "$1" = "-help" ] || [ "$1" = "--help" ]; then + usage + exit 0 + elif [ "$1" = "-list" ] || [ "$1" = "--list" ]; then + list_packages + exit 0 + elif [ "$1" = "-force" ] || [ "$1" = "--force" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--force" + shift + elif [ "$1" = "-no-cleanup" ] || [ "$1" = "--no-cleanup" ]; then + SLACKBUILD_ARGS="${SLACKBUILD_ARGS:+"$SLACKBUILD_ARGS "}--no-cleanup" + shift + elif [ "$1" = "-no-patchesdir" ] || [ "$1" = "--no-patchesdir" ]; then + NOPATCHESDIR=1 + shift + elif [ "$1" = "-no-skip" ] || [ "$1" = "--no-skip" ]; then + NOSKIP=1 + NOPATCHESDIR=1 + shift + elif [ "$1" = "-no-prune" ] || [ "$1" = "--no-prune" ]; then + NOPRUNE=1 + shift + elif [ "$1" = "-no-install" ] || [ "$1" = "--no-install" ]; then + NOINSTALL=1 + shift + elif [ "$1" = "-no-metapackages" ] || [ "$1" = "--no-metapackages" ]; then + NOMETAPACKAGES=1 + shift + elif [ "$1" = "-no-metafiles" ] || [ "$1" = "--no-metafiles" ]; then + NOMETAFILES=1 + shift + else + echo "${0##*/}: Unknown option: $1" + echo "Try: $0 --help" + exit 1 + fi +done + +# Temporary space, package and log file storage. +mkdir -p $TMP +mkdir -p $PKGDEST +mkdir -p $LOGSDIR +mkdir -p $LOGSDIR/$SECTION + +echo +echo "*********************************************************************" +echo "** Building section '$SECTION'..." +echo "*********************************************************************" + +# Process packages. +( for PACKAGE in $PACKAGES $( if [ "$NOMETAPACKAGES" = "0" ]; then \ + echo "$METAPACKAGES"; fi ) + do + # Build defaults. + SKIP_BUILD=0 + SUBDIR=$GSBDIR/$PACKAGESDIR/$SECTION + + echo + echo "*********************************************************************" + echo "*** Processing package '$PACKAGE'..." + echo "*********************************************************************" + + # Sanity checks. + [ ! -e "$PACKAGE/$PACKAGE.SlackBuild" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE.SlackBuild' not found." + echo "*********************************************************************" + exit 1 + } + [ ! -x "$PACKAGE/$PACKAGE.SlackBuild" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE.SlackBuild' is not executable." + echo "*********************************************************************" + exit 1 + } + + # Get package version and build numbers from the package SlackBuild. + declare PACKAGE_$( egrep -m 1 "^VERSION=.*" $PACKAGE/$PACKAGE.SlackBuild ) + declare PACKAGE_$( egrep -m 1 "^BUILD=.*" $PACKAGE/$PACKAGE.SlackBuild ) + + # Check that we got a version and build. + [ -z "$PACKAGE_VERSION" ] || [ -z "$PACKAGE_BUILD" ] && { + echo + echo "*********************************************************************" + echo "*** Error: failed to get VERSION or BUILD from '$PACKAGE.SlackBuild'" + echo "*********************************************************************" + exit 1 + } + + # Check if the package should be rebuilt, and where it should be put. + # The assumption is to always rebuild and put packages in the main + # directory, unless modified by the checks below. + if find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "" "" "" "\.tgz" >/dev/null && [ "$NOSKIP" = "0" ] + then + if find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" >/dev/null + then + # Package with same version/build was found in the main directory. + SKIP_BUILD=1 + else + # Not in the main directory, check patches. + if [ "$NOPATCHESDIR" = "0" ]; then + if find_package_files "$PKGDEST/$PATCHESDIR/$PACKAGESDIR/$SECTION" \ + "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" \ + "\.tgz" >/dev/null + then + # Found in patches dir. + SKIP_BUILD=1 + SUBDIR=$PATCHESDIR/$PACKAGESDIR/$SECTION + else + # No package in patches with the same version/build. + SUBDIR=$PATCHESDIR/$PACKAGESDIR/$SECTION + fi + fi + fi + fi + + # Build package if required. + if [ "$SKIP_BUILD" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Removing installed package (if required) and cleaning up files" + echo "*********************************************************************" + rm -f $( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz|\.txt|\.tgz\.md5" \ + | tr '\n' ' ' ) >/dev/null 2>&1 + find_package_files "/var/log/packages" "${PACKAGE//+/\+}" "" "" "" "" \ + >/dev/null && { + removepkg $( basename $( find_package_files "/var/log/packages" \ + "${PACKAGE//+/\+}" "" "" "" "" ) ) + } + + echo + echo "*********************************************************************" + echo "*** Building package '$PACKAGE'..." + echo "*********************************************************************" + mkdir -p $PKGDEST/$SUBDIR + ( cd $PACKAGE && export PKGDEST=$PKGDEST/$SUBDIR && + ./$PACKAGE.SlackBuild $SLACKBUILD_ARGS 2>&1 ) | \ + tee $LOGSDIR/$SECTION/$PACKAGE-$( date +%Y%m%d-%H%M%S ).log + ERR=${PIPESTATUS[0]} + [ "$ERR" != "0" ] && { + echo + echo "*********************************************************************" + echo "*** Error: '$PACKAGE' build failed." + echo "*********************************************************************" + exit $ERR + } + else + echo + echo "*********************************************************************" + echo "*** Skipping build of '$PACKAGE' - package up to date." + echo "*********************************************************************" + fi + + PRUNE_FILES="$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "" "" "" "\.tgz|\.txt|\.tgz\.md5" | grep -v "$( find_package_files \ + "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" \ + "$PACKAGE_BUILD" "\.tgz" )" | tr '\n' ' ' )" + [ ! -z "$PRUNE_FILES" ] && { + if [ "$NOPRUNE" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Pruning old '$PACKAGE' package files from tree..." + echo "*********************************************************************" + rm -f $PRUNE_FILES + else + echo + echo "*********************************************************************" + echo "*** Warning: not pruning any old '$PACKAGE' files." + echo "*********************************************************************" + fi + } + + if [ "$NOMETAFILES" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Creating meta files for '$PACKAGE'..." + echo "*********************************************************************" + gen_pkg_txt "$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" )" && + gen_pkg_md5 "$( find_package_files "$PKGDEST/$SUBDIR" "${PACKAGE//+/\+}" \ + "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" )" || { + echo + echo "*********************************************************************" + echo "*** Error: failed to create meta files for '$PACKAGE'." + echo "*********************************************************************" + exit 1 + } + else + echo + echo "*********************************************************************" + echo "*** Warning: not creating meta files for '$PACKAGE'." + echo "*********************************************************************" + fi + + if [ "$NOINSTALL" = "0" ]; then + echo + echo "*********************************************************************" + echo "*** Installing '$PACKAGE'..." + echo "*********************************************************************" + upgradepkg --install-new $( find_package_files "$PKGDEST/$SUBDIR" \ + "${PACKAGE//+/\+}" "${PACKAGE_VERSION//-/_}" "" "$PACKAGE_BUILD" "\.tgz" ) || { + echo + echo "*********************************************************************" + echo "*** Error: failed to install '$PACKAGE'." + echo "*********************************************************************" + exit 1 + } + else + echo + echo "*********************************************************************" + echo "*** Warning: not installing '$PACKAGE'." + echo "*********************************************************************" + fi + done + + echo + echo "*********************************************************************" + echo "** Finished building section '$SECTION'." + echo "*********************************************************************" + echo "** Binary packages can be found in sub directories of:" + echo "** $PKGDEST" + echo "** Individual build logs can be found in:" + echo "** $LOGSDIR/$SECTION" + echo "** Package files and build logs can be deleted if not required." + echo "*********************************************************************" + echo "** Section build time was $( runtime $SECONDS )." + echo "*********************************************************************" +) 2>&1 | tee $LOGSDIR/$SECTION-$(date +%Y%m%d-%H%M%S).log + +# Return the exit status from the sub-shell, not the tee command. +exit ${PIPESTATUS[0]}