diff --git a/src/etc/sbopkg/sbopkg.conf.sample b/src/etc/sbopkg/sbopkg.conf.sample index d513816..6afa23e 100644 --- a/src/etc/sbopkg/sbopkg.conf.sample +++ b/src/etc/sbopkg/sbopkg.conf.sample @@ -3,4 +3,5 @@ RSYNCMIRROR=slackbuilds.org::slackbuilds SLACKVER=12.0 LOCALREPO=/home/sbo +SRCDIR=/var/cache/sbopkg KEEPLOG=YES diff --git a/src/usr/bin/sbopkg b/src/usr/bin/sbopkg index b292cbb..a10f149 100755 --- a/src/usr/bin/sbopkg +++ b/src/usr/bin/sbopkg @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -x # # $Id$ # @@ -40,7 +40,12 @@ else RSYNCMIRROR=`grep RSYNCMIRROR $CONF | sed -e s/RSYNCMIRROR=//` SLACKVER=`grep SLACKVER $CONF | sed -e s/SLACKVER=//` LOCALREPO=`grep LOCALREPO $CONF | sed -e s/LOCALREPO=//` + SRCDIR=`grep SRCDIR $CONF | sed -e s/SRCDIR=//` LOGS=`grep KEEPLOG $CONF | sed -e s/KEEPLOG=//` + if [ ! -d "$SRCDIR" ]; then + echo "Creating local cache directory $SRCDIR to keep downloaded sources." + mkdir -p $SRCDIR + fi fi } @@ -203,11 +208,11 @@ function rsync_repo # This function does the rsync with SBo. if [ "$DIAG" = 1 ]; then OUTPUT=/tmp/sbopkg_output - ( /usr/bin/rsync -avz $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ >> $OUTPUT & ) 2>>$OUTPUT + ( /usr/bin/rsync -avz --delete $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ >> $OUTPUT & ) 2>>$OUTPUT dialog --backtitle "Rsyncing with SlackBuilds.org" --tailbox $OUTPUT 20 70 rm -f $OUTPUT else - /usr/bin/rsync -avz $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ + /usr/bin/rsync -avz --delete $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ fi } @@ -227,10 +232,9 @@ if [ ! `find -name "$PKG"` ]; then exit 0 fi fi -TESTPKGNAME=`echo $PKG | sed 's/.*\///'` PKGNAME=`echo $PKG | sed 's/.*\///'` DNLD=`grep DOWNLOAD $PKGPATH/$PKG.info | sed -e s/DOWNLOAD=// | sed -e s/\"//g` -SRCNAME=`echo $DNLD | sed 's/.*\///'` +SRCTARBALL=`echo $DNLD | sed 's/.*\///'` MD5=`grep MD5SUM $PKGPATH/$PKG.info | sed -e s/MD5SUM=// | sed -e s/\"//g` } @@ -241,25 +245,43 @@ function show_readme exit 0 } +function get_tarball +{ +# Check to see if the source tarball exists in the local cache +# directory. If it does, make a symlink to the package directory in +# the local mirror. If it does not, download it and make the link. +# Thanks to Robby Workman for this idea. + if [ ! -e $PKGPATH/$SRCTARBALL ]; then + if [ -e $SRCDIR/$SRCTARBALL ]; then + ln -s $SRCDIR/$SRCTARBALL $LOCALREPO/$SLACKVER/$PKGPATH/$SRCTARBALL + else + cd $SRCDIR + wget -T 20 $DNLD || exit 1 + cd - + ln -s $SRCDIR/$SRCTARBALL $LOCALREPO/$SLACKVER/$PKGPATH/$SRCTARBALL + fi + fi +} + function build_package () { # Start fetching and building the package. -echo ; echo "Building $PKG" +#echo ; echo "Building $PKG" cd $PKGPATH -if [ ! -e "$SRCNAME" ]; - then echo "Downloading source code for "$SRCNAME"..." - wget -T 20 $DNLD || exit 1 - #curl $DNLD || exit 1 -fi -echo "Checking MD5SUM for "$SRCNAME"..." -MD5CHK=`md5sum $SRCNAME | sed -e 's/ .*$//'` +get_tarball +#if [ ! -e "$SRCNAME" ]; +# then echo "Downloading source code for "$SRCNAME"..." +# wget -T 20 $DNLD || exit 1 +#fi +echo "Checking MD5SUM for "$SRCTARBALL"..." +MD5CHK=`md5sum $SRCTARBALL | sed -e 's/ .*$//'` if [ "$MD5CHK" == $MD5 ]; then echo "OK" else echo "MD5SUM check failed. Exiting." continue fi -echo "Building Slackware package for "$SRCNAME"..." +echo "Building Slackware package for "$SRCTARBALL"..." sh $PKG.SlackBuild echo "Done building $PKG." cd $LOCALREPO/$SLACKVER @@ -381,7 +403,6 @@ if [ -n "$BUILD" ]; then exit 0 fi for PKGBUILD in ${BUILD}; do - echo "Building $PKGBUILD" search_package $PKGBUILD build_package $PKGBUILD done