Skip to content

Commit

Permalink
Merge pull request #676 from bmpotter/mac-install-pkg
Browse files Browse the repository at this point in the history
added targets to Makefile to build a horizon-cli pkg for mac
  • Loading branch information
linggao authored Sep 12, 2018
2 parents dc04d62 + 3339216 commit 64bd1c0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ $(CLI_EXECUTABLE): $(shell find . -name '*.go' -not -path './vendor/*') gopathli
mkdir -p $(CLI_COMPLETION_DIR) && $(CLI_EXECUTABLE) --completion-script-bash > $(CLI_COMPLETION_DIR)/hzn_bash_autocomplete.sh; \
fi


# Build an install pkg for horizon-cli for mac
#todo: these targets should probably be moved into the official horizon build process
export MAC_PKG_VERSION ?= 2.17.14
MAC_PKG_IDENTIFIER ?= com.github.open-horizon.pkg.horizon-cli
MAC_PKG_INSTALL_DIR ?= /Users/Shared/horizon-cli

macpkg: $(CLI_EXECUTABLE)
mkdir -p pkg/mac/horizon-cli/bin pkg/mac/horizon-cli/share/horizon pkg/mac/horizon-cli/share/man/man1
cp $(CLI_EXECUTABLE) pkg/mac/horizon-cli/bin
cp LICENSE.txt pkg/mac/horizon-cli/share/horizon
cp $(CLI_MAN_DIR)/hzn.1 pkg/mac/horizon-cli/share/man/man1
cp $(CLI_COMPLETION_DIR)/hzn_bash_autocomplete.sh pkg/mac/horizon-cli/share/horizon
pkgbuild --root pkg/mac/horizon-cli --scripts pkg/mac/scripts --identifier $(MAC_PKG_IDENTIFIER) --version $(MAC_PKG_VERSION) --install-location $(MAC_PKG_INSTALL_DIR) pkg/mac/build/horizon-cli-$(MAC_PKG_VERSION).pkg
rm -f pkg/mac/build/horizon-cli-$(MAC_PKG_VERSION).pkg.zip
cd pkg/mac/build; zip horizon-cli-$(MAC_PKG_VERSION).pkg.zip horizon-cli-$(MAC_PKG_VERSION).pkg; cd ../../.. # need to be in the same dir to zip

macinstall: macpkg
sudo installer -pkg pkg/mac/build/horizon-cli-$(MAC_PKG_VERSION).pkg -target '/Volumes/Macintosh HD'

macpkginfo:
pkgutil --pkg-info $(MAC_PKG_IDENTIFIER)
pkgutil --only-files --files $(MAC_PKG_IDENTIFIER)

docker-image:
@echo "Producing anax docker image $(DOCKER_IMAGE)"
if [[ $(arch) == "amd64" ]]; then \
Expand Down
2 changes: 2 additions & 0 deletions pkg/mac/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
horizon-cli/
13 changes: 13 additions & 0 deletions pkg/mac/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# Create sym links from we where we install the horizon-cli files to where they need to be under /usr/local
# Note: this file must be given the executable permissions before giving it to pkgbuild

SRCDIR=/Users/Shared
DESTDIR=/usr/local

mkdir -p $DESTDIR/bin $DESTDIR/share/man/man1
ln -sf $SRCDIR/horizon-cli/bin/hzn $DESTDIR/bin
ln -sf $SRCDIR/horizon-cli/share/horizon $DESTDIR/share
ln -sf $SRCDIR/horizon-cli/share/man/man1/hzn.1 $DESTDIR/share/man/man1

exit 0

0 comments on commit 64bd1c0

Please sign in to comment.