Commit 5af37aa9 authored by Drew's avatar Drew

Initial commit

parents
This diff is collapsed.
(package
:name "package-homebrew"
:payload "package-homebrew"
:platforms ["osx"]
:type "executable"
)
\ No newline at end of file
#!/bin/bash
# Copyright (c) 2016 Anarchy Tools Contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# parse arguments
while :; do
case $1 in
--name)
if [ -n "$2" ]; then
NAME=$2
shift
fi
;;
--url)
if [ -n "$2" ]; then
URL=$2
shift
fi
;;
*)
if [ "$1" == "" ]; then
break
fi
echo "warning: unknown option $1"
shift
esac
shift
done
if [ -z ${NAME+x} ]; then
echo "NAME is required"
exit 1
fi
if [ -z ${ATBUILD_PACKAGE_VERSION+x} ]; then
echo "\$ATBUILD_PACKAGE_VERSION is required"
exit 1
fi
ATBIN="bin/${NAME}.atbin"
# look up payload by parsing the atbin format
PAYLOAD=`grep -o ':payload .*' bin/package-homebrew.atbin/compiled.atpkg | grep -Eo '".*"' | tr -d '"'`
echo "Compressing atbin..."
# compress the atbin file
tar c --options "xz:compression-level=9" -Jf bin/${NAME}.atbin.tar.xz bin/${NAME}.atbin -C bin
# we defer this so we can already have the atbin compressed at this point
if [ -z ${URL+x} ]; then
echo "URL is required"
exit 1
fi
# compute the sha256 sum
SHA=`shasum -a 256 bin/${NAME}.atbin.tar.xz`
echo "
# Documentation: https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Formula-Cookbook.md
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
class Atbuild < Formula
desc \"No description! file a bug at https://github.com/AnarchyTools/package-homebrew/issues\"
homepage \"No homepage! file a bug at https://github.com/AnarchyTools/package-homebrew/issues\"
url \"${URL}\"
version \"${ATBUILD_PACKAGE_VERSION}\"
sha256 \"$SHA\"
def install
bin.install \"${NAME}.atbin/${PAYLOAD}\"
end
end" > bin/${NAME}.rb
echo "Wrote formula to bin/${NAME}.rb"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment