Christopher Gregory wrote:
Hello,
I have finally overcome my 20 year hatred of scripts and am in the
process of creating bash scripts for all the packages in BLFS.
As packages get upgraded all the time, what I need to do is to have wild
cards to match the package tarballs. I have achieved that with regards
to the below example, however some packages have additional characters
such as boost has boost_1_56_0.tar.bz2 so the wild card match of ? would
not work in this case.
I have not been able to work out how to do a match for this type of
file.
Could someone please assist in this? I only want to know how to do it
in bash thanks.
#!/bin/bash
export PROGRAM=apr-1.5.?
tar -xvf $PROGRAM.tar.?z*
pushd $PROGRAM
./configure --prefix=/usr \
--disable-static \
--with-installbuilddir=/usr/share/apr-1/build &&
make -j2 &&
make install
popd
rm -rf $PROGRAM
Here is what I use:
$ cat make-apr-1.5.0
#!/bin/bash
source /usr/src/stats
#######################
DIR=`pwd`
PROGRAM=apr-1.5.0
LOG=$DIR/$PROGRAM.log
TITLE=$PROGRAM
TIMEFORMAT="$TIMEFMT $TITLE"
BUILDDIR=/tmp/apr
#DEST=$BUILDDIR/install
rm -f $LOG
rm -rf $BUILDDIR
mkdir $BUILDDIR
cd $BUILDDIR
before=`df -k /tmp | grep / | sed -e "s/ \{2,\}/ /g" | cut -d' ' -f3`
tar -xf $DIR/$PROGRAM.tar.?z* || exit 1
cd $PROGRAM
{ time \
{
echo Making $TITLE
date
./configure --prefix=/usr \
--disable-static \
--with-installbuilddir=/usr/share/apr-1/build &&
make &&
#make test &&
echo "BLFS Start INSTALL" &&
$SUDO make DESTDIR=$DEST install
}
} 2>&1 | tee -a $LOG
if [ $PIPESTATUS -ne 0 ]; then exit 1; fi;
stats $LOG $DIR/$PROGRAM.tar.?z* $before
exit 0
========
$ cat /usr/src/stats
#!/bin/bash
function stats()
{
log=$1
tarball=$2
b4=$3
base_sbu=118
free_now=`df -k /tmp | grep / | sed -e "s/ \{2,\}/ /g" | cut -d" " -f3`
buildtime=`tail -n1 $log|cut -f1 -d" "`
sbu=`echo "scale=3; $buildtime / $base_sbu" | bc`
psizeK=`du -k $tarball | cut -f1`
psizeM=`echo "scale=3; $psizeK / 1024" | bc`
bsizeK=`echo "$free_now - $b4" | bc`
bsizeM=`echo "scale=3; $bsizeK / 1024" | bc`
echo "SBU=$sbu" | tee -a $log
echo "$psizeK $tarball size ($psizeM MB)" | tee -a $log
echo "$bsizeK kilobytes build size ($bsizeM MB)" | tee -a $log
(echo -n "md5sum : "; md5sum $tarball) | tee -a $log
(echo -n "sha1sum: "; sha1sum $tarball) | tee -a $log
echo "`date` $tarball" >> /usr/src/packages-$(lsb_release -r|cut -f2).log
}
TIMEFMT='%1R Elapsed Time - '
SUDO='sudo -E'
=======
base_sbu is the binutils time.
You can modify this to pass parameters, but I generally edit the script
for any new version. The build procedures change often enough that I
generally copy the old build script to the new and update as needed.
I build in /tmp, but that can be modified as desired. I don't delete
until /tmp gets full so I can review if needed.
-- Bruce
--
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page