Build osx package too.
This commit is contained in:
parent
da5d7163cb
commit
41d2d201ac
|
|
@ -4,6 +4,7 @@
|
||||||
/*.1
|
/*.1
|
||||||
/*.deb
|
/*.deb
|
||||||
/*.rpm
|
/*.rpm
|
||||||
|
/*.pkg
|
||||||
/vendor
|
/vendor
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*~
|
*~
|
||||||
|
|
|
||||||
38
Makefile
38
Makefile
|
|
@ -5,7 +5,7 @@ all: clean test man build
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
for p in $(PACKAGES); do rm -f `echo $${p}|cut -d/ -f3`{,.1,.1.gz}; done
|
for p in $(PACKAGES); do rm -f `echo $${p}|cut -d/ -f3`{,.1,.1.gz}; done
|
||||||
rm -rf build unifi-poller_*.deb unifi-poller-*.rpm
|
rm -rf build unifi-poller_*.deb unifi-poller-*.rpm unifi-poller-*.pkg
|
||||||
|
|
||||||
build:
|
build:
|
||||||
for p in $(PACKAGES); do go build -ldflags "-w -s" $${p}; done
|
for p in $(PACKAGES); do go build -ldflags "-w -s" $${p}; done
|
||||||
|
|
@ -13,9 +13,30 @@ build:
|
||||||
linux:
|
linux:
|
||||||
for p in $(PACKAGES); do GOOS=linux go build -ldflags "-w -s" $${p}; done
|
for p in $(PACKAGES); do GOOS=linux go build -ldflags "-w -s" $${p}; done
|
||||||
|
|
||||||
|
darwin:
|
||||||
|
for p in $(PACKAGES); do GOOS=darwin go build -ldflags "-w -s" $${p}; done
|
||||||
|
|
||||||
test: lint
|
test: lint
|
||||||
for p in $(PACKAGES) $(LIBRARYS); do go test -race -covermode=atomic $${p}; done
|
for p in $(PACKAGES) $(LIBRARYS); do go test -race -covermode=atomic $${p}; done
|
||||||
|
|
||||||
|
man:
|
||||||
|
scripts/build_manpages.sh ./
|
||||||
|
|
||||||
|
rpm: clean test man linux
|
||||||
|
scripts/build_linux_packages.sh rpm
|
||||||
|
|
||||||
|
deb: clean test man linux
|
||||||
|
scripts/build_linux_packages.sh deb
|
||||||
|
|
||||||
|
osxpkg: clean test man darwin
|
||||||
|
scripts/build_osx_package.sh
|
||||||
|
|
||||||
|
install: all
|
||||||
|
scripts/local_install.sh
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
scripts/local_uninstall.sh
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
goimports -l $(PACKAGES)
|
goimports -l $(PACKAGES)
|
||||||
gofmt -l $(PACKAGES)
|
gofmt -l $(PACKAGES)
|
||||||
|
|
@ -25,18 +46,3 @@ lint:
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
dep ensure -update
|
dep ensure -update
|
||||||
|
|
||||||
man:
|
|
||||||
scripts/build_manpages.sh ./
|
|
||||||
|
|
||||||
rpm: all
|
|
||||||
scripts/build_packages.sh rpm
|
|
||||||
|
|
||||||
deb: all
|
|
||||||
scripts/build_packages.sh deb
|
|
||||||
|
|
||||||
install: all
|
|
||||||
scripts/local_install.sh
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
scripts/local_uninstall.sh
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
# untested, feedback welcomed.
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Unifi Poller - Ubiquiti Metrics->InfluxDB
|
Description=Unifi Poller - Ubiquiti Metrics->InfluxDB
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,26 @@ fi
|
||||||
|
|
||||||
echo "Building '${OUTPUT}' package."
|
echo "Building '${OUTPUT}' package."
|
||||||
|
|
||||||
|
PREFIX=
|
||||||
|
BINFIX=/usr
|
||||||
|
|
||||||
# Make a build environment.
|
# Make a build environment.
|
||||||
mkdir -p package_build/usr/bin package_build/etc/${BINARY} package_build/lib/systemd/system package_build/usr/share/man/man1
|
rm -rf package_build
|
||||||
|
mkdir -p package_build${BINFIX}/bin package_build${PREFIX}/etc/${BINARY} package_build${BINFIX}/share/man/man1
|
||||||
|
|
||||||
# Copy the binary, config file and man page into the env.
|
# Copy the binary, config file and man page into the env.
|
||||||
cp ${BINARY} package_build/usr/bin
|
cp ${BINARY} package_build${BINFIX}/bin
|
||||||
cp *.1.gz package_build/usr/share/man/man1
|
cp *.1.gz package_build${BINFIX}/share/man/man1
|
||||||
cp examples/up.conf.example package_build/etc/${BINARY}/up.conf
|
cp examples/up.conf.example package_build${PREFIX}/etc/${BINARY}/up.conf
|
||||||
|
|
||||||
# Fix the paths in the systemd unit file before copying it into the emv.
|
# Fix the paths in the systemd unit file before copying it into the emv.
|
||||||
sed "s#ExecStart.*#ExecStart=/usr/bin/${BINARY} --config=/etc/${BINARY}/up.conf#" \
|
mkdir -p package_build/lib/systemd/system
|
||||||
|
sed "s#ExecStart.*#ExecStart=${BINFIX}/bin/${BINARY} --config=${PREFIX}/etc/${BINARY}/up.conf#" \
|
||||||
init/systemd/unifi-poller.service > package_build/lib/systemd/system/${BINARY}.service
|
init/systemd/unifi-poller.service > package_build/lib/systemd/system/${BINARY}.service
|
||||||
|
|
||||||
fpm -s dir -t ${OUTPUT} \
|
fpm -s dir -t ${OUTPUT} \
|
||||||
-n ${BINARY} \
|
--name ${BINARY} \
|
||||||
-v ${VERSION} \
|
--version ${VERSION} \
|
||||||
--after-install scripts/after-install.sh \
|
--after-install scripts/after-install.sh \
|
||||||
|
--before-remove scripts/before-remove.sh \
|
||||||
-C package_build
|
-C package_build
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script builds a simple macos Installer pkg. Run by the Makefile.
|
||||||
|
# Use: `make osx`
|
||||||
|
|
||||||
|
OUTPUT=$1
|
||||||
|
BINARY=unifi-poller
|
||||||
|
VERSION=$(git tag -l --merged | tail -n1 | tr -d v)
|
||||||
|
|
||||||
|
fpm -h > /dev/null 2>&1
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
echo "fpm missing. Install fpm: https://fpm.readthedocs.io/en/latest/installing.html"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building 'osxpkg' package."
|
||||||
|
|
||||||
|
PREFIX=/usr/local
|
||||||
|
BINFIX=/usr/local
|
||||||
|
|
||||||
|
# Make a build environment.
|
||||||
|
rm -rf package_build
|
||||||
|
mkdir -p package_build${BINFIX}/bin package_build${PREFIX}/etc/${BINARY} package_build${BINFIX}/share/man/man1
|
||||||
|
|
||||||
|
# Copy the binary, config file and man page into the env.
|
||||||
|
cp ${BINARY} package_build${BINFIX}/bin
|
||||||
|
cp *.1.gz package_build${BINFIX}/share/man/man1
|
||||||
|
cp examples/up.conf.example package_build${PREFIX}/etc/${BINARY}/up.conf
|
||||||
|
|
||||||
|
# Copy in launch agent.
|
||||||
|
mkdir -p package_build/Library/LaunchAgents
|
||||||
|
cp init/launchd/com.github.davidnewhall.unifi-poller.plist package_build/Library/LaunchAgents/
|
||||||
|
|
||||||
|
# Make a package.
|
||||||
|
fpm -s dir -t osxpkg \
|
||||||
|
--name ${BINARY} \
|
||||||
|
--version ${VERSION} \
|
||||||
|
--osxpkg-identifier-prefix com.github.davidnewhall \
|
||||||
|
-C package_build
|
||||||
Loading…
Reference in New Issue