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}"
e3c8618a
 DESC="A shell script based dependency manager for 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
 
 set -e
 
 [ "$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}"
 
   def install
      system "./install.sh", "#{prefix}"
   end
 
   test do
   end
 end
 # FORMULA ${TARGET}.rb
 EOF