bin/generate-brew-formula.sh
157d058b
 #! /bin/sh
 #
 # Generate a formula formulle-xcode-settings stand alone
 #
 PROJECT=MulleBootstrap
 TARGET=mulle-bootstrap
 HOMEPAGE="http://www.mulle-kybernetik.com/software/git/${TARGET}"
fdd375ea
 DESC="Dependency manager for cross-platform projects"
fa860fc9
 
 VERSION="${1:-`./mulle-bootstrap version`}"
2d8f68ea
 [ $# -eq 0 ] || shift
fa860fc9
 ARCHIVEURL="${1:-http://www.mulle-kybernetik.com/software/git/${TARGET}/tarball/$VERSION}"
2d8f68ea
 [ $# -eq 0 ] || shift
157d058b
 
 [ "$VERSION" = "" ] && exit 1
 [ "$ARCHIVEURL" = "" ] && exit 1
 
 
 TMPARCHIVE="/tmp/${PROJECT}-${VERSION}-archive"
 
 if [ ! -f  "${TMPARCHIVE}" ]
 then
    curl -L -o "${TMPARCHIVE}" "${ARCHIVEURL}"
    if [ $? -ne 0 -o ! -f "${TMPARCHIVE}" ]
    then
       echo "Download failed" >&2
       exit 1
    fi
 else
    echo "using cached file ${TMPARCHIVE} instead of downloading again" >&2
 fi
 
 #
 # anything less than 17 KB is wrong
 #
 size="`du -k "${TMPARCHIVE}" | awk '{ print $ 1}'`"
 if [ $size -lt 17 ]
 then
    echo "Archive truncated or missing" >&2
    cat "${TMPARCHIVE}" >&2
    rm "${TMPARCHIVE}"
    exit 1
 fi
 
 HASH="`shasum -p -a 256 "${TMPARCHIVE}" | awk '{ print $1 }'`"
 
 cat <<EOF
 class ${PROJECT} < Formula
   homepage "${HOMEPAGE}"
   desc "${DESC}"
   url "${ARCHIVEURL}"
   version "${VERSION}"
   sha256 "${HASH}"
 
4272d072
   depends_on :git  => :run
   depends_on :curl => :run
   depends_on :bash => :run
 
 # we can live w/o cmake though
   depends_on :cmake => :run
 
157d058b
   def install
      system "./install.sh", "#{prefix}"
   end
 
   test do
   end
 end
 # FORMULA ${TARGET}.rb
 EOF