-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
48 lines (37 loc) · 1.19 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
NAME=peekaboo
SRCDIR=src/github.com/imc-trading/${NAME}
BUILDDIR=.build
RESDIR=/var/lib/${NAME}
VERSION:=$(shell awk -F '"' '/Version/ {print $$2}' ${SRCDIR}/version/version.go)
RELEASE:=$(shell date -u +%Y%m%d%H%M)
all: build
clean:
rm -f *.rpm
rm -rf pkg bin ${BUILDDIR}
deps:
go get github.com/constabulary/gb/...
test: clean
gb test
build: test
gb build
linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 gb build
darwin:
GOOS=darwin GOARCH=amd64 gb build
update:
gb vendor update --all
install:
cp bin/peekaboo /usr/bin
mkdir -p ${RESDIR}
cp -r ${SRCDIR}/static ${RESDIR}
cp -r ${SRCDIR}/templates ${RESDIR}
rpm:
docker pull mickep76/centos-golang:latest
docker run --rm -it -v "$$PWD":/go/src/${SRCDIR} -w /go/src/${SRCDIR} mickep76/centos-golang:latest make build-rpm
build-rpm: deps build
mkdir -p ${BUILDDIR}/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cp -r bin files static ${BUILDDIR}/SOURCES
sed -e "s/%NAME%/${NAME}/g" -e "s/%VERSION%/${VERSION}/g" -e "s/%RELEASE%/${RELEASE}/g" \
${NAME}.spec >${BUILDDIR}/SPECS/${NAME}.spec
rpmbuild -vv -bb --target="x86_64" --clean --define "_topdir $$(pwd)/${BUILDDIR}" ${BUILDDIR}/SPECS/${NAME}.spec
mv ${BUILDDIR}/RPMS/x86_64/*.rpm .