-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
146 lines (121 loc) · 4.84 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Shorewall templating module by James
# Copyright (C) 2012-2013+ James Shubin
# Written by James Shubin <james@shubin.ca>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
.PHONY: all docs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms
.SILENT:
# version of the program
VERSION := $(shell cat VERSION)
RELEASE = 1
SPEC = rpmbuild/SPECS/puppet-shorewall.spec
SOURCE = rpmbuild/SOURCES/puppet-shorewall-$(VERSION).tar.bz2
SRPM = rpmbuild/SRPMS/puppet-shorewall-$(VERSION)-$(RELEASE).src.rpm
RPM = rpmbuild/RPMS/puppet-shorewall-$(VERSION)-$(RELEASE).rpm
SERVER = 'dl.fedoraproject.org'
REMOTE_PATH = 'pub/puppet-shorewall'
all: docs rpm
docs: puppet-shorewall-documentation.pdf
puppet-shorewall-documentation.pdf: DOCUMENTATION.md
pandoc DOCUMENTATION.md -o 'puppet-shorewall-documentation.pdf'
#
# aliases
#
# TODO: does making an rpm depend on making a .srpm first ?
rpm: $(SRPM) $(RPM)
# do nothing
srpm: $(SRPM)
# do nothing
spec: $(SPEC)
# do nothing
tar: $(SOURCE)
# do nothing
upload: upload-sources upload-srpms upload-rpms
# do nothing
#
# rpmbuild
#
$(RPM): $(SPEC) $(SOURCE)
@echo Running rpmbuild -bb...
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bb $(SPEC) && \
mv rpmbuild/RPMS/noarch/puppet-shorewall-$(VERSION)-$(RELEASE).*.rpm $(RPM)
$(SRPM): $(SPEC) $(SOURCE)
@echo Running rpmbuild -bs...
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bs $(SPEC)
# renaming is not needed because we aren't using the dist variable
#mv rpmbuild/SRPMS/puppet-shorewall-$(VERSION)-$(RELEASE).*.src.rpm $(SRPM)
#
# spec
#
$(SPEC): rpmbuild/ puppet-shorewall.spec.in
@echo Running templater...
#cat puppet-shorewall.spec.in > $(SPEC)
sed -e s/__VERSION__/$(VERSION)/ -e s/__RELEASE__/$(RELEASE)/ < puppet-shorewall.spec.in > $(SPEC)
# append a changelog to the .spec file
git log --format="* %cd %aN <%aE>%n- (%h) %s%d%n" --date=local | sed -r 's/[0-9]+:[0-9]+:[0-9]+ //' >> $(SPEC)
#
# archive
#
$(SOURCE): rpmbuild/
@echo Running git archive...
# use HEAD if tag doesn't exist yet, so that development is easier...
git archive --prefix=puppet-shorewall-$(VERSION)/ -o $(SOURCE) $(VERSION) 2> /dev/null || (echo 'Warning: $(VERSION) does not exist.' && git archive --prefix=puppet-shorewall-$(VERSION)/ -o $(SOURCE) HEAD)
# TODO: ensure that each sub directory exists
rpmbuild/:
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
#
# sha256sum
#
rpmbuild/SOURCES/SHA256SUMS: rpmbuild/SOURCES/ $(SOURCE)
@echo Running SOURCES sha256sum...
cd rpmbuild/SOURCES/ && sha256sum *.tar.bz2 > SHA256SUMS; cd -
rpmbuild/SRPMS/SHA256SUMS: rpmbuild/SRPMS/ $(SRPM)
@echo Running SRPMS sha256sum...
cd rpmbuild/SRPMS/ && sha256sum *src.rpm > SHA256SUMS; cd -
rpmbuild/RPMS/SHA256SUMS: rpmbuild/RPMS/ $(RPM)
@echo Running RPMS sha256sum...
cd rpmbuild/RPMS/ && sha256sum *.rpm > SHA256SUMS; cd -
#
# gpg
#
rpmbuild/SOURCES/SHA256SUMS.asc: rpmbuild/SOURCES/SHA256SUMS
@echo Running SOURCES gpg...
# the --yes forces an overwrite of the SHA256SUMS.asc if necessary
gpg2 --yes --clearsign rpmbuild/SOURCES/SHA256SUMS
rpmbuild/SRPMS/SHA256SUMS.asc: rpmbuild/SRPMS/SHA256SUMS
@echo Running SRPMS gpg...
gpg2 --yes --clearsign rpmbuild/SRPMS/SHA256SUMS
rpmbuild/RPMS/SHA256SUMS.asc: rpmbuild/RPMS/SHA256SUMS
@echo Running RPMS gpg...
gpg2 --yes --clearsign rpmbuild/RPMS/SHA256SUMS
#
# upload
#
# upload to public server
upload-sources: rpmbuild/SOURCES/ rpmbuild/SOURCES/SHA256SUMS rpmbuild/SOURCES/SHA256SUMS.asc
if [ "`cat rpmbuild/SOURCES/SHA256SUMS`" != "`ssh $(SERVER) 'cd $(REMOTE_PATH)/SOURCES/ && cat SHA256SUMS'`" ]; then \
echo Running SOURCES upload...; \
rsync -avz rpmbuild/SOURCES/ $(SERVER):$(REMOTE_PATH)/SOURCES/; \
fi
upload-srpms: rpmbuild/SRPMS/ rpmbuild/SRPMS/SHA256SUMS rpmbuild/SRPMS/SHA256SUMS.asc
if [ "`cat rpmbuild/SRPMS/SHA256SUMS`" != "`ssh $(SERVER) 'cd $(REMOTE_PATH)/SRPMS/ && cat SHA256SUMS'`" ]; then \
echo Running SRPMS upload...; \
rsync -avz rpmbuild/SRPMS/ $(SERVER):$(REMOTE_PATH)/SRPMS/; \
fi
upload-rpms: rpmbuild/RPMS/ rpmbuild/RPMS/SHA256SUMS rpmbuild/RPMS/SHA256SUMS.asc
if [ "`cat rpmbuild/RPMS/SHA256SUMS`" != "`ssh $(SERVER) 'cd $(REMOTE_PATH)/RPMS/ && cat SHA256SUMS'`" ]; then \
echo Running RPMS upload...; \
rsync -avz --prune-empty-dirs rpmbuild/RPMS/ $(SERVER):$(REMOTE_PATH)/RPMS/; \
fi
# vim: ts=8