forked from Normation/rudder-packages
/
Makefile
548 lines (481 loc) · 24.4 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
#####################################################################################
# Copyright 2015 Normation SAS
#####################################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, Version 3.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################
.DEFAULT_GOAL := build
# Versions to use
RUDDER_VERSION_TO_PACKAGE = <put Rudder version or version-snapshot here>
RUDDER_MAJOR_VERSION := $(shell echo ${RUDDER_VERSION_TO_PACKAGE} | cut -d'.' -f 1-2)
CFENGINE_RELEASE = 3.7.4
FUSION_RELEASE = 2.3.6
LMDB_RELEASE = 0.9.18
OPENSSL_RELEASE = 1.0.2h
PERL_VERSION = 5.22.0
PCRE_RELEASE = 8.38
# Defauth PATHs
RUDDER_DIR = /opt/rudder
DESTDIR = $(CURDIR)/target
INSTALL_DIR = $(DESTDIR)$(RUDDER_DIR)
TRY_LDFLAGS=-pie -Wl,-z,relro -Wl,-z,now
TRY_CFLAGS=-fPIE -fstack-protector
# Autodetect wget or curl or curl usage and proxy configuration
PROXY_ENV = $(if $(PROXY), http_proxy=$(PROXY) ftp_proxy=$(PROXY))
WGET = wget -q -O
CURL = curl -s -o
FETCH = fetch -q -o
ifneq (,$(wildcard /usr/bin/curl))
GET = $(PROXY_ENV) $(CURL)
GET_OPT = --curl
CPAN_OPT = --curl --no-wget
else
ifneq (,$(wildcard /usr/bin/fetch))
GET = $(PROXY_ENV) $(FETCH)
else
GET = $(PROXY_ENV) $(WGET)
GET_OPT = --wget
CPAN_OPT = --wget
endif
endif
# Autodtect presence of gnu tools
TAR := $(shell type gtar >/dev/null 2>&1 && echo gtar || echo tar)
PATCH := $(shell type gpatch >/dev/null 2>&1 && echo gpatch || echo patch)
SED := $(shell type gsed >/dev/null 2>&1 && echo gsed || echo sed)
INSTALL := $(shell type ginstall >/dev/null 2>&1 && echo ginstall || echo install)
CP_A := cp -rp
FIND := find
# Use parameters to guess what should be packaged
BUILD_DEPS :=
INSTALL_DEPS :=
# default: do not build openssl
ifeq (false,$(USE_SYSTEM_OPENSSL))
BUILD_DEPS := $(BUILD_DEPS) build-ssl
INSTALL_DEPS := $(INSTALL_DEPS) install-ssl
OPENSSL_ARG := --with-openssl=$(CURDIR)/build-ssl/opt/rudder
endif
# default: build lmdb
ifneq (true,$(USE_SYSTEM_LMDB))
BUILD_DEPS := $(BUILD_DEPS) build-lmdb
INSTALL_DEPS := $(INSTALL_DEPS) install-lmdb
LMDB_ARG := --with-lmdb=$(CURDIR)/build-lmdb/opt/rudder
endif
# default: do not build pcre
ifeq (false,$(USE_SYSTEM_PCRE))
BUILD_DEPS := $(BUILD_DEPS) build-pcre
INSTALL_DEPS := $(INSTALL_DEPS) install-pcre
PCRE_ARG := --with-pcre=$(CURDIR)/build-pcre/opt/rudder
endif
# default: build perl
ifneq (true,$(USE_SYSTEM_PERL))
BUILD_DEPS := $(BUILD_DEPS) build-perl
FUSION_DEPS := install-perl
PERL:=$(INSTALL_DIR)/bin/perl
else
FUSION_DEPS := cpan-source
PERL := /usr/bin/perl
endif
# default: embed fusion
ifneq (true,$(USE_SYSTEM_FUSION))
INSTALL_DEPS := $(INSTALL_DEPS) install-fusion
endif
# Hack needed because openssl is not guessing correctly the architecture on solaris 32bits
ifeq (i386-pc-solaris2.10,$(shell ./config.guess))
SSL_CONFIGURE:=./Configure solaris-x86-gcc
# Hack needed because openssl is not guessing correctly the architecture on debian 32 bits chroot
else
ifeq (i386,$(shell [ -x /usr/bin/dpkg ] && dpkg --print-architecture))
SSL_CONFIGURE:=./Configure linux-generic32
else
SSL_CONFIGURE:=./config
endif
endif
# download dependencies
depend: localdepends
localdepends: initial-promises initial-ncf rudder-agent-utilities perl-$(PERL_VERSION) fusioninventory-agent cfengine-source openssl-source lmdb-source pcre-source rudder-agent.cron ./rudder.8.gz
# build binaries
build: build-cfengine
# install to DESTDIR
install: build $(INSTALL_DEPS) install-cfengine initial-promises initial-ncf rudder-agent-utilities rudder-agent.cron
# Directories
mkdir -p $(INSTALL_DIR)/etc
mkdir -p $(INSTALL_DIR)/bin
mkdir -p $(INSTALL_DIR)/share/commands
mkdir -p $(INSTALL_DIR)/share/lib
mkdir -p $(DESTDIR)/var/rudder/cfengine-community/bin
mkdir -p $(DESTDIR)/var/rudder/cfengine-community/inputs
mkdir -p $(DESTDIR)/var/rudder/tmp
mkdir -p $(DESTDIR)/var/rudder/tools
mkdir -p $(DESTDIR)/var/log/rudder/install
mkdir -p $(DESTDIR)/usr/bin
mkdir -p $(DESTDIR)/etc/cron.d
# Init files
ifneq (true,$(NO_INIT))
mkdir -p $(DESTDIR)/etc/init.d
mkdir -p $(DESTDIR)/etc/default
$(INSTALL) -m 755 rudder-agent.init $(DESTDIR)/etc/init.d/rudder-agent
$(INSTALL) -m 755 rudder.init $(DESTDIR)/etc/init.d/rudder
$(INSTALL) -m 644 rudder-agent.default $(DESTDIR)/etc/default/rudder-agent
endif
# cron files
ifneq (true,$(NO_CRON))
$(INSTALL) -m 644 rudder-agent.cron $(DESTDIR)/etc/cron.d/rudder-agent
endif
# Wrapper script
$(INSTALL) -m 755 run-inventory $(INSTALL_DIR)/bin/
# Signature script
$(INSTALL) -m 755 rudder-sign $(INSTALL_DIR)/bin/
$(INSTALL) -m 755 rudder-signature-check $(INSTALL_DIR)/bin/
$(INSTALL) -m 755 signature.sh $(INSTALL_DIR)/bin/ # for backwards compatibility, remove in the next major version after the next LTS after 3.1 is announced
# Install an empty uuid.hive file before generating an uuid
$(INSTALL) -m 644 uuid.hive $(INSTALL_DIR)/etc/
# Install /etc/ld.so.conf.d/rudder.conf in order to use libraries
# contained in /opt/rudder/lib like LMDB or OpenSSL
# (ld.so.conf.d is not supported on RHEL/CentOS 3 and aix)
ifneq (true,$(NO_LDSO))
mkdir -p $(DESTDIR)/etc/ld.so.conf.d
$(INSTALL) -m 644 rudder.conf $(DESTDIR)/etc/ld.so.conf.d/
endif
mkdir -p $(DESTDIR)/opt/rudder/share/package-scripts
$(INSTALL) -m 755 rudder-agent-postinst $(DESTDIR)/opt/rudder/share/package-scripts/
$(INSTALL) -m 755 check-rudder-agent $(DESTDIR)/opt/rudder/bin/
$(INSTALL) -m 755 vzps.py $(DESTDIR)/opt/rudder/bin/
$(INSTALL) -m 755 rudder-perl $(DESTDIR)/opt/rudder/bin/
# Rudder agent utilities
$(INSTALL) -m 755 rudder-agent-utilities/bin/rudder $(INSTALL_DIR)/bin/
$(INSTALL) -m 755 rudder-agent-utilities/share/commands/* $(INSTALL_DIR)/share/commands/
$(INSTALL) -m 755 rudder-agent-utilities/share/lib/* $(INSTALL_DIR)/share/lib/
# Create a symlink to make "rudder" available as part of the default PATH
ln -sf $(RUDDER_DIR)/bin/rudder $(DESTDIR)/usr/bin/rudder
# Install a profile script to make cf-* part of the PATH
ifneq (true,$(NO_PROFILE))
mkdir -p $(DESTDIR)/etc/profile.d
$(INSTALL) -m 644 rudder-agent.sh $(DESTDIR)/etc/profile.d/
endif
# Install a uuidgen script just in case the original one doesn't exist
$(INSTALL) -m 755 uuidgen $(INSTALL_DIR)/bin/
cp -r initial-promises/ $(INSTALL_DIR)/share/
cp -r initial-ncf/ $(INSTALL_DIR)/share/
# clean
clean: localclean
localclean:
rm -rf $(DESTDIR)
rm -rf build-ssl build-lmdb build-cfengine build-perl fusion-modules
rm -rf rudder-sources
[ -d cfengine-source ] && cd cfengine-source && $(MAKE) clean 2>/dev/null || true
[ -d lmdb-source ] && cd lmdb-source && $(MAKE) clean 2>/dev/null || true
[ -d openssl-source ] && cd openssl-source && $(MAKE) clean 2>/dev/null || true
[ -d perl-$(PERL_VERSION) ] && cd perl-$(PERL_VERSION) && $(MAKE) distclean 2>/dev/null || true
# standard name is mrproper
mrproper: veryclean
veryclean:
rm -f rudder-agent.cron
rm -f ./rudder-sources.tar.bz2
rm -rf initial-promises initial-ncf rudder-agent-utilities fusioninventory-agent
rm -rf cfengine-source lmdb-source openssl-source perl-$(PERL_VERSION)
##########################################
# Dependencies separated into components #
##########################################
cfengine-source:
ifeq ($(shell ../../build-caching get --force-config ./cfengine-source/ name=cfengine-src version=$(CFENGINE_RELEASE) >/dev/null 2>&1 || echo KO), KO)
$(eval TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX))
# Original URL: https://cfengine-package-repos.s3.amazonaws.com/tarballs/cfengine-$(CFENGINE_RELEASE).tar.gz
$(GET) $(TMP_DIR)/cfengine.tgz http://www.normation.com/tarball/cfengine/cfengine-$(CFENGINE_RELEASE).tar.gz
gunzip < $(TMP_DIR)/cfengine.tgz | $(TAR) xf -
mv ./cfengine-$(CFENGINE_RELEASE) ./cfengine-source
../../build-caching put --force-config ./cfengine-source/ name=cfengine-src version=$(CFENGINE_RELEASE)
rm -rf $(TMP_DIR)
endif
# Apply patches
for PATCHNAME in patches/cfengine/*.patch; do echo "Applying $$PATCHNAME..."; $(PATCH) -d ./cfengine-source -p1 < $$PATCHNAME; echo ""; done
# Make sure there were no rejects
test `$(FIND) ./cfengine-source -name \*.rej | wc -l` = 0
openssl-source:
ifeq ($(shell ../../build-caching get --force-config ./openssl-source/ name=openssl-src version=$(OPENSSL_RELEASE) >/dev/null 2>&1 || echo KO), KO)
$(eval TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX))
# Original URL: https://www.openssl.org/source/openssl-$(OPENSSL_RELEASE).tar.gz
$(GET) $(TMP_DIR)/openssl.tgz http://www.normation.com/tarball/openssl/openssl-$(OPENSSL_RELEASE).tar.gz
gunzip < $(TMP_DIR)/openssl.tgz | $(TAR) xf -
mv ./openssl-$(OPENSSL_RELEASE) ./openssl-source
../../build-caching put --force-config ./openssl-source/ name=openssl-src version=$(OPENSSL_RELEASE)
rm -rf $(TMP_DIR)
endif
lmdb-source:
ifeq ($(shell ../../build-caching get --force-config ./lmdb-source/ name=lmdb-src version=$(LMDB_RELEASE) >/dev/null 2>&1 || echo KO), KO)
$(eval TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX))
# Original URL: http://ftp.fr.debian.org/debian/pool/main/l/lmdb/lmdb_$(LMDB_RELEASE).orig.tar.xz
$(GET) $(TMP_DIR)/lmdb.tgz http://www.normation.com/tarball/lmdb/lmdb-$(LMDB_RELEASE).tar.gz
gunzip < $(TMP_DIR)/lmdb.tgz | $(TAR) xf -
mv ./lmdb-LMDB_$(LMDB_RELEASE) ./lmdb-source
../../build-caching put --force-config ./lmdb-source/ name=lmdb-src version=$(LMDB_RELEASE)
rm -rf $(TMP_DIR)
endif
pcre-source:
ifeq ($(shell ../../build-caching get --force-config ./pcre-source/ name=pcre-src version=$(PCRE_RELEASE) >/dev/null 2>&1 || echo KO), KO)
$(eval TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX))
# Original URL: http://vorboss.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.tar.gz
$(GET) $(TMP_DIR)/pcre.tgz http://www.normation.com/tarball/pcre/pcre-$(PCRE_RELEASE).tar.gz
gunzip < $(TMP_DIR)/pcre.tgz | $(TAR) xf -
mv ./pcre-$(PCRE_RELEASE) ./pcre-source
../../build-caching put --force-config ./pcre-source/ name=pcre-src version=$(PCRE_RELEASE)
rm -rf $(TMP_DIR)
endif
rudder-sources.tar.bz2:
$(GET) rudder-sources.tar.bz2 http://www.rudder-project.org/archives/rudder-sources-$(RUDDER_VERSION_TO_PACKAGE).tar.bz2
rudder-sources: rudder-sources.tar.bz2
bunzip2 < rudder-sources.tar.bz2 | $(TAR) xf -
mv rudder-sources-$(RUDDER_VERSION_TO_PACKAGE)*/ rudder-sources/ # the '*' is needed for nightly release
touch rudder-sources # to make it younger than the bzip source file
rudder.8.gz:
# Get man page from rudder-project.org
$(WGET) http://www.rudder-project.org/rudder-doc-${RUDDER_MAJOR_VERSION}/rudder.8
gzip -f rudder.8
initial-promises: ./rudder-sources
rm -rf ./initial-promises/
cp -r ./rudder-sources/rudder-techniques/initial-promises/node-server/ ./initial-promises
initial-ncf: ./rudder-sources ./initial-promises
rm -rf ./initial-ncf
cp -r ./rudder-sources/ncf/tree ./initial-ncf
# retreive the rudder specific ncf.conf
cp ./initial-promises/distributePolicy/ncf/rudder-ncf-conf ./initial-ncf/ncf.conf
rudder-agent-utilities: rudder-sources
rm -rf ./rudder-agent-utilities/
cp -r ./rudder-sources/rudder-agent/ ./rudder-agent-utilities
fusioninventory-agent:
ifeq ($(shell ../../build-caching get --force-config ./fusioninventory-agent/ name=fusioninventory-agent version=$(FUSION_RELEASE) >/dev/null 2>&1 || echo KO), KO)
$(eval TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX))
#Original URL: http://search.cpan.org/CPAN/authors/id/G/GR/GROUSSE/FusionInventory-Agent-$(FUSION_RELEASE).tar.gz
$(GET) $(TMP_DIR)/fusion.tgz http://www.normation.com/tarball/FusionInventory-Agent-$(FUSION_RELEASE).tar.gz
gunzip < $(TMP_DIR)/fusion.tgz | $(TAR) xf -
mv ./FusionInventory-Agent-$(FUSION_RELEASE) ./fusioninventory-agent
../../build-caching put --force-config ./fusioninventory-agent/ name=fusioninventory-agent version=$(FUSION_RELEASE)
rm -rf $(TMP_DIR)
endif
# Apply patches
for PATCHNAME in patches/fusioninventory/*.patch; do echo "Applying $$PATCHNAME... on FusionInventory"; $(PATCH) -d ./fusioninventory-agent -p1 < $$PATCHNAME; done
# Make sure there were no rejects
test `$(FIND) ./fusioninventory-agent -name \*.rej | wc -l` = 0
# Fix a lsusb invocation that crashes some SLES machines
$(FIND) ./fusioninventory-agent -name "USB.pm" -exec rm "{}" \;
# WARNING: Increment perl_source when changing one of the URLs (perl or cpanminus)
perl_source=002
perl-source: perl-$(PERL_VERSION)
perl-$(PERL_VERSION):
ifeq ($(shell ../../build-caching get --force-config ./perl-$(PERL_VERSION)/ name=perl-source versions=$(perl_source) >/dev/null 2>&1 || echo KO), KO)
$(eval TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX))
# Original URL: http://www.cpan.org/src/5.0/perl-5.22.0.tar.gz
$(GET) $(TMP_DIR)/perl.tar.gz http://www.normation.com/tarball/perl/perl-$(PERL_VERSION).tar.gz
gunzip < $(TMP_DIR)/perl.tar.gz | $(TAR) xf -
# Original URL: http://www.cpan.org/modules/by-module/App/App-cpanminus-1.7036.tar.gz
$(GET) ./perl-$(PERL_VERSION)/App-cpanminus.tar.gz http://www.normation.com/tarball/cpan/App-cpanminus-1.7036.tar.gz
cd perl-$(PERL_VERSION) && gunzip < App-cpanminus.tar.gz | $(TAR) xf -
mv ./perl-$(PERL_VERSION)/App-cpanminus-1.7036 ./perl-$(PERL_VERSION)/App-cpanminus
# cpanminus+curl have a bug on rhel3+64bits, this is the workaround, see http://www.rudder-project.org/redmine/issues/8533
sed -i -e "s/'-#',//" ./perl-$(PERL_VERSION)/App-cpanminus/bin/cpanm
../../build-caching put --force-config ./perl-$(PERL_VERSION)/ name=perl-source versions=$(perl_source)
rm -rf $(TMP_DIR)
endif
cpan-source: perl-$(PERL_VERSION)/App-cpanminus
perl-$(PERL_VERSION)/App-cpanminus:
mkdir -p ./perl-$(PERL_VERSION)
$(eval TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX))
# Original URL: http://www.cpan.org/modules/by-module/App/App-cpanminus-1.7036.tar.gz
$(GET) $(TMP_DIR)/App-cpanminus.tar.gz http://www.normation.com/tarball/cpan/App-cpanminus-1.7036.tar.gz
cd perl-$(PERL_VERSION) && gunzip < $(TMP_DIR)/App-cpanminus.tar.gz | $(TAR) xf -
mv ./perl-$(PERL_VERSION)/App-cpanminus-1.7036 ./perl-$(PERL_VERSION)/App-cpanminus
rm -rf $(TMP_DIR)
rudder-agent.cron: rudder-sources
cp ./rudder-sources/rudder-techniques/techniques/system/common/1.0/rudder_agent_community_cron.st ./rudder-agent.cron
# Set unexpanded variables of the cron file
$(SED) 's@\$${sys.workdir}@/var/rudder/cfengine-community@g' rudder-agent.cron | $(SED) 's@\$${g.rudder_base}@/opt/rudder@g' | $(SED) 's@\\&\\&@\&\&@g' | $(SED) 's@\\&1@\&1@g' > rudder-agent.cron.new
mv rudder-agent.cron.new rudder-agent.cron
####################################
# Builds separated into components #
####################################
# TODO generalize install in build-* to allow caching
build-ssl: openssl-source
cd openssl-source && $(SSL_CONFIGURE) -fPIC --prefix=$(RUDDER_DIR) --openssldir=$(RUDDER_DIR)/openssl shared
cd openssl-source && $(MAKE)
slibclean >/dev/null 2>&1 || true
# install to a temporary location is needed to build cfengine
cd openssl-source && $(MAKE) install INSTALL_PREFIX=$(CURDIR)/build-ssl
build-lmdb: lmdb-source
cd lmdb-source/libraries/liblmdb && $(MAKE)
# need a temporary install for cfengine
mkdir -p build-lmdb/opt/rudder
# LMDB's Makefile does not know how to create destination files, do it ourselves
cd build-lmdb/opt/rudder && mkdir -p bin lib include man/man1
# install to a temporary location is needed to build cfengine
cd lmdb-source/libraries/liblmdb && $(MAKE) install prefix=$(RUDDER_DIR) DESTDIR=$(CURDIR)/build-lmdb
build-pcre: pcre-source
cd pcre-source && ./configure --disable-cpp --enable-utf8 --enable-unicode-properties --prefix=$(RUDDER_DIR)
cd pcre-source && $(MAKE)
# install to a temporary location is needed to build cfengine
cd pcre-source && $(MAKE) install DESTDIR=$(CURDIR)/build-pcre
build-cfengine: get-flags $(BUILD_DEPS) cfengine-source build-cfengine-stamp
build-cfengine-stamp:
# If there is no configure, bootstrap with autogen.sh first
cd cfengine-source && [ -x ./configure ] || NO_CONFIGURE=1 ./autogen.sh
# remove temporary rpath added by configure to build options
cd cfengine-source && $(SED) 's/[A-Z]*_LDFLAGS="$[A-Z]*_LDFLAGS -R$with_[a-z]*\/lib"/true/' configure > configure.new && mv configure.new configure && chmod +x configure
cd cfengine-source && ./configure --prefix=$(RUDDER_DIR) --with-workdir=/var/rudder/cfengine-community --enable-static=yes --enable-shared=no --without-postgresql $(LMDB_ARG) $(OPENSSL_ARG) $(PCRE_ARG) CFLAGS="$(BUILD_CFLAGS) $(SECURE_CFLAGS)" LDFLAGS="-Wl,-R/opt/rudder/lib $(BUILD_LDFLAGS) $(SECURE_LDFLAGS)"
cd cfengine-source && $(MAKE)
touch $@
# Test if compiler supports hardening flags
get-flags:
$(eval BUILD_CFLAGS:=$(shell [ -x /usr/bin/dpkg-buildflags ] && /usr/bin/dpkg-buildflags --get CFLAGS ))
$(eval BUILD_LDFLAGS:=$(shell [ -x /usr/bin/dpkg-buildflags ] && /usr/bin/dpkg-buildflags --get LDFLAGS ))
$(eval HAVE_PROTECTION:=$(shell \
FLAG_TEST_FILE=`mktemp /tmp/hardening.XXXXXX` ;\
echo "void main() {}" > "$${FLAG_TEST_FILE}.c" ;\
gcc $(TRY_CFLAGS) $(TRY_LDFLAGS) -o "$${FLAG_TEST_FILE}" "$${FLAG_TEST_FILE}.c" 2>/dev/null && echo "OK";\
rm -f "$${FLAG_TEST_FILE}" "$${FLAG_TEST_FILE}".c ))
$(eval SECURE_CFLAGS:=$(if $(HAVE_PROTECTION),$(TRY_CFLAGS)))
$(eval SECURE_LDFLAGS:=$(if $(HAVE_PROTECTION),$(TRY_LDFLAGS)))
build-perl: perl-$(PERL_VERSION)
cd perl-$(PERL_VERSION) && $(MAKE) distclean 2>/dev/null || true # Or this can fail on an already used source
cd perl-$(PERL_VERSION) && ./Configure -Dnoextensions=ODBM_File -Duserelocatableinc -Dusethreads -des -Dcc="gcc" -Dinstallprefix=$(RUDDER_DIR) -Dsiteprefix=$(RUDDER_DIR) -Dprefix=$(RUDDER_DIR)
cd perl-$(PERL_VERSION) && $(MAKE)
touch $@
#####################################
# Install separated into components #
#####################################
install-ssl: build-ssl
mkdir -p $(DESTDIR)
# TODO cleanup a bit, we don't need everything here
$(CP_A) $(CURDIR)/build-ssl/* $(DESTDIR)
install-lmdb: build-lmdb
mkdir -p $(DESTDIR)
$(CP_A) $(CURDIR)/build-lmdb/* $(DESTDIR)
install-pcre: build-pcre
mkdir -p $(DESTDIR)
$(CP_A) $(CURDIR)/build-pcre/* $(DESTDIR)
install-cfengine: build-cfengine $(INSTALL_DEPS)
cd cfengine-source && $(MAKE) install DESTDIR=$(DESTDIR) STRIP=""
mkdir -p $(INSTALL_DIR)/share/man/man8
cd cfengine-source && for binary in cf-agent cf-promises cf-key cf-execd cf-serverd cf-monitord cf-runagent; do \
LD_LIBRARY_PATH="$(INSTALL_DIR)/lib" $${binary}/$${binary} -M | gzip > $(INSTALL_DIR)/share/man/man8/$${binary}.8.gz; \
done
install-perl: build-perl
cd perl-$(PERL_VERSION) && $(MAKE) install DESTDIR=$(DESTDIR)
touch build-perl # because perl-$(PERL_VERSION) is touched by make install
CPANM:=$(CURDIR)/perl-$(PERL_VERSION)/App-cpanminus/bin/cpanm $(CPAN_OPT)
MODULE_INSTALL:=MAKEFLAGS= $(PERL) $(CPANM) -l $(INSTALL_DIR) --skip-installed
MODULE_TEST:=$(PERL) -I $(INSTALL_DIR)/lib/perl5 -e1
fusion-modules: $(FUSION_DEPS)
mkdir -p $(INSTALL_DIR)/lib/perl5
# Fusion dependencies :
# * Text::Template -> server only
# * LWP
# * Net::IP
# * XML::TreePP
# * UNIVERSAL::require
# * File::Which
# Socket::GetAddrInfo: 0 -> network
# Archive::Extract: 0
# Compress::Zlib: 0
# Crypt::DES: 0
# Digest::MD5: 0
# Digest::SHA: 0
# File::Copy::Recursive: 0
# HTTP::Daemon: 0
# IO::Socket::SSL: 0
# JSON: 0
# LWP::Protocol::https: 0
# Net::CUPS: 0.6
# Net::NBName: 0
# Net::SNMP: 0
# Net::Write::Layer2: 0
# POE::Component::Client::Ping: 0
# Parse::EDID: 0
# Proc::Daemon: 0
# Proc::PID::File: 0
# URI::Escape: 0
#
# TODO rework these dependencies, they are not the right ones
# CPAN Modules installation
# Original URL: http://www.cpan.org/modules/by-module/URI/URI-1.67.tar.gz
$(MODULE_INSTALL) http://www.normation.com/tarball/cpan/URI-1.67.tar.gz
$(MODULE_TEST) -MURI
# # Original URL: http://www.cpan.org/modules/by-module/HTML/HTML-Tagset-3.20.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/HTML-Tagset-3.20.tar.gz
# $(MODULE_TEST) -MHTML::Tagset
# # Original URL: http://www.cpan.org/modules/by-module/HTML/HTML-Parser-3.71.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/HTML-Parser-3.71.tar.gz
# $(MODULE_TEST) -MHTML::Parser
# Original URL: http://www.cpan.org/modules/by-module/LWP/libwww-perl-6.13.tar.gz
$(MODULE_INSTALL) http://www.normation.com/tarball/cpan/libwww-perl-6.13.tar.gz
$(MODULE_TEST) -MLWP
# # Original URL: http://www.cpan.org/modules/by-module/Compress/Compress-Raw-Bzip2-2.068.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/Compress-Raw-Bzip2-2.068.tar.gz
# $(MODULE_TEST) -MCompress::Raw::Bzip2
# # Original URL: http://www.cpan.org/modules/by-module/Compress/Compress-Raw-Zlib-2.068.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/Compress-Raw-Zlib-2.068.tar.gz
# $(MODULE_TEST) -MCompress::Raw::Zlib
# # Original URL: http://www.cpan.org/modules/by-module/IO/IO-Compress-2.068.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/IO-Compress-2.068.tar.gz
# #No test: IO::Compress cannot be called directly
# Original URL: http://www.cpan.org/modules/by-module/Digest/Digest-MD5-2.54.tar.gz
$(MODULE_INSTALL) http://www.normation.com/tarball/cpan/Digest-MD5-2.54.tar.gz
$(MODULE_TEST) -MDigest::MD5
# Orignal URL: http://www.cpan.org/modules/by-module/Net/Net-IP-1.26.tar.gz
$(MODULE_INSTALL) http://www.normation.com/tarball/cpan/Net-IP-1.26.tar.gz
$(MODULE_TEST) -MNet::IP
# # Original URL: http://www.cpan.org/modules/by-module/XML/XML-NamespaceSupport-1.11.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/XML-NamespaceSupport-1.11.tar.gz
# $(MODULE_TEST) -MXML::NamespaceSupport
# # Original URL: http://www.cpan.org/modules/by-module/XML/XML-SAX-0.99.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/XML-SAX-0.99.tar.gz
# $(MODULE_TEST) -MXML::SAX
# # Original URL: http://www.cpan.org/modules/by-module/XML/XML-Simple-2.20.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/XML-Simple-2.20.tar.gz
# $(MODULE_TEST) -MXML::Simple
# Original URL: http://www.cpan.org/modules/by-module/XML/XML-TreePP-0.43.tar.gz
$(MODULE_INSTALL) http://www.normation.com/tarball/cpan/XML-TreePP-0.43.tar.gz
$(MODULE_TEST) -MXML::TreePP
# Original URL: http://www.cpan.org/modules/by-module/UNIVERSAL/UNIVERSAL-require-0.18.tar.gz
$(MODULE_INSTALL) http://www.normation.com/tarball/cpan/UNIVERSAL-require-0.18.tar.gz
$(MODULE_TEST) -MUNIVERSAL::require
# # Original URL: http://search.cpan.org/CPAN/authors/id/K/KW/KWILLIAMS/Probe-Perl-0.03.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/Probe-Perl-0.03.tar.gz
# $(MODULE_TEST) -MProbe::Perl
# # Original URL: http://www.cpan.org/modules/by-module/IPC/IPC-Run3-0.048.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/IPC-Run3-0.048.tar.gz
# $(MODULE_TEST) -MIPC::Run3
# # Original URL: http://www.cpan.org/modules/by-module/Test/Test-Script-1.10.tar.gz
# $(MODULE_INSTALL) http://www.normation.com/tarball/cpan/Test-Script-1.10.tar.gz
# $(MODULE_TEST) -MTest::Script
# Original URL: http://www.cpan.org/modules/by-module/File/File-Which-1.18.tar.gz
$(MODULE_INSTALL) http://www.normation.com/tarball/cpan/File-Which-1.18.tar.gz
$(MODULE_TEST) -MFile::Which
# Replace destdir by prefix in files generated by cpanm
find $(INSTALL_DIR)/lib/perl5 -type f -name "*.packlist" -o -name "*.pod" -exec sed -i "s,$(DESTDIR),," {} \;
touch $@
install-fusion: fusioninventory-agent fusion-modules
# Fusion installation
mkdir -p $(INSTALL_DIR)/share/fusion-utils
cp -r fusioninventory-agent/share/* $(INSTALL_DIR)/share/fusion-utils/
ifeq ($(INSTALL),ginstall)
# fusion doesn't know how to make install without gnu tools in the path
$(SED) 's/\([^g]\)install -m/\1ginstall -m/' fusioninventory-agent/Makefile.PL > fusioninventory-agent/Makefile.PL.new
mv fusioninventory-agent/Makefile.PL.new fusioninventory-agent/Makefile.PL
endif
cd fusioninventory-agent && PERL_MM_USE_DEFAULT=1 $(PERL) Makefile.PL --default PREFIX=$(RUDDER_DIR)
cd fusioninventory-agent && $(MAKE) install DESTDIR=$(DESTDIR)
# bug in fusion installer that doesn't set the right owner to some files
chown root $(DESTDIR)/opt/rudder/share/fusioninventory
chown root $(DESTDIR)/opt/rudder/share/fusioninventory/html
chown root $(DESTDIR)/opt/rudder/etc/fusioninventory
cp -r fusioninventory-agent/lib/FusionInventory $(INSTALL_DIR)/lib/perl5/
.PHONY: localclean localdepends veryclean depend build install clean mrproper install-ssl install-lmdb install-cfengine install-perl install-fusion get-flags