Create Makefile to target rpm/dep w/ nfpm

This commit is contained in:
Christopher 'Chief' Najewicz 2018-10-12 11:24:27 -04:00
parent 16c469d714
commit d05e6b04eb
3 changed files with 29 additions and 16 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
gotop*
dist/
build/gotop
pkg/

View File

@ -1,13 +1,34 @@
VERSION=$(shell awk '/([0-9]{1}.?){3}/ {print $$4;}' main.go)
build/gotop:
@go build
.PHONY: all
all: pkg/gotop.rpm pkg/gotop.deb
build/nfpm.rpm:
build/gotop:
@GOOS=linux GOARCH=amd64 go build -o $@
pkg:
@mkdir $@
pkg/gotop.rpm: pkg build/gotop
@docker run --rm \
-v "$(PWD)/build:/tmp/pkg" \
-e "VERSION=$(VERSION)" \
goreleaser/nfpm pkg \
--config /tmp/pkg/nfpm.yaml \
--target /tmp/pkg/nfpm.rpm
--config /tmp/pkg/gotop-nfpm.yaml \
--target /tmp/pkg/gotop.rpm \
&& mv ./build/gotop.rpm $@
pkg/gotop.deb: pkg build/gotop
@docker run --rm \
-v "$(PWD)/build:/tmp/pkg" \
-e "VERSION=$(VERSION)" \
goreleaser/nfpm pkg \
--config /tmp/pkg/gotop-nfpm.yaml \
--target /tmp/pkg/gotop.deb \
&& mv ./build/gotop.deb $@
.PHONY: clean
clean:
@-rm -f build/gotop
@-rm -rf pkg

View File

@ -12,13 +12,4 @@ homepage: "https://github.com/cjbassi/gotop"
license: "GNU Affero General Public License v3.0"
bindir: "/usr/local/bin"
files:
./gotop: "/usr/local/bin/gotop"
overrides:
rpm:
scripts:
preinstall: ./scripts/preinstall.sh
postremove: ./scripts/postremove.sh
deb:
scripts:
postinstall: ./scripts/postinstall.sh
preremove: ./scripts/preremove.sh
/tmp/pkg/gotop: "/usr/local/bin/gotop"