forked from ake-persson/etcdtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (42 loc) · 1.51 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
49
50
51
52
53
54
NAME=etcdtool
BUILDDIR=.build
SRCDIR=github.com/mickep76/$(NAME)
VERSION:=$(shell git describe --abbrev=0 --tags)
RELEASE:=$(shell date -u +%Y%m%d%H%M)
ARCH:=$(shell uname -p)
all: build
clean:
rm -rf bin pkg ${NAME} ${BUILDDIR} release
update:
gb vendor update --all
deps:
go get github.com/constabulary/gb/...
build: clean
gb build
darwin:
gb build
mkdir release || true
mv bin/etcdtool release/etcdtool-${VERSION}-${RELEASE}.darwin.x86_64
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
binary:
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-binary
mkdir release || true
mv bin/etcdtool release/etcdtool-${VERSION}-${RELEASE}.linux.x86_64
set-version:
sed -i .tmp "s/const Version =.*/const Version = \"${VERSION}\"/" src/${SRCDIR}/version.go
rm -f src/${SRCDIR}/version.go.tmp
release: clean set-version darwin rpm binary
build-binary: deps
gb build
build-rpm: deps
gb build
mkdir -p ${BUILDDIR}/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cp bin/${NAME} ${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="${ARCH}" --clean --define "_topdir $$(pwd)/${BUILDDIR}" ${BUILDDIR}/SPECS/${NAME}.spec
mkdir release || true
mv ${BUILDDIR}/RPMS/${ARCH}/*.rpm release