Kaynağa Gözat

chore: switch to nfpm for package creation

Mustafa Arici 5 yıl önce
ebeveyn
işleme
e8daf853a1
2 değiştirilmiş dosya ile 50 ekleme ve 2 silme
  1. 17 2
      Makefile
  2. 33 0
      nfpm.yaml

+ 17 - 2
Makefile

@@ -13,9 +13,13 @@ development-deps:
 	# static asset bundling
 	go get github.com/kevinburke/go-bindata/...
 
+	# for creating rpm, deb packages
+	go get github.com/goreleaser/nfpm/cmd/nfpm@latest
+
 	# webui related dependencies
 	pacman -Sy yarn
 
+# Runs unit tests.
 test:
 	go test -count=1 -race -coverprofile=coverage.txt -covermode=atomic .
 
@@ -40,11 +44,22 @@ bundle-swagger: proto
 bundle: clean-bundle bundle-webui bundle-swagger
 	go-bindata -pkg bundle -o bundle/bindata.go bundle/...
 
+# Builds server and client binaries under ./bin folder. Accetps $VERSION env var.
 build: bundle
 	@echo Building
 	rm -rf bin/
 	mkdir -p bin/
 	# CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./bin/ovpm  ./cmd/ovpm 
 	# CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./bin/ovpmd ./cmd/ovpmd
-	GOOS=linux go build -o ./bin/ovpm  ./cmd/ovpm 
-	GOOS=linux go build -o ./bin/ovpmd ./cmd/ovpmd
+	GOOS=linux go build -ldflags="-X 'github.com/cad/ovpm.Version=$(VERSION)'" -o ./bin/ovpm  ./cmd/ovpm 
+	GOOS=linux go build -ldflags="-X 'github.com/cad/ovpm.Version=$(VERSION)'" -o ./bin/ovpmd ./cmd/ovpmd
+
+clean-dist:
+	rm -rf dist/
+	mkdir -p dist/
+
+# Builds rpm and dep packages under ./dist folder. Accepts $VERSION env var.
+dist: clean-dist build
+	@echo Generating VERSION=$(VERSION) rpm and deb packages under dist/
+	nfpm pkg -t ./dist/ovpm.rpm
+	nfpm pkg -t ./dist/ovpm.deb

+ 33 - 0
nfpm.yaml

@@ -0,0 +1,33 @@
+name: "ovpm"
+arch: "amd64"
+platform: "linux"
+version: "${VERSION}"
+section: "default"
+priority: "extra"
+depends:
+- openvpn
+maintainer: "Mustafa ARICI <mustafa@arici.io>"
+description: |
+  OVPM makes all aspects of OpenVPN server administration a breeze.
+vendor: ""
+homepage: "https://github.com/cad/ovpm"
+license: "AGPL3"
+overrides:
+  rpm:
+    files:
+      ./bin/ovpm: "/bin/ovpm"
+      ./bin/ovpmd: "/sbin/ovpmd"
+      ./contrib/systemd/ovpmd.service: "/usr/lib/systemd/system/ovpmd.service"
+  deb:
+    files:
+      ./bin/ovpm: "/bin/ovpm"
+      ./bin/ovpmd: "/sbin/ovpmd"
+      ./contrib/systemd/ovpmd.service: "/lib/systemd/system/ovpmd.service"
+scripts:
+  preinstall: ./scripts/preinstall.sh
+  postinstall: ./scripts/postinstall.sh
+  preremove: ./scripts/preremove.sh
+  postremove: ./scripts/postremove.sh
+empty_folders: 
+  - "/var/db/ovpm"
+