-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
66 lines (56 loc) · 1.88 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
55
56
57
58
59
60
61
62
63
64
65
66
NAME := hungryfox
GIT_TAG := $(shell git describe --always --tags --abbrev=0 | tail -c +2)
GIT_COMMIT := $(shell git rev-list v${GIT_TAG}..HEAD --count)
GO_VERSION := $(shell go version | cut -d' ' -f3)
VERSION := ${GIT_TAG}.${GIT_COMMIT}
RELEASE := 1
GO_VERSION := $(shell go version | cut -d' ' -f3)
BUILD_DATE := $(shell date --iso-8601=second)
LDFLAGS := -ldflags "-X main.version=${VERSION}-${RELEASE} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}"
.PHONY: default clean prepare test test_codecov build rpm travis
default: clean test build
clean:
rm -rf build
test:
go test ./...
test_codecov:
go test -race -coverprofile="coverage.txt" ./...
build:
mkdir -p build/root/usr/bin
go build ${LDFLAGS} -o build/root/usr/bin/${NAME} ./cmd/hungryfox
tar:
mkdir -p build/root/usr/lib/systemd/system
cp pkg/${NAME}.service build/root/usr/lib/systemd/system/${NAME}.service
mkdir -p build/root/etc/${NAME}
build/root/usr/bin/${NAME} -default-config > build/root/etc/${NAME}/config.yml
cp -r pkg/patterns build/root/etc/${NAME}/
cp -r pkg/filters build/root/etc/${NAME}/
tar -czvPf build/${NAME}-${VERSION}-${RELEASE}.tar.gz -C build/root .
rpm:
fpm -t rpm \
-s "tar" \
--description "HungryFox" \
--vendor "Alexander Akulov" \
--url "https://github.com/AlexAkulov/hungryfox" \
--license "MIT" \
--name "${NAME}" \
--version "${VERSION}" \
--iteration "${RELEASE}" \
--config-files "/etc/${NAME}" \
--after-install "./pkg/postinst" \
-p build \
build/${NAME}-${VERSION}-${RELEASE}.tar.gz
deb:
fpm -t deb \
-s "tar" \
--description "HungryFox" \
--vendor "Alexander Akulov" \
--url "https://github.com/AlexAkulov/hungryfox" \
--license "MIT" \
--name "${NAME}" \
--version "${VERSION}" \
--iteration "${RELEASE}" \
--after-install "./pkg/postinst" \
-p build \
build/${NAME}-${VERSION}-${RELEASE}.tar.gz
travis: test_codecov build tar rpm deb