OS X package maker via relocating homebrew packages

This commit is contained in:
mike@arpaia.co 2014-10-03 01:02:58 -07:00
parent cf6941fea4
commit d214901d57
2 changed files with 52 additions and 0 deletions

View File

@ -44,3 +44,9 @@ function set_cc() {
export CC=$1
export CMAKE_C_COMPILER=$1
}
function contains_element() {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}

46
tools/make_osx_package.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PATH="$PATH:/usr/local/bin"
. $SCRIPT_DIR/lib.sh
BREW_PACKAGES=(rocksdb boost gflags glog thrift)
BREW_PREFIX=`brew --prefix`
BREW_CELLAR=`brew --cellar`
function main() {
platform OS
if [[ ! "$OS" = "darwin" ]]; then
fatal "This script must be ran on OS X"
fi
log "Calculating dependencies"
dependency_list=("${BREW_PACKAGES[@]}")
for package in ${BREW_PACKAGES[*]}; do
for dep in `brew deps $package`; do
if ! contains_element $dep "${dependency_list[@]}"; then
dependency_list+=($dep)
fi
done
done
log "Done calculating dependencies:"
for dep in ${dependency_list[*]}; do
dep_dir=`brew info $dep | grep Cellar | awk '{print $1}'`
brew unlink $dep 2>&1 1>/dev/null
links=`brew link --dry-run $dep`
brew link --overwrite $dep 2>&1 1>/dev/null
echo " - $dep ($dep_dir)"
for link in $links; do
if [[ $link = $BREW_PREFIX* ]]; then
target="`dirname $link`/`ls -l $link | awk '{print $11}'`"
echo " - $link => $target"
fi
done
done
}
main