-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
124 lines (93 loc) · 3.81 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
# Variables needed to build the kernel module
#
name = cern-rpmverify
#
# Distributions which src rpms are built for by default
# The corresponding spec file is needed: DIST/$(name).spec
#
DISTS ?= slc6 el7.centos
#
# Get current version number
#
version = $(shell cat VERSION | cut -d- -f1)
release = $(shell cat VERSION | cut -d- -f2)
#
# Get machine architecture
#
arch = $(shell uname -i)
#
# variables for all external commands (we try to be verbose)
#
GIT = git
PERL = perl
RPMBUILD = rpmbuild
SED = sed
all: srpms
#+++############################################################################
# #
# version management #
# #
#---############################################################################
#
# internal targets
#
.PHONY: _increment_version _increment_release _increment_release_build _update_spec _git_commit_tag
_increment_version:
@$(PERL) -pi -e 'die("invalid version: $$_\n") unless \
s/^(\d+)\.(\d+)-\d+(.*?)$$/sprintf("%d.%d-%d%s", $$1+1, 0, 1, $$3)/e' VERSION
_increment_release:
@$(PERL) -pi -e 'die("invalid version: $$_\n") unless \
s/^(\d+)\.(\d+)-\d+(.*?)$$/sprintf("%d.%d-%d%s", $$1, $$2+1, 1, $$3)/e' VERSION
_increment_release_build:
@$(PERL) -pi -e 'die("invalid version: $$_\n") unless \
s/^(\d+)\.(\d+)-(\d+)(.*?)$$/sprintf("%d.%d-%d%s", $$1, $$2, $$3+1, $$4)/e' VERSION
_update_spec: $(DISTS:=.specfile)
%.specfile: $(name).spec
@version=`cat VERSION | cut -d- -f1`; \
$(SED) -i -e "s/^\(Version:\s\+\)\S\+\s*$$/\1$$version/" $<
@release=`cat VERSION | cut -d- -f2`; \
$(SED) -i -e "s/^\(Release:\s\+\)\d\+\(\S*\)\s*$$/\1$$release\2/" $<
_git_commit_tag:
@version=`cat VERSION | cut -d- -f1`; \
$(GIT) commit -a -m "global commit for version $(version)" || exit 1; \
tag="v$(version)" ; \
$(GIT) tag $$tag || exit 1; \
$(GIT) push || exit 1; \
$(GIT) push origin $$tag || exit 1; \
echo "New version is $(version) (tag $$tag)"
_git_force_commit_tag:
@version=`cat VERSION | cut -d- -f1`; \
$(GIT) commit -a -m "global commit for version $(version)" || exit 1; \
tag="v$(version)" ; \
$(GIT) tag -f $$tag || exit 1; \
$(GIT) push || exit 1; \
$(GIT) push origin $$tag || exit 1; \
echo "New version is $(version) (tag $$tag)"
#
# standard targets
#
version: _increment_version _update_spec _git_commit_tag
release: _increment_release _update_spec _git_commit_tag
release_build: _increment_release_build _update_spec _git_force_commit_tag
#+++############################################################################
# #
# RPMs building #
# #
#---############################################################################
dist: $(name)-$(version).tgz
%.tgz:
@git archive --format=tar --prefix=$(name)-$(version)/ v$(version) \
| gzip > $(name)-$(version).tgz
dir.%:
@mkdir -p $*
srpms: $(DISTS:=.srpm)
rpms: $(DISTS:=.rpm)
slc5.srpm: $(name).spec dist dir.rpms
@$(RPMBUILD) --define "_sourcedir ${PWD}" --define "_srcrpmdir ${PWD}/rpms" --define "dist .slc5" --define '_source_filedigest_algorithm 1' --define '_binary_filedigest_algorithm 1' --define '_binary_payload w9.gzdio' -bs $<;
%.srpm: $(name).spec dist dir.rpms
@$(RPMBUILD) --define "_sourcedir ${PWD}" --define "_srcrpmdir ${PWD}/rpms" --define "dist .$*" -bs $<;
%.rpm: %.srpm
@rpmbuild --rebuild --define '_rpmdir ${PWD}/rpms' --define 'dist .$*' rpms/$(name)-$(version)-$(release).$*.src.rpm
dist.clean:
@rm -f *tgz