Merge pull request #61 from davidnewhall/dn2_more_pkgs
Make more packages.
This commit is contained in:
commit
194e511682
|
|
@ -5,9 +5,10 @@
|
|||
/unifi-poller*.1
|
||||
/unifi-poller*.deb
|
||||
/unifi-poller*.rpm
|
||||
/unifi-poller.*.arm
|
||||
/unifi-poller.exe
|
||||
/unifi-poller.macos
|
||||
/unifi-poller.linux
|
||||
/unifi-poller.*.macos
|
||||
/unifi-poller.*.linux
|
||||
/unifi-poller.rb
|
||||
*.sha256
|
||||
/vendor
|
||||
|
|
|
|||
127
Makefile
127
Makefile
|
|
@ -36,20 +36,20 @@ VERSION_PATH:=github.com/$(GHUSER)/$(BINARY)/$(shell echo $(BINARY) | tr -d -- -
|
|||
all: man build
|
||||
|
||||
# Prepare a release. Called in Travis CI.
|
||||
release: clean vendor test macos windows $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb
|
||||
release: clean vendor test macos arm windows linux_packages
|
||||
# Prepareing a release!
|
||||
mkdir -p release
|
||||
mv $(BINARY).linux $(BINARY).macos release/
|
||||
mv $(BINARY).*.linux $(BINARY).*.macos release/
|
||||
gzip -9r release/
|
||||
zip -9qm release/$(BINARY).exe.zip $(BINARY).exe
|
||||
mv $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb release/
|
||||
for i in $(BINARY)*.exe; do zip -9qm release/$$i.zip $$i;done
|
||||
mv *.rpm *.deb release/
|
||||
# Generating File Hashes
|
||||
for i in release/*; do /bin/echo -n "$$i " ; (openssl dgst -r -sha256 "$$i" | head -c64 ; echo) | tee "$$i.sha256.txt"; done
|
||||
|
||||
# Delete all build assets.
|
||||
clean:
|
||||
# Cleaning up.
|
||||
rm -f $(BINARY){.macos,.linux,.1,}{,.gz} $(BINARY).rb
|
||||
rm -f $(BINARY) $(BINARY).*.{macos,linux,exe}{,.gz} $(BINARY).1{,.gz} $(BINARY).rb
|
||||
rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256
|
||||
rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html
|
||||
rm -rf package_build_* release
|
||||
|
|
@ -79,28 +79,41 @@ build: $(BINARY)
|
|||
$(BINARY):
|
||||
go build -o $(BINARY) -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
|
||||
linux: $(BINARY).linux
|
||||
$(BINARY).linux:
|
||||
linux: $(BINARY).amd64.linux
|
||||
$(BINARY).amd64.linux:
|
||||
# Building linux binary.
|
||||
GOOS=linux go build -o $(BINARY).linux -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
GOOS=linux GOARCH=amd64 go build -o $(BINARY).amd64.linux -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
|
||||
macos: $(BINARY).macos
|
||||
$(BINARY).macos:
|
||||
linux386: $(BINARY).i386.linux
|
||||
$(BINARY).i386.linux:
|
||||
# Building linux binary.
|
||||
GOOS=linux GOARCH=386 go build -o $(BINARY).i386.linux -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
|
||||
arm: $(BINARY).arm.linux
|
||||
$(BINARY).arm.linux:
|
||||
# Building linux binary.
|
||||
GOOS=linux GOARCH=arm GOARM=5 go build -o $(BINARY).arm.linux -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
|
||||
macos: $(BINARY).amd64.macos
|
||||
$(BINARY).amd64.macos:
|
||||
# Building darwin binary.
|
||||
GOOS=darwin go build -o $(BINARY).macos -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
GOOS=darwin GOARCH=amd64 go build -o $(BINARY).amd64.macos -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
|
||||
exe: $(BINARY).exe
|
||||
windows: $(BINARY).exe
|
||||
$(BINARY).exe:
|
||||
exe: $(BINARY).amd64.exe
|
||||
windows: $(BINARY).amd64.exe
|
||||
$(BINARY).amd64.exe:
|
||||
# Building windows binary.
|
||||
GOOS=windows go build -o $(BINARY).exe -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
GOOS=windows GOARCH=amd64 go build -o $(BINARY).amd64.exe -ldflags "-w -s -X $(VERSION_PATH)"
|
||||
|
||||
# Packages
|
||||
|
||||
linux_packages: rpm deb rpm386 deb386 debarm rpmarm
|
||||
|
||||
rpm: $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm
|
||||
$(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm: check_fpm package_build_linux
|
||||
@echo "Building 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'."
|
||||
fpm -s dir -t rpm \
|
||||
--architecture x86_64 \
|
||||
--name $(BINARY) \
|
||||
--rpm-os linux \
|
||||
--version $(RPMVERSION) \
|
||||
|
|
@ -118,6 +131,7 @@ deb: $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb
|
|||
$(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb: check_fpm package_build_linux
|
||||
@echo "Building 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'."
|
||||
fpm -s dir -t deb \
|
||||
--architecture amd64 \
|
||||
--name $(BINARY) \
|
||||
--deb-no-default-config-files \
|
||||
--version $(VERSION) \
|
||||
|
|
@ -131,6 +145,77 @@ $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb: check_fpm package_build_linux
|
|||
--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
|
||||
--chdir package_build_linux
|
||||
|
||||
rpm386: $(BINARY)-$(RPMVERSION)-$(ITERATION).i386.rpm
|
||||
$(BINARY)-$(RPMVERSION)-$(ITERATION).i386.rpm: check_fpm package_build_linux_386
|
||||
@echo "Building 32-bit 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'."
|
||||
fpm -s dir -t rpm \
|
||||
--architecture i386 \
|
||||
--name $(BINARY) \
|
||||
--rpm-os linux \
|
||||
--version $(RPMVERSION) \
|
||||
--iteration $(ITERATION) \
|
||||
--after-install scripts/after-install.sh \
|
||||
--before-remove scripts/before-remove.sh \
|
||||
--license MIT \
|
||||
--url $(URL) \
|
||||
--maintainer "$(MAINT)" \
|
||||
--description "$(DESC)" \
|
||||
--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
|
||||
--chdir package_build_linux_386
|
||||
|
||||
deb386: $(BINARY)_$(VERSION)-$(ITERATION)_i386.deb
|
||||
$(BINARY)_$(VERSION)-$(ITERATION)_i386.deb: check_fpm package_build_linux_386
|
||||
@echo "Building 32-bit 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'."
|
||||
fpm -s dir -t deb \
|
||||
--architecture i386 \
|
||||
--name $(BINARY) \
|
||||
--deb-no-default-config-files \
|
||||
--version $(VERSION) \
|
||||
--iteration $(ITERATION) \
|
||||
--after-install scripts/after-install.sh \
|
||||
--before-remove scripts/before-remove.sh \
|
||||
--license MIT \
|
||||
--url $(URL) \
|
||||
--maintainer "$(MAINT)" \
|
||||
--description "$(DESC)" \
|
||||
--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
|
||||
--chdir package_build_linux_386
|
||||
|
||||
rpmarm: $(BINARY)-$(RPMVERSION)-$(ITERATION).arm.rpm
|
||||
$(BINARY)-$(RPMVERSION)-$(ITERATION).arm.rpm: check_fpm package_build_linux_arm
|
||||
@echo "Building 32-bit ARM 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'."
|
||||
fpm -s dir -t rpm \
|
||||
--architecture arm \
|
||||
--name $(BINARY) \
|
||||
--rpm-os linux \
|
||||
--version $(RPMVERSION) \
|
||||
--iteration $(ITERATION) \
|
||||
--after-install scripts/after-install.sh \
|
||||
--before-remove scripts/before-remove.sh \
|
||||
--license MIT \
|
||||
--url $(URL) \
|
||||
--maintainer "$(MAINT)" \
|
||||
--description "$(DESC)" \
|
||||
--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
|
||||
--chdir package_build_linux_arm
|
||||
|
||||
debarm: $(BINARY)_$(VERSION)-$(ITERATION)_arm.deb
|
||||
$(BINARY)_$(VERSION)-$(ITERATION)_arm.deb: check_fpm package_build_linux_arm
|
||||
@echo "Building 32-bit ARM 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'."
|
||||
fpm -s dir -t deb \
|
||||
--architecture arm \
|
||||
--name $(BINARY) \
|
||||
--deb-no-default-config-files \
|
||||
--version $(VERSION) \
|
||||
--iteration $(ITERATION) \
|
||||
--after-install scripts/after-install.sh \
|
||||
--before-remove scripts/before-remove.sh \
|
||||
--license MIT \
|
||||
--url $(URL) \
|
||||
--maintainer "$(MAINT)" \
|
||||
--description "$(DESC)" \
|
||||
--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
|
||||
--chdir package_build_linux_arm
|
||||
docker:
|
||||
docker build -f init/docker/Dockerfile -t $(DHUSER)/$(BINARY) .
|
||||
|
||||
|
|
@ -140,7 +225,7 @@ package_build_linux: readme man linux
|
|||
mkdir -p $@/usr/bin $@/etc/$(BINARY) $@/lib/systemd/system
|
||||
mkdir -p $@/usr/share/man/man1 $@/usr/share/doc/$(BINARY)
|
||||
# Copying the binary, config file, unit file, and man page into the env.
|
||||
cp $(BINARY).linux $@/usr/bin/$(BINARY)
|
||||
cp $(BINARY).amd64.linux $@/usr/bin/$(BINARY)
|
||||
cp *.1.gz $@/usr/share/man/man1
|
||||
cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/
|
||||
cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/$(CONFIG_FILE)
|
||||
|
|
@ -148,6 +233,16 @@ package_build_linux: readme man linux
|
|||
# These go to their own folder so the img src in the html pages continue to work.
|
||||
cp init/systemd/$(BINARY).service $@/lib/systemd/system/
|
||||
|
||||
package_build_linux_386: package_build_linux linux386
|
||||
mkdir -p package_build_linux_386
|
||||
cp -r package_build_linux/* package_build_linux_386/
|
||||
cp $(BINARY).i386.linux $@/usr/bin/$(BINARY)
|
||||
|
||||
package_build_linux_arm: package_build_linux arm
|
||||
mkdir -p package_build_linux_arm
|
||||
cp -r package_build_linux/* package_build_linux_arm/
|
||||
cp $(BINARY).arm.linux $@/usr/bin/$(BINARY)
|
||||
|
||||
check_fpm:
|
||||
@fpm --version > /dev/null || (echo "FPM missing. Install FPM: https://fpm.readthedocs.io/en/latest/installing.html" && false)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ RUN dep ensure \
|
|||
&& CGO_ENABLED=0 make linux
|
||||
|
||||
#
|
||||
# creating container for run
|
||||
# to use this container use the following command:
|
||||
# creating container for run
|
||||
# to use this container use the following command:
|
||||
#
|
||||
# docker run -d -v /your/config/up.conf:/etc/unifi-poller/up.conf golift/unifi-poller
|
||||
#
|
||||
# by using "-e UNIFI_PASSWORD=your-secret-pasword" you can avoid this configuration in the config file
|
||||
#
|
||||
FROM scratch
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.linux /unifi-poller
|
||||
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.amd64.linux /unifi-poller
|
||||
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/examples/up.conf.example /etc/unifi-poller/up.conf
|
||||
|
||||
VOLUME [ "/etc/unifi-poller"]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This is a quick and drity script to install the latest Linux package.
|
||||
#
|
||||
# Use it like this: (sudo is optional)
|
||||
# ===
|
||||
# curl https://raw.githubusercontent.com/davidnewhall/unifi-poller/master/scripts/install.sh | sudo bash
|
||||
# ===
|
||||
# If you're on redhat, this installs the latest rpm. If you're on Debian, it installs the latest deb package.
|
||||
#
|
||||
|
||||
REPO=davidnewhall/unifi-poller
|
||||
LATEST=https://api.github.com/repos/${REPO}/releases/latest
|
||||
ARCH=$(uname -m)
|
||||
|
||||
# $ARCH is passed into egrep to find the right file.
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
ARCH="$ARCH|amd64"
|
||||
elif [ "$ARCH" = "amd64" ]; then
|
||||
ARCH="$ARCH|x86_64"
|
||||
elif [[ $ARCH == *arm* ]]; then
|
||||
ARCH="arm"
|
||||
else
|
||||
echo "Unknown Architecture. Submit a pull request to fix this, please."
|
||||
echo ==> $ARCH
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" == "deb" ] || [ "$1" == "rpm" ]; then
|
||||
FILE=$1
|
||||
else
|
||||
# If you have both, rpm wins.
|
||||
rpm --version > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
FILE=rpm
|
||||
else
|
||||
dpkg --version > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
FILE=deb
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$FILE" = "" ]; then
|
||||
echo "No dpkg or rpm package managers found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# curl or wget?
|
||||
curl --version > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
CMD="curl -L"
|
||||
else
|
||||
wget --version > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
CMD="wget -O-"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$CMD" = "" ]; then
|
||||
echo "Need curl or wget - could not find either!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Grab latest release file from github.
|
||||
URL=$($CMD ${LATEST} | egrep "browser_download_url.*\.(${ARCH}).${FILE}\"" | cut -d\" -f 4)
|
||||
|
||||
if [ "$?" != "0" ] || [ "$URL" = "" ]; then
|
||||
echo "Error locating latest release at ${LATEST}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INSTALLER="rpm -Uvh"
|
||||
if [ "$FILE" = "deb" ]; then
|
||||
INSTALLER="dpkg -i"
|
||||
fi
|
||||
|
||||
FILE=$(basename ${URL})
|
||||
echo "Downloading: ${URL} to /tmp/${FILE}"
|
||||
$CMD ${URL} > /tmp/${FILE}
|
||||
|
||||
# Install it.
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
echo "==================================="
|
||||
echo "Downloaded. Installing the package!"
|
||||
echo "Running: ${INSTALLER} /tmp/${FILE}"
|
||||
$INSTALLER /tmp/${FILE}
|
||||
else
|
||||
echo "================================"
|
||||
echo "Downloaded. Install the package:"
|
||||
echo "sudo $INSTALLER /tmp/${FILE}"
|
||||
fi
|
||||
Loading…
Reference in New Issue