forked from finley/SystemImager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
713 lines (625 loc) · 27.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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
#
# "SystemImager"
#
# Copyright (C) 1999-2012 Brian Elliott Finley
# Copyright (C) 2001-2004 Hewlett-Packard Company <[email protected]>
#
# Others who have contributed to this code:
# Sean Dague <[email protected]>
#
# $Id$
# vi: set filetype=make:
#
# 2012.03.09 Brian Elliott Finley
# * Fix egrep regex so that e2fsprogs targets show with 'make show_all_targets'
#
#
# 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; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# ERRORS when running make:
# If you encounter errors when running "make", because make couldn't find
# certain things that it needs, and you are fortunate enough to be building
# on a Debian system, you can issue the following command to ensure that
# all of the proper tools are installed.
#
# On Debian, "apt-get build-dep systemimager ; apt-get install wget libssl-dev", will
# install all the right tools. Note that you need the deb-src entries in
# your /etc/apt/sources.list file.
#
#
# SystemImager file location standards:
# o images will be stored in: /var/lib/systemimager/images/
# o autoinstall scripts: /var/lib/systemimager/scripts/
# o tarball files for BT: /var/lib/systemimager/tarballs/
# o torrent files: /var/lib/systemimager/torrents/
# o override directories: /var/lib/systemimager/overrides/
#
# o web gui pages: /usr/share/systemimager/web-gui/
#
# o kernels: /usr/share/systemimager/boot/`arch`/flavor/
# o initrd.img: /usr/share/systemimager/boot/`arch`/flavor/
# o boel_binaries.tar.gz: /usr/share/systemimager/boot/`arch`/flavor/
#
# o perl libraries: /%{perl_vendorlib}
#
# o docs: Use distribution appropriate location.
# Defaults to /usr/share/doc/systemimager/
# for installs from tarball or source.
#
# o man pages: /usr/share/man/man8/
#
# o log files: /var/log/systemimager/
#
# o configuration files: /etc/systemimager/
# o rsyncd.conf: /etc/systemimager/rsyncd.conf
# o rsyncd init script: /etc/init.d/systemimager
# o netbootmond init script: /etc/init.d/netbootmond
#
# o tftp files will be copied to the appropriate destination (as determined
# by the local SysAdmin when running "mkbootserver".
#
# o user visible binaries: /usr/bin
# (si_lsimage, si_mkautoinstalldisk, si_mkautoinstallcd)
# o sysadmin binaries: /usr/sbin
# (all other binaries)
#
#
# Standards for pre-defined rsync modules:
# o boot (directory that holds architecture specific directories with
# boot files for clients)
# o overrides
# o scripts
# o torrents
#
#
DESTDIR :=
VERSION := $(shell cat VERSION)
## is this an unstable release?
MINOR = $(shell echo $(VERSION) | cut -d "." -f 2)
UNSTABLE = 0
ifeq ($(shell echo "$(MINOR) % 2" | bc),1)
UNSTABLE = 1
endif
FLAVOR = $(shell cat FLAVOR)
TOPDIR := $(CURDIR)
# RELEASE_DOCS are toplevel files that should be included with all posted
# tarballs, but aren't installed onto the destination machine by default
RELEASE_DOCS = CHANGE.LOG COPYING CREDITS README VERSION
ARCH = $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
# Follows is a set of arch manipulations to distinguish between ppc types
ifeq ($(ARCH),ppc64)
# Check if machine is Playstation 3
IS_PS3 = $(shell grep -q PS3 /proc/cpuinfo && echo 1)
ifeq ($(IS_PS3),1)
ARCH = ppc64-ps3
else
IS_PPC64 := 1
ifneq ($(shell ls /proc/iSeries 2>/dev/null),)
ARCH = ppc64-iSeries
endif
endif
endif
# is userspace 64bit
USERSPACE64 := 0
ifeq ($(ARCH),ia64)
USERSPACE64 := 1
endif
ifeq ($(ARCH),x86_64)
USERSPACE64 := 1
endif
ifneq ($(BUILD_ARCH),)
ARCH := $(BUILD_ARCH)
endif
#
# To be used by "make" for rules that can take it!
NCPUS := $(shell egrep -c '^processor' /proc/cpuinfo )
MANUAL_DIR = $(TOPDIR)/doc/manual_source
MANPAGE_DIR = $(TOPDIR)/doc/man
PATCH_DIR = $(TOPDIR)/patches
LIB_SRC = $(TOPDIR)/lib
SRC_DIR = $(TOPDIR)/src
BINARY_SRC = $(TOPDIR)/sbin
# destination directories
PREFIX = /usr
ETC = $(DESTDIR)/etc
INITD = $(ETC)/init.d
USR = $(DESTDIR)$(PREFIX)
DOC = $(USR)/share/doc/systemimager-doc
BIN = $(USR)/bin
SBIN = $(USR)/sbin
MAN8 = $(USR)/share/man/man8
LIBEXEC_DEST = $(USR)/lib/systemimager
LIB_DEST = $(DESTDIR)$(shell perl -V:vendorlib | sed s/vendorlib=\'// | sed s/\'\;//)
#LIB_DEST = $(USR)/lib/systemimager/perl
LOG_DIR = $(DESTDIR)/var/log/systemimager
LOCK_DIR = $(DESTDIR)/var/lock/systemimager
INITRD_DIR = $(TOPDIR)/initrd_source
INITRD_BUILD_DIR = $(INITRD_DIR)/build_dir
BOOT_BIN_DEST = $(USR)/share/systemimager/boot/$(ARCH)/$(FLAVOR)
PXE_CONF_SRC = etc/pxelinux.cfg
PXE_CONF_DEST = $(ETC)/systemimager/pxelinux.cfg
KBOOT_CONF_SRC = etc/kboot.cfg
KBOOT_CONF_DEST = $(ETC)/systemimager/kboot.cfg
BINARIES := si_mkautoinstallcd si_mkautoinstalldisk si_psh si_pcp si_pushoverrides si_clusterconfig
SBINARIES := si_addclients si_cpimage si_getimage si_mkdhcpserver si_mkdhcpstatic si_mkautoinstallscript si_mkbootserver si_mvimage si_pushupdate si_pushinstall si_rmimage si_mkrsyncd_conf si_mkclientnetboot si_netbootmond si_mkbootpackage si_monitor si_monitortk si_installbtimage
CLIENT_SBINARIES := si_updateclient si_prepareclient
COMMON_BINARIES = si_lsimage
IMAGESRC = $(TOPDIR)/var/lib/systemimager/images
IMAGEDEST = $(DESTDIR)/var/lib/systemimager/images
WARNING_FILES = $(IMAGESRC)/README $(IMAGESRC)/CUIDADO $(IMAGESRC)/ACHTUNG
AUTOINSTALL_SCRIPT_DIR = $(DESTDIR)/var/lib/systemimager/scripts
AUTOINSTALL_TORRENT_DIR = $(DESTDIR)/var/lib/systemimager/torrents
AUTOINSTALL_TARBALL_DIR = $(DESTDIR)/var/lib/systemimager/tarballs
OVERRIDES_DIR = $(DESTDIR)/var/lib/systemimager/overrides
OVERRIDES_README = $(TOPDIR)/var/lib/systemimager/overrides/README
FLAMETHROWER_STATE_DIR = $(DESTDIR)/var/state/systemimager/flamethrower
RSYNC_STUB_DIR = $(ETC)/systemimager/rsync_stubs
CHECK_FLOPPY_SIZE = expr \`du -b $(INITRD_DIR)/initrd.img | cut -f 1\` + \`du -b $(LINUX_IMAGE) | cut -f 1\`
SI_INSTALL = $(TOPDIR)/tools/si_install --si-prefix=$(PREFIX)
GETSOURCE = $(TOPDIR)/tools/getsource
# Some root tools are probably needed to build SystemImager packages, so
# explicitly add the right paths here. -AR-
PATH := $(PATH):/sbin:/usr/sbin:/usr/local/sbin
########################################################################
#
# BEGIN Give friendly config and packages help. -BEF-
#
IS_CONFIGURED = $(shell test -e config.inc && echo 1 || echo 0)
ifeq ($(IS_CONFIGURED),0)
.PHONY: all
all: show_build_deps
else
include config.inc
# build everything, install nothing
.PHONY: all
all: kernel $(INITRD_DIR)/initrd.img manpages
endif
#
# END Give friendly config and packages help. -BEF-
#
########################################################################
binaries: $(BOEL_BINARIES_TARBALL) kernel $(INITRD_DIR)/initrd.img
# All has been modified as docs don't build on non debian platforms
#
#all: $(BOEL_BINARIES_TARBALL) kernel $(INITRD_DIR)/initrd.img docs manpages
#
# Now include the other targets. Some of these may have order dependencies.
# Order as appropriate. -BEF-
#
# Why does ordered dependencies matter? Make will read all these
# snippets before it evaluates the rule. If there are dependencies caused
# by setting a variable in one and using it in another, then that should be
# abstracted out. Its much more robust to include *.rul... -dannf
#
include $(TOPDIR)/make.d/kernel.rul
include $(TOPDIR)/initrd_source/initrd.rul
# a complete server install
.PHONY: install_server_all
install_server_all: install_server install_common install_binaries
# a complete client install
.PHONY: install_client_all
install_client_all: install_client install_common install_initrd_template
# install server-only architecture independent files
.PHONY: install_server
install_server: install_server_man \
install_configs \
install_server_libs \
$(BITTORRENT_DIR).build
$(SI_INSTALL) -d $(BIN)
$(SI_INSTALL) -d $(SBIN)
$(foreach binary, $(BINARIES), \
$(SI_INSTALL) -m 755 $(BINARY_SRC)/$(binary) $(BIN);)
$(foreach binary, $(SBINARIES), \
$(SI_INSTALL) -m 755 $(BINARY_SRC)/$(binary) $(SBIN);)
$(SI_INSTALL) -d -m 755 $(LOG_DIR)
$(SI_INSTALL) -d -m 755 $(LOCK_DIR)
$(SI_INSTALL) -d -m 755 $(BOOT_BIN_DEST)
$(SI_INSTALL) -d -m 755 $(AUTOINSTALL_SCRIPT_DIR)
$(SI_INSTALL) -d -m 755 $(AUTOINSTALL_TARBALL_DIR)
$(SI_INSTALL) -d -m 755 $(AUTOINSTALL_TORRENT_DIR)
$(SI_INSTALL) -d -m 755 $(AUTOINSTALL_SCRIPT_DIR)/pre-install
$(SI_INSTALL) -m 644 --backup --text \
$(TOPDIR)/var/lib/systemimager/scripts/pre-install/99all.harmless_example_script \
$(AUTOINSTALL_SCRIPT_DIR)/pre-install/
$(SI_INSTALL) -m 644 --backup --text \
$(TOPDIR)/var/lib/systemimager/scripts/pre-install/README \
$(AUTOINSTALL_SCRIPT_DIR)/pre-install/
$(SI_INSTALL) -d -m 755 $(AUTOINSTALL_SCRIPT_DIR)/post-install
$(SI_INSTALL) -m 644 --backup --text \
$(TOPDIR)/var/lib/systemimager/scripts/post-install/99all.harmless_example_script \
$(TOPDIR)/var/lib/systemimager/scripts/post-install/95all.monitord_rebooted \
$(TOPDIR)/var/lib/systemimager/scripts/post-install/10all.fix_swap_uuids\
$(TOPDIR)/var/lib/systemimager/scripts/post-install/11all.replace_byid_device\
$(AUTOINSTALL_SCRIPT_DIR)/post-install/
$(SI_INSTALL) -m 644 --backup --text \
$(TOPDIR)/var/lib/systemimager/scripts/post-install/README \
$(AUTOINSTALL_SCRIPT_DIR)/post-install/
$(SI_INSTALL) -d -m 755 $(OVERRIDES_DIR)
$(SI_INSTALL) -m 644 $(OVERRIDES_README) $(OVERRIDES_DIR)
$(SI_INSTALL) -d -m 755 $(PXE_CONF_DEST)
$(SI_INSTALL) -m 644 --backup --text $(PXE_CONF_SRC)/message.txt \
$(PXE_CONF_DEST)/message.txt
$(SI_INSTALL) -m 644 --backup $(PXE_CONF_SRC)/syslinux.cfg \
$(PXE_CONF_DEST)/syslinux.cfg
$(SI_INSTALL) -m 644 --backup $(PXE_CONF_SRC)/syslinux.cfg.localboot \
$(PXE_CONF_DEST)/syslinux.cfg.localboot
$(SI_INSTALL) -m 644 --backup $(PXE_CONF_SRC)/syslinux.cfg.localboot \
$(PXE_CONF_DEST)/default
$(SI_INSTALL) -d -m 755 $(KBOOT_CONF_DEST)
# $(SI_INSTALL) -m 644 --backup --text $(KBOOT_CONF_SRC)/message.txt \
# $(KBOOT_CONF_DEST)/message.txt
$(SI_INSTALL) -m 644 --backup $(KBOOT_CONF_SRC)/localboot \
$(KBOOT_CONF_DEST)/
$(SI_INSTALL) -m 644 --backup $(KBOOT_CONF_SRC)/default \
$(KBOOT_CONF_DEST)/
$(SI_INSTALL) -d -m 755 $(IMAGEDEST)
$(SI_INSTALL) -m 644 $(WARNING_FILES) $(IMAGEDEST)
cp -a $(IMAGEDEST)/README $(IMAGEDEST)/DO_NOT_TOUCH_THESE_DIRECTORIES
$(SI_INSTALL) -d -m 755 $(FLAMETHROWER_STATE_DIR)
# install client-only files
.PHONY: install_client
install_client: install_client_man install_client_libs
mkdir -p $(ETC)/systemimager
$(SI_INSTALL) -b -m 644 etc/updateclient.local.exclude \
$(ETC)/systemimager
$(SI_INSTALL) -b -m 644 etc/client.conf \
$(ETC)/systemimager
mkdir -p $(SBIN)
$(foreach binary, $(CLIENT_SBINARIES), \
$(SI_INSTALL) -m 755 $(BINARY_SRC)/$(binary) $(SBIN);)
# install files common to both the server and client
.PHONY: install_common
install_common: install_common_man install_common_libs
mkdir -p $(ETC)/systemimager
$(SI_INSTALL) -b -m 644 etc/UYOK.modules_to_exclude $(ETC)/systemimager
$(SI_INSTALL) -b -m 644 etc/UYOK.modules_to_include $(ETC)/systemimager
mkdir -p $(BIN)
$(foreach binary, $(COMMON_BINARIES), \
$(SI_INSTALL) -m 755 $(BINARY_SRC)/$(binary) $(BIN);)
# install server-only libraries
.PHONY: install_server_libs
install_server_libs:
mkdir -p $(LIB_DEST)/SystemImager
mkdir -p $(LIB_DEST)/BootMedia
mkdir -p $(LIB_DEST)/BootGen/Dev
mkdir -p $(LIB_DEST)/BootGen/InitrdFS
$(SI_INSTALL) -m 644 $(LIB_SRC)/SystemImager/Server.pm $(LIB_DEST)/SystemImager
$(SI_INSTALL) -m 644 $(LIB_SRC)/SystemImager/HostRange.pm $(LIB_DEST)/SystemImager
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootMedia/BootMedia.pm $(LIB_DEST)/BootMedia
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootMedia/MediaLib.pm $(LIB_DEST)/BootMedia
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootMedia/alpha.pm $(LIB_DEST)/BootMedia
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootMedia/i386.pm $(LIB_DEST)/BootMedia
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootGen/Dev.pm $(LIB_DEST)/BootGen/
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootGen/Dev/Devfs.pm $(LIB_DEST)/BootGen/Dev/
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootGen/Dev/Static.pm $(LIB_DEST)/BootGen/Dev/
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootGen/InitrdFS.pm $(LIB_DEST)/BootGen/
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootGen/InitrdFS/Cramfs.pm $(LIB_DEST)/BootGen/InitrdFS/
$(SI_INSTALL) -m 644 $(LIB_SRC)/BootGen/InitrdFS/Ext2.pm $(LIB_DEST)/BootGen/InitrdFS/
mkdir -p $(USR)/share/systemimager/icons
$(SI_INSTALL) -m 644 $(LIB_SRC)/icons/serverinit.gif $(USR)/share/systemimager/icons
$(SI_INSTALL) -m 644 $(LIB_SRC)/icons/serverinst.gif $(USR)/share/systemimager/icons
$(SI_INSTALL) -m 644 $(LIB_SRC)/icons/serverok.gif $(USR)/share/systemimager/icons
$(SI_INSTALL) -m 644 $(LIB_SRC)/icons/servererror.gif $(USR)/share/systemimager/icons
# install client-only libraries
.PHONY: install_client_libs
install_client_libs:
mkdir -p $(LIB_DEST)/SystemImager
$(SI_INSTALL) -m 644 $(LIB_SRC)/SystemImager/Client.pm $(LIB_DEST)/SystemImager
# install common libraries
.PHONY: install_common_libs
install_common_libs:
mkdir -p $(LIB_DEST)/SystemImager
$(SI_INSTALL) -m 644 $(LIB_SRC)/SystemImager/Common.pm $(LIB_DEST)/SystemImager
$(SI_INSTALL) -m 644 $(LIB_SRC)/SystemImager/Options.pm $(LIB_DEST)/SystemImager
$(SI_INSTALL) -m 644 $(LIB_SRC)/SystemImager/Config.pm $(LIB_DEST)/SystemImager
$(SI_INSTALL) -m 644 $(LIB_SRC)/SystemImager/UseYourOwnKernel.pm $(LIB_DEST)/SystemImager
mkdir -p $(LIBEXEC_DEST)
$(SI_INSTALL) -m 755 $(LIB_SRC)/confedit $(LIBEXEC_DEST)
# checks the sized of the i386 kernel and initrd to make sure they'll fit
# on an autoinstall diskette
.PHONY: check_floppy_size
check_floppy_size: $(LINUX_IMAGE) $(INITRD_DIR)/initrd.img
ifeq ($(ARCH), i386)
@### see if the kernel and ramdisk are larger than the size of a 1.44MB
@### floppy image, minus about 10k for syslinux stuff
@echo -n "Ramdisk + Kernel == "
@echo "`$(CHECK_FLOPPY_SIZE)`"
@echo " 1454080 is the max that will fit."
@[ `$(CHECK_FLOPPY_SIZE)` -lt 1454081 ] || \
(echo "" && \
echo "************************************************" && \
echo "Dammit. The kernel and ramdisk are too large. " && \
echo "************************************************" && \
exit 1)
@echo " - ok, that should fit on a floppy"
endif
# install the initscript & config files for the server
.PHONY: install_configs
install_configs:
$(SI_INSTALL) -d $(ETC)/systemimager
$(SI_INSTALL) -m 644 etc/systemimager.conf $(ETC)/systemimager/
$(SI_INSTALL) -m 644 etc/flamethrower.conf $(ETC)/systemimager/
$(SI_INSTALL) -m 644 --backup etc/bittorrent.conf $(ETC)/systemimager/
$(SI_INSTALL) -m 644 --backup etc/cluster.xml $(ETC)/systemimager/
$(SI_INSTALL) -m 644 etc/autoinstallscript.template $(ETC)/systemimager/
$(SI_INSTALL) -m 644 etc/getimage.exclude $(ETC)/systemimager/
mkdir -p $(RSYNC_STUB_DIR)
$(SI_INSTALL) -b -m 644 etc/rsync_stubs/10header $(RSYNC_STUB_DIR)
[ -f $(RSYNC_STUB_DIR)/99local ] \
&& $(SI_INSTALL) -b -m 644 etc/rsync_stubs/99local $(RSYNC_STUB_DIR)/99local.dist~ \
|| $(SI_INSTALL) -b -m 644 etc/rsync_stubs/99local $(RSYNC_STUB_DIR)
$(SI_INSTALL) -b -m 644 etc/rsync_stubs/README $(RSYNC_STUB_DIR)
[ "$(INITD)" != "" ] || exit 1
mkdir -p $(INITD)
$(SI_INSTALL) -b -m 755 etc/init.d/systemimager-server-rsyncd $(INITD)
$(SI_INSTALL) -b -m 755 etc/init.d/systemimager-server-netbootmond $(INITD)
$(SI_INSTALL) -b -m 755 etc/init.d/systemimager-server-flamethrowerd $(INITD)
$(SI_INSTALL) -b -m 755 etc/init.d/systemimager-server-bittorrent $(INITD)
$(SI_INSTALL) -b -m 755 etc/init.d/systemimager-server-monitord $(INITD)
########## END initrd ##########
########## BEGIN dev_tarball ##########
# XXX deprecated -- no longer needed with udev. -BEF- 2011.02.15
########## END dev_tarball ##########
########## BEGIN man pages ##########
# build all of the manpages
.PHONY: manpages install_server_man install_client_man install_common_man install_docs docs
ifeq ($(SI_BUILD_DOCS),1)
manpages:
$(MAKE) -C $(MANPAGE_DIR) TOPDIR=$(TOPDIR)
# install the manpages for the server
install_server_man: manpages
cd $(MANPAGE_DIR) && $(MAKE) install_server_man TOPDIR=$(TOPDIR) PREFIX=$(PREFIX) $@
# install the manpages for the client
install_client_man: manpages
cd $(MANPAGE_DIR) && $(MAKE) install_client_man TOPDIR=$(TOPDIR) PREFIX=$(PREFIX) $@
# install manpages common to the server and client
install_common_man: manpages
cd $(MANPAGE_DIR) && $(MAKE) install_common_man TOPDIR=$(TOPDIR) PREFIX=$(PREFIX) $@
########## END man pages ##########
# installs the manual and some examples
install_docs: docs
mkdir -p $(DOC)
cp -a $(MANUAL_DIR)/html $(DOC)
cp $(MANUAL_DIR)/*.ps $(MANUAL_DIR)/*.pdf $(DOC)
rsync -av --exclude 'CVS/' --exclude '.svn/' doc/examples/ $(DOC)/examples/
#XXX $(SI_INSTALL) -m 644 doc/media-api.txt $(DOC)/
# builds the manual from SGML source
docs:
$(MAKE) -C $(MANUAL_DIR) html ps pdf
endif
# pre-download the source to other packages that are needed by
# the build system
.PHONY: pre_download_source
pre_download_source: $(ALL_SOURCE)
.PHONY: get_source
get_source: $(ALL_SOURCE)
.PHONY: install
install:
@echo ''
@echo 'Try "make help", and/or read README for installation details.'
@echo ''
.PHONY: install_binaries
install_binaries: install_kernel \
install_initrd \
install_initrd_template
.PHONY: complete_source_tarball
complete_source_tarball: $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source.tar.bz2.sign
$(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source.tar.bz2.sign: $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source.tar.bz2
cd $(TOPDIR)/tmp && gpg --detach-sign -a --output systemimager-$(VERSION)-complete_source.tar.bz2.sign systemimager-$(VERSION)-complete_source.tar.bz2
cd $(TOPDIR)/tmp && gpg --verify systemimager-$(VERSION)-complete_source.tar.bz2.sign
$(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source.tar.bz2: systemimager.spec
rm -fr $(TOPDIR)/tmp
if [ -d $(TOPDIR)/.svn ]; then \
mkdir -p $(TOPDIR)/tmp; \
svn export . $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source; \
else \
make distclean && mkdir -p $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source; \
(cd $(TOPDIR) && tar --exclude=tmp -cvf - .) | (cd $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source && tar -xvf -); \
fi
cd $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source && ./configure
$(MAKE) -C $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source get_source
#
# Make sure we've got all kernel source. NOTE: The egrep -v '-' bit is so that we don't include customized kernels (Ie: -ydl).
$(foreach linux_version, $(shell grep 'LINUX_VERSION =' make.d/kernel.rul | egrep -v '(^#|-)' | sort -u | perl -pi -e 's#.*= ##'), \
$(GETSOURCE) $(shell dirname $(LINUX_URL))/linux-$(linux_version).tar.bz2 $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source/src;)
$(MAKE) -C $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source clean
ifeq ($(UNSTABLE), 1)
if [ -f README.unstable ]; then \
cd $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source && cp README README.tmp; \
cd $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source && cp README.unstable README; \
cd $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source && cat README.tmp >> README; \
cd $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source && rm README.tmp; \
fi
endif
rm -f $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source/README.unstable
perl -pi -e "s/^%define\s+ver\s+\d+\.\d+\.\d+.*/%define ver $(VERSION)/" \
$(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source/systemimager.spec
find $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source -type f -exec chmod ug+r {} \;
find $(TOPDIR)/tmp/systemimager-$(VERSION)-complete_source -type d -exec chmod ug+rx {} \;
cd $(TOPDIR)/tmp && tar -ch systemimager-$(VERSION)-complete_source | bzip2 > systemimager-$(VERSION)-complete_source.tar.bz2
@echo
@echo "complete source tarball has been created in $(TOPDIR)/tmp"
@echo
.PHONY: source_tarball
source_tarball: $(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2.sign
$(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2.sign: $(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2
cd $(TOPDIR)/tmp && gpg --detach-sign -a --output systemimager-$(VERSION).tar.bz2.sign systemimager-$(VERSION).tar.bz2
cd $(TOPDIR)/tmp && gpg --verify systemimager-$(VERSION).tar.bz2.sign
$(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2: $(TOPDIR)/systemimager.spec
rm -fr $(TOPDIR)/tmp
if [ -d $(TOPDIR)/.svn ]; then \
mkdir -p $(TOPDIR)/tmp; \
svn export . $(TOPDIR)/tmp/systemimager-$(VERSION); \
else \
make distclean && mkdir -p $(TOPDIR)/tmp/systemimager-$(VERSION); \
(cd $(TOPDIR) && tar --exclude=tmp --exclude=.git -cvf - .) | (cd $(TOPDIR)/tmp/systemimager-$(VERSION) && tar -xvf -); \
fi
ifeq ($(UNSTABLE), 1)
if [ -f README.unstable ]; then \
cd $(TOPDIR)/tmp/systemimager-$(VERSION) && cp README README.tmp; \
cd $(TOPDIR)/tmp/systemimager-$(VERSION) && cp README.unstable README; \
cd $(TOPDIR)/tmp/systemimager-$(VERSION) && cat README.tmp >> README; \
cd $(TOPDIR)/tmp/systemimager-$(VERSION) && rm README.tmp; \
fi
endif
rm -f $(TOPDIR)/tmp/systemimager-$(VERSION)/README.unstable
perl -pi -e "s/^%define\s+ver\s+\d+\.\d+\.\d+.*/%define ver $(VERSION)/" \
$(TOPDIR)/tmp/systemimager-$(VERSION)/systemimager.spec
find $(TOPDIR)/tmp/systemimager-$(VERSION) -type f -exec chmod ug+r {} \;
find $(TOPDIR)/tmp/systemimager-$(VERSION) -type d -exec chmod ug+rx {} \;
cd $(TOPDIR)/tmp && tar -ch systemimager-$(VERSION) | bzip2 > systemimager-$(VERSION).tar.bz2
@echo
@echo "source tarball has been created in $(TOPDIR)/tmp"
@echo
# make the srpms for systemimager
.PHONY: srpm
srpm: $(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2 $(TOPDIR)/systemimager.spec
rpmbuild --define '%dist %{nil}' -ts $(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2
# make the rpms for systemimager
.PHONY: rpm rpms
rpms: rpm
rpm: $(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2 $(TOPDIR)/systemimager.spec
rpmbuild -tb $(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2
# make the debs for systemimager
#
# I wonder if installing libpam-dev would eliminate the need for
# "--disable-login --disable-su" in initrd_source/make.d/util-linux.rul
# ?? -BEF- If so, we should add libpam-dev to UBUNTU_PRECISE_BUILD_DEPS
# in initrd_source/make.d/util-linux.rul.
#
UBUNTU_PRECISE_BUILD_DEPS += dos2unix docbook-utils libncurses-dev
.PHONY: deb debs
debs: deb
deb: $(TOPDIR)/tmp/systemimager-$(VERSION).tar.bz2
# Check package version.
@(if [ ! "`dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2`" = $(VERSION) ]; then \
echo "ERROR: versions in debian/changelog doesn't match with version specified into the file VERSION"; \
echo "Please fix it."; \
exit 1; \
else \
exit 0; \
fi)
@cd $(TOPDIR)/tmp && tar xvjf systemimager-$(VERSION).tar.bz2
@cd $(TOPDIR)/tmp/systemimager-$(VERSION) && make -f debian/rules debian/control
@cd $(TOPDIR)/tmp/systemimager-$(VERSION) && dpkg-buildpackage -rfakeroot -uc -us
@echo "=== deb packages for systemimager ==="
@ls -l $(TOPDIR)/tmp/*.deb
@echo "====================================="
# removes object files, docs, editor backup files, etc.
.PHONY: clean
clean: $(subst .rul,_clean,$(shell cd $(TOPDIR)/make.d && ls *.rul)) initrd_clean
-$(MAKE) -C $(MANPAGE_DIR) clean
-$(MAKE) -C $(MANUAL_DIR) clean
## where the tarballs are built
-rm -rf tmp
## editor backups
-find . -name "*~" -exec rm -f {} \;
-find . -name "#*#" -exec rm -f {} \;
-find . -name ".#*" -exec rm -f {} \;
rm -f config.inc config.log config.status
# same as clean, but also removes downloaded source, stamp files, etc.
.PHONY: distclean
distclean: clean initrd_distclean
-rm -rf $(SRC_DIR) $(INITRD_SRC_DIR)
.PHONY: help
help: show_build_deps
#
#
# Show me a list of all targets in this entire build heirarchy
.PHONY: show_targets
show_targets:
@echo
@echo Makefile targets you are probably most interested in:
@echo ---------------------------------------------------------------------
@echo "all"
@echo " Build everything you need for your machine's architecture."
@echo " "
@echo "install_client_all"
@echo " Install all files needed by a client."
@echo " "
@echo "install_server_all"
@echo " Install all files needed by a server."
@echo " "
@echo "install_initrd"
@echo ""
@echo "pre_download_source"
@echo " Download source tarballs, but don't build anything."
@echo " Useful to prep for offline builds."
@echo ""
@echo "source_tarball"
@echo " Make a source tarball for distribution."
@echo " "
@echo " Includes SystemImager source only. Source for all"
@echo " the tools SystemImager depends on will be found in /usr/src "
@echo " or will be automatically downloaded at build time."
@echo " "
@echo "complete_source_tarball"
@echo " Make a source tarball for distribution."
@echo " "
@echo " Includes all necessary source for building SystemImager and"
@echo " all of it's supporting tools."
@echo " "
@echo "rpm"
@echo " Build all of the RPMs that can be build on your platform."
@echo ""
@echo "srpm"
@echo " Build yourself a source RPM."
@echo ""
@echo "deb"
@echo " Build all of the debs that can be build on your platform."
@echo ""
@echo "show_build_deps"
@echo " Shows the list of packages necessary for building on"
@echo " various distributions and releases."
@echo
@echo "show_all_targets"
@echo " Show all available targets."
@echo
.PHONY: show_build_deps
show_build_deps:
@echo "Before you can build SystemImager, you'll need to do the following:"
@echo
@echo "1) Install the appropriate build dependencies for your distribution."
@echo " The easiest path is to cut and paste the command below that is"
@echo " appropriate for your distribution."
@echo
@echo " Ubuntu 12.04 and newer:"
@echo " apt-get install build-essential rpm flex $(UBUNTU_PRECISE_BUILD_DEPS)"
@echo
@echo " Ubuntu 6.06:"
@echo " apt-get install build-essential flex $(UBUNTU_DAPPER_BUILD_DEPS)"
@echo
@echo " RHEL6, CentOS6, and friends:"
@echo " yum install rpm-build patch wget flex bc docbook-utils dos2unix device-mapper-devel gperf pam-devel quilt lzop glib2-devel PyXML glibc-static $(RHEL6_BUILD_DEPS)"
@echo
@echo " Debian Stable:"
@echo " apt-get install build-essential flex $(DEBIAN_STABLE_BUILD_DEPS)"
@echo
@echo " NOTE: Other distro versions may build fine, and are simply untested by"
@echo " the SystemImage dev team."
@echo
@echo "2) Run './configure'"
@echo
@echo "3) Run 'make show_targets' to see a list of make targets from which you can"
@echo " choose."
@echo
.PHONY: show_all_targets
SHOW_TARGETS_ALL_MAKEFILES = $(shell find . make.d/ initrd_source/ initrd_source/make.d/ -maxdepth 1 -name 'Makefile' -or -name '*.rul' )
show_all_targets:
@echo All Available Targets Include:
@echo ---------------------------------------------------------------------
@cat $(SHOW_TARGETS_ALL_MAKEFILES) | egrep '^[a-zA-Z0-9_]+:' | sed 's/:.*//' | sort -u
@echo