Merge pull request #80 from davidnewhall/dn2_fix_restart
Fix bug: always restart
This commit is contained in:
		
						commit
						546e2e0ee6
					
				
							
								
								
									
										11
									
								
								.metadata.sh
								
								
								
								
							
							
						
						
									
										11
									
								
								.metadata.sh
								
								
								
								
							|  | @ -5,8 +5,6 @@ | ||||||
| BINARY="unifi-poller" | BINARY="unifi-poller" | ||||||
| # github username | # github username | ||||||
| GHUSER="davidnewhall" | GHUSER="davidnewhall" | ||||||
| # docker hub username |  | ||||||
| DHUSER="golift" |  | ||||||
| # Github repo containing homebrew formula repo. | # Github repo containing homebrew formula repo. | ||||||
| HBREPO="golift/homebrew-mugs" | HBREPO="golift/homebrew-mugs" | ||||||
| MAINT="David Newhall II <david at sleepers dot pro>" | MAINT="David Newhall II <david at sleepers dot pro>" | ||||||
|  | @ -16,10 +14,15 @@ GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals" | ||||||
| # Example must exist at examples/$CONFIG_FILE.example | # Example must exist at examples/$CONFIG_FILE.example | ||||||
| CONFIG_FILE="up.conf" | CONFIG_FILE="up.conf" | ||||||
| LICENSE="MIT" | LICENSE="MIT" | ||||||
|  | # FORMULA is either 'service' or 'tool'. Services run as a daemon, tools do not. | ||||||
|  | # This affects the homebrew formula (launchd) and linux packages (systemd). | ||||||
|  | FORMULA="service" | ||||||
| 
 | 
 | ||||||
| export BINARY GHUSER DHUSER HBREPO MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LICENSE | export BINARY GHUSER HBREPO MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LICENSE FORMULA | ||||||
| 
 | 
 | ||||||
| # The rest is mostly automatic. | # The rest is mostly automatic. | ||||||
|  | # Fix the repo if it doesn't match the binary name. | ||||||
|  | # Provide a better URL if one exists. | ||||||
| 
 | 
 | ||||||
| GHREPO="${GHUSER}/${BINARY}" | GHREPO="${GHUSER}/${BINARY}" | ||||||
| URL="https://github.com/${GHREPO}" | URL="https://github.com/${GHREPO}" | ||||||
|  | @ -30,7 +33,7 @@ URL="https://github.com/${GHREPO}" | ||||||
| VERSION_PATH="github.com/${GHREPO}/$(echo ${BINARY} | tr -d -- -).Version" | VERSION_PATH="github.com/${GHREPO}/$(echo ${BINARY} | tr -d -- -).Version" | ||||||
| 
 | 
 | ||||||
| # Dynamic. Recommend not changing. | # Dynamic. Recommend not changing. | ||||||
| VERSION="$(git tag -l --merged | tail -n1 | tr -d v || echo development)" | VERSION="$(git tag -l --merged | tail -n1 | tr -d v | grep -E '^\S+$' || echo development)" | ||||||
| # This produces a 0 in some envirnoments (like Homebrew), but it's only used for packages. | # This produces a 0 in some envirnoments (like Homebrew), but it's only used for packages. | ||||||
| ITERATION=$(git rev-list --count --all || echo 0) | ITERATION=$(git rev-list --count --all || echo 0) | ||||||
| DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" | DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" | ||||||
|  |  | ||||||
							
								
								
									
										26
									
								
								.travis.yml
								
								
								
								
							
							
						
						
									
										26
									
								
								.travis.yml
								
								
								
								
							|  | @ -25,18 +25,24 @@ install: | ||||||
| #- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest | #- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest | ||||||
| - rvm install 2.0.0 | - rvm install 2.0.0 | ||||||
| - rvm 2.0.0 do gem install --no-document fpm | - rvm 2.0.0 do gem install --no-document fpm | ||||||
| - make docker | before_script: | ||||||
|  |   - source .metadata.sh | ||||||
|  |   - make vendor | ||||||
| script: | script: | ||||||
|  |   # Test Go and Docker. | ||||||
|  |   - make test | ||||||
|  |   - make docker | ||||||
|   # Test built docker image. |   # Test built docker image. | ||||||
| - docker run golift/unifi-poller:local 2>&1 | grep -Eq "Loading Configuration File[:] /etc/unifi-poller/up.conf" |   - docker run $BINARY -v 2>&1 | grep -Eq "^$BINARY v$VERSION" | ||||||
| # test and build everything |   # Build everything | ||||||
| - rvm 2.0.0 do make release |   - rvm 2.0.0 do make release | ||||||
| after_success: | after_success: | ||||||
|   # Display Release Folder |   # Display Release Folder | ||||||
|   - ls -l release/ |   - ls -l release/ | ||||||
|   - | |   - | | ||||||
|       declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)" |     mkdir -p $HOME/.ssh | ||||||
|       echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config |     declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)" | ||||||
|  |     echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> $HOME/.ssh/config | ||||||
|       # Get deploy key for golift/homebrew-mugs. |       # Get deploy key for golift/homebrew-mugs. | ||||||
|       openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in ".travis/github_deploy_key.enc" -out "$SSH_FILE" -d |       openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in ".travis/github_deploy_key.enc" -out "$SSH_FILE" -d | ||||||
|       chmod 600 "$SSH_FILE" \ |       chmod 600 "$SSH_FILE" \ | ||||||
|  | @ -44,7 +50,7 @@ after_success: | ||||||
|           "Host github.com" \ |           "Host github.com" \ | ||||||
|           "  IdentityFile $SSH_FILE" \ |           "  IdentityFile $SSH_FILE" \ | ||||||
|           "  StrictHostKeyChecking no" \ |           "  StrictHostKeyChecking no" \ | ||||||
|           "  LogLevel ERROR" >> ~/.ssh/config |           "  LogLevel ERROR" >> $HOME/.ssh/config | ||||||
| deploy: | deploy: | ||||||
|   - provider: releases |   - provider: releases | ||||||
|     api_key: |     api_key: | ||||||
|  | @ -54,14 +60,8 @@ deploy: | ||||||
|     file_glob: true |     file_glob: true | ||||||
|     file: release/* |     file: release/* | ||||||
|     on: |     on: | ||||||
|       repo: davidnewhall/unifi-poller |  | ||||||
|       tags: true |       tags: true | ||||||
|   - provider: script |   - provider: script | ||||||
|     script: scripts/formula-deploy.sh |     script: scripts/formula-deploy.sh | ||||||
|     on: |     on: | ||||||
|       tags: true |       tags: true | ||||||
|       repo: davidnewhall/unifi-poller |  | ||||||
| env: |  | ||||||
|   global: |  | ||||||
|     - GH_USER_NAME=unifi-auto-releaser |  | ||||||
|     - GH_USER_EMAIL=unifi@auto.releaser |  | ||||||
|  |  | ||||||
							
								
								
									
										187
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										187
									
								
								Makefile
								
								
								
								
							|  | @ -1,9 +1,9 @@ | ||||||
| # This Makefile is written as generic as possible.
 | # This# This Makefile is written as generic as possible.
 | ||||||
| # Setting the variables in .metadata.sh and creating the paths in the repo makes this work.
 | # Setting the variables in .metadata.sh and creating the paths in the repo makes this work.
 | ||||||
| #
 | #
 | ||||||
| 
 | 
 | ||||||
| # Suck in our application information.
 | # Suck in our application information.
 | ||||||
| IGNORE := $(shell bash -c "source .metadata.sh ; env | sed 's/=/:=/;s/^/export /' > .metadata.make") | IGNORED:=$(shell bash -c "source .metadata.sh ; env | sed 's/=/:=/;s/^/export /' > .metadata.make") | ||||||
| 
 | 
 | ||||||
| # md2roff turns markdown into man files and html files.
 | # md2roff turns markdown into man files and html files.
 | ||||||
| MD2ROFF_BIN=github.com/github/hub/md2roff-bin | MD2ROFF_BIN=github.com/github/hub/md2roff-bin | ||||||
|  | @ -23,12 +23,31 @@ endif | ||||||
| # rpm is wierd and changes - to _ in versions.
 | # rpm is wierd and changes - to _ in versions.
 | ||||||
| RPMVERSION:=$(shell echo $(VERSION) | tr -- - _) | RPMVERSION:=$(shell echo $(VERSION) | tr -- - _) | ||||||
| 
 | 
 | ||||||
|  | PACKAGE_SCRIPTS= | ||||||
|  | ifeq ($(FORMULA),service) | ||||||
|  | 	PACKAGE_SCRIPTS=--after-install scripts/after-install.sh --before-remove scripts/before-remove.sh | ||||||
|  | endif | ||||||
|  | 
 | ||||||
|  | define PACKAGE_ARGS | ||||||
|  | $(PACKAGE_SCRIPTS) \ | ||||||
|  | --name $(BINARY) \ | ||||||
|  | --deb-no-default-config-files \ | ||||||
|  | --rpm-os linux \ | ||||||
|  | --iteration $(ITERATION) \ | ||||||
|  | --license $(LICENSE) \ | ||||||
|  | --url $(URL) \ | ||||||
|  | --maintainer "$(MAINT)" \ | ||||||
|  | --vendor "$(VENDOR)" \ | ||||||
|  | --description "$(DESC)" \ | ||||||
|  | --config-files "/etc/$(BINARY)/$(CONFIG_FILE)" | ||||||
|  | endef | ||||||
|  | 
 | ||||||
| # Makefile targets follow.
 | # Makefile targets follow.
 | ||||||
| 
 | 
 | ||||||
| all: build | all: build | ||||||
| 
 | 
 | ||||||
| # Prepare a release. Called in Travis CI.
 | # Prepare a release. Called in Travis CI.
 | ||||||
| release: clean vendor test macos arm windows linux_packages | release: clean macos arm windows linux_packages | ||||||
| 	# Prepareing a release! | 	# Prepareing a release! | ||||||
| 	mkdir -p $@ | 	mkdir -p $@ | ||||||
| 	mv $(BINARY).*.macos $(BINARY).*.linux $@/ | 	mv $(BINARY).*.macos $(BINARY).*.linux $@/ | ||||||
|  | @ -42,7 +61,7 @@ release: clean vendor test macos arm windows linux_packages | ||||||
| clean: | clean: | ||||||
| 	# Cleaning up. | 	# Cleaning up. | ||||||
| 	rm -f $(BINARY) $(BINARY).*.{macos,linux,exe}{,.gz,.zip} $(BINARY).1{,.gz} $(BINARY).rb | 	rm -f $(BINARY) $(BINARY).*.{macos,linux,exe}{,.gz,.zip} $(BINARY).1{,.gz} $(BINARY).rb | ||||||
| 	rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256 .metadata.make | 	rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256 examples/MANUAL .metadata.make | ||||||
| 	rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html | 	rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html | ||||||
| 	rm -rf package_build_* release | 	rm -rf package_build_* release | ||||||
| 
 | 
 | ||||||
|  | @ -111,161 +130,42 @@ linux_packages: rpm deb rpm386 deb386 debarm rpmarm debarmhf rpmarmhf | ||||||
| rpm: $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm | rpm: $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm | ||||||
| $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm: package_build_linux check_fpm | $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm: package_build_linux check_fpm | ||||||
| 	@echo "Building 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | 	@echo "Building 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t rpm \
 | 	fpm -s dir -t rpm $(PACKAGE_ARGS) -a x86_64 -v $(RPMVERSION) -C $< | ||||||
| 		--architecture x86_64 \
 |  | ||||||
| 		--name $(BINARY) \
 |  | ||||||
| 		--rpm-os linux \
 |  | ||||||
| 		--version $(RPMVERSION) \
 |  | ||||||
| 		--iteration $(ITERATION) \
 |  | ||||||
| 		--after-install scripts/after-install.sh \
 |  | ||||||
| 		--before-remove scripts/before-remove.sh \
 |  | ||||||
| 		--license $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 | 
 | ||||||
| deb: $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb | deb: $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb | ||||||
| $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb: package_build_linux check_fpm | $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb: package_build_linux check_fpm | ||||||
| 	@echo "Building 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | 	@echo "Building 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t deb \
 | 	fpm -s dir -t deb $(PACKAGE_ARGS) -a amd64 -v $(VERSION) -C $< | ||||||
| 		--architecture amd64 \
 |  | ||||||
| 		--name $(BINARY) \
 |  | ||||||
| 		--deb-no-default-config-files \
 |  | ||||||
| 		--version $(VERSION) \
 |  | ||||||
| 		--iteration $(ITERATION) \
 |  | ||||||
| 		--after-install scripts/after-install.sh \
 |  | ||||||
| 		--before-remove scripts/before-remove.sh \
 |  | ||||||
| 		--license $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 | 
 | ||||||
| rpm386: $(BINARY)-$(RPMVERSION)-$(ITERATION).i386.rpm | rpm386: $(BINARY)-$(RPMVERSION)-$(ITERATION).i386.rpm | ||||||
| $(BINARY)-$(RPMVERSION)-$(ITERATION).i386.rpm: package_build_linux_386 check_fpm | $(BINARY)-$(RPMVERSION)-$(ITERATION).i386.rpm: package_build_linux_386 check_fpm | ||||||
| 	@echo "Building 32-bit 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | 	@echo "Building 32-bit 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t rpm \
 | 	fpm -s dir -t rpm $(PACKAGE_ARGS) -a i386 -v $(RPMVERSION) -C $< | ||||||
| 		--architecture i386 \
 |  | ||||||
| 		--name $(BINARY) \
 |  | ||||||
| 		--rpm-os linux \
 |  | ||||||
| 		--version $(RPMVERSION) \
 |  | ||||||
| 		--iteration $(ITERATION) \
 |  | ||||||
| 		--after-install scripts/after-install.sh \
 |  | ||||||
| 		--before-remove scripts/before-remove.sh \
 |  | ||||||
| 		--license $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 | 
 | ||||||
| deb386: $(BINARY)_$(VERSION)-$(ITERATION)_i386.deb | deb386: $(BINARY)_$(VERSION)-$(ITERATION)_i386.deb | ||||||
| $(BINARY)_$(VERSION)-$(ITERATION)_i386.deb: package_build_linux_386 check_fpm | $(BINARY)_$(VERSION)-$(ITERATION)_i386.deb: package_build_linux_386 check_fpm | ||||||
| 	@echo "Building 32-bit 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | 	@echo "Building 32-bit 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t deb \
 | 	fpm -s dir -t deb $(PACKAGE_ARGS) -a i386 -v $(VERSION) -C $< | ||||||
| 		--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 $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 | 
 | ||||||
| rpmarm: $(BINARY)-$(RPMVERSION)-$(ITERATION).arm64.rpm | rpmarm: $(BINARY)-$(RPMVERSION)-$(ITERATION).arm64.rpm | ||||||
| $(BINARY)-$(RPMVERSION)-$(ITERATION).arm64.rpm: package_build_linux_arm64 check_fpm | $(BINARY)-$(RPMVERSION)-$(ITERATION).arm64.rpm: package_build_linux_arm64 check_fpm | ||||||
| 	@echo "Building 64-bit ARM8 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | 	@echo "Building 64-bit ARM8 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t rpm \
 | 	fpm -s dir -t rpm $(PACKAGE_ARGS) -a arm64 -v $(RPMVERSION) -C $< | ||||||
| 		--architecture arm64 \
 |  | ||||||
| 		--name $(BINARY) \
 |  | ||||||
| 		--rpm-os linux \
 |  | ||||||
| 		--version $(RPMVERSION) \
 |  | ||||||
| 		--iteration $(ITERATION) \
 |  | ||||||
| 		--after-install scripts/after-install.sh \
 |  | ||||||
| 		--before-remove scripts/before-remove.sh \
 |  | ||||||
| 		--license $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 | 
 | ||||||
| debarm: $(BINARY)_$(VERSION)-$(ITERATION)_arm64.deb | debarm: $(BINARY)_$(VERSION)-$(ITERATION)_arm64.deb | ||||||
| $(BINARY)_$(VERSION)-$(ITERATION)_arm64.deb: package_build_linux_arm64 check_fpm | $(BINARY)_$(VERSION)-$(ITERATION)_arm64.deb: package_build_linux_arm64 check_fpm | ||||||
| 	@echo "Building 64-bit ARM8 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | 	@echo "Building 64-bit ARM8 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t deb \
 | 	fpm -s dir -t deb $(PACKAGE_ARGS) -a arm64 -v $(VERSION) -C $< | ||||||
| 		--architecture arm64 \
 |  | ||||||
| 		--name $(BINARY) \
 |  | ||||||
| 		--deb-no-default-config-files \
 |  | ||||||
| 		--version $(VERSION) \
 |  | ||||||
| 		--iteration $(ITERATION) \
 |  | ||||||
| 		--after-install scripts/after-install.sh \
 |  | ||||||
| 		--before-remove scripts/before-remove.sh \
 |  | ||||||
| 		--license $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 | 
 | ||||||
| rpmarmhf: $(BINARY)-$(RPMVERSION)-$(ITERATION).armhf.rpm | rpmarmhf: $(BINARY)-$(RPMVERSION)-$(ITERATION).armhf.rpm | ||||||
| $(BINARY)-$(RPMVERSION)-$(ITERATION).armhf.rpm: package_build_linux_armhf check_fpm | $(BINARY)-$(RPMVERSION)-$(ITERATION).armhf.rpm: package_build_linux_armhf check_fpm | ||||||
| 	@echo "Building 32-bit ARM6/7 HF 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | 	@echo "Building 32-bit ARM6/7 HF 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t rpm \
 | 	fpm -s dir -t rpm $(PACKAGE_ARGS) -a armhf -v $(RPMVERSION) -C $< | ||||||
| 		--architecture armhf \
 |  | ||||||
| 		--name $(BINARY) \
 |  | ||||||
| 		--rpm-os linux \
 |  | ||||||
| 		--version $(RPMVERSION) \
 |  | ||||||
| 		--iteration $(ITERATION) \
 |  | ||||||
| 		--after-install scripts/after-install.sh \
 |  | ||||||
| 		--before-remove scripts/before-remove.sh \
 |  | ||||||
| 		--license $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 | 
 | ||||||
| debarmhf: $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb | debarmhf: $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb | ||||||
| $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb: package_build_linux_armhf check_fpm | $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb: package_build_linux_armhf check_fpm | ||||||
| 	@echo "Building 32-bit ARM6/7 HF 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | 	@echo "Building 32-bit ARM6/7 HF 'deb' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." | ||||||
| 	fpm -s dir -t deb \
 | 	fpm -s dir -t deb $(PACKAGE_ARGS) -a armhf -v $(VERSION) -C $< | ||||||
| 		--architecture armhf \
 |  | ||||||
| 		--name $(BINARY) \
 |  | ||||||
| 		--deb-no-default-config-files \
 |  | ||||||
| 		--version $(VERSION) \
 |  | ||||||
| 		--iteration $(ITERATION) \
 |  | ||||||
| 		--after-install scripts/after-install.sh \
 |  | ||||||
| 		--before-remove scripts/before-remove.sh \
 |  | ||||||
| 		--license $(LICENSE) \
 |  | ||||||
| 		--url $(URL) \
 |  | ||||||
| 		--maintainer "$(MAINT)" \
 |  | ||||||
| 		--description "$(DESC)" \
 |  | ||||||
| 		--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \
 |  | ||||||
| 		--chdir $< |  | ||||||
| 
 |  | ||||||
| docker: |  | ||||||
| 	docker build -f init/docker/Dockerfile \
 |  | ||||||
| 		--build-arg "BUILD_DATE=$(DATE)" \
 |  | ||||||
| 		--build-arg "COMMIT=$(COMMIT)" \
 |  | ||||||
| 		--build-arg "VERSION=$(VERSION)-$(ITERATION)" \
 |  | ||||||
| 		--build-arg "LICENSE=$(LICENSE)" \
 |  | ||||||
| 		--build-arg "DESC=$(DESC)" \
 |  | ||||||
| 		--build-arg "URL=$(URL)" \
 |  | ||||||
| 		--build-arg "VENDOR=$(VENDOR)" \
 |  | ||||||
| 		--build-arg "AUTHOR=$(MAINT)" \
 |  | ||||||
| 		--build-arg "BINARY=$(BINARY)" \
 |  | ||||||
| 		--build-arg "GHREPO=$(GHREPO)" \
 |  | ||||||
| 		--build-arg "CONFIG_FILE=$(CONFIG_FILE)" \
 |  | ||||||
| 		--tag $(DHUSER)/$(BINARY):local . |  | ||||||
| 
 | 
 | ||||||
| # Build an environment that can be packaged for linux.
 | # Build an environment that can be packaged for linux.
 | ||||||
| package_build_linux: readme man linux | package_build_linux: readme man linux | ||||||
|  | @ -277,8 +177,8 @@ package_build_linux: readme man linux | ||||||
| 	cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/ | 	cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/ | ||||||
| 	cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/$(CONFIG_FILE) | 	cp examples/$(CONFIG_FILE).example $@/etc/$(BINARY)/$(CONFIG_FILE) | ||||||
| 	cp LICENSE *.html examples/*?.?* $@/usr/share/doc/$(BINARY)/ | 	cp LICENSE *.html examples/*?.?* $@/usr/share/doc/$(BINARY)/ | ||||||
| 	[ ! -f init/systemd/template.unit.service ] || mkdir -p $@/lib/systemd/system | 	[ "$(FORMULA)" != "service" ] || mkdir -p $@/lib/systemd/system | ||||||
| 	[ ! -f init/systemd/template.unit.service ] || \
 | 	[ "$(FORMULA)" != "service" ] || \
 | ||||||
| 		sed -e "s/{{BINARY}}/$(BINARY)/g" -e "s/{{DESC}}/$(DESC)/g" \
 | 		sed -e "s/{{BINARY}}/$(BINARY)/g" -e "s/{{DESC}}/$(DESC)/g" \
 | ||||||
| 		init/systemd/template.unit.service > $@/lib/systemd/system/$(BINARY).service | 		init/systemd/template.unit.service > $@/lib/systemd/system/$(BINARY).service | ||||||
| 
 | 
 | ||||||
|  | @ -300,6 +200,21 @@ package_build_linux_armhf: package_build_linux armhf | ||||||
| check_fpm: | check_fpm: | ||||||
| 	@fpm --version > /dev/null || (echo "FPM missing. Install FPM: https://fpm.readthedocs.io/en/latest/installing.html" && false) | 	@fpm --version > /dev/null || (echo "FPM missing. Install FPM: https://fpm.readthedocs.io/en/latest/installing.html" && false) | ||||||
| 
 | 
 | ||||||
|  | docker: | ||||||
|  | 	docker build -f init/docker/Dockerfile \
 | ||||||
|  | 		--build-arg "BUILD_DATE=$(DATE)" \
 | ||||||
|  | 		--build-arg "COMMIT=$(COMMIT)" \
 | ||||||
|  | 		--build-arg "VERSION=$(VERSION)-$(ITERATION)" \
 | ||||||
|  | 		--build-arg "LICENSE=$(LICENSE)" \
 | ||||||
|  | 		--build-arg "DESC=$(DESC)" \
 | ||||||
|  | 		--build-arg "URL=$(URL)" \
 | ||||||
|  | 		--build-arg "VENDOR=$(VENDOR)" \
 | ||||||
|  | 		--build-arg "AUTHOR=$(MAINT)" \
 | ||||||
|  | 		--build-arg "BINARY=$(BINARY)" \
 | ||||||
|  | 		--build-arg "GHREPO=$(GHREPO)" \
 | ||||||
|  | 		--build-arg "CONFIG_FILE=$(CONFIG_FILE)" \
 | ||||||
|  | 		--tag $(BINARY) . | ||||||
|  | 
 | ||||||
| # This builds a Homebrew formula file that can be used to install this app from source.
 | # This builds a Homebrew formula file that can be used to install this app from source.
 | ||||||
| # The source used comes from the released version on GitHub. This will not work with local source.
 | # The source used comes from the released version on GitHub. This will not work with local source.
 | ||||||
| # This target is used by Travis CI to update the released Forumla when a new tag is created.
 | # This target is used by Travis CI to update the released Forumla when a new tag is created.
 | ||||||
|  | @ -317,7 +232,7 @@ $(BINARY).rb: v$(VERSION).tar.gz.sha256 | ||||||
| 		-e "s%{{GHREPO}}%$(GHREPO)%g" \
 | 		-e "s%{{GHREPO}}%$(GHREPO)%g" \
 | ||||||
| 		-e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \
 | 		-e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \
 | ||||||
| 		-e "s%{{Class}}%$(shell echo $(BINARY) | perl -pe 's/(?:\b|-)(\p{Ll})/\u$$1/g')%g" \
 | 		-e "s%{{Class}}%$(shell echo $(BINARY) | perl -pe 's/(?:\b|-)(\p{Ll})/\u$$1/g')%g" \
 | ||||||
| 		init/homebrew/formula.rb.tmpl | tee $(BINARY).rb | 		init/homebrew/$(FORMULA).rb.tmpl | tee $(BINARY).rb | ||||||
| 
 | 
 | ||||||
| # Extras
 | # Extras
 | ||||||
| 
 | 
 | ||||||
|  | @ -344,9 +259,9 @@ deps: | ||||||
| install: man readme $(BINARY) | install: man readme $(BINARY) | ||||||
| 	@echo -  Done Building!  - | 	@echo -  Done Building!  - | ||||||
| 	@echo -  Local installation with the Makefile is only supported on macOS. | 	@echo -  Local installation with the Makefile is only supported on macOS. | ||||||
| 	@echo If you wish to install the application manually on Linux, check out the wiki: $(URL)/wiki/Installation | 	@echo If you wish to install the application manually on Linux, check out the wiki: https://github.com/$(GHREPO)/wiki/Installation | ||||||
| 	@echo -  Otherwise, build and install a package: make rpm -or- make deb | 	@echo -  Otherwise, build and install a package: make rpm -or- make deb | ||||||
| 	@echo See the Package Install wiki for more info: $(URL)/wiki/Package-Install | 	@echo See the Package Install wiki for more info: https://github.com/$(GHREPO)/wiki/Package-Install | ||||||
| 	@[ "$(shell uname)" = "Darwin" ] || (echo "Unable to continue, not a Mac." && false) | 	@[ "$(shell uname)" = "Darwin" ] || (echo "Unable to continue, not a Mac." && false) | ||||||
| 	@[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) | 	@[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) | ||||||
| 	@[ "$(ETC)" != "" ] || (echo "Unable to continue, ETC not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) | 	@[ "$(ETC)" != "" ] || (echo "Unable to continue, ETC not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ Requires=network.target | ||||||
| ExecStart=/usr/bin/{{BINARY}} $DAEMON_OPTS | ExecStart=/usr/bin/{{BINARY}} $DAEMON_OPTS | ||||||
| EnvironmentFile=-/etc/default/{{BINARY}} | EnvironmentFile=-/etc/default/{{BINARY}} | ||||||
| EnvironmentFile=-/etc/sysconfig/{{BINARY}} | EnvironmentFile=-/etc/sysconfig/{{BINARY}} | ||||||
| Restart=on-error | Restart=always | ||||||
| StandardOutput=syslog | StandardOutput=syslog | ||||||
| StandardError=syslog | StandardError=syslog | ||||||
| SyslogIdentifier={{BINARY}} | SyslogIdentifier={{BINARY}} | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| # Deploys a new homebrew formula file to golift/homebrew-tap. | # Deploys a new homebrew formula file to golift/homebrew-tap. | ||||||
| # Requires SSH credentials in ssh-agent to work. | # Requires SSH credentials in ssh-agent to work. | ||||||
| # Run by Travis-CI when a new release is created on GitHub. | # Run by Travis-CI when a new release is created on GitHub. | ||||||
|  | # Do not edit this file. | ||||||
| 
 | 
 | ||||||
| source .metadata.sh | source .metadata.sh | ||||||
| 
 | 
 | ||||||
|  | @ -16,6 +17,7 @@ git clone git@github.com:${HBREPO}.git homebrew_release_repo | ||||||
| 
 | 
 | ||||||
| cp ${BINARY}.rb homebrew_release_repo/Formula | cp ${BINARY}.rb homebrew_release_repo/Formula | ||||||
| pushd homebrew_release_repo | pushd homebrew_release_repo | ||||||
| git commit -m "Update ${BINARY} on Release: v${VERSION}-${ITERATION}" Formula/${BINARY}.rb | git add Formula/${BINARY}.rb | ||||||
|  | git commit -m "Update ${BINARY} on Release: v${VERSION}-${ITERATION}" | ||||||
| git push | git push | ||||||
| popd | popd | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue