forked from vmware/photon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
683 lines (606 loc) · 25.3 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
#
# Copyright VMware, Inc 2015
#
SRCROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
MAKEROOT=$(SRCROOT)/support/make
# do not build these targets as '%'
$(MAKEROOT)/makedefs.mk: ;
Makefile: ;
include $(MAKEROOT)/makedefs.mk
export PATH := $(SRCROOT)/tools/bin:$(PATH)
export PHOTON_BUILD_NUM=$(PHOTON_BUILD_NUMBER)
export PHOTON_RELEASE_VER=$(PHOTON_RELEASE_VERSION)
ifdef PHOTON_CACHE_PATH
PHOTON_PACKAGES_MINIMAL := packages-cached
PHOTON_PACKAGES := packages-cached
else
PHOTON_PACKAGES_MINIMAL := packages-minimal
PHOTON_PACKAGES := packages
endif
ifdef PHOTON_SOURCES_PATH
PHOTON_SOURCES := sources-cached
else
PHOTON_SOURCES ?= sources
endif
FULL_PACKAGE_LIST_FILE := build_install_options_all.json
MINIMAL_PACKAGE_LIST_FILE := build_install_options_minimal.json
ifdef PHOTON_PUBLISH_RPMS_PATH
PHOTON_PUBLISH_RPMS := publish-rpms-cached
else
PHOTON_PUBLISH_RPMS := publish-rpms
endif
ifdef PHOTON_PUBLISH_XRPMS_PATH
PHOTON_PUBLISH_XRPMS := publish-x-rpms-cached
else
PHOTON_PUBLISH_XRPMS := publish-x-rpms
endif
# Tri state RPMCHECK:
# 1) RPMCHECK is not specified: just build
# 2) RPMCHECK=enable: build and run %check section. do not stop on error. will generate report file.
# 3) RPMCHECK=enable_stop_on_error: build and run %check section. stop on first error.
#
# We use 2 parameters:
# -u: enable checking.
# -q: quit on error. if -q is not specified it will keep going
ifeq ($(RPMCHECK),enable)
PHOTON_RPMCHECK_FLAGS := --enable-rpmcheck
else ifeq ($(RPMCHECK),enable_stop_on_error)
PHOTON_RPMCHECK_FLAGS := --enable-rpmcheck --rpmcheck-stop-on-error
else
PHOTON_RPMCHECK_FLAGS :=
endif
# KAT build for FIPS certification
# Use KAT_BUILD=enable to build a kat kernel. By default, KAT_BUILD is disabled.
ifeq ($(KAT_BUILD),enable)
PHOTON_KAT_BUILD_FLAGS := --enable-katbuild
endif
ifeq ($(BUILDDEPS),true)
PUBLISH_BUILD_DEPENDENCIES := --publish-build-dependencies True
else
PUBLISH_BUILD_DEPENDENCIES :=
endif
PACKAGE_WEIGHTS = --package-weights-path $(SRCROOT)/common/data/packageWeights.json
ifdef PKG_BUILD_OPTIONS
PACKAGE_BUILD_OPTIONS = --pkg-build-option-file $(PKG_BUILD_OPTIONS)
else
PACKAGE_BUILD_OPTIONS =
endif
ifdef CROSS_TARGET
CROSS_TARGET_FLAGS = --cross-target $(CROSS_TARGET)
else
CROSS_TARGET_FLAGS =
endif
TOOLS_BIN := $(SRCROOT)/tools/bin
CONTAIN := $(TOOLS_BIN)/contain
ifeq ($(ARCH),x86_64)
VIXDISKUTIL := $(TOOLS_BIN)/vixdiskutil
else
VIXDISKUTIL :=
endif
#marker file indicating if run from container
DOCKER_ENV=/.dockerenv
$(TOOLS_BIN):
mkdir -p $(TOOLS_BIN)
$(CONTAIN): $(TOOLS_BIN)
gcc -O2 -std=gnu99 -Wall -Wextra $(SRCROOT)/tools/src/contain/*.c -o $@_unpriv
sudo install -o root -g root -m 4755 $@_unpriv $@
$(VIXDISKUTIL): $(TOOLS_BIN)
@cd $(SRCROOT)/tools/src/vixDiskUtil && \
make
.PHONY : all iso clean image all-images \
check-tools check-docker check-bison check-g++ check-gawk check-repo-tool check-kpartx check-sanity \
clean-install clean-chroot build-updated-packages check generate-yaml-files
THREADS?=1
LOGLEVEL?=info
# Build targets for rpm build
#-------------------------------------------------------------------------------
packages-minimal: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) generate-dep-lists
@echo "Building all minimal RPMS..."
@echo ""
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--packages-json-input $(PHOTON_DATA_DIR)/packages_minimal.json \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
--pkginfo-file $(PHOTON_PKGINFO_FILE) \
$(PHOTON_RPMCHECK_FLAGS) \
$(PUBLISH_BUILD_DEPENDENCIES) \
$(PACKAGE_WEIGHTS) \
--threads ${THREADS}
packages-initrd: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) generate-dep-lists
@echo "Building all initrd package RPMS..."
@echo ""
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--packages-json-input $(PHOTON_DATA_DIR)/packages_installer_initrd.json \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
--pkginfo-file $(PHOTON_PKGINFO_FILE) \
$(PHOTON_RPMCHECK_FLAGS) \
$(PUBLISH_BUILD_DEPENDENCIES) \
$(PACKAGE_WEIGHTS) \
--threads ${THREADS}
packages: check-docker-py check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) check-spec-files generate-dep-lists
@echo "Building all RPMS..."
@echo ""
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--build-type $(PHOTON_BUILD_TYPE) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-rpm-path $(PHOTON_SRPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
--pkginfo-file $(PHOTON_PKGINFO_FILE) \
$(PACKAGE_BUILD_OPTIONS) \
$(PHOTON_RPMCHECK_FLAGS) \
$(PHOTON_KAT_BUILD_FLAGS) \
$(CROSS_TARGET_FLAGS) \
$(PUBLISH_BUILD_DEPENDENCIES) \
$(PACKAGE_WEIGHTS) \
--threads ${THREADS}
$(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR)
packages-docker: check-docker-py check-docker-service check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
@echo "Building all RPMS..."
@echo ""
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--build-type $(PHOTON_BUILD_TYPE) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-rpm-path $(PHOTON_SRPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
--pkginfo-file $(PHOTON_PKGINFO_FILE) \
$(PACKAGE_BUILD_OPTIONS) \
$(PHOTON_RPMCHECK_FLAGS) \
$(CROSS_TARGET_FLAGS) \
$(PUBLISH_BUILD_DEPENDENCIES) \
$(PACKAGE_WEIGHTS) \
--threads ${THREADS}
updated-packages: check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
@echo "Building only updated RPMS..."
@echo ""
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_UPDATED_RPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
--input-RPMS-path $(PHOTON_INPUT_RPMS_DIR) \
$(PHOTON_KAT_BUILD_FLAGS) \
$(PHOTON_RPMCHECK_FLAGS) \
$(PUBLISH_BUILD_DEPENDENCIES) \
$(PACKAGE_WEIGHTS) \
--threads ${THREADS}
tool-chain-stage1: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
@echo "Building all RPMS..."
@echo ""
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-rpm-path $(PHOTON_SRPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--threads ${THREADS} \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
$(PHOTON_RPMCHECK_FLAGS) \
--tool-chain-stage stage1
tool-chain-stage2: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
@echo "Building all RPMS..."
@echo ""
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-rpm-path $(PHOTON_SRPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--threads ${THREADS} \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
$(PHOTON_RPMCHECK_FLAGS) \
--tool-chain-stage stage2
%: check-tools $(PHOTON_PUBLISH_RPMS) $(PHOTON_PUBLISH_XRPMS) $(PHOTON_SOURCES) $(CONTAIN) check-spec-files $(eval PKG_NAME = $@)
$(eval PKG_NAME = $@)
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) --install-package $(PKG_NAME)\
--build-type $(PHOTON_BUILD_TYPE) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-rpm-path $(PHOTON_SRPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--log-level $(LOGLEVEL) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
$(PACKAGE_BUILD_OPTIONS) \
$(PHOTON_RPMCHECK_FLAGS) \
$(PHOTON_KAT_BUILD_FLAGS) \
$(CROSS_TARGET_FLAGS) \
--log-path $(PHOTON_LOGS_DIR) \
--threads ${THREADS}
check: packages
ifeq ($(RPMCHECK),enable_stop_on_error)
$(eval rpmcheck_stop_on_error = -q)
endif
@echo "Testing all RPMS ..."
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_PACKAGE_BUILDER) \
--build-type $(PHOTON_BUILD_TYPE) \
--spec-path $(PHOTON_SPECS_DIR) \
--rpm-path $(PHOTON_RPMS_DIR) \
--source-rpm-path $(PHOTON_SRPMS_DIR) \
--source-path $(PHOTON_SRCS_DIR) \
--build-root-path $(PHOTON_CHROOT_PATH) \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--dist-tag $(PHOTON_DIST_TAG) \
--build-number $(PHOTON_BUILD_NUMBER) \
--release-version $(PHOTON_RELEASE_VERSION) \
--pkginfo-file $(PHOTON_PKGINFO_FILE) \
$(PACKAGE_BUILD_OPTIONS) \
--enable-rpmcheck \
$(rpmcheck_stop_on_error) \
--threads ${THREADS}
#-------------------------------------------------------------------------------
# The targets listed under "all" are the installer built artifacts
#===============================================================================
all: iso photon-docker-image k8s-docker-images all-images src-iso minimal-iso
iso: check-tools photon-stage $(PHOTON_PACKAGES) ostree-repo
@echo "Building Photon Full ISO..."
@cd $(PHOTON_IMAGE_BUILDER_DIR) && \
sudo $(PHOTON_IMAGE_BUILDER) \
--iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
--debug-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
--log-path $(PHOTON_STAGE)/LOGS \
--log-level $(LOGLEVEL) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--srpm-path $(PHOTON_STAGE)/SRPMS \
--package-list-file $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
--generated-data-path $(PHOTON_STAGE)/common/data \
--pkg-to-rpm-map-file $(PHOTON_PKGINFO_FILE)
minimal-iso: check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) packages-minimal packages-initrd
@echo "Building Photon Minimal ISO..."
@$(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR)
@$(CP) -f $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) $(PHOTON_GENERATED_DATA_DIR)/
@cd $(PHOTON_IMAGE_BUILDER_DIR) && \
sudo $(PHOTON_IMAGE_BUILDER) \
--iso-path $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUM).iso \
--debug-iso-path $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
--log-path $(PHOTON_STAGE)/LOGS \
--log-level $(LOGLEVEL) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--srpm-path $(PHOTON_STAGE)/SRPMS \
--package-list-file $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) \
--generated-data-path $(PHOTON_STAGE)/common/data \
--pkg-to-rpm-map-file $(PHOTON_PKGINFO_FILE) \
--pkg-to-be-copied-conf-file $(PHOTON_GENERATED_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE)
src-iso: check-tools photon-stage $(PHOTON_PACKAGES)
@echo "Building Photon Full Source ISO..."
@cd $(PHOTON_IMAGE_BUILDER_DIR) && \
sudo $(PHOTON_IMAGE_BUILDER) \
--src-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).src.iso \
--log-path $(PHOTON_STAGE)/LOGS \
--log-level $(LOGLEVEL) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--srpm-path $(PHOTON_STAGE)/SRPMS \
--package-list-file $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
--generated-data-path $(PHOTON_STAGE)/common/data \
--pkg-to-rpm-map-file $(PHOTON_PKGINFO_FILE) > \
$(PHOTON_LOGS_DIR)/sourceiso-installer.log 2>&1
image: check-kpartx photon-stage $(VIXDISKUTIL) $(PHOTON_PACKAGES)
@echo "Building image using $(CONFIG)..."
@cd $(PHOTON_IMAGE_BUILDER_DIR)
$(PHOTON_IMAGE_BUILDER) \
--config-file=$(CONFIG) \
--img-name=$(IMG_NAME) \
--src-root=$(SRCROOT) \
--generated-data-path=$(PHOTON_DATA_DIR) \
--stage-path=$(PHOTON_STAGE) \
--rpm-path $(PHOTON_STAGE)/RPMS
all-images: check-kpartx photon-stage $(VIXDISKUTIL) $(PHOTON_PACKAGES)
@echo "Building all images - gce, ami, azure, ova..."
@cd $(PHOTON_IMAGE_BUILDER_DIR)
$(PHOTON_IMAGE_BUILDER) \
--src-root=$(SRCROOT) \
--generated-data-path=$(PHOTON_DATA_DIR) \
--stage-path=$(PHOTON_STAGE) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--img-name=ami
$(PHOTON_IMAGE_BUILDER) \
--src-root=$(SRCROOT) \
--generated-data-path=$(PHOTON_DATA_DIR) \
--stage-path=$(PHOTON_STAGE) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--img-name=gce
$(PHOTON_IMAGE_BUILDER) \
--src-root=$(SRCROOT) \
--generated-data-path=$(PHOTON_DATA_DIR) \
--stage-path=$(PHOTON_STAGE) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--img-name=azure
$(PHOTON_IMAGE_BUILDER) \
--src-root=$(SRCROOT) \
--generated-data-path=$(PHOTON_DATA_DIR) \
--stage-path=$(PHOTON_STAGE) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--img-name=ova
$(PHOTON_IMAGE_BUILDER) \
--src-root=$(SRCROOT) \
--generated-data-path=$(PHOTON_DATA_DIR) \
--stage-path=$(PHOTON_STAGE) \
--rpm-path $(PHOTON_STAGE)/RPMS \
--img-name=ova_uefi
photon-docker-image:
$(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR)
sudo docker build --no-cache --tag photon-build ./support/dockerfiles/photon
sudo docker run \
--rm \
--privileged \
--net=host \
-e PHOTON_BUILD_NUMBER=$(PHOTON_BUILD_NUMBER) \
-e PHOTON_RELEASE_VERSION=$(PHOTON_RELEASE_VERSION) \
-v `pwd`:/workspace \
photon-build \
./support/dockerfiles/photon/make-docker-image.sh tdnf
k8s-docker-images: start-docker photon-docker-image
mkdir -p $(PHOTON_STAGE)/docker_images && \
cd ./support/dockerfiles/k8s-docker-images && \
./build-k8s-base-image.sh $(PHOTON_RELEASE_VERSION) $(PHOTON_BUILD_NUMBER) $(PHOTON_STAGE) && \
./build-k8s-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-k8s-metrics-server-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-k8s-coredns-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-k8s-dns-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-k8s-dashboard-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-flannel-docker-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-calico-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-k8s-heapster-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-k8s-nginx-ingress.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
./build-wavefront-proxy-docker-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE)
ostree-repo: start-docker $(PHOTON_PACKAGES)
@echo "Creating OSTree repo from local RPMs in ostree-repo.tar.gz..."
@if [ -f $(PHOTON_STAGE)/ostree-repo.tar.gz ]; then \
echo "ostree-repo.tar.gz already present, not creating again..."; \
else \
$(SRCROOT)/support/image-builder/ostree-tools/make-ostree-image.sh $(SRCROOT); \
fi
#===============================================================================
# Set up Build environment
#_______________________________________________________________________________
packages-cached:
@echo "Using cached RPMS..."
@$(RM) -f $(PHOTON_RPMS_DIR_NOARCH)/* && \
$(RM) -f $(PHOTON_RPMS_DIR_ARCH)/* && \
$(CP) -f $(PHOTON_CACHE_PATH)/RPMS/noarch/* $(PHOTON_RPMS_DIR_NOARCH)/ && \
$(CP) -f $(PHOTON_CACHE_PATH)/RPMS/$(ARCH)/* $(PHOTON_RPMS_DIR_ARCH)/
$(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR)
sources:
@$(MKDIR) -p $(PHOTON_SRCS_DIR)
sources-cached:
@echo "Using cached SOURCES..."
@ln -sf $(PHOTON_SOURCES_PATH) $(PHOTON_SRCS_DIR)
publish-rpms:
@echo "Pulling toolchain rpms..."
@cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \
$(PHOTON_PULL_PUBLISH_RPMS) $(PHOTON_PUBLISH_RPMS_DIR)
publish-x-rpms:
@echo "Pulling X toolchain rpms..."
@cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \
$(PHOTON_PULL_PUBLISH_X_RPMS) $(PHOTON_PUBLISH_XRPMS_DIR)
publish-rpms-cached:
@echo "Using cached toolchain rpms..."
@$(MKDIR) -p $(PHOTON_PUBLISH_RPMS_DIR)/{$(ARCH),noarch} && \
cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \
$(PHOTON_PULL_PUBLISH_RPMS) $(PHOTON_PUBLISH_RPMS_DIR) $(PHOTON_PUBLISH_RPMS_PATH)
publish-x-rpms-cached:
@echo "Using cached X toolchain rpms..."
@$(MKDIR) -p $(PHOTON_PUBLISH_XRPMS_DIR)/{$(ARCH),noarch} && \
cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \
$(PHOTON_PULL_PUBLISH_X_RPMS) $(PHOTON_PUBLISH_XRPMS_DIR) $(PHOTON_PUBLISH_XRPMS_PATH)
photon-stage:
@echo "Creating staging folder and subitems..."
@test -d $(PHOTON_STAGE) || $(MKDIR) -p $(PHOTON_STAGE)
@test -d $(PHOTON_CHROOT_PATH) || $(MKDIR) -p $(PHOTON_CHROOT_PATH)
@test -d $(PHOTON_RPMS_DIR_NOARCH) || $(MKDIR) -p $(PHOTON_RPMS_DIR_NOARCH)
@test -d $(PHOTON_RPMS_DIR_ARCH) || $(MKDIR) -p $(PHOTON_RPMS_DIR_ARCH)
@test -d $(PHOTON_SRPMS_DIR) || $(MKDIR) -p $(PHOTON_SRPMS_DIR)
@test -d $(PHOTON_UPDATED_RPMS_DIR_NOARCH) || $(MKDIR) -p $(PHOTON_UPDATED_RPMS_DIR_NOARCH)
@test -d $(PHOTON_UPDATED_RPMS_DIR_ARCH) || $(MKDIR) -p $(PHOTON_UPDATED_RPMS_DIR_ARCH)
@test -d $(PHOTON_SRCS_DIR) || $(MKDIR) -p $(PHOTON_SRCS_DIR)
@test -d $(PHOTON_LOGS_DIR) || $(MKDIR) -p $(PHOTON_LOGS_DIR)
@install -m 444 $(SRCROOT)/COPYING $(PHOTON_STAGE)/COPYING
@install -m 444 $(SRCROOT)/NOTICE $(PHOTON_STAGE)/NOTICE
#_______________________________________________________________________________
# Clean build environment
#==================================================================
clean: clean-install clean-chroot
@echo "Deleting Photon ISO..."
@$(RM) -f $(PHOTON_STAGE)/photon-*.iso
@echo "Deleting stage dir..."
@$(RMDIR) $(PHOTON_STAGE)
@echo "Deleting chroot path..."
@$(RMDIR) $(PHOTON_CHROOT_PATH)
@echo "Deleting tools/bin..."
@$(RMDIR) $(TOOLS_BIN)
clean-install:
@echo "Cleaning installer working directory..."
@if [ -d $(PHOTON_STAGE)/photon_iso ]; then \
$(PHOTON_CHROOT_CLEANER) $(PHOTON_STAGE)/photon_iso; \
fi
clean-chroot:
@echo "Cleaning chroot path..."
@if [ -d $(PHOTON_CHROOT_PATH) ]; then \
$(PHOTON_CHROOT_CLEANER) $(PHOTON_CHROOT_PATH); \
fi
#==================================================================
# Targets to check for tools support in build environment
#__________________________________________________________________________________
check-tools: check-bison check-g++ check-gawk check-repo-tool check-texinfo check-sanity check-docker check-pyopenssl
check-docker:
ifeq (,$(wildcard $(DOCKER_ENV)))
@command -v docker >/dev/null 2>&1 || { echo "Package docker not installed. Aborting." >&2; exit 1; }
endif
check-docker-service:
ifeq (,$(wildcard $(DOCKER_ENV)))
@docker ps >/dev/null 2>&1 || { echo "Docker service is not running. Aborting." >&2; exit 1; }
endif
check-docker-py:
ifeq (,$(wildcard $(DOCKER_ENV)))
@python3 -c "import docker; assert docker.__version__ >= '$(PHOTON_DOCKER_PY_VER)'" >/dev/null 2>&1 || { echo "Error: Python3 package docker-py3 $(PHOTON_DOCKER_PY_VER) not installed.\nPlease use: pip3 install docker==$(PHOTON_DOCKER_PY_VER)" >&2; exit 1; }
endif
check-pyopenssl:
@python3 -c "import OpenSSL" > /dev/null 2>&1 || { echo "Error pyOpenSSL package not installed.\nPlease use: pip3 install pyOpenSSL" >&2; exit 1; }
check-bison:
@command -v bison >/dev/null 2>&1 || { echo "Package bison not installed. Aborting." >&2; exit 1; }
check-texinfo:
@command -v makeinfo >/dev/null 2>&1 || { echo "Package texinfo not installed. Aborting." >&2; exit 1; }
check-g++:
@command -v g++ >/dev/null 2>&1 || { echo "Package g++ not installed. Aborting." >&2; exit 1; }
check-gawk:
@command -v gawk >/dev/null 2>&1 || { echo "Package gawk not installed. Aborting." >&2; exit 1; }
check-repo-tool:
@command -v $(PHOTON_REPO_TOOL) >/dev/null 2>&1 || { echo "Package $(PHOTON_REPO_TOOL) not installed. Aborting." >&2; exit 1; }
check-kpartx:
@command -v kpartx >/dev/null 2>&1 || { echo "Package kpartx not installed. Aborting." >&2; exit 1; }
check-sanity:
@$(SRCROOT)/support/sanity_check.sh
@echo ""
start-docker: check-docker
systemctl start docker
install-photon-docker-image: photon-docker-image
sudo docker build -t photon:tdnf .
#__________________________________________________________________________________
# Spec file checker and utilities
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
check-spec-files:
@./tools/scripts/check_spec_files.sh
generate-dep-lists:
@echo ""
@$(RMDIR) $(PHOTON_GENERATED_DATA_DIR)
@$(MKDIR) -p $(PHOTON_GENERATED_DATA_DIR)
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
--spec-path $(PHOTON_SPECS_DIR) \
--stage-dir $(PHOTON_STAGE) \
--log-path $(PHOTON_LOGS_DIR) \
--log-level $(LOGLEVEL) \
--pkg $(PHOTON_GENERATED_DATA_DIR) \
--input-type=json \
--file "$$(ls $(PHOTON_DATA_DIR)/packages_*.json)" \
--display-option json \
--input-data-dir $(PHOTON_DATA_DIR)
@echo ""
pkgtree:
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
--spec-path $(PHOTON_SPECS_DIR) \
--log-level $(LOGLEVEL) \
--input-type pkg \
--pkg $(pkg)
imgtree:
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
--spec-path $(PHOTON_SPECS_DIR) \
--log-level $(LOGLEVEL) \
--input-type json \
--file $(PHOTON_DATA_DIR)/packages_$(img).json
who-needs:
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
--spec-path $(PHOTON_SPECS_DIR) \
--log-level $(LOGLEVEL) \
--input-type who-needs \
--pkg $(pkg)
print-upward-deps:
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
--spec-path $(PHOTON_SPECS_DIR) \
--input-type print-upward-deps \
--pkg $(pkg)
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
generate-yaml-files: check-tools photon-stage $(PHOTON_PACKAGES)
@echo "Generating yaml files for packages ..."
@cd $(PHOTON_PKG_BUILDER_DIR) && \
$(PHOTON_GENERATE_OSS_FILES) --generate-yaml-files \
--spec-path $(PHOTON_SPECS_DIR) \
--source-rpm-path $(PHOTON_SRPMS_DIR) \
--log-path $(PHOTON_LOGS_DIR) \
--dist-tag $(PHOTON_DIST_TAG) \
--log-level $(LOGLEVEL) \
--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
--pkg-blacklist-file $(PHOTON_PKG_BLACKLIST_FILE)
# Input args: BASE_COMMIT= (optional)
#
# This target removes staged RPMS that can be affected by change(s) and should
# be rebuilt as part of incremental build support
# For every spec file touched - remove all upward dependent packages (rpms)
# If support folder was touched - do full build
#
# The analyzed changes are:
# - commits from BASE_COMMIT to HEAD (if BASE_COMMIT= parameter is specified)
# - local changes (if no commits specified)
clean-stage-for-incremental-build:
@test -z "$$(git diff --name-only $(BASE_COMMIT) @ | grep SPECS)" || $(PHOTON_SPECDEPS) --spec-path $(PHOTON_SPECS_DIR) -i remove-upward-deps -p $$(echo `git diff --name-only $(BASE_COMMIT) @ | grep .spec | xargs -n1 basename 2>/dev/null` | tr ' ' :)
@test -n "$$(git diff --name-only @~1 @ | grep '^support/\(make\|package-builder\|pullpublishrpms\)')" && { echo "Remove all staged RPMs"; $(RM) -rf $(PHOTON_RPMS_DIR); } ||: