diff --git a/.gitignore b/.gitignore index 8a9b7d90..0e27b067 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -gotop* dist/ +build/gotop +pkg/ \ No newline at end of file diff --git a/Makefile b/Makefile index 7eec9d0d..7ddce408 100644 --- a/Makefile +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/build/nfpm.yaml b/build/gotop-nfpm.yaml similarity index 60% rename from build/nfpm.yaml rename to build/gotop-nfpm.yaml index 14801080..a15824af 100644 --- a/build/nfpm.yaml +++ b/build/gotop-nfpm.yaml @@ -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"