initial code to create cache directory to store sources; add function to get the tarball if it does not exist and then create a symlink to the package directory; add --delete to rsync calls; minor cleanups; add -x to script for debugging; added SRCDIR to sbopkg.conf.sample

This commit is contained in:
chess.griffin 2008-03-25 03:35:06 +00:00
parent ee8f8483aa
commit 40eb44a179
2 changed files with 37 additions and 15 deletions

View File

@ -3,4 +3,5 @@
RSYNCMIRROR=slackbuilds.org::slackbuilds
SLACKVER=12.0
LOCALREPO=/home/sbo
SRCDIR=/var/cache/sbopkg
KEEPLOG=YES

View File

@ -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