From 16c469d714ee8b38f605afd353e4e95d0be87085 Mon Sep 17 00:00:00 2001 From: Christopher Najewicz Date: Fri, 12 Oct 2018 10:03:00 -0400 Subject: [PATCH 1/3] Work-in-progress adding nfpm --- Makefile | 13 +++++++++++++ build/nfpm.yaml | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Makefile create mode 100644 build/nfpm.yaml diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..7eec9d0d --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ + +VERSION=$(shell awk '/([0-9]{1}.?){3}/ {print $$4;}' main.go) + +build/gotop: + @go build + +build/nfpm.rpm: + @docker run --rm \ + -v "$(PWD)/build:/tmp/pkg" \ + -e "VERSION=$(VERSION)" \ + goreleaser/nfpm pkg \ + --config /tmp/pkg/nfpm.yaml \ + --target /tmp/pkg/nfpm.rpm diff --git a/build/nfpm.yaml b/build/nfpm.yaml new file mode 100644 index 00000000..14801080 --- /dev/null +++ b/build/nfpm.yaml @@ -0,0 +1,24 @@ +name: "gotop" +arch: "amd64" +platform: "linux" +version: "v${VERSION}" +section: "default" +priority: "extra" +maintainer: "Caleb Bassi " +description: | + A terminal based graphical activity monitor inspired by gtop and vtop +vendor: "Caleb Bassi" +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 From d05e6b04ebd42d96885a29eb484a3220742ecbde Mon Sep 17 00:00:00 2001 From: Christopher 'Chief' Najewicz Date: Fri, 12 Oct 2018 11:24:27 -0400 Subject: [PATCH 2/3] Create Makefile to target rpm/dep w/ nfpm --- .gitignore | 3 ++- Makefile | 29 ++++++++++++++++++++++++---- build/{nfpm.yaml => gotop-nfpm.yaml} | 11 +---------- 3 files changed, 28 insertions(+), 15 deletions(-) rename build/{nfpm.yaml => gotop-nfpm.yaml} (60%) 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" From 4bcf8a4c635e9276dba5da0ef95c908874df65e9 Mon Sep 17 00:00:00 2001 From: Christopher 'Chief' Najewicz Date: Fri, 12 Oct 2018 11:49:58 -0400 Subject: [PATCH 3/3] Adding instructions to README --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index a9076a09..0cb6b6dc 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,17 @@ To make a custom colorscheme, check out the [template](https://github.com/cjbass `-p`, `--percpu` Show each CPU in the CPU widget. `-a`, `--averagecpu` Show average CPU in the CPU widget. + +## Building deb/rpms + +To build dep/rpms using [nfpm](https://github.com/goreleaser/nfpm): + +```bash +make all +``` + +This will place the built packages into the `pkg` folder. + ## Credits - [mdnazmulhasan27771](https://github.com/mdnazmulhasan27771) for the [logo](https://github.com/cjbassi/gotop/blob/master/assets/logo.png)