mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-11-10 05:07:25 +01:00
127 lines
4.2 KiB
Makefile
127 lines
4.2 KiB
Makefile
|
TARGET = ./cc-metric-store
|
||
|
VERSION = 1.3.0
|
||
|
GIT_HASH := $(shell git rev-parse --short HEAD || echo 'development')
|
||
|
CURRENT_TIME = $(shell date +"%Y-%m-%d:T%H:%M:%S")
|
||
|
LD_FLAGS = '-s -X main.date=${CURRENT_TIME} -X main.version=${VERSION} -X main.commit=${GIT_HASH}'
|
||
|
|
||
|
.PHONY: clean test tags $(TARGET)
|
||
|
|
||
|
.NOTPARALLEL:
|
||
|
|
||
|
$(TARGET):
|
||
|
$(info ===> BUILD cc-backend)
|
||
|
@go build -ldflags=${LD_FLAGS} ./cmd/cc-metric-store
|
||
|
|
||
|
<<<<<<< HEAD
|
||
|
=======
|
||
|
BINDIR ?= bin
|
||
|
|
||
|
|
||
|
.PHONY: all
|
||
|
all: $(APP)
|
||
|
|
||
|
$(APP): $(GOSRC)
|
||
|
go get
|
||
|
go build -o $(APP) $(GOSRC_APP) $(GOSRC_FILES)
|
||
|
|
||
|
install: $(APP)
|
||
|
@WORKSPACE=$(PREFIX)
|
||
|
@if [ -z "$${WORKSPACE}" ]; then exit 1; fi
|
||
|
@mkdir --parents --verbose $${WORKSPACE}/usr/$(BINDIR)
|
||
|
@install -Dpm 755 $(APP) $${WORKSPACE}/usr/$(BINDIR)/$(APP)
|
||
|
@install -Dpm 600 config.json $${WORKSPACE}/etc/$(APP)/$(APP).json
|
||
|
|
||
|
.PHONY: clean test fmt
|
||
|
.ONESHELL:
|
||
|
>>>>>>> main
|
||
|
clean:
|
||
|
$(info ===> CLEAN)
|
||
|
@go clean
|
||
|
@rm -f $(TARGET)
|
||
|
|
||
|
test:
|
||
|
$(info ===> TESTING)
|
||
|
@go clean -testcache
|
||
|
@go build ./...
|
||
|
@go vet ./...
|
||
|
@go test ./...
|
||
|
<<<<<<< HEAD
|
||
|
|
||
|
tags:
|
||
|
$(info ===> TAGS)
|
||
|
@ctags -R
|
||
|
=======
|
||
|
|
||
|
fmt:
|
||
|
go fmt $(GOSRC_APP)
|
||
|
|
||
|
# Run linter for the Go programming language.
|
||
|
# Using static analysis, it finds bugs and performance issues, offers simplifications, and enforces style rules
|
||
|
.PHONY: staticcheck
|
||
|
staticcheck:
|
||
|
go install honnef.co/go/tools/cmd/staticcheck@latest
|
||
|
$$(go env GOPATH)/bin/staticcheck ./...
|
||
|
|
||
|
.ONESHELL:
|
||
|
.PHONY: RPM
|
||
|
RPM: scripts/cc-metric-store.spec
|
||
|
@WORKSPACE="$${PWD}"
|
||
|
@SPECFILE="$${WORKSPACE}/scripts/cc-metric-store.spec"
|
||
|
# Setup RPM build tree
|
||
|
@eval $$(rpm --eval "ARCH='%{_arch}' RPMDIR='%{_rpmdir}' SOURCEDIR='%{_sourcedir}' SPECDIR='%{_specdir}' SRPMDIR='%{_srcrpmdir}' BUILDDIR='%{_builddir}'")
|
||
|
@mkdir --parents --verbose "$${RPMDIR}" "$${SOURCEDIR}" "$${SPECDIR}" "$${SRPMDIR}" "$${BUILDDIR}"
|
||
|
# Create source tarball
|
||
|
@COMMITISH="HEAD"
|
||
|
@VERS=$$(git describe --tags $${COMMITISH})
|
||
|
@VERS=$${VERS#v}
|
||
|
@VERS=$$(echo $$VERS | sed -e s+'-'+'_'+g)
|
||
|
@if [ "$${VERS}" = "" ]; then VERS="0.0.1"; fi
|
||
|
@eval $$(rpmspec --query --queryformat "NAME='%{name}' VERSION='%{version}' RELEASE='%{release}' NVR='%{NVR}' NVRA='%{NVRA}'" --define="VERS $${VERS}" "$${SPECFILE}")
|
||
|
@PREFIX="$${NAME}-$${VERSION}"
|
||
|
@FORMAT="tar.gz"
|
||
|
@SRCFILE="$${SOURCEDIR}/$${PREFIX}.$${FORMAT}"
|
||
|
@git archive --verbose --format "$${FORMAT}" --prefix="$${PREFIX}/" --output="$${SRCFILE}" $${COMMITISH}
|
||
|
# Build RPM and SRPM
|
||
|
@rpmbuild -ba --define="VERS $${VERS}" --rmsource --clean "$${SPECFILE}"
|
||
|
# Report RPMs and SRPMs when in GitHub Workflow
|
||
|
@if [[ "$${GITHUB_ACTIONS}" == true ]]; then
|
||
|
@ RPMFILE="$${RPMDIR}/$${ARCH}/$${NVRA}.rpm"
|
||
|
@ SRPMFILE="$${SRPMDIR}/$${NVR}.src.rpm"
|
||
|
@ echo "RPM: $${RPMFILE}"
|
||
|
@ echo "SRPM: $${SRPMFILE}"
|
||
|
@ echo "::set-output name=SRPM::$${SRPMFILE}"
|
||
|
@ echo "::set-output name=RPM::$${RPMFILE}"
|
||
|
@fi
|
||
|
|
||
|
.ONESHELL:
|
||
|
.PHONY: DEB
|
||
|
DEB: scripts/cc-metric-store.deb.control $(APP)
|
||
|
@BASEDIR=$${PWD}
|
||
|
@WORKSPACE=$${PWD}/.dpkgbuild
|
||
|
@DEBIANDIR=$${WORKSPACE}/debian
|
||
|
@DEBIANBINDIR=$${WORKSPACE}/DEBIAN
|
||
|
@mkdir --parents --verbose $$WORKSPACE $$DEBIANBINDIR
|
||
|
#@mkdir --parents --verbose $$DEBIANDIR
|
||
|
@CONTROLFILE="$${BASEDIR}/scripts/cc-metric-store.deb.control"
|
||
|
@COMMITISH="HEAD"
|
||
|
@VERS=$$(git describe --tags --abbrev=0 $${COMMITISH})
|
||
|
@VERS=$${VERS#v}
|
||
|
@VERS=$$(echo $$VERS | sed -e s+'-'+'_'+g)
|
||
|
@if [ "$${VERS}" = "" ]; then VERS="0.0.1"; fi
|
||
|
@ARCH=$$(uname -m)
|
||
|
@ARCH=$$(echo $$ARCH | sed -e s+'_'+'-'+g)
|
||
|
@if [ "$${ARCH}" = "x86-64" ]; then ARCH=amd64; fi
|
||
|
@PREFIX="$${NAME}-$${VERSION}_$${ARCH}"
|
||
|
@SIZE_BYTES=$$(du -bcs --exclude=.dpkgbuild "$$WORKSPACE"/ | awk '{print $$1}' | head -1 | sed -e 's/^0\+//')
|
||
|
@SIZE="$$(awk -v size="$$SIZE_BYTES" 'BEGIN {print (size/1024)+1}' | awk '{print int($$0)}')"
|
||
|
#@sed -e s+"{VERSION}"+"$$VERS"+g -e s+"{INSTALLED_SIZE}"+"$$SIZE"+g -e s+"{ARCH}"+"$$ARCH"+g $$CONTROLFILE > $${DEBIANDIR}/control
|
||
|
@sed -e s+"{VERSION}"+"$$VERS"+g -e s+"{INSTALLED_SIZE}"+"$$SIZE"+g -e s+"{ARCH}"+"$$ARCH"+g $$CONTROLFILE > $${DEBIANBINDIR}/control
|
||
|
@make PREFIX=$${WORKSPACE} install
|
||
|
@DEB_FILE="cc-metric-store_$${VERS}_$${ARCH}.deb"
|
||
|
@dpkg-deb -b $${WORKSPACE} "$$DEB_FILE"
|
||
|
@rm -r "$${WORKSPACE}"
|
||
|
@if [ "$${GITHUB_ACTIONS}" = "true" ]; then
|
||
|
@ echo "::set-output name=DEB::$${DEB_FILE}"
|
||
|
@fi
|
||
|
>>>>>>> main
|