Use install instead of cp. Add homebrew formula.

This commit is contained in:
David Newhall II 2019-06-12 12:25:53 -07:00
parent 4cc22bccb9
commit 83c02560ac
3 changed files with 46 additions and 11 deletions

View File

@ -22,7 +22,7 @@ before_install:
- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
install:
- dep ensure
- rvm $brew_ruby do gem install --no-document ronn fpm
- rvm $brew_ruby do gem install --no-document fpm
script:
- rvm $brew_ruby do make release
deploy:

View File

@ -0,0 +1,36 @@
# Homebrew Formula, still under development - June 2019
require "language/go"
# Classname should match the name of the installed package.
class UnifiPoller < Formula
version "1.2.3"
desc "This daemon polls a Unifi controller at a short interval and stores the collected metric data in an Influx Database."
homepage "https://github.com/davidnewhall/unifi-poller"
# Source code archive. Each tagged release will have one
url "https://github.com/davidnewhall/unifi-poller/archive/v#{version}.tar.gz"
sha256 "d536cb767b663a1c24410b27bd7e51a2b9a78820ed1ceeb2bb61e30e27235890"
head "https://github.com/davidnewhall/unifi-poller"
depends_on "go" => :build
depends_on "dep"
def install
ENV["GOPATH"] = buildpath
bin_path = buildpath/"src/github.com/davidnewhall/unifi-poller"
# Copy all files from their current location (GOPATH root)
# to $GOPATH/src/github.com/davidnewhall/unifi-poller
bin_path.install Dir["*"]
cd bin_path do
# Install the compiled binary into Homebrew's `bin` - a pre-existing
# global variable
system "dep", "ensure"
system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}"
end
end
test do
assert_match "unifi-poller v#{version}", shell_output("#{bin}/unifi-poller -v 2>&1", 2)
end
end

View File

@ -162,18 +162,17 @@ install: man readme $(BINARY)
@echo If you wish to install the application manually on Linux, check out the wiki: https://github.com/davidnewhall/unifi-poller/wiki/Installation
@echo - Otherwise, build and install a package: make rpm -or- make deb
@echo See the Package Install wiki for more info: https://github.com/davidnewhall/unifi-poller/wiki/Package-Install
@[ "$$(uname)" = "Darwin" ] || (echo "Unable to continue, not a Mac." && exit)
@[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local" && exit)
mkdir -p $(PREFIX)/bin $(PREFIX)/etc/$(BINARY) $(PREFIX)/var/log/unifi-poller
mkdir -p $(PREFIX)/share/man/man1 $(PREFIX)/share/doc/$(BINARY)/examples
@[ "$$(uname)" = "Darwin" ] || (echo "Unable to continue, not a Mac." && false)
@[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local" && false)
# Copying the binary, config file, unit file, and man page into the env.
cp $(BINARY) $(PREFIX)/bin/$(BINARY)
cp *.1.gz $(PREFIX)/share/man/man1
cp examples/*.conf.example $(PREFIX)/etc/$(BINARY)/
cp examples/up.conf.example $(PREFIX)/etc/$(BINARY)/up.conf
cp *.html examples/{*dash.json,up.conf.example} $(PREFIX)/share/doc/$(BINARY)/
/usr/bin/install -m 0755 -d $(PREFIX)/bin $(PREFIX)/share/man/man1 $(PREFIX)/etc/$(BINARY) $(PREFIX)/share/doc/$(BINARY)/examples
/usr/bin/install -m 0755 -cp $(BINARY) $(PREFIX)/bin/$(BINARY)
/usr/bin/install -m 0644 -cp $(BINARY).1.gz $(PREFIX)/share/man/man1
/usr/bin/install -m 0644 -cp examples/up.conf.example $(PREFIX)/etc/$(BINARY)/
[ -f $(PREFIX)/etc/$(BINARY)/up.conf ] || /usr/bin/install -m 0644 -cp examples/up.conf.example $(PREFIX)/etc/$(BINARY)/up.conf
/usr/bin/install -m 0644 -cp *.html examples/{*dash.json,up.conf.example} $(PREFIX)/share/doc/$(BINARY)/
# These go to their own folder so the img src in the html pages continue to work.
cp examples/*.png $(PREFIX)/share/doc/$(BINARY)/examples
/usr/bin/install -m 0644 -cp examples/*.png $(PREFIX)/share/doc/$(BINARY)/examples
# If you installed with `make install` run `make uninstall` before installing a binary package.
# This will remove the package install from macOS, it will not remove a package install from Linux.