-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
285 lines (234 loc) · 6.7 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
VERSION= 1.2.4
RELEASE= 3
build:
# Build instructions
SUBDIR+= bin/bluecat \
bin/trxctl \
gpio \
lib/liblua \
lib/libtrx-control \
extension \
protocol \
trx \
sbin/trxd \
udev \
external/bsd/luacurl \
external/mit/luaexpat \
external/mit/lualinux \
external/bsd/luapgsql \
external/bsd/luasqlite \
external/mit/luayaml \
yum \
zypp \
systemd
MANDIR?= /usr/share/man
.PHONY: build
build: $(SUBDIR)
build: subdir
.PHONY: subdir $(SUBDIR)
subdir: $(SUBDIR)
$(SUBDIR):
VERSION=$(VERSION) $(MAKE) -C $@ $(TARGET)
# Recursive targets
.PHONY: clean
clean: TARGET=clean
clean: subdir
.PHONY: cleandir
cleandir: TARGET=cleandir
cleandir: subdir
.PHONY: install trx-control.7
install: TARGET=install
install: subdir trx-control.7
@echo all installed
trx-control.7:
@install -D -m 644 $@ $(DESTDIR)$(MANDIR)/man7/$@
@gzip -f $(DESTDIR)$(MANDIR)/man7/$@
# Dependencies
bin/trxctl: lib/libtrx-control lib/liblua
bin/xqrg: lib/libtrx-control lib/liblua
sbin/trxd: lib/libtrx-control lib/liblua
external/mit/luayaml: sbin/trxd
# Package building
# Definitions and targets for package building
# Variables needed for distribution building
ifeq ($(ID), none)
ID= $(shell lsb_release -si)
endif
ifeq ($(ID), "almalinux")
ID="rhel"
endif
RELEASEVER= $(shell echo $(VERSION_ID) | cut -d . -f 1)
ARCH= $(shell uname -m)
REPOHOST= trx-control.msys.ch
REPOBASE= /var/www/trx-control/pub/repos
PKGDEST= /tmp/trx-control
YUMDEST= $(PKGDEST)/yum
APTDEST= $(PKGDEST)/apt
ZYPPDEST= $(PKGDEST)/zypp
REPOUSER= root
REPOPATH= $(REPOBASE)/rhel-$(RELEASEVER)-$(ARCH)
REDHAT_BASED= alma-10-kitten \
alma-9 \
alma-8 \
rocky-9 \
rocky-8 \
fedora-rawhide \
fedora-41 \
fedora-40 \
fedora-39
SUSE_BASED= opensuse-leap-15.6 \
opensuse-leap-15.5 \
opensuse-tumbleweed
DEBIAN_BASED= ubuntu-24.04 \
ubuntu-22.04 \
ubuntu-20.04 \
debian-13 \
debian-12 \
debian-11
# The following targets are used within the docker container
CODENAME?= $(shell lsb_release -sc)
DEBBASE= /apt/dists/$(CODENAME)
ifeq ($(ARCH), x86_64)
DEBPATH= /apt/dists/$(CODENAME)/stable/binary-amd64
DEBARCH= amd64
endif
ifeq ($(ARCH), aarch64)
DEBPATH= /apt/dists/$(CODENAME)/stable/binary-arm64
DEBARCH= arm64
endif
prepare:
gpg --import /keys/private.asc
gpg --import /keys/public.asc
mkdir /build
cp -a /dist/* /build/
redhat-packages: prepare
rm -f ~/rpmbuild/RPMS/*/trx-control-*
(cd /build && \
VERSION=$(VERSION) RELEASE=$(RELEASE) PG_VERSION=$(PG_VERSION) \
DISTRIBUTION=$@ make -C package/redhat)
cp -a ~/rpmbuild/RPMS/* /yum
suse-packages: prepare
rm -f ~/rpmbuild/RPMS/*/trx-control-*
(cd /build && \
VERSION=$(VERSION) RELEASE=$(RELEASE) PG_VERSION=$(PG_VERSION) \
PG_CONFIG=/usr/bin/pgconfig \
make -C package/suse)
cp -a ~/rpmbuild/RPMS/* /zypp
debian-packages: prepare
chmod 700 /root/.gnupg
mkdir -p $(DEBPATH)
(cd /build && PG_CONFIG=/usr/bin/pg_config dpkg-buildpackage -b)
cp /trx-control*.deb $(DEBPATH)
cd /apt && \
dpkg-scanpackages \
dists/$(CODENAME)/stable/binary-$(DEBARCH) > $(DEBPATH)/Packages
gzip -c $(DEBPATH)/Packages > $(DEBPATH)/Packages.gz
echo Origin: trx-control > $(DEBBASE)/Release
echo Label: trx-control >> $(DEBBASE)/Release
echo Suite: stable >> $(DEBBASE)/Release
echo Version: $(VERSION)-$(RELEASE) >> $(DEBBASE)/Release
echo Codename: $(CODENAME) >> $(DEBBASE)/Release
apt-ftparchive release $(DEBBASE) >> $(DEBBASE)/Release
gpg -a --yes --output $(DEBBASE)/Release.gpg \
--local-user "[email protected]" \
--detach-sign $(DEBBASE)/Release
packages: $(REDHAT_BASED) $(SUSE_BASED) $(DEBIAN_BASED)
@echo All packages built
redhat: $(REDHAT_BASED)
suse: $(SUSE_BASED)
debian: connect fetch-debian $(DEBIAN_BASED) disconnect
packages-clean:
rm -rf $(PKGDEST)
# Package building targets run on the container host
# Special targets to build rpms and install them. Should eventually be
# be replaced by a CI/CD pipeline.
UID= $(shell id -u)
SOCK= /tmp/.trx-control.$(UID)
repos: connect fetch-debian packages redhat-repo suse-repo debian-repo \
pubkey fix-permissions remove-old-packages disconnect
repos-nb: connect redhat-repo suse-repo debian-repo pubkey disconnect
connect:
ssh -S $(SOCK) -M -N -o ControlMaster=yes -f [email protected]
@echo connected
fetch-debian:
rsync -avz -e "ssh -o ControlPath=$(SOCK)" \
[email protected]:$(REPOBASE)/apt $(PKGDEST)
pubkey:
gpg --export -a [email protected] | \
ssh -S $(SOCK) trx-control.msys.ch cat \> \
$(REPOBASE)/trx-control.asc
fix-permissions:
ssh -S $(SOCK) trx-control.msys.ch chmod -R g+r,a+r $(REPOBASE)
remove-old-packages:
ssh -S $(SOCK) trx-control.msys.ch find $(REPOBASE) -type f -mtime +7 \
-exec rm {} " \;"
disconnect:
ssh -S $(SOCK) -O exit trx-control.msys.ch
@echo disconnected
redhat-repo:
ssh -S $(SOCK) trx-control.msys.ch mkdir -p $(REPOBASE)/yum
rsync -avz -e "ssh -o ControlPath=$(SOCK)" \
$(YUMDEST) [email protected]:$(REPOBASE)
for f in $(REDHAT_BASED); \
do \
ssh -S $(SOCK) trx-control.msys.ch \
createrepo $(REPOBASE)/yum/$$f; \
ssh -S $(SOCK) trx-control.msys.ch \
ln -f -s \
$(REPOBASE)/yum/$$f/noarch/trx-control-repo-$(VERSION)-$(RELEASE).noarch.rpm \
$(REPOBASE)/yum/$$f/noarch/trx-control-repo-latest.noarch.rpm; \
done
suse-repo:
ssh -S $(SOCK) trx-control.msys.ch mkdir -p $(REPOBASE)/zypp
rsync -avz -e "ssh -o ControlPath=$(SOCK)" \
$(ZYPPDEST) [email protected]:$(REPOBASE)
for f in $(SUSE_BASED); \
do \
ssh -S $(SOCK) trx-control.msys.ch \
createrepo $(REPOBASE)/zypp/$$f; \
ssh -S $(SOCK) trx-control.msys.ch \
ln -f -s \
$(REPOBASE)/zypp/$$f/noarch/trx-control-repo-$(VERSION)-$(RELEASE).noarch.rpm \
$(REPOBASE)/zypp/$$f/noarch/trx-control-repo-latest.noarch.rpm; \
done
debian-repo:
ssh -S $(SOCK) trx-control.msys.ch mkdir -p $(REPOBASE)/apt
rsync -avz -e "ssh -o ControlPath=$(SOCK)" \
$(APTDEST) [email protected]:$(REPOBASE)
keys:
-mkdir -p $(PKGDEST)
rm -f $(PKGDEST)/*.asc
-gpg -q --output $(PKGDEST)/public.asc --armor \
--export [email protected]
-gpg -q --output $(PKGDEST)/private.asc --armor \
--export-secret-key [email protected]
$(REDHAT_BASED): keys
-mkdir -p $(YUMDEST)/$@
docker run --rm \
-e REPO=$@ \
-v `pwd`:/dist \
-v $(YUMDEST)/$@:/yum \
-v $(PKGDEST):/keys \
--name $@ \
pkg-builder/$@ \
/usr/bin/make -C /dist redhat-packages
$(SUSE_BASED): keys
-mkdir -p $(ZYPPDEST)/$@
docker run --rm \
-e REPO=$@ \
-v `pwd`:/dist \
-v $(ZYPPDEST)/$@:/zypp \
-v $(PKGDEST):/keys \
--name $@ \
pkg-builder/$@ \
/usr/bin/make -C /dist suse-packages
$(DEBIAN_BASED): keys
-mkdir -p $(APTDEST)
docker run --rm \
-e REPO=$@ \
-v `pwd`:/dist \
-v $(APTDEST):/apt \
-v $(PKGDEST):/keys \
--name $@ \
pkg-builder/$@ \
/usr/bin/make -C /dist debian-packages