Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Commit

Permalink
Create Makefile to target rpm/dep w/ nfpm
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefy committed Oct 12, 2018
1 parent 16c469d commit d05e6b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
gotop*
dist/
build/gotop
pkg/
29 changes: 25 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@

VERSION=$(shell awk '/([0-9]{1}.?){3}/ {print $$4;}' main.go)

.PHONY: all
all: pkg/gotop.rpm pkg/gotop.deb

build/gotop:
@go build
@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/gotop-nfpm.yaml \
--target /tmp/pkg/gotop.rpm \
&& mv ./build/gotop.rpm $@

build/nfpm.rpm:
pkg/gotop.deb: 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.deb \
&& mv ./build/gotop.deb $@

.PHONY: clean
clean:
@-rm -f build/gotop
@-rm -rf pkg
11 changes: 1 addition & 10 deletions build/nfpm.yaml → build/gotop-nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit d05e6b0

Please sign in to comment.