by on
osx-avr

Tack #1

Write script to download and patch FreeBSD sources.

#!/bin/bash
function getfiles ()
{
for fname in $FILES ; do
echo "GETTING ----- $fname -----"
case ${fname##*.} in
  bz2)
     echo "GETTING ----- $fname ----- using bunzip "
     curl ftp://ftp2.freebsd.org/pub/FreeBSD/distfiles/$fname 
      |bunzip2 -dc|tar -xf -
     ;;
  gz|tgz)
     echo "GETTING ----- $fname ----- using gunzip "
     curl ftp://ftp2.freebsd.org/pub/FreeBSD/distfiles/$fname 
      |gzip -dc|tar -xf -
     ;;
esac
done

}

function patchfiles () {
PORTNAME=`cat $port/Makefile |grep ^PORTNAME|cut -f2`
PORTVERSION=`cat $port/Makefile |grep ^PORTVERSION|cut -f2`
ocd=`pwd`
cd $PORTNAME-$PORTVERSION*
echo "-------- PATCHING HERE `pwd`  ------"
for p in $ocd/$port/files/patch* ; do
   patch -p0 -u <$p
done
cd $ocd

}

function makeit () {
PREFIX=/usr/local
LOCALBASE=/usr/local
CONFIGURE_ARGS=`cat $port/Makefile |grep ^CONFIGURE_ARGS|sed 's/^CONFIGURE_ARGS=t//'`
MAKE_ARGS=`cat $port/Makefile |grep ^MAKE_ARGS|sed 's/^MAKE_ARGS=t//'`
PORTNAME=`cat $port/Makefile |grep ^PORTNAME|cut -f2`
PORTVERSION=`cat $port/Makefile |grep ^PORTVERSION|cut -f2`
ocd=`pwd`
cd $PORTNAME-$PORTVERSION*
echo "-------- CONFIGURING HERE `pwd`  ------"
echo "$CONFIGURE_ENV ./configure $CONFIGURE_ARGS "
export `cat $port/Makefile |grep ^CONFIGURE_ENV|sed 's/t/ /g'|sed 's/^CONFIGURE_ENV=//'`
./configure $CONFIGURE_ARGS >config.out
echo "$MAKE_ENV make $MAKE_FLAGS && $MAKE_ENV make $MAKE_FLAGS install"
export `cat $port/Makefile |grep ^MAKE_ENV|sed 's/t/ /g'|sed 's/^MAKE_ENV=//'`
make $MAKE_FLAGS && make $MAKE_FLAGS install
# make $MAKE_FLAGS distclean
cd $ocd
}

for port in avr-binutils avr-gcc avr-libc avr-gdb avarice simulavr ; do
curl  "http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/$port/$port.tar.gz?tarball=1"|gzip -dc|tar -xvf -
export FILES=`grep MD5 $port/distinfo|cut -d( -f2|cut -d) -f1`
getfiles "$FILES"
patchfiles "$port" "$FILES"
makeit "$port" "$FILES"
done

Tack #2

Work with the ports tree, bsdmake and the .mk files to try to get the download, build and packaging to work as they do in the ports.

Leave a Reply

  • (will not be published)