From 59a3a1045fc0db2fdb569651e72385d72d6e2202 Mon Sep 17 00:00:00 2001 From: Jack Murdock Date: Tue, 19 Nov 2019 11:57:08 -0800 Subject: [PATCH] fix rpm creation (#176) * fix rpm creation * remove conf/ --- Makefile | 31 +++++++++++++++---------------- deploy/packaging/caduceus.spec | 4 ++-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 74033fe6..621a0b52 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ GOFMT ?= $(GO)fmt APP := caduceus DOCKER_ORG := xmidt FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) -BINARY := $(FIRST_GOPATH)/bin/$(APP) +BINARY := $(FIRST_GOPATH)/bin/$(APP) PROGVER = $(shell git describe --tags `git rev-list --tags --max-count=1` | tail -1 | sed 's/v\(.*\)/\1/') RPM_VERSION=$(shell echo $(PROGVER) | sed 's/\(.*\)-\(.*\)/\1/') @@ -19,20 +19,20 @@ go-mod-vendor: .PHONY: build build: go-mod-vendor - $(GO) build -o $(APP) + $(GO) build -o $(APP) -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)" rpm: mkdir -p ./.ignore/SOURCES - tar -czf ./.ignore/SOURCES/$(APP)-$(RPM_VERSION)-$(RPM_RELEASE).tar.gz --transform 's/^\./$(APP)-$(RPM_VERSION)-$(RPM_RELEASE)/' --exclude ./.git --exclude ./.ignore --exclude ./conf --exclude ./deploy --exclude ./vendor --exclude ./vendor . - cp conf/$(APP).service ./.ignore/SOURCES - cp $(APP).yaml ./.ignore/SOURCES - cp LICENSE ./.ignore/SOURCES - cp NOTICE ./.ignore/SOURCES - cp CHANGELOG.md ./.ignore/SOURCES + tar -czvf ./.ignore/SOURCES/$(APP)-$(RPM_VERSION)-$(RPM_RELEASE).tar.gz . --exclude ./.git --exclude ./.ignore --exclude ./conf --exclude ./deploy --exclude ./vendor + cp conf/$(APP).service ./.ignore/SOURCES/ + cp $(APP).yaml ./.ignore/SOURCES/ + cp LICENSE ./.ignore/SOURCES/ + cp NOTICE ./.ignore/SOURCES/ + cp CHANGELOG.md ./.ignore/SOURCES/ rpmbuild --define "_topdir $(CURDIR)/.ignore" \ - --define "_version $(RPM_VERSION)" \ - --define "_release $(RPM_RELEASE)" \ - -ba deploy/packaging/$(APP).spec + --define "_version $(RPM_VERSION)" \ + --define "_release $(RPM_RELEASE)" \ + -ba deploy/packaging/$(APP).spec .PHONY: version version: @@ -54,13 +54,13 @@ update-version: .PHONY: install install: go-mod-vendor - go install -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)" + $(GO) install -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)" .PHONY: release-artifacts release-artifacts: go-mod-vendor mkdir -p ./.ignore - GOOS=darwin GOARCH=amd64 $(GO) build -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)" -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 - GOOS=linux GOARCH=amd64 $(GO) build -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)" -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 + GOOS=darwin GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)" + GOOS=linux GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(PROGVER)" .PHONY: docker docker: @@ -70,7 +70,6 @@ docker: --build-arg BUILDTIME='$(BUILDTIME)' \ -f ./deploy/Dockerfile -t $(DOCKER_ORG)/$(APP):$(PROGVER) . -# build docker without running modules .PHONY: local-docker local-docker: docker build \ @@ -101,4 +100,4 @@ it: .PHONY: clean clean: - rm -rf ./$(APP) ./OPATH ./coverage.txt ./vendor + rm -rf ./$(APP) ./.ignore ./coverage.txt ./vendor diff --git a/deploy/packaging/caduceus.spec b/deploy/packaging/caduceus.spec index 5c157a28..667e152e 100644 --- a/deploy/packaging/caduceus.spec +++ b/deploy/packaging/caduceus.spec @@ -11,7 +11,7 @@ Packager: Comcast Group: System Environment/Daemons License: ASL 2.0 URL: https://github.com/xmidt-org/caduceus -Source0: %{name}-%{_version}.tar.gz +Source0: %{name}-%{_version}-%{_release}.tar.gz Prefix: /opt BuildRoot: %{_tmppath}/%{name} @@ -19,7 +19,7 @@ BuildRequires: systemd BuildRequires: golang >= 1.12 %description -The Xmidt API interface server. +The XMiDT server for delivering events %build GO111MODULE=on go build -ldflags "-X 'main.BuildTime=`date -u '+%Y-%m-%d %H:%M:%S'`' -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=%{_version}" -o $RPM_SOURCE_DIR/%{name} %{_topdir}/..