-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (56 loc) · 1.97 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
SHELL = /bin/bash
TARGETS = zek
PKGNAME = zek
ARCH = amd64
VERSION = 0.1.16
.PHONY: all
all: $(TARGETS)
$(TARGETS): %: cmd/%/main.go
go get -v ./...
go build -ldflags="-s -w" -v -o $@ $<
.PHONY: test
test:
go test -cover -v ./...
.PHONY: clean
clean:
rm -f $(TARGETS)
rm -f $(PKGNAME)*.deb
rm -f $(PKGNAME)-*.rpm
rm -rf packaging/deb/$(PKGNAME)/usr
rm -f docs/$(PKGNAME).1
rm -rf dist
docs/$(PKGNAME).1: docs/$(PKGNAME).md
pandoc -s -t man $< > $@
.PHONY: deb
deb: $(TARGETS) docs/$(PKGNAME).1
mkdir -p packaging/deb/$(PKGNAME)/usr/sbin
mkdir -p packaging/deb/$(PKGNAME)/usr/share/man/man1
cp docs/$(PKGNAME).1 packaging/deb/$(PKGNAME)/usr/share/man/man1
find packaging/deb/$(PKGNAME)/usr -type d -exec chmod 0755 {} \;
find packaging/deb/$(PKGNAME)/usr -type f -exec chmod 0644 {} \;
mkdir -p packaging/deb/$(PKGNAME)/DEBIAN/
cp $(TARGETS) packaging/deb/$(PKGNAME)/usr/sbin
cp packaging/deb/control.$(ARCH) packaging/deb/$(PKGNAME)/DEBIAN/control
cd packaging/deb && fakeroot dpkg-deb --build $(PKGNAME) .
mv packaging/deb/$(PKGNAME)_*.deb .
.PHONY: rpm
rpm: $(TARGETS) docs/$(PKGNAME).1
mkdir -p $(HOME)/rpmbuild/{BUILD,SOURCES,SPECS,RPMS}
cp ./packaging/rpm/$(PKGNAME).spec $(HOME)/rpmbuild/SPECS
cp $(TARGETS) $(HOME)/rpmbuild/BUILD
cp docs/$(PKGNAME).1 $(HOME)/rpmbuild/BUILD
./packaging/rpm/buildrpm.sh $(PKGNAME)
cp $(HOME)/rpmbuild/RPMS/x86_64/$(PKGNAME)*.rpm .
.PHONY: release
release:
@export GITHUB_TOKEN="..."
@echo go tag $(VERSION)
@echo goreleaser release --rm-dist
.PHONY: update-version
update-version:
sed -i -e 's@^const Version =.*@const Version = "$(VERSION)"@' version.go
sed -i -e 's@^Version:.*@Version: $(VERSION)@' packaging/deb/zek/DEBIAN/control
sed -i -e 's@^Version:.*@Version: $(VERSION)@' packaging/deb/control.amd64
sed -i -e 's@^Version:.*@Version: $(VERSION)@' packaging/deb/control.any
sed -i -e 's@^Version:.*@Version: $(VERSION)@' packaging/deb/control.amd64
sed -i -e 's@^Version:.*@Version: $(VERSION)@' packaging/rpm/zek.spec