#!/bin/sh # BuildSBO script v0.2 2007-07-02 # by Chess Griffin {chess at chessgriffin dot com} # # This script is intended to be used with the Slackbuilds.org # repository of Slackware build scripts. The script can rsync with a # Slackbuilds.org repository and also build one or more packages # from the mirrored slackbuilds. The build process includes downloading # the source code, checking the MD5SUM, and then running the appropriate # slackbuild script. Since this script calls the slackbuild process, # this script needs to be run as root. # # Example 1: ./buildsbo -l /home/user/sbo -r # # This will rsync with Slackbuilds.org into the local mirror directory # of /home/user/sbo and then exit. The -l is optional as you can set # the local mirror directory in the "Configurable Options" section # below. # # Example 2: ./buildsbo foo foo2 # # This will fetch and build foo and foo2 in that order from your local # Slackbuilds.org repository. # # Changelog: # v0.1 2007-06-22 Initial release # v0.2 2007-07-02 Updated for Slackware 12; can now use with # different versions of Slackbuilds.org repos; # added ability to create the local mirror dir; # added ability to build more than 1 package # at a time. # Start Configurable Options # # This is the location of your local Slackbuilds.org mirror. # This can be overridden with the -l option LOCALMIRROR=/home/sbo/ # This is the version of Slackware Slackbuilds.org scripts # you wish to use. A command line option to change Slackware version # will probably be in an updated version of this script. SLACKRELEASE=12.0 # # End Configurable Options - No changes should be necessary below. # BuildSBO version number VER=0.2 # Usage while getopts ":hl:r" OPT do case $OPT in h ) echo "BuildSBO v$VER by Chess Griffin" echo "Usage: $0 [OPTIONS] " echo "Options are:" echo " -h Display this help message." echo " -l localdir Location of local Slackbuilds.org mirror." echo " This is currently set to" echo " $LOCALMIRROR." echo " -r Rsync the Slackbuilds.org respository with" echo " the local mirror and then quit." exit ;; l ) LOCALMIRROR=${OPTARG} ;; r ) RSY=1 ;; * ) echo "No options given. Run '$0 -h' for help. Exiting." exit ;; esac done # End of option parsing. shift $(($OPTIND - 1)) # Check to make sure $LOCALMIRROR exists and if not, offer to make it if [ ! -e "$LOCALMIRROR" ]; then echo "The local mirror directory at $LOCALMIRROR does not exist. Do you want to create it? [y/N]" read -s -n 1 ANSWER if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ]; then mkdir -p $LOCALMIRROR echo "$LOCALMIRROR created. Exiting." elif [ "$ANSWER" == "n" ] || [ "$ANSWER" == "N" ]; then echo "$LOCALMIRROR not created. Exiting." exit else exit fi fi CWD=$PWD cd $LOCALMIRROR # Do rsync of Slackbuilds.org into $LOCALMIRROR if -r is used, and then exit if [ -n "$RSY" ]; then echo "Rsyncing with Slackbuilds.org repository into $LOCALMIRROR." /usr/bin/rsync -avz slackbuilds.org::slackbuilds/$SLACKRELEASE/ $LOCALMIRROR/$SLACKRELEASE/ echo "Done." exit fi # Start a loop for each package name for PKGSTEP in $*; do # Additional variables for this section PKG=$PKGSTEP PKGPATH=`find -name $PKG` PKGNAME=`echo $PKG | sed 's/.*\///'` DNLD=`grep DOWNLOAD $PKGPATH/$PKG.info | sed -e s/DOWNLOAD=//` SRCNAME=`echo $DNLD | sed 's/.*\///'` MD5=`grep MD5SUM $PKGPATH/$PKG.info | sed -e s/MD5SUM=//` # Search for package name and exit if not found if [ ! `find -name "$PKG"` ]; then echo "Slackbuild script for $PKG not found. Exiting." exit fi # Start fetching and building echo "Building $PKG" cd $PKGPATH if [ ! -e "$SRCNAME" ]; then echo "Downloading source code for "$SRCNAME"..." wget $DNLD || exit 1 fi echo "Checking MD5SUM for "$SRCNAME"..." MD5CHK=`md5sum $SRCNAME | sed -e 's/ .*$//'` if [ "$MD5CHK" == $MD5 ]; then echo "OK" else echo "MD5SUM check failed. Exiting." exit fi echo "Building Slackware package for "$SRCNAME"..." sh $PKG.SlackBuild echo "Done building $PKG." cd $LOCALMIRROR done # end of loop cd $CWD echo "All done." exit