- Introduced build.py in order to replace Makefile.
- The script is divided into 6 classes Utilities, BuildImage, RpmBuildTarget, CleanUp, Build_Config and BuildEnvironmentSetup.
- function defs from builder.py, imagebuilder.py and imagegenerator.py is used directly by build.py.
- A new config file called config.json which contains branch specific data and command-line arguments.
- Usage:
- In order to build following command needs to be used.
- Copy config.json to that cloned repo.
- If already cloned photon
Command : make [target-name] CONF=[config.json path](if config.json in current directory then no need to give config path)
Ex- make packages CONF=/root/dev/photon/config.json
- Done:
- Built iso,ova,azure,gce,ami for master and dev branches.
- Built all as well as specified packages.
- To-Do:
- Testing each target
- Testing all the images
Change-Id: Ifb93b03def33cc0e89fbc50a788805db3c8da95f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/8429
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
| ... | ... |
@@ -1,754 +1,6 @@ |
| 1 |
-# |
|
| 2 |
-# Copyright VMware, Inc 2015 |
|
| 3 |
-# |
|
| 4 |
- |
|
| 5 |
-SRCROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) |
|
| 6 |
-MAKEROOT=$(SRCROOT)/support/make |
|
| 7 |
- |
|
| 8 |
-# do not build these targets as '%' |
|
| 9 |
-$(MAKEROOT)/makedefs.mk: ; |
|
| 10 |
-Makefile: ; |
|
| 11 |
- |
|
| 12 |
-include $(MAKEROOT)/makedefs.mk |
|
| 13 |
- |
|
| 14 |
-export PATH := $(SRCROOT)/tools/bin:$(PATH) |
|
| 15 |
-export PHOTON_BUILD_NUM=$(PHOTON_BUILD_NUMBER) |
|
| 16 |
-export PHOTON_RELEASE_VER=$(PHOTON_RELEASE_VERSION) |
|
| 17 |
- |
|
| 18 |
-ifdef PHOTON_CACHE_PATH |
|
| 19 |
-PHOTON_PACKAGES_MINIMAL := packages-cached |
|
| 20 |
-PHOTON_PACKAGES := packages-cached |
|
| 21 |
-else |
|
| 22 |
-PHOTON_PACKAGES_MINIMAL := packages-minimal |
|
| 23 |
-PHOTON_PACKAGES := packages |
|
| 24 |
-endif |
|
| 25 |
- |
|
| 26 |
-ifdef PHOTON_SOURCES_PATH |
|
| 27 |
-PHOTON_SOURCES := sources-cached |
|
| 28 |
-else |
|
| 29 |
-PHOTON_SOURCES ?= sources |
|
| 30 |
-endif |
|
| 31 |
- |
|
| 32 |
-FULL_PACKAGE_LIST_FILE := build_install_options_all.json |
|
| 33 |
-MINIMAL_PACKAGE_LIST_FILE := build_install_options_minimal.json |
|
| 34 |
-RT_PACKAGE_LIST_FILE := build_install_options_rt.json |
|
| 35 |
- |
|
| 36 |
-ifdef PHOTON_PUBLISH_RPMS_PATH |
|
| 37 |
-PHOTON_PUBLISH_RPMS := publish-rpms-cached |
|
| 38 |
-else |
|
| 39 |
-PHOTON_PUBLISH_RPMS := publish-rpms |
|
| 40 |
-endif |
|
| 41 |
- |
|
| 42 |
-ifdef PHOTON_PUBLISH_XRPMS_PATH |
|
| 43 |
-PHOTON_PUBLISH_XRPMS := publish-x-rpms-cached |
|
| 44 |
-else |
|
| 45 |
-PHOTON_PUBLISH_XRPMS := publish-x-rpms |
|
| 46 |
-endif |
|
| 47 |
- |
|
| 48 |
-# Tri state RPMCHECK: |
|
| 49 |
-# 1) RPMCHECK is not specified: just build |
|
| 50 |
-# 2) RPMCHECK=enable: build and run %check section. do not stop on error. will generate report file. |
|
| 51 |
-# 3) RPMCHECK=enable_stop_on_error: build and run %check section. stop on first error. |
|
| 52 |
-# |
|
| 53 |
-# We use 2 parameters: |
|
| 54 |
-# -u: enable checking. |
|
| 55 |
-# -q: quit on error. if -q is not specified it will keep going |
|
| 56 |
- |
|
| 57 |
-ifeq ($(RPMCHECK),enable) |
|
| 58 |
-PHOTON_RPMCHECK_FLAGS := --enable-rpmcheck |
|
| 59 |
-else ifeq ($(RPMCHECK),enable_stop_on_error) |
|
| 60 |
-PHOTON_RPMCHECK_FLAGS := --enable-rpmcheck --rpmcheck-stop-on-error |
|
| 61 |
-else |
|
| 62 |
-PHOTON_RPMCHECK_FLAGS := |
|
| 63 |
-endif |
|
| 64 |
- |
|
| 65 |
-ifeq ($(SCHEDULER_SERVER),enable) |
|
| 66 |
-START_SCHEDULER_SERVER := --start-scheduler-server True |
|
| 67 |
-else |
|
| 68 |
-START_SCHEDULER_SERVER := |
|
| 69 |
-endif |
|
| 70 |
- |
|
| 71 |
-# KAT build for FIPS certification |
|
| 72 |
-# Use KAT_BUILD=enable to build a kat kernel. By default, KAT_BUILD is disabled. |
|
| 73 |
-ifeq ($(KAT_BUILD),enable) |
|
| 74 |
-PHOTON_KAT_BUILD_FLAGS := --enable-katbuild |
|
| 75 |
-endif |
|
| 76 |
- |
|
| 77 |
-ifeq ($(BUILDDEPS),true) |
|
| 78 |
-PUBLISH_BUILD_DEPENDENCIES := --publish-build-dependencies True |
|
| 79 |
-else |
|
| 80 |
-PUBLISH_BUILD_DEPENDENCIES := |
|
| 81 |
-endif |
|
| 82 |
- |
|
| 83 |
-PACKAGE_WEIGHTS = --package-weights-path $(SRCROOT)/common/data/packageWeights.json |
|
| 84 |
- |
|
| 85 |
-ifdef PKG_BUILD_OPTIONS |
|
| 86 |
-PACKAGE_BUILD_OPTIONS = --pkg-build-option-file $(PKG_BUILD_OPTIONS) |
|
| 87 |
-else |
|
| 88 |
-PACKAGE_BUILD_OPTIONS = |
|
| 1 |
+ifndef CONF |
|
| 2 |
+ CONF := config.json |
|
| 89 | 3 |
endif |
| 90 | 4 |
|
| 91 |
-ifdef DISTRIBUTED_BUILD_CONFIG |
|
| 92 |
-DISTRIBUTED_BUILD_OPTIONS = --distributed-build-option-file $(DISTRIBUTED_BUILD_CONFIG) |
|
| 93 |
-else |
|
| 94 |
-DISTRIBUTED_BUILD_OPTIONS = |
|
| 95 |
-endif |
|
| 96 |
- |
|
| 97 |
-ifdef CROSS_TARGET |
|
| 98 |
-CROSS_TARGET_FLAGS = --cross-target $(CROSS_TARGET) |
|
| 99 |
-else |
|
| 100 |
-CROSS_TARGET_FLAGS = |
|
| 101 |
-endif |
|
| 102 |
- |
|
| 103 |
-TOOLS_BIN := $(SRCROOT)/tools/bin |
|
| 104 |
-CONTAIN := $(TOOLS_BIN)/contain |
|
| 105 |
-ifeq ($(ARCH),x86_64) |
|
| 106 |
-VIXDISKUTIL := $(TOOLS_BIN)/vixdiskutil |
|
| 107 |
-else |
|
| 108 |
-VIXDISKUTIL := |
|
| 109 |
-endif |
|
| 110 |
- |
|
| 111 |
-#marker file indicating if run from container |
|
| 112 |
-DOCKER_ENV=/.dockerenv |
|
| 113 |
- |
|
| 114 |
-$(TOOLS_BIN): |
|
| 115 |
- mkdir -p $(TOOLS_BIN) |
|
| 116 |
- |
|
| 117 |
-$(CONTAIN): $(TOOLS_BIN) |
|
| 118 |
- gcc -O2 -std=gnu99 -Wall -Wextra $(SRCROOT)/tools/src/contain/*.c -o $@_unpriv |
|
| 119 |
- sudo install -o root -g root -m 4755 $@_unpriv $@ |
|
| 120 |
- |
|
| 121 |
-$(VIXDISKUTIL): $(TOOLS_BIN) |
|
| 122 |
- @cd $(SRCROOT)/tools/src/vixDiskUtil && \ |
|
| 123 |
- make |
|
| 124 |
- |
|
| 125 |
-.PHONY : all iso clean image all-images \ |
|
| 126 |
-check-tools check-docker check-bison check-g++ check-gawk check-repo-tool check-kpartx check-sanity \ |
|
| 127 |
-clean-install clean-chroot build-updated-packages check generate-yaml-files |
|
| 128 |
- |
|
| 129 |
-THREADS?=1 |
|
| 130 |
-LOGLEVEL?=info |
|
| 131 |
- |
|
| 132 |
-# Build targets for rpm build |
|
| 133 |
-#------------------------------------------------------------------------------- |
|
| 134 |
-packages-minimal: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) generate-dep-lists |
|
| 135 |
- @echo "Building all minimal RPMS..." |
|
| 136 |
- @echo "" |
|
| 137 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 138 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 139 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 140 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 141 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 142 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 143 |
- --packages-json-input $(PHOTON_DATA_DIR)/packages_minimal.json \ |
|
| 144 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 145 |
- --log-level $(LOGLEVEL) \ |
|
| 146 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 147 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 148 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 149 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 150 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 151 |
- --pkginfo-file $(PHOTON_PKGINFO_FILE) \ |
|
| 152 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 153 |
- $(START_SCHEDULER_SERVER) \ |
|
| 154 |
- $(PUBLISH_BUILD_DEPENDENCIES) \ |
|
| 155 |
- $(PACKAGE_WEIGHTS) \ |
|
| 156 |
- --threads ${THREADS}
|
|
| 157 |
- |
|
| 158 |
-packages-rt: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) generate-dep-lists |
|
| 159 |
- @echo "Building minimal RPMS for Real Time..." |
|
| 160 |
- @echo "" |
|
| 161 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 162 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 163 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 164 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 165 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 166 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 167 |
- --packages-json-input $(PHOTON_DATA_DIR)/packages_rt.json \ |
|
| 168 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 169 |
- --log-level $(LOGLEVEL) \ |
|
| 170 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 171 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 172 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 173 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 174 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 175 |
- --pkginfo-file $(PHOTON_PKGINFO_FILE) \ |
|
| 176 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 177 |
- $(PUBLISH_BUILD_DEPENDENCIES) \ |
|
| 178 |
- $(PACKAGE_WEIGHTS) \ |
|
| 179 |
- --threads ${THREADS}
|
|
| 180 |
- |
|
| 181 |
-packages-initrd: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) generate-dep-lists |
|
| 182 |
- @echo "Building all initrd package RPMS..." |
|
| 183 |
- @echo "" |
|
| 184 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 185 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 186 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 187 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 188 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 189 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 190 |
- --packages-json-input $(PHOTON_DATA_DIR)/packages_installer_initrd.json \ |
|
| 191 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 192 |
- --log-level $(LOGLEVEL) \ |
|
| 193 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 194 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 195 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 196 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 197 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 198 |
- --pkginfo-file $(PHOTON_PKGINFO_FILE) \ |
|
| 199 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 200 |
- $(START_SCHEDULER_SERVER) \ |
|
| 201 |
- $(PUBLISH_BUILD_DEPENDENCIES) \ |
|
| 202 |
- $(PACKAGE_WEIGHTS) \ |
|
| 203 |
- --threads ${THREADS}
|
|
| 204 |
- |
|
| 205 |
-packages: check-docker-py check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) check-spec-files generate-dep-lists |
|
| 206 |
- @echo "Building all RPMS..." |
|
| 207 |
- @echo "" |
|
| 208 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 209 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 210 |
- --build-type $(PHOTON_BUILD_TYPE) \ |
|
| 211 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 212 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 213 |
- --source-rpm-path $(PHOTON_SRPMS_DIR) \ |
|
| 214 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 215 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 216 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 217 |
- --log-level $(LOGLEVEL) \ |
|
| 218 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 219 |
- --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \ |
|
| 220 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 221 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 222 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 223 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 224 |
- --pkginfo-file $(PHOTON_PKGINFO_FILE) \ |
|
| 225 |
- $(PACKAGE_BUILD_OPTIONS) \ |
|
| 226 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 227 |
- $(START_SCHEDULER_SERVER) \ |
|
| 228 |
- $(PHOTON_KAT_BUILD_FLAGS) \ |
|
| 229 |
- $(CROSS_TARGET_FLAGS) \ |
|
| 230 |
- $(PUBLISH_BUILD_DEPENDENCIES) \ |
|
| 231 |
- $(PACKAGE_WEIGHTS) \ |
|
| 232 |
- --threads ${THREADS}
|
|
| 233 |
- $(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR) |
|
| 234 |
- |
|
| 235 |
-packages-docker: check-docker-py check-docker-service check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
|
| 236 |
- @echo "Building all RPMS..." |
|
| 237 |
- @echo "" |
|
| 238 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 239 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 240 |
- --build-type $(PHOTON_BUILD_TYPE) \ |
|
| 241 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 242 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 243 |
- --source-rpm-path $(PHOTON_SRPMS_DIR) \ |
|
| 244 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 245 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 246 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 247 |
- --log-level $(LOGLEVEL) \ |
|
| 248 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 249 |
- --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \ |
|
| 250 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 251 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 252 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 253 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 254 |
- --pkginfo-file $(PHOTON_PKGINFO_FILE) \ |
|
| 255 |
- $(PACKAGE_BUILD_OPTIONS) \ |
|
| 256 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 257 |
- $(START_SCHEDULER_SERVER) \ |
|
| 258 |
- $(CROSS_TARGET_FLAGS) \ |
|
| 259 |
- $(PUBLISH_BUILD_DEPENDENCIES) \ |
|
| 260 |
- $(PACKAGE_WEIGHTS) \ |
|
| 261 |
- --threads ${THREADS}
|
|
| 262 |
- |
|
| 263 |
-updated-packages: check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
|
| 264 |
- @echo "Building only updated RPMS..." |
|
| 265 |
- @echo "" |
|
| 266 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 267 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 268 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 269 |
- --rpm-path $(PHOTON_UPDATED_RPMS_DIR) \ |
|
| 270 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 271 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 272 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 273 |
- --log-level $(LOGLEVEL) \ |
|
| 274 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 275 |
- --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \ |
|
| 276 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 277 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 278 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 279 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 280 |
- --input-RPMS-path $(PHOTON_INPUT_RPMS_DIR) \ |
|
| 281 |
- $(PHOTON_KAT_BUILD_FLAGS) \ |
|
| 282 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 283 |
- $(START_SCHEDULER_SERVER) \ |
|
| 284 |
- $(PUBLISH_BUILD_DEPENDENCIES) \ |
|
| 285 |
- $(PACKAGE_WEIGHTS) \ |
|
| 286 |
- --threads ${THREADS}
|
|
| 287 |
- |
|
| 288 |
-tool-chain-stage1: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
|
| 289 |
- @echo "Building all RPMS..." |
|
| 290 |
- @echo "" |
|
| 291 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 292 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 293 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 294 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 295 |
- --source-rpm-path $(PHOTON_SRPMS_DIR) \ |
|
| 296 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 297 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 298 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 299 |
- --log-level $(LOGLEVEL) \ |
|
| 300 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 301 |
- --threads ${THREADS} \
|
|
| 302 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 303 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 304 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 305 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 306 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 307 |
- $(START_SCHEDULER_SERVER) \ |
|
| 308 |
- --tool-chain-stage stage1 |
|
| 309 |
- |
|
| 310 |
-tool-chain-stage2: check-tools photon-stage $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
|
| 311 |
- @echo "Building all RPMS..." |
|
| 312 |
- @echo "" |
|
| 313 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 314 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 315 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 316 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 317 |
- --source-rpm-path $(PHOTON_SRPMS_DIR) \ |
|
| 318 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 319 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 320 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 321 |
- --log-level $(LOGLEVEL) \ |
|
| 322 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 323 |
- --threads ${THREADS} \
|
|
| 324 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 325 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 326 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 327 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 328 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 329 |
- $(START_SCHEDULER_SERVER) \ |
|
| 330 |
- --tool-chain-stage stage2 |
|
| 331 |
- |
|
| 332 |
-%: check-tools $(PHOTON_PUBLISH_RPMS) $(PHOTON_PUBLISH_XRPMS) $(PHOTON_SOURCES) $(CONTAIN) check-spec-files $(eval PKG_NAME = $@) |
|
| 333 |
- $(eval PKG_NAME = $@) |
|
| 334 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 335 |
- $(PHOTON_PACKAGE_BUILDER) --install-package $(PKG_NAME)\ |
|
| 336 |
- --build-type $(PHOTON_BUILD_TYPE) \ |
|
| 337 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 338 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 339 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 340 |
- --source-rpm-path $(PHOTON_SRPMS_DIR) \ |
|
| 341 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 342 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 343 |
- --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \ |
|
| 344 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 345 |
- --log-level $(LOGLEVEL) \ |
|
| 346 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 347 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 348 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 349 |
- $(PACKAGE_BUILD_OPTIONS) \ |
|
| 350 |
- $(PHOTON_RPMCHECK_FLAGS) \ |
|
| 351 |
- $(START_SCHEDULER_SERVER) \ |
|
| 352 |
- $(PHOTON_KAT_BUILD_FLAGS) \ |
|
| 353 |
- $(CROSS_TARGET_FLAGS) \ |
|
| 354 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 355 |
- --threads ${THREADS}
|
|
| 356 |
- |
|
| 357 |
-check: packages |
|
| 358 |
- ifeq ($(RPMCHECK),enable_stop_on_error) |
|
| 359 |
- $(eval rpmcheck_stop_on_error = -q) |
|
| 360 |
- endif |
|
| 361 |
- @echo "Testing all RPMS ..." |
|
| 362 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 363 |
- $(PHOTON_PACKAGE_BUILDER) \ |
|
| 364 |
- --build-type $(PHOTON_BUILD_TYPE) \ |
|
| 365 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 366 |
- --rpm-path $(PHOTON_RPMS_DIR) \ |
|
| 367 |
- --source-rpm-path $(PHOTON_SRPMS_DIR) \ |
|
| 368 |
- --source-path $(PHOTON_SRCS_DIR) \ |
|
| 369 |
- --build-root-path $(PHOTON_CHROOT_PATH) \ |
|
| 370 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 371 |
- --log-level $(LOGLEVEL) \ |
|
| 372 |
- --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
| 373 |
- --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \ |
|
| 374 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 375 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 376 |
- --build-number $(PHOTON_BUILD_NUMBER) \ |
|
| 377 |
- --release-version $(PHOTON_RELEASE_VERSION) \ |
|
| 378 |
- --pkginfo-file $(PHOTON_PKGINFO_FILE) \ |
|
| 379 |
- $(PACKAGE_BUILD_OPTIONS) \ |
|
| 380 |
- --enable-rpmcheck \ |
|
| 381 |
- $(rpmcheck_stop_on_error) \ |
|
| 382 |
- --threads ${THREADS}
|
|
| 383 |
- |
|
| 384 |
-distributed-build: |
|
| 385 |
- @echo "Building RPMS through kubernetes ..." |
|
| 386 |
- @echo "" |
|
| 387 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 388 |
- $(PHOTON_DISTRIBUTED_BUILDER) \ |
|
| 389 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 390 |
- --log-level $(LOGLEVEL) \ |
|
| 391 |
- $(DISTRIBUTED_BUILD_OPTIONS) |
|
| 392 |
- |
|
| 393 |
-#------------------------------------------------------------------------------- |
|
| 394 |
- |
|
| 395 |
-# The targets listed under "all" are the installer built artifacts |
|
| 396 |
-#=============================================================================== |
|
| 397 |
-all: iso photon-docker-image all-images src-iso minimal-iso |
|
| 398 |
- |
|
| 399 |
-iso: check-tools photon-stage $(PHOTON_PACKAGES) ostree-repo |
|
| 400 |
- @echo "Building Photon Full ISO..." |
|
| 401 |
- @cd $(PHOTON_IMAGE_BUILDER_DIR) && \ |
|
| 402 |
- sudo $(PHOTON_IMAGE_BUILDER) \ |
|
| 403 |
- --iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \ |
|
| 404 |
- --debug-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \ |
|
| 405 |
- --log-path $(PHOTON_STAGE)/LOGS \ |
|
| 406 |
- --log-level $(LOGLEVEL) \ |
|
| 407 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 408 |
- --srpm-path $(PHOTON_STAGE)/SRPMS \ |
|
| 409 |
- --package-list-file $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \ |
|
| 410 |
- --generated-data-path $(PHOTON_STAGE)/common/data \ |
|
| 411 |
- --pkg-to-rpm-map-file $(PHOTON_PKGINFO_FILE) |
|
| 412 |
- |
|
| 413 |
-minimal-iso: check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) packages-minimal packages-initrd |
|
| 414 |
- @echo "Building Photon Minimal ISO..." |
|
| 415 |
- @$(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR) |
|
| 416 |
- @$(CP) -f $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) $(PHOTON_GENERATED_DATA_DIR)/ |
|
| 417 |
- @cd $(PHOTON_IMAGE_BUILDER_DIR) && \ |
|
| 418 |
- sudo $(PHOTON_IMAGE_BUILDER) \ |
|
| 419 |
- --iso-path $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUM).iso \ |
|
| 420 |
- --debug-iso-path $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \ |
|
| 421 |
- --log-path $(PHOTON_STAGE)/LOGS \ |
|
| 422 |
- --log-level $(LOGLEVEL) \ |
|
| 423 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 424 |
- --srpm-path $(PHOTON_STAGE)/SRPMS \ |
|
| 425 |
- --package-list-file $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) \ |
|
| 426 |
- --generated-data-path $(PHOTON_STAGE)/common/data \ |
|
| 427 |
- --pkg-to-rpm-map-file $(PHOTON_PKGINFO_FILE) \ |
|
| 428 |
- --pkg-to-be-copied-conf-file $(PHOTON_GENERATED_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) |
|
| 429 |
- |
|
| 430 |
-rt-iso: check-tools photon-stage $(PHOTON_PUBLISH_XRPMS) packages-rt packages-initrd |
|
| 431 |
- @echo "Building Photon Real Time ISO..." |
|
| 432 |
- @$(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR) |
|
| 433 |
- @$(CP) -f $(PHOTON_DATA_DIR)/$(RT_PACKAGE_LIST_FILE) $(PHOTON_GENERATED_DATA_DIR)/ |
|
| 434 |
- @cd $(PHOTON_IMAGE_BUILDER_DIR) && \ |
|
| 435 |
- sudo $(PHOTON_IMAGE_BUILDER) \ |
|
| 436 |
- --iso-path $(PHOTON_STAGE)/photon-rt-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUM).iso \ |
|
| 437 |
- --debug-iso-path $(PHOTON_STAGE)/photon-rt-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \ |
|
| 438 |
- --log-path $(PHOTON_STAGE)/LOGS \ |
|
| 439 |
- --log-level $(LOGLEVEL) \ |
|
| 440 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 441 |
- --srpm-path $(PHOTON_STAGE)/SRPMS \ |
|
| 442 |
- --package-list-file $(PHOTON_DATA_DIR)/$(RT_PACKAGE_LIST_FILE) \ |
|
| 443 |
- --generated-data-path $(PHOTON_STAGE)/common/data \ |
|
| 444 |
- --pkg-to-rpm-map-file $(PHOTON_PKGINFO_FILE) \ |
|
| 445 |
- --pkg-to-be-copied-conf-file $(PHOTON_GENERATED_DATA_DIR)/$(RT_PACKAGE_LIST_FILE) |
|
| 446 |
- |
|
| 447 |
-src-iso: check-tools photon-stage $(PHOTON_PACKAGES) |
|
| 448 |
- @echo "Building Photon Full Source ISO..." |
|
| 449 |
- @cd $(PHOTON_IMAGE_BUILDER_DIR) && \ |
|
| 450 |
- sudo $(PHOTON_IMAGE_BUILDER) \ |
|
| 451 |
- --src-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).src.iso \ |
|
| 452 |
- --log-path $(PHOTON_STAGE)/LOGS \ |
|
| 453 |
- --log-level $(LOGLEVEL) \ |
|
| 454 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 455 |
- --srpm-path $(PHOTON_STAGE)/SRPMS \ |
|
| 456 |
- --package-list-file $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \ |
|
| 457 |
- --generated-data-path $(PHOTON_STAGE)/common/data \ |
|
| 458 |
- --pkg-to-rpm-map-file $(PHOTON_PKGINFO_FILE) > \ |
|
| 459 |
- $(PHOTON_LOGS_DIR)/sourceiso-installer.log 2>&1 |
|
| 460 |
- |
|
| 461 |
-image: check-kpartx photon-stage $(VIXDISKUTIL) $(PHOTON_PACKAGES) ostree-repo |
|
| 462 |
- @echo "Building image using $(CONFIG)..." |
|
| 463 |
- @cd $(PHOTON_IMAGE_BUILDER_DIR) |
|
| 464 |
- $(PHOTON_IMAGE_BUILDER) \ |
|
| 465 |
- --config-file=$(CONFIG) \ |
|
| 466 |
- --img-name=$(IMG_NAME) \ |
|
| 467 |
- --src-root=$(SRCROOT) \ |
|
| 468 |
- --generated-data-path=$(PHOTON_DATA_DIR) \ |
|
| 469 |
- --stage-path=$(PHOTON_STAGE) \ |
|
| 470 |
- --rpm-path $(PHOTON_STAGE)/RPMS |
|
| 471 |
- |
|
| 472 |
-all-images: check-kpartx photon-stage $(VIXDISKUTIL) $(PHOTON_PACKAGES) ostree-repo |
|
| 473 |
- @echo "Building all images - gce, ami, azure, ova..." |
|
| 474 |
- @cd $(PHOTON_IMAGE_BUILDER_DIR) |
|
| 475 |
- $(PHOTON_IMAGE_BUILDER) \ |
|
| 476 |
- --src-root=$(SRCROOT) \ |
|
| 477 |
- --generated-data-path=$(PHOTON_DATA_DIR) \ |
|
| 478 |
- --stage-path=$(PHOTON_STAGE) \ |
|
| 479 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 480 |
- --img-name=ami |
|
| 481 |
- $(PHOTON_IMAGE_BUILDER) \ |
|
| 482 |
- --src-root=$(SRCROOT) \ |
|
| 483 |
- --generated-data-path=$(PHOTON_DATA_DIR) \ |
|
| 484 |
- --stage-path=$(PHOTON_STAGE) \ |
|
| 485 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 486 |
- --img-name=gce |
|
| 487 |
- $(PHOTON_IMAGE_BUILDER) \ |
|
| 488 |
- --src-root=$(SRCROOT) \ |
|
| 489 |
- --generated-data-path=$(PHOTON_DATA_DIR) \ |
|
| 490 |
- --stage-path=$(PHOTON_STAGE) \ |
|
| 491 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 492 |
- --img-name=azure |
|
| 493 |
- $(PHOTON_IMAGE_BUILDER) \ |
|
| 494 |
- --src-root=$(SRCROOT) \ |
|
| 495 |
- --generated-data-path=$(PHOTON_DATA_DIR) \ |
|
| 496 |
- --stage-path=$(PHOTON_STAGE) \ |
|
| 497 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 498 |
- --img-name=ova |
|
| 499 |
- $(PHOTON_IMAGE_BUILDER) \ |
|
| 500 |
- --src-root=$(SRCROOT) \ |
|
| 501 |
- --generated-data-path=$(PHOTON_DATA_DIR) \ |
|
| 502 |
- --stage-path=$(PHOTON_STAGE) \ |
|
| 503 |
- --rpm-path $(PHOTON_STAGE)/RPMS \ |
|
| 504 |
- --img-name=ova_uefi |
|
| 505 |
- |
|
| 506 |
-photon-docker-image: |
|
| 507 |
- $(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR) |
|
| 508 |
- sudo docker build --no-cache --tag photon-build ./support/dockerfiles/photon |
|
| 509 |
- sudo docker run \ |
|
| 510 |
- --rm \ |
|
| 511 |
- --privileged \ |
|
| 512 |
- --net=host \ |
|
| 513 |
- -e PHOTON_BUILD_NUMBER=$(PHOTON_BUILD_NUMBER) \ |
|
| 514 |
- -e PHOTON_RELEASE_VERSION=$(PHOTON_RELEASE_VERSION) \ |
|
| 515 |
- -v `pwd`:/workspace \ |
|
| 516 |
- photon-build \ |
|
| 517 |
- ./support/dockerfiles/photon/make-docker-image.sh tdnf |
|
| 518 |
- |
|
| 519 |
-k8s-docker-images: start-docker photon-docker-image |
|
| 520 |
- mkdir -p $(PHOTON_STAGE)/docker_images && \ |
|
| 521 |
- cd ./support/dockerfiles/k8s-docker-images && \ |
|
| 522 |
- ./build-k8s-base-image.sh $(PHOTON_RELEASE_VERSION) $(PHOTON_BUILD_NUMBER) $(PHOTON_STAGE) && \ |
|
| 523 |
- ./build-k8s-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 524 |
- ./build-k8s-metrics-server-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 525 |
- ./build-k8s-coredns-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 526 |
- ./build-k8s-dns-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 527 |
- ./build-k8s-dashboard-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 528 |
- ./build-flannel-docker-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 529 |
- ./build-calico-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 530 |
- ./build-k8s-heapster-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 531 |
- ./build-k8s-nginx-ingress.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \ |
|
| 532 |
- ./build-wavefront-proxy-docker-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) |
|
| 533 |
- |
|
| 534 |
-ostree-repo: start-docker $(PHOTON_PACKAGES) |
|
| 535 |
- @echo "Creating OSTree repo from local RPMs in ostree-repo.tar.gz..." |
|
| 536 |
- @if [ -f $(PHOTON_STAGE)/ostree-repo.tar.gz ]; then \ |
|
| 537 |
- echo "ostree-repo.tar.gz already present, not creating again..."; \ |
|
| 538 |
- else \ |
|
| 539 |
- $(SRCROOT)/support/image-builder/ostree-tools/make-ostree-image.sh $(SRCROOT); \ |
|
| 540 |
- fi |
|
| 541 |
-#=============================================================================== |
|
| 542 |
- |
|
| 543 |
-# Set up Build environment |
|
| 544 |
-#_______________________________________________________________________________ |
|
| 545 |
-packages-cached: |
|
| 546 |
- @echo "Using cached RPMS..." |
|
| 547 |
- @$(RM) -f $(PHOTON_RPMS_DIR_NOARCH)/* && \ |
|
| 548 |
- $(RM) -f $(PHOTON_RPMS_DIR_ARCH)/* && \ |
|
| 549 |
- $(CP) -f $(PHOTON_CACHE_PATH)/RPMS/noarch/* $(PHOTON_RPMS_DIR_NOARCH)/ && \ |
|
| 550 |
- $(CP) -f $(PHOTON_CACHE_PATH)/RPMS/$(ARCH)/* $(PHOTON_RPMS_DIR_ARCH)/ |
|
| 551 |
- $(PHOTON_REPO_TOOL) $(PHOTON_RPMS_DIR) |
|
| 552 |
- |
|
| 553 |
-sources: |
|
| 554 |
- @$(MKDIR) -p $(PHOTON_SRCS_DIR) |
|
| 555 |
- |
|
| 556 |
-sources-cached: |
|
| 557 |
- @echo "Using cached SOURCES..." |
|
| 558 |
- @ln -sf $(PHOTON_SOURCES_PATH) $(PHOTON_SRCS_DIR) |
|
| 559 |
- |
|
| 560 |
-publish-rpms: |
|
| 561 |
- @echo "Pulling toolchain rpms..." |
|
| 562 |
- @cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \ |
|
| 563 |
- $(PHOTON_PULL_PUBLISH_RPMS) $(PHOTON_PUBLISH_RPMS_DIR) |
|
| 564 |
- |
|
| 565 |
-publish-x-rpms: |
|
| 566 |
- @echo "Pulling X toolchain rpms..." |
|
| 567 |
- @cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \ |
|
| 568 |
- $(PHOTON_PULL_PUBLISH_X_RPMS) $(PHOTON_PUBLISH_XRPMS_DIR) |
|
| 569 |
- |
|
| 570 |
-publish-rpms-cached: |
|
| 571 |
- @echo "Using cached toolchain rpms..." |
|
| 572 |
- @$(MKDIR) -p $(PHOTON_PUBLISH_RPMS_DIR)/{$(ARCH),noarch} && \
|
|
| 573 |
- cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \ |
|
| 574 |
- $(PHOTON_PULL_PUBLISH_RPMS) $(PHOTON_PUBLISH_RPMS_DIR) $(PHOTON_PUBLISH_RPMS_PATH) |
|
| 575 |
- |
|
| 576 |
-publish-x-rpms-cached: |
|
| 577 |
- @echo "Using cached X toolchain rpms..." |
|
| 578 |
- @$(MKDIR) -p $(PHOTON_PUBLISH_XRPMS_DIR)/{$(ARCH),noarch} && \
|
|
| 579 |
- cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \ |
|
| 580 |
- $(PHOTON_PULL_PUBLISH_X_RPMS) $(PHOTON_PUBLISH_XRPMS_DIR) $(PHOTON_PUBLISH_XRPMS_PATH) |
|
| 581 |
- |
|
| 582 |
-photon-stage: |
|
| 583 |
- @echo "Creating staging folder and subitems..." |
|
| 584 |
- @test -d $(PHOTON_STAGE) || $(MKDIR) -p $(PHOTON_STAGE) |
|
| 585 |
- @test -d $(PHOTON_CHROOT_PATH) || $(MKDIR) -p $(PHOTON_CHROOT_PATH) |
|
| 586 |
- @test -d $(PHOTON_RPMS_DIR_NOARCH) || $(MKDIR) -p $(PHOTON_RPMS_DIR_NOARCH) |
|
| 587 |
- @test -d $(PHOTON_RPMS_DIR_ARCH) || $(MKDIR) -p $(PHOTON_RPMS_DIR_ARCH) |
|
| 588 |
- @test -d $(PHOTON_SRPMS_DIR) || $(MKDIR) -p $(PHOTON_SRPMS_DIR) |
|
| 589 |
- @test -d $(PHOTON_UPDATED_RPMS_DIR_NOARCH) || $(MKDIR) -p $(PHOTON_UPDATED_RPMS_DIR_NOARCH) |
|
| 590 |
- @test -d $(PHOTON_UPDATED_RPMS_DIR_ARCH) || $(MKDIR) -p $(PHOTON_UPDATED_RPMS_DIR_ARCH) |
|
| 591 |
- @test -d $(PHOTON_SRCS_DIR) || $(MKDIR) -p $(PHOTON_SRCS_DIR) |
|
| 592 |
- @test -d $(PHOTON_LOGS_DIR) || $(MKDIR) -p $(PHOTON_LOGS_DIR) |
|
| 593 |
- @install -m 444 $(SRCROOT)/COPYING $(PHOTON_STAGE)/COPYING |
|
| 594 |
- @install -m 444 $(SRCROOT)/NOTICE-GPL2.0 $(PHOTON_STAGE)/NOTICE-GPL2.0 |
|
| 595 |
- @install -m 444 $(SRCROOT)/NOTICE-Apachev2 $(PHOTON_STAGE)/NOTICE-Apachev2 |
|
| 596 |
-#_______________________________________________________________________________ |
|
| 597 |
- |
|
| 598 |
-# Clean build environment |
|
| 599 |
-#================================================================== |
|
| 600 |
-clean: clean-install clean-chroot |
|
| 601 |
- @echo "Deleting Photon ISO..." |
|
| 602 |
- @$(RM) -f $(PHOTON_STAGE)/photon-*.iso |
|
| 603 |
- @echo "Deleting stage dir..." |
|
| 604 |
- @$(RMDIR) $(PHOTON_STAGE) |
|
| 605 |
- @echo "Deleting chroot path..." |
|
| 606 |
- @$(RMDIR) $(PHOTON_CHROOT_PATH) |
|
| 607 |
- @echo "Deleting tools/bin..." |
|
| 608 |
- @$(RMDIR) $(TOOLS_BIN) |
|
| 609 |
- |
|
| 610 |
-clean-install: |
|
| 611 |
- @echo "Cleaning installer working directory..." |
|
| 612 |
- @if [ -d $(PHOTON_STAGE)/photon_iso ]; then \ |
|
| 613 |
- $(PHOTON_CHROOT_CLEANER) $(PHOTON_STAGE)/photon_iso; \ |
|
| 614 |
- fi |
|
| 615 |
- |
|
| 616 |
-clean-chroot: |
|
| 617 |
- @echo "Cleaning chroot path..." |
|
| 618 |
- @if [ -d $(PHOTON_CHROOT_PATH) ]; then \ |
|
| 619 |
- $(PHOTON_CHROOT_CLEANER) $(PHOTON_CHROOT_PATH); \ |
|
| 620 |
- fi |
|
| 621 |
- |
|
| 622 |
-#================================================================== |
|
| 623 |
- |
|
| 624 |
-# Targets to check for tools support in build environment |
|
| 625 |
-#__________________________________________________________________________________ |
|
| 626 |
-check-tools: check-bison check-g++ check-gawk check-repo-tool check-texinfo check-sanity check-docker check-pyopenssl |
|
| 627 |
- |
|
| 628 |
-check-docker: |
|
| 629 |
-ifeq (,$(wildcard $(DOCKER_ENV))) |
|
| 630 |
- @command -v docker >/dev/null 2>&1 || { echo "Package docker not installed. Aborting." >&2; exit 1; }
|
|
| 631 |
-endif |
|
| 632 |
- |
|
| 633 |
-check-docker-service: |
|
| 634 |
-ifeq (,$(wildcard $(DOCKER_ENV))) |
|
| 635 |
- @docker ps >/dev/null 2>&1 || { echo "Docker service is not running. Aborting." >&2; exit 1; }
|
|
| 636 |
-endif |
|
| 637 |
- |
|
| 638 |
-check-docker-py: |
|
| 639 |
-ifeq (,$(wildcard $(DOCKER_ENV))) |
|
| 640 |
- @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; }
|
|
| 641 |
-endif |
|
| 642 |
- |
|
| 643 |
-check-pyopenssl: |
|
| 644 |
- @python3 -c "import OpenSSL" > /dev/null 2>&1 || { echo "Error pyOpenSSL package not installed.\nPlease use: pip3 install pyOpenSSL" >&2; exit 1; }
|
|
| 645 |
- |
|
| 646 |
-check-bison: |
|
| 647 |
- @command -v bison >/dev/null 2>&1 || { echo "Package bison not installed. Aborting." >&2; exit 1; }
|
|
| 648 |
- |
|
| 649 |
-check-texinfo: |
|
| 650 |
- @command -v makeinfo >/dev/null 2>&1 || { echo "Package texinfo not installed. Aborting." >&2; exit 1; }
|
|
| 651 |
- |
|
| 652 |
-check-g++: |
|
| 653 |
- @command -v g++ >/dev/null 2>&1 || { echo "Package g++ not installed. Aborting." >&2; exit 1; }
|
|
| 654 |
- |
|
| 655 |
-check-gawk: |
|
| 656 |
- @command -v gawk >/dev/null 2>&1 || { echo "Package gawk not installed. Aborting." >&2; exit 1; }
|
|
| 657 |
- |
|
| 658 |
-check-repo-tool: |
|
| 659 |
- @command -v $(PHOTON_REPO_TOOL) >/dev/null 2>&1 || { echo "Package $(PHOTON_REPO_TOOL) not installed. Aborting." >&2; exit 1; }
|
|
| 660 |
- |
|
| 661 |
-check-kpartx: |
|
| 662 |
- @command -v kpartx >/dev/null 2>&1 || { echo "Package kpartx not installed. Aborting." >&2; exit 1; }
|
|
| 663 |
- |
|
| 664 |
-check-sanity: |
|
| 665 |
- @$(SRCROOT)/support/sanity_check.sh |
|
| 666 |
- @echo "" |
|
| 667 |
- |
|
| 668 |
-start-docker: check-docker |
|
| 669 |
- systemctl start docker |
|
| 670 |
- |
|
| 671 |
-install-photon-docker-image: photon-docker-image |
|
| 672 |
- sudo docker build -t photon:tdnf . |
|
| 673 |
-#__________________________________________________________________________________ |
|
| 674 |
- |
|
| 675 |
-# Spec file checker and utilities |
|
| 676 |
-#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 677 |
-check-spec-files: |
|
| 678 |
- @./tools/scripts/check_spec_files.sh |
|
| 679 |
- |
|
| 680 |
-generate-dep-lists: |
|
| 681 |
- @echo "" |
|
| 682 |
- @$(RMDIR) $(PHOTON_GENERATED_DATA_DIR) |
|
| 683 |
- @$(MKDIR) -p $(PHOTON_GENERATED_DATA_DIR) |
|
| 684 |
- @cd $(PHOTON_SPECDEPS_DIR) && \ |
|
| 685 |
- $(PHOTON_SPECDEPS) \ |
|
| 686 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 687 |
- --stage-dir $(PHOTON_STAGE) \ |
|
| 688 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 689 |
- --log-level $(LOGLEVEL) \ |
|
| 690 |
- --pkg $(PHOTON_GENERATED_DATA_DIR) \ |
|
| 691 |
- --input-type=json \ |
|
| 692 |
- --file "$$(ls $(PHOTON_DATA_DIR)/packages_*.json)" \ |
|
| 693 |
- --display-option json \ |
|
| 694 |
- --input-data-dir $(PHOTON_DATA_DIR) |
|
| 695 |
- @echo "" |
|
| 696 |
-pkgtree: |
|
| 697 |
- @cd $(PHOTON_SPECDEPS_DIR) && \ |
|
| 698 |
- $(PHOTON_SPECDEPS) \ |
|
| 699 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 700 |
- --log-level $(LOGLEVEL) \ |
|
| 701 |
- --input-type pkg \ |
|
| 702 |
- --pkg $(pkg) |
|
| 703 |
- |
|
| 704 |
-imgtree: |
|
| 705 |
- @cd $(PHOTON_SPECDEPS_DIR) && \ |
|
| 706 |
- $(PHOTON_SPECDEPS) \ |
|
| 707 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 708 |
- --log-level $(LOGLEVEL) \ |
|
| 709 |
- --input-type json \ |
|
| 710 |
- --file $(PHOTON_DATA_DIR)/packages_$(img).json |
|
| 711 |
- |
|
| 712 |
-who-needs: |
|
| 713 |
- @cd $(PHOTON_SPECDEPS_DIR) && \ |
|
| 714 |
- $(PHOTON_SPECDEPS) \ |
|
| 715 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 716 |
- --log-level $(LOGLEVEL) \ |
|
| 717 |
- --input-type who-needs \ |
|
| 718 |
- --pkg $(pkg) |
|
| 719 |
- |
|
| 720 |
-print-upward-deps: |
|
| 721 |
- @cd $(PHOTON_SPECDEPS_DIR) && \ |
|
| 722 |
- $(PHOTON_SPECDEPS) \ |
|
| 723 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 724 |
- --input-type print-upward-deps \ |
|
| 725 |
- --pkg $(pkg) |
|
| 726 |
- |
|
| 727 |
-#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 728 |
- |
|
| 729 |
-generate-yaml-files: check-tools photon-stage $(PHOTON_PACKAGES) |
|
| 730 |
- @echo "Generating yaml files for packages ..." |
|
| 731 |
- @cd $(PHOTON_PKG_BUILDER_DIR) && \ |
|
| 732 |
- $(PHOTON_GENERATE_OSS_FILES) --generate-yaml-files \ |
|
| 733 |
- --spec-path $(PHOTON_SPECS_DIR) \ |
|
| 734 |
- --source-rpm-path $(PHOTON_SRPMS_DIR) \ |
|
| 735 |
- --log-path $(PHOTON_LOGS_DIR) \ |
|
| 736 |
- --dist-tag $(PHOTON_DIST_TAG) \ |
|
| 737 |
- --log-level $(LOGLEVEL) \ |
|
| 738 |
- --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \ |
|
| 739 |
- --pkg-blacklist-file $(PHOTON_PKG_BLACKLIST_FILE) |
|
| 740 |
- |
|
| 741 |
-# Input args: BASE_COMMIT= (optional) |
|
| 742 |
-# |
|
| 743 |
-# This target removes staged RPMS that can be affected by change(s) and should |
|
| 744 |
-# be rebuilt as part of incremental build support |
|
| 745 |
-# For every spec file touched - remove all upward dependent packages (rpms) |
|
| 746 |
-# If support folder was touched - do full build |
|
| 747 |
-# |
|
| 748 |
-# The analyzed changes are: |
|
| 749 |
-# - commits from BASE_COMMIT to HEAD (if BASE_COMMIT= parameter is specified) |
|
| 750 |
-# - local changes (if no commits specified) |
|
| 751 |
-clean-stage-for-incremental-build: |
|
| 752 |
- @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 ' ' :) |
|
| 753 |
- @test -n "$$(git diff --name-only @~1 @ | grep '^support/\(make\|package-builder\|pullpublishrpms\)')" && { echo "Remove all staged RPMs"; $(RM) -rf $(PHOTON_RPMS_DIR); } ||:
|
|
| 754 |
- |
|
| 5 |
+%: |
|
| 6 |
+ @./build.py -c $(CONF) -t $@ |
| 755 | 7 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,1099 @@ |
| 0 |
+#!/usr/bin/env python3 |
|
| 1 |
+ |
|
| 2 |
+import sys |
|
| 3 |
+import os |
|
| 4 |
+sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "support/package-builder")) |
|
| 5 |
+sys.path.insert(1, os.path.join(os.path.dirname(os.path.realpath(__file__)), "support/image-builder")) |
|
| 6 |
+from pathlib import PurePath |
|
| 7 |
+from constants import constants |
|
| 8 |
+from argparse import ArgumentParser |
|
| 9 |
+from CommandUtils import CommandUtils |
|
| 10 |
+from builder import Builder |
|
| 11 |
+from Logger import Logger |
|
| 12 |
+from utils import Utils |
|
| 13 |
+import subprocess |
|
| 14 |
+import json |
|
| 15 |
+import docker |
|
| 16 |
+import shutil |
|
| 17 |
+import traceback |
|
| 18 |
+import glob |
|
| 19 |
+configdict = {}
|
|
| 20 |
+ |
|
| 21 |
+targetList = {
|
|
| 22 |
+ "image":["iso", "ami", "gce", "azure", "rpi3", "ova", "ova_uefi", "all", "src-iso", |
|
| 23 |
+ "photon-docker-image", "k8s-docker-images", "all-images", "minimal-iso", "rt-iso"], |
|
| 24 |
+ |
|
| 25 |
+ "rpmBuild": ["packages", "packages-minimal", "packages-initrd", "packages-docker", |
|
| 26 |
+ "updated-packages", "tool-chain-stage1", "tool-chain-stage2", "check", |
|
| 27 |
+ "ostree-repo", "generate-yaml-files", "create-repo", "distributed-build"], |
|
| 28 |
+ |
|
| 29 |
+ "buildEnvironment": ["packages-cached", "sources", "sources-cached", "publish-rpms", |
|
| 30 |
+ "publish-x-rpms", "publish-rpms-cached", "publish-x-rpms-cached", "photon-stage"], |
|
| 31 |
+ |
|
| 32 |
+ "cleanup": ["clean", "clean-install", "clean-chroot", "clean-stage-for-incremental-build"], |
|
| 33 |
+ |
|
| 34 |
+ "tool-checkup": ["check-tools", "check-docker", "check-docker-service", "check-docker-py", |
|
| 35 |
+ "check-bison", "check-texinfo", "check-g++", "check-gawk", "check-repo-tool", |
|
| 36 |
+ "check-kpartx", "check-sanity", "start-docker", "install-photon-docker-image", |
|
| 37 |
+ "check-spec-files", "check-pyopenssl"], |
|
| 38 |
+ |
|
| 39 |
+ "utilities": ["generate-dep-lists", "pkgtree", "imgtree", "who-needs", "print-upward-deps"] |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+curDir = os.getcwd() |
|
| 43 |
+ |
|
| 44 |
+check_prerequesite = {
|
|
| 45 |
+ "vixdiskutil": False, |
|
| 46 |
+ "tools-bin": False, |
|
| 47 |
+ "contain": False, |
|
| 48 |
+ "initialize-constants": False |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+def vixdiskutil(): |
|
| 52 |
+ check_prerequesite["vixdiskutil"] = True |
|
| 53 |
+ if not check_prerequesite["tools-bin"]: |
|
| 54 |
+ tools_bin() |
|
| 55 |
+ if subprocess.Popen(["cd " + curDir + "/tools/src/vixDiskUtil && make"], shell=True).wait() != 0: |
|
| 56 |
+ raise Exception("Not able to make vixDiskUtil")
|
|
| 57 |
+ |
|
| 58 |
+def tools_bin(): |
|
| 59 |
+ check_prerequesite["tools-bin"] = True |
|
| 60 |
+ if not os.path.isdir(os.path.join(curDir, "tools/bin")): |
|
| 61 |
+ os.mkdir(os.path.join("tools","bin"))
|
|
| 62 |
+ |
|
| 63 |
+def contain(): |
|
| 64 |
+ check_prerequesite["contain"] = True |
|
| 65 |
+ if not check_prerequesite["tools-bin"]: |
|
| 66 |
+ tools_bin() |
|
| 67 |
+ |
|
| 68 |
+ if subprocess.Popen(["gcc -O2 -std=gnu99 -Wall -Wextra " + curDir + \ |
|
| 69 |
+ "/tools/src/contain/*.c -o tools/bin/contain_unpriv && sudo install -o root -g root \ |
|
| 70 |
+ -m 4755 tools/bin/contain_unpriv tools/bin/contain"], shell=True).wait() != 0: |
|
| 71 |
+ raise Exception("contain failed")
|
|
| 72 |
+ |
|
| 73 |
+ |
|
| 74 |
+class Build_Config: |
|
| 75 |
+ buildThreads = 1 |
|
| 76 |
+ stagePath = "" |
|
| 77 |
+ pkgJsonInput = None |
|
| 78 |
+ rpmNoArchPath = "" |
|
| 79 |
+ chrootPath = "" |
|
| 80 |
+ generatedDataPath = "" |
|
| 81 |
+ pullPublishRPMSDir = "" |
|
| 82 |
+ pullPublishRPMS = "" |
|
| 83 |
+ pullPublishXRPMS = "" |
|
| 84 |
+ updatedRpmPath = "" |
|
| 85 |
+ updatedRpmNoArchPath = "" |
|
| 86 |
+ dockerEnv = "/.dockerenv" |
|
| 87 |
+ updatedRpmArchPath = "" |
|
| 88 |
+ installerPath = "" |
|
| 89 |
+ pkgInfoFile = "" |
|
| 90 |
+ rpmArchPath = "" |
|
| 91 |
+ commonDir = "" |
|
| 92 |
+ pkgBuildType = "" |
|
| 93 |
+ dataDir = "" |
|
| 94 |
+ packageListFile = "build_install_options_all.json" |
|
| 95 |
+ pkgToBeCopiedConfFile = None |
|
| 96 |
+ confFile = None |
|
| 97 |
+ distributedBuildFile = "distributed_build_options.json" |
|
| 98 |
+ |
|
| 99 |
+ @staticmethod |
|
| 100 |
+ def setDockerEnv(dockerEnv): |
|
| 101 |
+ Build_Config.dockerEnv = dockerEnv |
|
| 102 |
+ |
|
| 103 |
+ @staticmethod |
|
| 104 |
+ def setDistributedBuildFile(distributedBuildFile): |
|
| 105 |
+ Build_Config.distributedBuildFile = distributedBuildFile |
|
| 106 |
+ |
|
| 107 |
+ @staticmethod |
|
| 108 |
+ def setPkgToBeCopiedConfFile(pkgToBeCopiedConfFile): |
|
| 109 |
+ Build_Config.pkgToBeCopiedConfFile = pkgToBeCopiedConfFile |
|
| 110 |
+ |
|
| 111 |
+ @staticmethod |
|
| 112 |
+ def setRpmNoArchPath(): |
|
| 113 |
+ Build_Config.rpmNoArchPath = os.path.join(constants.rpmPath, "noarch") |
|
| 114 |
+ |
|
| 115 |
+ @staticmethod |
|
| 116 |
+ def setRpmArchPath(): |
|
| 117 |
+ Build_Config.rpmArchPath = os.path.join(constants.rpmPath, constants.buildArch) |
|
| 118 |
+ |
|
| 119 |
+ @staticmethod |
|
| 120 |
+ def setConfFile(confFile): |
|
| 121 |
+ Build_Config.confFile = confFile |
|
| 122 |
+ |
|
| 123 |
+ @staticmethod |
|
| 124 |
+ def setPkgBuildType(pkgBuildType): |
|
| 125 |
+ Build_Config.pkgBuildType = pkgBuildType |
|
| 126 |
+ |
|
| 127 |
+ @staticmethod |
|
| 128 |
+ def setBuildThreads(buildThreads): |
|
| 129 |
+ Build_Config.buildThreads = buildThreads |
|
| 130 |
+ |
|
| 131 |
+ @staticmethod |
|
| 132 |
+ def setPkgJsonInput(pkgJsonInput): |
|
| 133 |
+ Build_Config.pkgJsonInput = pkgJsonInput |
|
| 134 |
+ |
|
| 135 |
+ @staticmethod |
|
| 136 |
+ def setUpdatedRpmPath(updatedRpmPath): |
|
| 137 |
+ Build_Config.updatedRpmPath = updatedRpmPath |
|
| 138 |
+ Build_Config.updatedRpmNoArchPath = os.path.join(updatedRpmPath , "noarch") |
|
| 139 |
+ Build_Config.updatedRpmArchPath = os.path.join(updatedRpmPath, constants.buildArch) |
|
| 140 |
+ |
|
| 141 |
+ @staticmethod |
|
| 142 |
+ def setStagePath(stagePath): |
|
| 143 |
+ Build_Config.stagePath = stagePath |
|
| 144 |
+ |
|
| 145 |
+ @staticmethod |
|
| 146 |
+ def setInstallerPath(installerPath): |
|
| 147 |
+ Build_Config.installerPath = installerPath |
|
| 148 |
+ |
|
| 149 |
+ @staticmethod |
|
| 150 |
+ def setPkgInfoFile(pkgInfoFile): |
|
| 151 |
+ Build_Config.pkgInfoFile = pkgInfoFile |
|
| 152 |
+ |
|
| 153 |
+ @staticmethod |
|
| 154 |
+ def setChrootPath(chrootPath): |
|
| 155 |
+ Build_Config.chrootPath = chrootPath |
|
| 156 |
+ |
|
| 157 |
+ @staticmethod |
|
| 158 |
+ def setGeneratedDataDir(generatedDataDir): |
|
| 159 |
+ Build_Config.generatedDataPath = generatedDataDir |
|
| 160 |
+ |
|
| 161 |
+ @staticmethod |
|
| 162 |
+ def setCommonDir(commonDir): |
|
| 163 |
+ Build_Config.commonDir = commonDir |
|
| 164 |
+ |
|
| 165 |
+ @staticmethod |
|
| 166 |
+ def setDataDir(dataDir): |
|
| 167 |
+ Build_Config.dataDir = dataDir |
|
| 168 |
+ Build_Config.packageListFile = os.path.join(Build_Config.dataDir, Build_Config.packageListFile) |
|
| 169 |
+ |
|
| 170 |
+ @staticmethod |
|
| 171 |
+ def setPullPublishRPMSDir(pullPublishRPMSDir): |
|
| 172 |
+ Build_Config.pullPublishRPMSDir = pullPublishRPMSDir |
|
| 173 |
+ |
|
| 174 |
+ @staticmethod |
|
| 175 |
+ def setPullPublishXRPMS(pullPublishXRPMS): |
|
| 176 |
+ Build_Config.pullPublishXRPMS = pullPublishXRPMS |
|
| 177 |
+ |
|
| 178 |
+ @staticmethod |
|
| 179 |
+ def setPullPublishRPMS(pullPublishRPMS): |
|
| 180 |
+ Build_Config.pullPublishRPMS = pullPublishRPMS |
|
| 181 |
+ |
|
| 182 |
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 183 |
+# class Utilities is used for generating spec dependency, priniting upward dependencies for package.. + |
|
| 184 |
+# + |
|
| 185 |
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 186 |
+class Utilities: |
|
| 187 |
+ |
|
| 188 |
+ global configdict |
|
| 189 |
+ global check_prerequesite |
|
| 190 |
+ |
|
| 191 |
+ def __init__(self): |
|
| 192 |
+ |
|
| 193 |
+ from SpecDeps import SpecDependencyGenerator |
|
| 194 |
+ |
|
| 195 |
+ cmdUtils = CommandUtils() |
|
| 196 |
+ self.img = configdict.get("utility", {}).get("img", None)
|
|
| 197 |
+ self.json_file = configdict.get("utility", {}).get("file", "packages_*.json")
|
|
| 198 |
+ self.display_option = configdict.get("utility", {}).get("display-option", "json")
|
|
| 199 |
+ self.input_type = configdict.get("utility", {}).get("input-type", "json")
|
|
| 200 |
+ self.pkg = configdict.get("utility", {}).get("pkg", None)
|
|
| 201 |
+ |
|
| 202 |
+ self.logger = Logger.getLogger("SpecDeps", constants.logPath, constants.logLevel)
|
|
| 203 |
+ if not os.path.isdir(Build_Config.generatedDataPath): |
|
| 204 |
+ cmdUtils.runCommandInShell("mkdir -p " + Build_Config.generatedDataPath)
|
|
| 205 |
+ |
|
| 206 |
+ if configdict["targetName"] in ["pkgtree", "who-needs", "print-upward-deps"] and "pkg" not in os.environ: |
|
| 207 |
+ raise Exception("pkg not present in os.environ")
|
|
| 208 |
+ elif configdict["targetName"] in ["pkgtree", "who-needs", "print-upward-deps"]: |
|
| 209 |
+ self.pkg = os.environ["pkg"] |
|
| 210 |
+ self.display_option = "tree" |
|
| 211 |
+ |
|
| 212 |
+ if configdict["targetName"] == "imgtree" and "img" not in os.environ: |
|
| 213 |
+ raise Exception("img not present in os.environ")
|
|
| 214 |
+ elif configdict["targetName"] == "imgtree": |
|
| 215 |
+ self.json_file = "packages_" + os.environ["img"] + ".json" |
|
| 216 |
+ |
|
| 217 |
+ self.specDepsObject = SpecDependencyGenerator(constants.logPath, constants.logLevel) |
|
| 218 |
+ |
|
| 219 |
+ def generate_dep_lists(self): |
|
| 220 |
+ check_prerequesite["generate-dep-lists"] = True |
|
| 221 |
+ list_json_files = glob.glob(os.path.join(Build_Config.dataDir, self.json_file)) |
|
| 222 |
+ # Generate the expanded package dependencies json file based on package_list_file |
|
| 223 |
+ self.logger.info("Generating the install time dependency list for all json files")
|
|
| 224 |
+ if list_json_files: |
|
| 225 |
+ shutil.copy2(os.path.join(Build_Config.dataDir, "build_install_options_all.json"), Build_Config.generatedDataPath) |
|
| 226 |
+ shutil.copy2(os.path.join(Build_Config.dataDir, "build_install_options_minimal.json"), Build_Config.generatedDataPath) |
|
| 227 |
+ shutil.copy2(os.path.join(Build_Config.dataDir, "build_install_options_rt.json"), Build_Config.generatedDataPath) |
|
| 228 |
+ for json_file in list_json_files: |
|
| 229 |
+ output_file = None |
|
| 230 |
+ if self.display_option == "json": |
|
| 231 |
+ output_file = os.path.join(Build_Config.generatedDataPath, os.path.splitext(os.path.basename(json_file))[0]+"_expanded.json") |
|
| 232 |
+ self.specDepsObject.process(self.input_type, json_file, self.display_option, output_file) |
|
| 233 |
+ |
|
| 234 |
+ def pkgtree(self): |
|
| 235 |
+ self.input_type = "pkg" |
|
| 236 |
+ self.specDepsObject.process(self.input_type, self.pkg, self.display_option) |
|
| 237 |
+ |
|
| 238 |
+ def who_needs(self): |
|
| 239 |
+ self.input_type = "who-needs" |
|
| 240 |
+ self.specDepsObject.process(self.input_type, self.pkg, self.display_option) |
|
| 241 |
+ |
|
| 242 |
+ def imgtree(self): |
|
| 243 |
+ self.input_type = "json" |
|
| 244 |
+ self.generate_dep_lists() |
|
| 245 |
+ |
|
| 246 |
+ def print_upward_deps(self): |
|
| 247 |
+ whoNeedsList = self.specDepsObject.process("get-upward-deps", self.pkg, self.display_option)
|
|
| 248 |
+ self.logger.info("Upward dependencies: " + str(whoNeedsList))
|
|
| 249 |
+ |
|
| 250 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 251 |
+# class Buildenvironmentsetup does job like pulling toolchain RPMS and creating stage... + |
|
| 252 |
+# + |
|
| 253 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 254 |
+ |
|
| 255 |
+ |
|
| 256 |
+class BuildEnvironmentSetup: |
|
| 257 |
+ |
|
| 258 |
+ global configdict |
|
| 259 |
+ global check_prerequesite |
|
| 260 |
+ |
|
| 261 |
+ def packages_cached(): |
|
| 262 |
+ check_prerequesite["packages-cached"]=True |
|
| 263 |
+ CommandUtils.runCommandInShell("rm -rf " + Build_Config.rpmNoArchPath + "/*")
|
|
| 264 |
+ CommandUtils.runCommandInShell("rm -rf " + Build_Config.rpmArchPath + "/*")
|
|
| 265 |
+ CommandUtils.runCommandInShell("cp -rf " + configdict["additional-path"]["photon-cache-path"] + "/RPMS/noarch/* " + Build_Config.rpmNoArchPath)
|
|
| 266 |
+ CommandUtils.runCommandInShell("cp -rf " + configdict["additional-path"]["photon-cache-path"] + \
|
|
| 267 |
+ "/RPMS/" + constants.currentArch + "/* " + Build_Config.rpmArchPath) |
|
| 268 |
+ RpmBuildTarget.create_repo() |
|
| 269 |
+ |
|
| 270 |
+ def sources(): |
|
| 271 |
+ if configdict['additional-path']['photon-sources-path'] is None: |
|
| 272 |
+ check_prerequesite["sources"]=True |
|
| 273 |
+ if not os.path.isdir(constants.sourcePath): |
|
| 274 |
+ os.mkdir(constants.sourcePath) |
|
| 275 |
+ else: |
|
| 276 |
+ BuildEnvironmentSetup.sources_cached() |
|
| 277 |
+ |
|
| 278 |
+ def sources_cached(): |
|
| 279 |
+ check_prerequesite["sources-cached"]=True |
|
| 280 |
+ print("Using cached SOURCES...")
|
|
| 281 |
+ CommandUtils.runCommandInShell("ln -sf " + configdict["additional-path"]["photon-sources-path"] + " " + constants.sourcePath)
|
|
| 282 |
+ |
|
| 283 |
+ def publish_rpms(): |
|
| 284 |
+ if configdict['additional-path']['photon-publish-rpms-path'] is None: |
|
| 285 |
+ check_prerequesite["publish-rpms"]=True |
|
| 286 |
+ print("Pulling toolchain RPMS...")
|
|
| 287 |
+ if subprocess.Popen(["cd " + Build_Config.pullPublishRPMSDir + " && " \ |
|
| 288 |
+ + Build_Config.pullPublishRPMS + " " + constants.prevPublishRPMRepo], shell=True).wait() != 0: |
|
| 289 |
+ raise Exception("Cannot run publish-rpms")
|
|
| 290 |
+ else: |
|
| 291 |
+ BuildEnvironmentSetup.publish_rpms_cached() |
|
| 292 |
+ |
|
| 293 |
+ def publish_rpms_cached(): |
|
| 294 |
+ check_prerequesite["publish-rpms-cached"]=True |
|
| 295 |
+ if not os.path.isdir(constants.prevPublishRPMRepo + "/" + constants.currentArch): |
|
| 296 |
+ os.makedirs(constants.prevPublishRPMRepo + "/" + constants.currentArch) |
|
| 297 |
+ if not os.path.isdir(constants.prevPublishRPMRepo + "/noarch"): |
|
| 298 |
+ os.makedirs(constants.prevPublishRPMRepo + "/noarch") |
|
| 299 |
+ if subprocess.Popen(["cd " + Build_Config.pullPublishRPMSDir + " && " + \ |
|
| 300 |
+ Build_Config.pullPublishRPMS + " " + constants.prevPublishRPMRepo + " " + \ |
|
| 301 |
+ configdict["additional-path"]["photon-publish-rpms-path"]], shell=True).wait() != 0: |
|
| 302 |
+ raise Exception("Cannot run publish-rpms-cached")
|
|
| 303 |
+ |
|
| 304 |
+ def publish_x_rpms_cached(): |
|
| 305 |
+ check_prerequesite["publish-x-rpms-cached"]=True |
|
| 306 |
+ if not os.path.isdir(constants.prevPublishXRPMRepo + "/" + constants.currentArch): |
|
| 307 |
+ os.makedirs(constants.prevPublishXRPMRepo + "/" + constants.currentArch) |
|
| 308 |
+ if not os.path.isdir(constants.prevPublishRPMRepo + "/noarch"): |
|
| 309 |
+ os.makedirs(constants.prevPublishXRPMRepo + "/noarch") |
|
| 310 |
+ if subprocess.Popen(["cd " + Build_Config.pullPublishRPMSDir + " && " + Build_Config.pullPublishXRPMS \ |
|
| 311 |
+ + " " + constants.prevPublishXRPMRepo + " " + \ |
|
| 312 |
+ configdict["additional-path"]["photon-publish-x-rpms-path"]], shell=True).wait() != 0: |
|
| 313 |
+ raise Exception("Cannot run publish-x-rpms-cached")
|
|
| 314 |
+ |
|
| 315 |
+ |
|
| 316 |
+ def publish_x_rpms(): |
|
| 317 |
+ if configdict['additional-path']['photon-publish-x-rpms-path'] is None: |
|
| 318 |
+ check_prerequesite["publish-x-rpms"]=True |
|
| 319 |
+ print("\nPulling X toolchain RPMS...")
|
|
| 320 |
+ if subprocess.Popen(["cd " + Build_Config.pullPublishRPMSDir + " && " + Build_Config.pullPublishXRPMS \ |
|
| 321 |
+ + " " + constants.prevPublishXRPMRepo], shell=True).wait() != 0: |
|
| 322 |
+ raise Exception("Cannot run publishx-rpms")
|
|
| 323 |
+ else: |
|
| 324 |
+ BuildEnvironmentSetup.publish_x_rpms_cached() |
|
| 325 |
+ |
|
| 326 |
+ def photon_stage(): |
|
| 327 |
+ check_prerequesite["photon-stage"]=True |
|
| 328 |
+ print("\nCreating staging folder and subitems...")
|
|
| 329 |
+ |
|
| 330 |
+ if not os.path.isdir(Build_Config.stagePath): |
|
| 331 |
+ os.mkdir(Build_Config.stagePath) |
|
| 332 |
+ |
|
| 333 |
+ if not os.path.isdir(constants.buildRootPath): |
|
| 334 |
+ os.mkdir(constants.buildRootPath) |
|
| 335 |
+ |
|
| 336 |
+ if not os.path.isdir(constants.rpmPath): |
|
| 337 |
+ os.mkdir(constants.rpmPath) |
|
| 338 |
+ if not os.path.isdir(Build_Config.rpmArchPath): |
|
| 339 |
+ os.mkdir(Build_Config.rpmArchPath) |
|
| 340 |
+ if not os.path.isdir(Build_Config.rpmNoArchPath): |
|
| 341 |
+ os.mkdir(Build_Config.rpmNoArchPath) |
|
| 342 |
+ |
|
| 343 |
+ if not os.path.isdir(constants.sourceRpmPath): |
|
| 344 |
+ os.mkdir(constants.sourceRpmPath) |
|
| 345 |
+ |
|
| 346 |
+ if not os.path.isdir(Build_Config.updatedRpmPath): |
|
| 347 |
+ os.mkdir(Build_Config.updatedRpmPath) |
|
| 348 |
+ if not os.path.isdir(Build_Config.updatedRpmNoArchPath): |
|
| 349 |
+ os.mkdir(Build_Config.updatedRpmNoArchPath) |
|
| 350 |
+ if not os.path.isdir(Build_Config.updatedRpmArchPath): |
|
| 351 |
+ os.mkdir(Build_Config.updatedRpmArchPath) |
|
| 352 |
+ |
|
| 353 |
+ if not os.path.isdir(constants.sourcePath): |
|
| 354 |
+ os.mkdir(constants.sourcePath) |
|
| 355 |
+ |
|
| 356 |
+ if not os.path.isdir(constants.logPath): |
|
| 357 |
+ os.mkdir(constants.logPath) |
|
| 358 |
+ |
|
| 359 |
+ if not os.path.isfile(Build_Config.stagePath + "/COPYING"): |
|
| 360 |
+ CommandUtils.runCommandInShell("install -m 444 " + curDir + "/COPYING " + Build_Config.stagePath + "/COPYING")
|
|
| 361 |
+ |
|
| 362 |
+ if not os.path.isfile(Build_Config.stagePath + "/NOTICE-GPL2.0"): |
|
| 363 |
+ CommandUtils.runCommandInShell("install -m 444 " + curDir + "/NOTICE-GPL2.0 " + Build_Config.stagePath + "/NOTICE-GPL2.0")
|
|
| 364 |
+ |
|
| 365 |
+ if not os.path.isfile(Build_Config.stagePath + "/NOTICE-Apachev2"): |
|
| 366 |
+ CommandUtils.runCommandInShell("install -m 444 " + curDir + "/NOTICE-Apachev2 " + Build_Config.stagePath + "/NOTICE-Apachev2")
|
|
| 367 |
+ |
|
| 368 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 369 |
+# class Cleanup does the job of cleaning up the stage directory... + |
|
| 370 |
+# + |
|
| 371 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 372 |
+class CleanUp: |
|
| 373 |
+ |
|
| 374 |
+ def clean(): |
|
| 375 |
+ CleanUp.clean_install() |
|
| 376 |
+ CleanUp.clean_chroot() |
|
| 377 |
+ print("Deleting Photon ISO...")
|
|
| 378 |
+ CommandUtils.runCommandInShell("rm -f " + Build_Config.stagePath + "/photon-*.iso")
|
|
| 379 |
+ print("Deleting stage dir...")
|
|
| 380 |
+ CommandUtils.runCommandInShell("rm -rf " + Build_Config.stagePath)
|
|
| 381 |
+ print("Deleting chroot path...")
|
|
| 382 |
+ CommandUtils.runCommandInShell("rm -rf " + constants.buildRootPath)
|
|
| 383 |
+ print("Deleting tools/bin...")
|
|
| 384 |
+ CommandUtils.runCommandInShell("rm -rf tools/bin")
|
|
| 385 |
+ |
|
| 386 |
+ def clean_install(): |
|
| 387 |
+ print("Cleaning installer working directory...")
|
|
| 388 |
+ if os.path.isdir(os.path.join(Build_Config.stagePath, "photon_iso")): |
|
| 389 |
+ if subprocess.Popen(["support/package-builder/clean-up-chroot.py", os.path.join(Build_Config.stagePath, "photon_iso")]).wait() != 0: |
|
| 390 |
+ raise Exception("Not able to clean chroot")
|
|
| 391 |
+ |
|
| 392 |
+ def clean_chroot(): |
|
| 393 |
+ print("Cleaning chroot path...")
|
|
| 394 |
+ if os.path.isdir(constants.buildRootPath): |
|
| 395 |
+ if subprocess.Popen([curDir + "/support/package-builder/clean-up-chroot.py", constants.buildRootPath]).wait() != 0: |
|
| 396 |
+ raise Exception("Not able to clean chroot")
|
|
| 397 |
+ |
|
| 398 |
+ def clean_stage_for_incremental_build(): |
|
| 399 |
+ command = ["cd "+ configdict["photon-path"]+ ";test -z \"$$(git diff --name-only "\ |
|
| 400 |
+ + configdict["photon-build-param"].get("base-commit", "") + " @ | grep SPECS)\" || "\
|
|
| 401 |
+ + curDir + "/support/package-builder/SpecDeps.py --spec-path SPECS/ -i remove-upward-deps -p \"$$(echo `git diff --name-only "\ |
|
| 402 |
+ + configdict["photon-build-param"].get("base-commit", "")+" @ | grep .spec | xargs -n1 basename 2>/dev/null` | tr ' ' :)\""]
|
|
| 403 |
+ subprocess.Popen(command, shell=True).wait() |
|
| 404 |
+ |
|
| 405 |
+ command = ["test -n \"$$(git diff --name-only @~1 @ | grep '^support/\(make\|package-builder\|pullpublishrpms\)')\" && " \ |
|
| 406 |
+ + "{ cd " + configdict["photon-path"] + "; echo 'Remove all staged RPMs'; /bin/rm -rf ./stage/RPMS; } ||:"]
|
|
| 407 |
+ if subprocess.Popen(command, shell=True).wait() != 0: |
|
| 408 |
+ raise Exception("Not able to run clean_stage_for_incremental_build")
|
|
| 409 |
+ return |
|
| 410 |
+ |
|
| 411 |
+ |
|
| 412 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 413 |
+# class Rpmbuildtarget does the job of building all the RPMs for the SPECS + |
|
| 414 |
+# It uses Builder class in builder.py in order to build packages. + |
|
| 415 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 416 |
+ |
|
| 417 |
+class RpmBuildTarget: |
|
| 418 |
+ |
|
| 419 |
+ global configdict |
|
| 420 |
+ global check_prerequesite |
|
| 421 |
+ |
|
| 422 |
+ def __init__(self): |
|
| 423 |
+ from SpecData import SPECS |
|
| 424 |
+ |
|
| 425 |
+ self.logger = Logger.getLogger("Main", constants.logPath, constants.logLevel)
|
|
| 426 |
+ |
|
| 427 |
+ if not check_prerequesite["check-docker-py"]: |
|
| 428 |
+ CheckTools.check_docker_py() |
|
| 429 |
+ |
|
| 430 |
+ if not check_prerequesite["check-tools"]: |
|
| 431 |
+ CheckTools.check_tools() |
|
| 432 |
+ |
|
| 433 |
+ if not check_prerequesite["photon-stage"]: |
|
| 434 |
+ BuildEnvironmentSetup.photon_stage() |
|
| 435 |
+ |
|
| 436 |
+ if configdict["additional-path"]["photon-publish-x-rpms-path"] is not None and not check_prerequesite["publish-x-rpms-cached"]: |
|
| 437 |
+ BuildEnvironmentSetup.publish_x_rpms_cached() |
|
| 438 |
+ else: |
|
| 439 |
+ if not check_prerequesite["publish-x-rpms"]: |
|
| 440 |
+ BuildEnvironmentSetup.publish_x_rpms() |
|
| 441 |
+ |
|
| 442 |
+ if configdict["additional-path"]["photon-publish-rpms-path"] is not None and not check_prerequesite["publish-rpms-cached"]: |
|
| 443 |
+ BuildEnvironmentSetup.publish_rpms_cached() |
|
| 444 |
+ else: |
|
| 445 |
+ if not check_prerequesite["publish-rpms"]: |
|
| 446 |
+ BuildEnvironmentSetup.publish_rpms() |
|
| 447 |
+ |
|
| 448 |
+ if configdict["additional-path"]["photon-sources-path"] is not None and not check_prerequesite["sources-cached"]: |
|
| 449 |
+ BuildEnvironmentSetup.sources_cached() |
|
| 450 |
+ else: |
|
| 451 |
+ if not check_prerequesite["sources"]: |
|
| 452 |
+ BuildEnvironmentSetup.sources() |
|
| 453 |
+ |
|
| 454 |
+ if not check_prerequesite["contain"]: |
|
| 455 |
+ contain() |
|
| 456 |
+ |
|
| 457 |
+ if not check_prerequesite["check-spec-files"]: |
|
| 458 |
+ CheckTools.check_spec_files() |
|
| 459 |
+ |
|
| 460 |
+ a = Utilities() |
|
| 461 |
+ a.generate_dep_lists() |
|
| 462 |
+ |
|
| 463 |
+ if constants.buildArch != constants.targetArch: |
|
| 464 |
+ CommandUtils.runCommandInShell("mkdir -p " + constants.rpmPath + "/" + constants.targetArch)
|
|
| 465 |
+ |
|
| 466 |
+ self.logger.debug("Source Path :" + constants.sourcePath)
|
|
| 467 |
+ self.logger.debug("Spec Path :" + constants.specPath)
|
|
| 468 |
+ self.logger.debug("Rpm Path :" + constants.rpmPath)
|
|
| 469 |
+ self.logger.debug("Log Path :" + constants.logPath)
|
|
| 470 |
+ self.logger.debug("Log Level :" + constants.logLevel)
|
|
| 471 |
+ self.logger.debug("Top Dir Path :" + constants.topDirPath)
|
|
| 472 |
+ self.logger.debug("Publish RPMS Path :" + constants.prevPublishRPMRepo)
|
|
| 473 |
+ self.logger.debug("Publish X RPMS Path :" + constants.prevPublishXRPMRepo)
|
|
| 474 |
+ |
|
| 475 |
+ Builder.get_packages_with_build_options(configdict['photon-build-param']['pkg-build-options']) |
|
| 476 |
+ |
|
| 477 |
+ os.chdir(str(PurePath(curDir, "support", "package-builder"))) |
|
| 478 |
+ if not check_prerequesite["generate-dep-lists"]: |
|
| 479 |
+ SPECS() |
|
| 480 |
+ if constants.buildArch != constants.targetArch: |
|
| 481 |
+ # It is cross compilation |
|
| 482 |
+ # first build all native packages |
|
| 483 |
+ Builder.buildPackagesForAllSpecs(Build_Config.buildThreads, Build_Config.pkgBuildType, Build_Config.pkgInfoFile, self.logger) |
|
| 484 |
+ |
|
| 485 |
+ # Then do the build to the target |
|
| 486 |
+ constants.currentArch = constants.targetArch |
|
| 487 |
+ constants.crossCompiling = True |
|
| 488 |
+ |
|
| 489 |
+ |
|
| 490 |
+ @staticmethod |
|
| 491 |
+ def create_repo(): |
|
| 492 |
+ check_prerequesite["create-repo"]=True |
|
| 493 |
+ if subprocess.Popen(["createrepo " + constants.rpmPath], shell=True).wait() != 0: |
|
| 494 |
+ raise Exception("Not able to create repodata")
|
|
| 495 |
+ |
|
| 496 |
+ @staticmethod |
|
| 497 |
+ def ostree_repo(): |
|
| 498 |
+ check_prerequesite["ostree-repo"]=True |
|
| 499 |
+ if not check_prerequesite["start-docker"]: |
|
| 500 |
+ CheckTools.start_docker() |
|
| 501 |
+ if not os.path.isfile(os.path.join(Build_Config.stagePath, "ostree-repo.tar.gz")): |
|
| 502 |
+ process = subprocess.Popen([curDir + "/support/image-builder/ostree-tools/make-ostree-image.sh", curDir, Build_Config.stagePath]) |
|
| 503 |
+ |
|
| 504 |
+ retval = process.wait() |
|
| 505 |
+ if retval != 0: |
|
| 506 |
+ print("Not able to execute make-ostree-image.sh")
|
|
| 507 |
+ else: |
|
| 508 |
+ print("Creating OSTree repo from local RPMs in ostree-repo.tar.gz...")
|
|
| 509 |
+ |
|
| 510 |
+ def packages(self): |
|
| 511 |
+ check_prerequesite["packages"]=True |
|
| 512 |
+ if configdict['additional-path']['photon-cache-path'] is None: |
|
| 513 |
+ Builder.buildPackagesForAllSpecs(Build_Config.buildThreads, |
|
| 514 |
+ Build_Config.pkgBuildType, |
|
| 515 |
+ Build_Config.pkgInfoFile, |
|
| 516 |
+ self.logger) |
|
| 517 |
+ RpmBuildTarget.create_repo() |
|
| 518 |
+ else: |
|
| 519 |
+ BuildEnvironmentSetup.packages_cached() |
|
| 520 |
+ os.chdir(curDir) |
|
| 521 |
+ |
|
| 522 |
+ def package(self, pkgName): |
|
| 523 |
+ check_prerequesite["package"] = True |
|
| 524 |
+ self.logger.debug("Package to build:" + pkgName)
|
|
| 525 |
+ Builder.buildSpecifiedPackages([pkgName], Build_Config.buildThreads, Build_Config.pkgBuildType) |
|
| 526 |
+ os.chdir(curDir) |
|
| 527 |
+ |
|
| 528 |
+ def packages_minimal(self): |
|
| 529 |
+ check_prerequesite["packages-minimal"] = True |
|
| 530 |
+ if configdict['additional-path']['photon-cache-path'] is None: |
|
| 531 |
+ Builder.buildPackagesInJson(os.path.join(Build_Config.dataDir, "packages_minimal.json"), \ |
|
| 532 |
+ Build_Config.buildThreads, Build_Config.pkgBuildType, Build_Config.pkgInfoFile, self.logger) |
|
| 533 |
+ else: |
|
| 534 |
+ BuildEnvironmentSetup.packages_cached() |
|
| 535 |
+ os.chdir(curDir) |
|
| 536 |
+ |
|
| 537 |
+ def packages_rt(self): |
|
| 538 |
+ check_prerequesite["packages-rt"] = True |
|
| 539 |
+ if configdict['additional-path']['photon-cache-path'] is None: |
|
| 540 |
+ Builder.buildPackagesInJson(os.path.join(Build_Config.dataDir, "packages_rt.json"), \ |
|
| 541 |
+ Build_Config.buildThreads, Build_Config.pkgBuildType, Build_Config.pkgInfoFile, self.logger) |
|
| 542 |
+ else: |
|
| 543 |
+ BuildEnvironmentSetup.packages_cached() |
|
| 544 |
+ os.chdir(curDir) |
|
| 545 |
+ |
|
| 546 |
+ def packages_initrd(self): |
|
| 547 |
+ check_prerequesite["packages-initrd"] = True |
|
| 548 |
+ Builder.buildPackagesInJson(os.path.join(Build_Config.dataDir, "packages_installer_initrd.json"), \ |
|
| 549 |
+ Build_Config.buildThreads, Build_Config.pkgBuildType, Build_Config.pkgInfoFile, self.logger) |
|
| 550 |
+ os.chdir(curDir) |
|
| 551 |
+ |
|
| 552 |
+ def packages_docker(self): |
|
| 553 |
+ check_prerequesite["packages-docker"] = True |
|
| 554 |
+ Builder.buildPackagesForAllSpecs(Build_Config.buildThreads, Build_Config.pkgBuildType, Build_Config.pkgInfoFile, self.logger) |
|
| 555 |
+ os.chdir(curDir) |
|
| 556 |
+ |
|
| 557 |
+ def updated_packages(self): |
|
| 558 |
+ check_prerequesite["updated-packages"] = True |
|
| 559 |
+ constants.setRpmPath(Build_Config.updatedRpmPath) |
|
| 560 |
+ Builder.buildPackagesForAllSpecs(Build_Config.buildThreads, Build_Config.pkgBuildType, Build_Config.pkgInfoFile, self.logger) |
|
| 561 |
+ os.chdir(curDir) |
|
| 562 |
+ |
|
| 563 |
+ def check(self): |
|
| 564 |
+ check_prerequesite["check"] = True |
|
| 565 |
+ constants.setRPMCheck(True) |
|
| 566 |
+ constants.setRpmCheckStopOnError(True) |
|
| 567 |
+ Builder.buildPackagesForAllSpecs(Build_Config.buildThreads, Build_Config.pkgBuildType, Build_Config.pkgInfoFile, self.logger) |
|
| 568 |
+ os.chdir(curDir) |
|
| 569 |
+ |
|
| 570 |
+ def distributed_build(): |
|
| 571 |
+ from DistributedBuilder import DistributedBuilder |
|
| 572 |
+ print("Building RPMS through kubernetes ...")
|
|
| 573 |
+ os.chdir(str(PurePath(curDir, "support", "package-builder"))) |
|
| 574 |
+ with open(Build_Config.distributedBuildFile, 'r') as configFile: |
|
| 575 |
+ distributedBuildConfig = json.load(configFile) |
|
| 576 |
+ |
|
| 577 |
+ distributedBuilder = DistributedBuilder(distributedBuildConfig) |
|
| 578 |
+ distributedBuilder.create() |
|
| 579 |
+ distributedBuilder.getLogs() |
|
| 580 |
+ distributedBuilder.monitorJob() |
|
| 581 |
+ distributedBuilder.copyFromNfs() |
|
| 582 |
+ distributedBuilder.deleteBuild() |
|
| 583 |
+ distributedBuilder.clean() |
|
| 584 |
+ |
|
| 585 |
+ os.chdir(curDir) |
|
| 586 |
+ |
|
| 587 |
+ def tool_chain_stage1(self): |
|
| 588 |
+ from PackageManager import PackageManager |
|
| 589 |
+ check_prerequesite["tool-chain-stage1"] = True |
|
| 590 |
+ pkgManager = PackageManager() |
|
| 591 |
+ pkgManager.buildToolChain() |
|
| 592 |
+ |
|
| 593 |
+ def tool_chain_stage2(self): |
|
| 594 |
+ from PackageManager import PackageManager |
|
| 595 |
+ check_prerequesite["tool-chain-stage2"] = True |
|
| 596 |
+ pkgManager = PackageManager() |
|
| 597 |
+ pkgManager.buildToolChainPackages(Build_Config.buildThreads) |
|
| 598 |
+ |
|
| 599 |
+ def generate_yaml_files(self): |
|
| 600 |
+ |
|
| 601 |
+ import GenerateOSSFiles |
|
| 602 |
+ |
|
| 603 |
+ print("Generating yaml files for packages...")
|
|
| 604 |
+ check_prerequesite["generate-yaml-files"] = True |
|
| 605 |
+ if not check_prerequesite["check-tools"]: |
|
| 606 |
+ CheckTools.check_tools() |
|
| 607 |
+ if not check_prerequesite["photon-stage"]: |
|
| 608 |
+ BuildEnvironmentSetup.photon_stage() |
|
| 609 |
+ if not check_prerequesite["packages"]: |
|
| 610 |
+ rpmBuildTarget = RpmBuildTarget() |
|
| 611 |
+ rpmBuildTarget.packages() |
|
| 612 |
+ os.chdir(curDir + "/support/package-builder") |
|
| 613 |
+ if "generate-pkg-list" in configdict["photon-build-param"] and configdict["photon-build-param"]["generate-pkg-list"]: |
|
| 614 |
+ GenerateOSSFiles.buildPackagesList(os.path.join(Build_Config.stagePath, "packages_list.csv")) |
|
| 615 |
+ else: |
|
| 616 |
+ blackListPkgs = GenerateOSSFiles.readBlackListPackages(configdict.get("additional-path", {}).get("pkg-black-list-file", ""))
|
|
| 617 |
+ logger = Logger.getLogger("GenerateYamlFiles", constants.logPath, constants.logLevel)
|
|
| 618 |
+ GenerateOSSFiles.buildSourcesList(Build_Config.stagePath, blackListPkgs, logger) |
|
| 619 |
+ GenerateOSSFiles.buildSRPMList(constants.sourceRpmPath, Build_Config.stagePath, blackListPkgs, constants.dist, logger) |
|
| 620 |
+ os.chdir(curDir) |
|
| 621 |
+ |
|
| 622 |
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 623 |
+# class CheckTools does the job of checking weather all the tools required for starting build process are present on the system + |
|
| 624 |
+# + |
|
| 625 |
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 626 |
+ |
|
| 627 |
+class CheckTools: |
|
| 628 |
+ |
|
| 629 |
+ global configdict |
|
| 630 |
+ global check_prerequesite |
|
| 631 |
+ |
|
| 632 |
+ def check_tools(): |
|
| 633 |
+ check_prerequesite["check-tools"] = True |
|
| 634 |
+ CheckTools.check_bison() |
|
| 635 |
+ CheckTools.check_gplusplus() |
|
| 636 |
+ CheckTools.check_gawk() |
|
| 637 |
+ CheckTools.check_repo_tool() |
|
| 638 |
+ CheckTools.check_texinfo() |
|
| 639 |
+ CheckTools.check_sanity() |
|
| 640 |
+ CheckTools.check_docker() |
|
| 641 |
+ CheckTools.check_pyopenssl() |
|
| 642 |
+ |
|
| 643 |
+ def check_bison(): |
|
| 644 |
+ check_prerequesite["check-bison"]=True |
|
| 645 |
+ if shutil.which("bison") is None:
|
|
| 646 |
+ raise Exception("bison not present")
|
|
| 647 |
+ |
|
| 648 |
+ def check_gplusplus(): |
|
| 649 |
+ check_prerequesite["check-gplusplus"]=True |
|
| 650 |
+ if shutil.which('g++') is None:
|
|
| 651 |
+ raise Exception("g++ not present")
|
|
| 652 |
+ |
|
| 653 |
+ def check_gawk(): |
|
| 654 |
+ check_prerequesite["check-gawk"]=True |
|
| 655 |
+ if shutil.which('gawk') is None:
|
|
| 656 |
+ raise Exception("gawk not present")
|
|
| 657 |
+ |
|
| 658 |
+ def check_repo_tool(): |
|
| 659 |
+ check_prerequesite["check-repotool"]=True |
|
| 660 |
+ if shutil.which('createrepo') is None:
|
|
| 661 |
+ raise Exception("createrepo not present")
|
|
| 662 |
+ |
|
| 663 |
+ def check_texinfo(): |
|
| 664 |
+ check_prerequesite["check-texinfo"]=True |
|
| 665 |
+ if shutil.which('makeinfo') is None:
|
|
| 666 |
+ raise Exception("texinfo not present")
|
|
| 667 |
+ |
|
| 668 |
+ def check_sanity(): |
|
| 669 |
+ check_prerequesite["check-sanity"]=True |
|
| 670 |
+ if subprocess.Popen([curDir + "/support/sanity_check.sh"], shell=True).wait() != 0: |
|
| 671 |
+ raise Exception("Not able to run script sanity_check.sh")
|
|
| 672 |
+ |
|
| 673 |
+ def check_docker(): |
|
| 674 |
+ check_prerequesite["check-docker"]=True |
|
| 675 |
+ if not glob.glob(Build_Config.dockerEnv) and shutil.which('docker') is None:
|
|
| 676 |
+ raise Exception("docker not present")
|
|
| 677 |
+ |
|
| 678 |
+ def check_docker_service(): |
|
| 679 |
+ check_prerequesite["check-docker-service"]=True |
|
| 680 |
+ if not glob.glob(Build_Config.dockerEnv) and subprocess.Popen(["docker ps >/dev/null 2>&1"], shell=True).wait() != 0: |
|
| 681 |
+ raise Exception("Docker service is not running. Aborting.")
|
|
| 682 |
+ |
|
| 683 |
+ def check_docker_py(): |
|
| 684 |
+ check_prerequesite["check-docker-py"]=True |
|
| 685 |
+ if not glob.glob(Build_Config.dockerEnv) and docker.__version__ < "2.3.0": |
|
| 686 |
+ raise Exception("Error: Python3 package docker-py3 2.3.0 not installed.\nPlease use: pip3 install docker==2.3.0")
|
|
| 687 |
+ |
|
| 688 |
+ def check_pyopenssl(): |
|
| 689 |
+ check_prerequesite["check-pyopenssl"]=True |
|
| 690 |
+ try: |
|
| 691 |
+ import OpenSSL |
|
| 692 |
+ except Exception as e: |
|
| 693 |
+ raise Exception(e) |
|
| 694 |
+ |
|
| 695 |
+ def check_spec_files(): |
|
| 696 |
+ check_prerequesite["check-spec-files"]=True |
|
| 697 |
+ print() |
|
| 698 |
+ if "base-commit" in configdict["photon-build-param"]: |
|
| 699 |
+ command = ["./tools/scripts/check_spec_files.sh", str(configdict["photon-build-param"].get("base-commit"))]
|
|
| 700 |
+ else: |
|
| 701 |
+ command = ["./tools/scripts/check_spec_files.sh"] |
|
| 702 |
+ if subprocess.Popen(command, shell=True).wait() != 0: |
|
| 703 |
+ raise Exception("spec file check failed")
|
|
| 704 |
+ |
|
| 705 |
+ def check_kpartx(): |
|
| 706 |
+ check_prerequesite["check-kpartx"]=True |
|
| 707 |
+ if shutil.which('kpartx') is None:
|
|
| 708 |
+ raise Exception("Package kpartx not installed. Aborting.")
|
|
| 709 |
+ |
|
| 710 |
+ def start_docker(): |
|
| 711 |
+ check_prerequesite["start-docker"]=True |
|
| 712 |
+ CheckTools.check_docker() |
|
| 713 |
+ if subprocess.Popen(["systemctl start docker"], shell=True).wait() != 0: |
|
| 714 |
+ raise Exception("Not able to start docker")
|
|
| 715 |
+ |
|
| 716 |
+ def install_photon_docker_image(): |
|
| 717 |
+ if not check_prerequesite["photon-docker-image"]: |
|
| 718 |
+ BuildImage.photon_docker_image() |
|
| 719 |
+ if subprocess.Popen("sudo docker build -t photon:tdnf .").wait() != 0:
|
|
| 720 |
+ raise Exception("Not able to install photon docker image")
|
|
| 721 |
+ |
|
| 722 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 723 |
+# class BuildImage does the job of building all the images like iso, rpi3, ami, gce, azure, ova... + |
|
| 724 |
+# It uses class ImageBuilder to build different images. + |
|
| 725 |
+# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 726 |
+ |
|
| 727 |
+class BuildImage: |
|
| 728 |
+ |
|
| 729 |
+ global configdict |
|
| 730 |
+ global check_prerequesite |
|
| 731 |
+ |
|
| 732 |
+ def __init__(self, imgName): |
|
| 733 |
+ self.src_root = configdict["photon-path"] |
|
| 734 |
+ self.installer_path = Build_Config.installerPath |
|
| 735 |
+ self.generated_data_path = Build_Config.dataDir |
|
| 736 |
+ self.stage_path = Build_Config.stagePath |
|
| 737 |
+ self.log_path = constants.logPath |
|
| 738 |
+ self.log_level = constants.logLevel |
|
| 739 |
+ self.config_file = configdict["additional-path"]["conf-file"] |
|
| 740 |
+ self.img_name = imgName |
|
| 741 |
+ self.rpm_path = constants.rpmPath |
|
| 742 |
+ self.srpm_path = constants.sourceRpmPath |
|
| 743 |
+ self.pkg_to_rpm_map_file = os.path.join(Build_Config.stagePath, "pkg_info.json") |
|
| 744 |
+ |
|
| 745 |
+ def set_Iso_Parameters(self, imgName): |
|
| 746 |
+ self.generated_data_path = Build_Config.stagePath + "/common/data" |
|
| 747 |
+ self.src_iso_path = None |
|
| 748 |
+ if imgName == "iso": |
|
| 749 |
+ self.iso_path = os.path.join(Build_Config.stagePath, "photon-"+constants.releaseVersion+"-"+constants.buildNumber+".iso") |
|
| 750 |
+ self.debug_iso_path = self.iso_path.rpartition(".")[0]+".debug.iso"
|
|
| 751 |
+ |
|
| 752 |
+ if imgName == "minimal-iso": |
|
| 753 |
+ self.iso_path = os.path.join(Build_Config.stagePath, "photon-minimal-"+constants.releaseVersion+"-"+constants.buildNumber+".iso") |
|
| 754 |
+ self.debug_iso_path = self.iso_path.rpartition(".")[0]+".debug.iso"
|
|
| 755 |
+ self.package_list_file = os.path.join(Build_Config.dataDir, "build_install_options_minimal.json") |
|
| 756 |
+ self.pkg_to_be_copied_conf_file = os.path.join(Build_Config.generatedDataPath, "build_install_options_minimal.json") |
|
| 757 |
+ elif imgName == "rt-iso": |
|
| 758 |
+ self.iso_path = os.path.join(Build_Config.stagePath, "photon-rt-"+constants.releaseVersion+"-"+constants.buildNumber+".iso") |
|
| 759 |
+ self.debug_iso_path = self.iso_path.rpartition(".")[0]+".debug.iso"
|
|
| 760 |
+ self.package_list_file = os.path.join(Build_Config.dataDir, "build_install_options_rt.json") |
|
| 761 |
+ self.pkg_to_be_copied_conf_file = os.path.join(Build_Config.generatedDataPath, "build_install_options_rt.json") |
|
| 762 |
+ |
|
| 763 |
+ else: |
|
| 764 |
+ self.pkg_to_be_copied_conf_file = Build_Config.pkgToBeCopiedConfFile |
|
| 765 |
+ self.package_list_file = Build_Config.packageListFile |
|
| 766 |
+ |
|
| 767 |
+ if imgName == "src-iso": |
|
| 768 |
+ self.iso_path = None |
|
| 769 |
+ self.debug_iso_path = None |
|
| 770 |
+ self.src_iso_path = os.path.join(Build_Config.stagePath, "photon-"+constants.releaseVersion+"-"+constants.buildNumber+".src.iso") |
|
| 771 |
+ |
|
| 772 |
+ |
|
| 773 |
+ def build_iso(self): |
|
| 774 |
+ |
|
| 775 |
+ import imagebuilder |
|
| 776 |
+ |
|
| 777 |
+ rpmBuildTarget = RpmBuildTarget() |
|
| 778 |
+ if not check_prerequesite["check-tools"]: |
|
| 779 |
+ CheckTools.check_tools() |
|
| 780 |
+ if not check_prerequesite["photon-stage"]: |
|
| 781 |
+ BuildEnvironmentSetup.photon_stage() |
|
| 782 |
+ if self.img_name == "iso" and not check_prerequesite["packages"]: |
|
| 783 |
+ rpmBuildTarget.packages() |
|
| 784 |
+ elif self.img_name == "rt-iso": |
|
| 785 |
+ rpmBuildTarget.packages_rt() |
|
| 786 |
+ else: |
|
| 787 |
+ rpmBuildTarget.packages_minimal() |
|
| 788 |
+ if self.img_name == "rt-iso" or "minimal-iso" and not check_prerequesite["packages-initrd"]: |
|
| 789 |
+ rpmBuildTarget.packages_initrd() |
|
| 790 |
+ if not check_prerequesite["create-repo"]: |
|
| 791 |
+ RpmBuildTarget.create_repo() |
|
| 792 |
+ if self.img_name != "minimal-iso" and not check_prerequesite["ostree-repo"]: |
|
| 793 |
+ RpmBuildTarget.ostree_repo() |
|
| 794 |
+ self.generated_data_path = Build_Config.generatedDataPath |
|
| 795 |
+ print("Building Full ISO...")
|
|
| 796 |
+ os.chdir(str(PurePath(curDir, "support", "image-builder"))) |
|
| 797 |
+ imagebuilder.createIso(self) |
|
| 798 |
+ os.chdir(curDir) |
|
| 799 |
+ |
|
| 800 |
+ def build_image(self): |
|
| 801 |
+ |
|
| 802 |
+ import imagebuilder |
|
| 803 |
+ |
|
| 804 |
+ if not check_prerequesite["check-kpartx"]: |
|
| 805 |
+ CheckTools.check_kpartx() |
|
| 806 |
+ if not check_prerequesite["photon-stage"]: |
|
| 807 |
+ BuildEnvironmentSetup.photon_stage() |
|
| 808 |
+ if not check_prerequesite["vixdiskutil"]: |
|
| 809 |
+ vixdiskutil() |
|
| 810 |
+ rpmBuildTarget = None |
|
| 811 |
+ if not check_prerequesite["packages"]: |
|
| 812 |
+ rpmBuildTarget = RpmBuildTarget() |
|
| 813 |
+ rpmBuildTarget.packages() |
|
| 814 |
+ if not check_prerequesite["ostree-repo"]: |
|
| 815 |
+ RpmBuildTarget.ostree_repo() |
|
| 816 |
+ print("Building image " + self.img_name)
|
|
| 817 |
+ os.chdir(str(PurePath(curDir, "support", "image-builder"))) |
|
| 818 |
+ imagebuilder.createImage(self) |
|
| 819 |
+ os.chdir(curDir) |
|
| 820 |
+ |
|
| 821 |
+ @staticmethod |
|
| 822 |
+ def photon_docker_image(): |
|
| 823 |
+ if not check_prerequesite["create-repo"]: |
|
| 824 |
+ RpmBuildTarget.create_repo() |
|
| 825 |
+ if subprocess.Popen(["cd " + configdict["photon-path"] + ";sudo docker build --no-cache --tag photon-build " + curDir + "/support/dockerfiles/photon && sudo docker run --rm --privileged --net=host -e PHOTON_BUILD_NUMBER="+constants.buildNumber + " -e PHOTON_RELEASE_VERSION="+constants.releaseVersion + " -v "+curDir+":/workspace -v "+Build_Config.stagePath+":/workspace/stage photon-build ./support/dockerfiles/photon/make-docker-image.sh tdnf"], shell=True).wait() != 0: |
|
| 826 |
+ raise Exception("Not able to run photon-docker-image")
|
|
| 827 |
+ |
|
| 828 |
+ def k8s_docker_images(self): |
|
| 829 |
+ if not check_prerequesite["start-docker"]: |
|
| 830 |
+ CheckTools.start_docker() |
|
| 831 |
+ if not check_prerequesite["photon-docker-image"]: |
|
| 832 |
+ BuildImage.photon_docker_image() |
|
| 833 |
+ if not os.path.isdir(os.path.join(Build_Config.stagePath, "docker_images")): |
|
| 834 |
+ os.mkdir(os.path.join(Build_Config.stagePath, "docker_images")) |
|
| 835 |
+ os.chdir(os.path.join(curDir, 'support/dockerfiles/k8s-docker-images')) |
|
| 836 |
+ if subprocess.Popen(['./build-k8s-base-image.sh', constants.releaseVersion, constants.buildNumber, Build_Config.stagePath]).wait() == 0 and \ |
|
| 837 |
+ subprocess.Popen(['./build-k8s-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 838 |
+ subprocess.Popen(['./build-k8s-metrics-server-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() ==0 and \ |
|
| 839 |
+ subprocess.Popen(['./build-k8s-coredns-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 840 |
+ subprocess.Popen(['./build-k8s-dns-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 841 |
+ subprocess.Popen(['./build-k8s-dashboard-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 842 |
+ subprocess.Popen(['./build-flannel-docker-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 843 |
+ subprocess.Popen(['./build-calico-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 844 |
+ subprocess.Popen(['./build-k8s-heapster-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 845 |
+ subprocess.Popen(['./build-k8s-nginx-ingress.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 846 |
+ subprocess.Popen(['./build-wavefront-proxy-docker-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0: |
|
| 847 |
+ print("Successfully built all the docker images")
|
|
| 848 |
+ |
|
| 849 |
+ else: |
|
| 850 |
+ raise Exception("k8s-docker-images build failed")
|
|
| 851 |
+ os.chdir(curDir) |
|
| 852 |
+ |
|
| 853 |
+ def all_images(self): |
|
| 854 |
+ images = ["ami", "gce", "azure", "ova_uefi", "ova" ] |
|
| 855 |
+ for img in images: |
|
| 856 |
+ self.img_name = img |
|
| 857 |
+ self.build_image() |
|
| 858 |
+ |
|
| 859 |
+ def all(self): |
|
| 860 |
+ images = ["iso", "photon-docker-image", "k8s-docker-images", "all-images", "src-iso", "minimal-iso"] |
|
| 861 |
+ for img in images: |
|
| 862 |
+ self.img_name = img |
|
| 863 |
+ self.set_Iso_Parameters(img) |
|
| 864 |
+ if img in ["iso", "src-iso"]: |
|
| 865 |
+ self.build_iso() |
|
| 866 |
+ else: |
|
| 867 |
+ configdict["targetName"] = img.replace('-', '_')
|
|
| 868 |
+ getattr(self, configdict["targetName"])() |
|
| 869 |
+ |
|
| 870 |
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 871 |
+# initialize_constants initialize all the paths like stage Path, spec path, rpm path, and other parameters + |
|
| 872 |
+# used by package-builder and imagebuilder... + |
|
| 873 |
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 874 |
+ |
|
| 875 |
+def initialize_constants(): |
|
| 876 |
+ |
|
| 877 |
+ global configdict |
|
| 878 |
+ global check_prerequesite |
|
| 879 |
+ check_prerequesite["initialize-constants"]=True |
|
| 880 |
+ |
|
| 881 |
+ Build_Config.setStagePath(os.path.join(str(PurePath(configdict["photon-path"], configdict["stage-path"])), "stage")) |
|
| 882 |
+ constants.setSpecPath(os.path.join(str(PurePath(configdict["photon-path"], configdict["spec-path"])), "SPECS")) |
|
| 883 |
+ Build_Config.setBuildThreads(configdict["photon-build-param"]["threads"]) |
|
| 884 |
+ Build_Config.setPkgBuildType(configdict["photon-build-param"]["photon-build-type"]) |
|
| 885 |
+ Build_Config.setPkgJsonInput(configdict.get("additional-path", {}).get("pkg-json-input", None))
|
|
| 886 |
+ constants.setLogPath(os.path.join(Build_Config.stagePath ,"LOGS")) |
|
| 887 |
+ constants.setLogLevel(configdict["photon-build-param"]["loglevel"]) |
|
| 888 |
+ constants.setDist(configdict["photon-build-param"]["photon-dist-tag"]) |
|
| 889 |
+ constants.setBuildNumber(configdict["photon-build-param"]["input-photon-build-number"]) |
|
| 890 |
+ constants.setReleaseVersion(configdict["photon-build-param"]["photon-release-version"]) |
|
| 891 |
+ constants.setPullSourcesURL(Builder.get_baseurl(configdict["pull-sources-config"])) |
|
| 892 |
+ constants.setRPMCheck(configdict["photon-build-param"].get("rpm-check-flag", False))
|
|
| 893 |
+ constants.setRpmCheckStopOnError(configdict["photon-build-param"].get("rpm-check-stop-on-error", False))
|
|
| 894 |
+ constants.setPublishBuildDependencies(configdict["photon-build-param"].get("publish-build-dependencies", False))
|
|
| 895 |
+ constants.setRpmPath(os.path.join(Build_Config.stagePath ,"RPMS")) |
|
| 896 |
+ Build_Config.setRpmNoArchPath() |
|
| 897 |
+ Build_Config.setRpmArchPath() |
|
| 898 |
+ constants.setSourceRpmPath(os.path.join(Build_Config.stagePath ,"SRPMS")) |
|
| 899 |
+ Build_Config.setUpdatedRpmPath(os.path.join(Build_Config.stagePath ,"UPDATED_RPMS")) |
|
| 900 |
+ constants.setSourcePath(os.path.join(Build_Config.stagePath ,"SOURCES")) |
|
| 901 |
+ constants.setPrevPublishRPMRepo(os.path.join(Build_Config.stagePath , "PUBLISHRPMS")) |
|
| 902 |
+ constants.setPrevPublishXRPMRepo(os.path.join(Build_Config.stagePath , "PUBLISHXRPMS")) |
|
| 903 |
+ Build_Config.setInstallerPath(os.path.join(configdict["photon-path"], "installer")) |
|
| 904 |
+ Build_Config.setPkgInfoFile(os.path.join(Build_Config.stagePath ,"pkg_info.json")) |
|
| 905 |
+ constants.setBuildRootPath(os.path.join(Build_Config.stagePath ,"photonroot")) |
|
| 906 |
+ Build_Config.setGeneratedDataDir(os.path.join(Build_Config.stagePath ,"common/data")) |
|
| 907 |
+ constants.setTopDirPath("/usr/src/photon")
|
|
| 908 |
+ Build_Config.setCommonDir(os.path.join(curDir ,"common")) |
|
| 909 |
+ Build_Config.setDataDir(os.path.join(curDir, "common/data")) |
|
| 910 |
+ constants.setInputRPMSPath(configdict.get("input-rpms-path", os.path.join(curDir,"inputRPMS")))
|
|
| 911 |
+ Build_Config.setPullPublishRPMSDir(os.path.join(curDir, "support/pullpublishrpms")) |
|
| 912 |
+ Build_Config.setPullPublishRPMS(os.path.join(Build_Config.pullPublishRPMSDir ,"pullpublishrpms.sh")) |
|
| 913 |
+ Build_Config.setPullPublishXRPMS(os.path.join(Build_Config.pullPublishRPMSDir ,"pullpublishXrpms.sh")) |
|
| 914 |
+ constants.setPackageWeightsPath(os.path.join(Build_Config.dataDir ,"packageWeights.json")) |
|
| 915 |
+ constants.setKatBuild(configdict["photon-build-param"].get("kat-build", False))
|
|
| 916 |
+ Build_Config.setConfFile(configdict["additional-path"]["conf-file"]) |
|
| 917 |
+ Build_Config.setPkgToBeCopiedConfFile(configdict.get("additional-path", {}).get("pkg-to-be-copied-conf-file"))
|
|
| 918 |
+ Build_Config.setDistributedBuildFile(configdict.get("additional-path", {}).get("distributed-build-option-file", PurePath(curDir, "common", "data", "distributed_build_options.json")))
|
|
| 919 |
+ Builder.get_packages_with_build_options(configdict['photon-build-param']['pkg-build-options']) |
|
| 920 |
+ Build_Config.setCommonDir(PurePath(curDir, "common", "data")) |
|
| 921 |
+ constants.setStartSchedulerServer(configdict["photon-build-param"]['start-scheduler-server']) |
|
| 922 |
+ constants.initialize() |
|
| 923 |
+ |
|
| 924 |
+ |
|
| 925 |
+def set_default_value_of_config(): |
|
| 926 |
+ |
|
| 927 |
+ global configdict |
|
| 928 |
+ |
|
| 929 |
+ configdict["pull-sources-config"] = os.path.join(curDir , "support/package-builder/bintray.conf") |
|
| 930 |
+ configdict.setdefault("additional-path", {}).setdefault("photon-cache-path", None)
|
|
| 931 |
+ configdict["photon-build-param"]["input-photon-build-number"]=subprocess.check_output(["git rev-parse --short HEAD"], shell=True).decode('ASCII').rstrip()
|
|
| 932 |
+ configdict.setdefault('additional-path', {}).setdefault('photon-sources-path', None)
|
|
| 933 |
+ configdict.setdefault('additional-path', {}).setdefault('photon-publish-rpms-path', None)
|
|
| 934 |
+ configdict.setdefault('additional-path', {}).setdefault('photon-publish-x-rpms-path', None)
|
|
| 935 |
+ configdict['photon-build-param']['pkg-build-options'] = curDir + "/common/data/" + configdict['photon-build-param']['pkg-build-options'] |
|
| 936 |
+ configdict.setdefault("additional-path", {}).setdefault("conf-file", None)
|
|
| 937 |
+ configdict.setdefault("photon-build-param", {}).setdefault("start-scheduler-server", False)
|
|
| 938 |
+ |
|
| 939 |
+ |
|
| 940 |
+def main(): |
|
| 941 |
+ |
|
| 942 |
+ parser = ArgumentParser() |
|
| 943 |
+ |
|
| 944 |
+ parser.add_argument("-b", "--branch", dest="photonBranch", default=None)
|
|
| 945 |
+ parser.add_argument("-c", "--config", dest="configPath", default=None)
|
|
| 946 |
+ parser.add_argument("-t", "--target", dest="targetName", default=None)
|
|
| 947 |
+ |
|
| 948 |
+ options = parser.parse_args() |
|
| 949 |
+ |
|
| 950 |
+ if options.photonBranch is None and options.configPath is None: |
|
| 951 |
+ raise Exception("Either specify branchName or configpath...")
|
|
| 952 |
+ |
|
| 953 |
+ if options.photonBranch is not None and not os.path.isdir(os.path.join(curDir ,"photon-" + options.photonBranch)): |
|
| 954 |
+ CommandUtils.runCommandInShell("git clone https://github.com/vmware/photon.git -b " + options.photonBranch + " photon-" + options.photonBranch)
|
|
| 955 |
+ elif options.photonBranch is not None: |
|
| 956 |
+ print("Using already cloned repository...")
|
|
| 957 |
+ |
|
| 958 |
+ if options.configPath is None: |
|
| 959 |
+ options.configPath = str(PurePath(curDir, "photon-" + options.photonBranch, "config.json")) |
|
| 960 |
+ |
|
| 961 |
+ global configdict |
|
| 962 |
+ global check_prerequesite |
|
| 963 |
+ |
|
| 964 |
+ with open(options.configPath) as jsonData: |
|
| 965 |
+ configdict = json.load(jsonData) |
|
| 966 |
+ |
|
| 967 |
+ options.configPath = os.path.abspath(options.configPath) |
|
| 968 |
+ |
|
| 969 |
+ set_default_value_of_config() |
|
| 970 |
+ |
|
| 971 |
+ os.environ['PHOTON_RELEASE_VER']=configdict["photon-build-param"]["photon-release-version"] |
|
| 972 |
+ os.environ['PHOTON_BUILD_NUM']=configdict["photon-build-param"]["input-photon-build-number"] |
|
| 973 |
+ |
|
| 974 |
+ |
|
| 975 |
+ if configdict["photon-path"] == "": |
|
| 976 |
+ configdict["photon-path"] = os.path.dirname(options.configPath) |
|
| 977 |
+ |
|
| 978 |
+ if 'INPUT_PHOTON_BUILD_NUMBER' in os.environ: |
|
| 979 |
+ configdict["photon-build-param"]["input-photon-build-number"]=os.environ['IMPUT_PHOTON_BUILD_NUMBER'] |
|
| 980 |
+ |
|
| 981 |
+ if 'THREADS' in os.environ: |
|
| 982 |
+ configdict["photon-build-param"]["threads"] = int(os.environ['THREADS']) |
|
| 983 |
+ |
|
| 984 |
+ if 'LOGLEVEL' in os.environ: |
|
| 985 |
+ configdict["photon-build-param"]["loglevel"] = os.environ["LOGLEVEL"] |
|
| 986 |
+ |
|
| 987 |
+ if 'PHOTON_PULLSOURCES_CONFIG' in os.environ: |
|
| 988 |
+ configdict['pull-sources-config'] = os.environ['PHOTON_PULLSOURCES_CONFIG'] |
|
| 989 |
+ |
|
| 990 |
+ if 'PHOTON_CACHE_PATH' in os.environ: |
|
| 991 |
+ configdict.setdefault("additional-path", {}).setdefault("photon-cache-path", os.environ['PHOTON_CACHE_PATH'])
|
|
| 992 |
+ if 'PHOTON_SOURCES_PATH' in os.environ: |
|
| 993 |
+ configdict.setdefault('additional-path', {}).setdefault('photon-sources-path', os.environ["PHOTON_SOURCES_PATH"])
|
|
| 994 |
+ |
|
| 995 |
+ if 'PHOTON_PUBLISH_RPMS_PATH' in os.environ: |
|
| 996 |
+ configdict.setdefault('additional-path', {}).setdefault('photon-publish-rpms-path', os.environ['PHOTON_PUBLISH_RPMS_PATH'])
|
|
| 997 |
+ |
|
| 998 |
+ if 'PHOTON_PUBLISH_XRPMS_PATH' in os.environ: |
|
| 999 |
+ configdict.setdefault('additional-path', {}).setdefault('photon-publish-x-rpms-path', os.environ['PHOTON_PUBLISH_XRPMS_PATH'])
|
|
| 1000 |
+ |
|
| 1001 |
+ if "PHOTON_PKG_BLACKLIST_FILE" in os.environ: |
|
| 1002 |
+ configdict["additional-path"]["pkg-black-list-file"] = os.environ["PHOTON_PKG_BLACKLIST_FILE"] |
|
| 1003 |
+ |
|
| 1004 |
+ if "DISTRIBUTED_BUILD_CONFIG" in os.environ: |
|
| 1005 |
+ configdict["additional-path"]["distributed-build-option-file"] = os.environ["DISTRIBUTED_BUILD_CONFIG"] |
|
| 1006 |
+ if 'RPMCHECK' in os.environ: |
|
| 1007 |
+ if os.environ['RPMCHECK']=="enable": |
|
| 1008 |
+ configdict['photon-build-param']['rpm-check-flag'] = True |
|
| 1009 |
+ elif os.environ['RPMCHECK']=="enable_stop_on_error": |
|
| 1010 |
+ configdict['photon-build-param']["rpm-check-stop-on-error"] = True |
|
| 1011 |
+ |
|
| 1012 |
+ if 'KAT_BUILD' in os.environ and os.environ['KAT_BUILD'] == "enable": |
|
| 1013 |
+ configdict['photon-build-param']['kat-build'] = True |
|
| 1014 |
+ |
|
| 1015 |
+ if 'BUILDDEPS' in os.environ and os.environ['BUILDDEPS']=="True": |
|
| 1016 |
+ configdict['photon-build-param']['publish-build-dependencies'] = True |
|
| 1017 |
+ |
|
| 1018 |
+ if 'PKG_BUILD_OPTIONS' in os.environ: |
|
| 1019 |
+ configdict['photon-build-param']['pkg-build-options'] = os.environ['PKG_BUILD_OPTIONS'] |
|
| 1020 |
+ |
|
| 1021 |
+ if 'CROSS_TARGET' in os.environ: |
|
| 1022 |
+ configdict['photon-build-param']['tarsetdefaultArch'] = os.environ['CROSS_TARGET'] |
|
| 1023 |
+ |
|
| 1024 |
+ if 'CONFIG' in os.environ: |
|
| 1025 |
+ configdict['additional-path']['conf-file'] = os.path.abspath(os.environ['CONFIG']) |
|
| 1026 |
+ jsonData = Utils.jsonread(os.environ['CONFIG']) |
|
| 1027 |
+ options.targetName = jsonData['image_type'] |
|
| 1028 |
+ |
|
| 1029 |
+ if 'IMG_NAME' in os.environ: |
|
| 1030 |
+ options.targetName = os.environ['IMG_NAME'] |
|
| 1031 |
+ |
|
| 1032 |
+ if 'SCHEDULER_SERVER' in os.environ and os.environ['SCHEDULER_SERVER'] == "enable": |
|
| 1033 |
+ configdict['photon-build-param']['start-scheduler-server'] = True |
|
| 1034 |
+ |
|
| 1035 |
+ if 'DOCKER_ENV' in os.environ: |
|
| 1036 |
+ Build_Config.setDockerEnv(os.environ['DOCKER_ENV']) |
|
| 1037 |
+ |
|
| 1038 |
+ |
|
| 1039 |
+ initialize_constants() |
|
| 1040 |
+ |
|
| 1041 |
+ configdict["packageName"]=None |
|
| 1042 |
+ |
|
| 1043 |
+ for target in targetList: |
|
| 1044 |
+ for item in targetList[target]: |
|
| 1045 |
+ check_prerequesite[item]=False |
|
| 1046 |
+ |
|
| 1047 |
+ if options.targetName is None: |
|
| 1048 |
+ options.targetName = configdict["photon-build-param"]["target"] |
|
| 1049 |
+ |
|
| 1050 |
+ configdict["targetName"] = options.targetName.replace('-', '_')
|
|
| 1051 |
+ |
|
| 1052 |
+ try: |
|
| 1053 |
+ if options.targetName in targetList["image"]: |
|
| 1054 |
+ buildImage = BuildImage(options.targetName) |
|
| 1055 |
+ if options.targetName in ["iso", "src-iso", "minimal-iso", "rt-iso"]: |
|
| 1056 |
+ buildImage.set_Iso_Parameters(options.targetName) |
|
| 1057 |
+ buildImage.build_iso() |
|
| 1058 |
+ elif options.targetName in ["ami", "gce", "ova", "ova_uefi", "rpi3", "azure"]: |
|
| 1059 |
+ buildImage.build_image() |
|
| 1060 |
+ else: |
|
| 1061 |
+ attr = getattr(buildImage, configdict["targetName"]) |
|
| 1062 |
+ attr() |
|
| 1063 |
+ elif options.targetName in targetList["rpmBuild"]: |
|
| 1064 |
+ attr = None |
|
| 1065 |
+ if options.targetName != "distributed-build": |
|
| 1066 |
+ rpmBuildTarget = RpmBuildTarget() |
|
| 1067 |
+ attr = getattr(rpmBuildTarget, configdict["targetName"]) |
|
| 1068 |
+ else: |
|
| 1069 |
+ attr = getattr(RpmBuildTarget, configdict["targetName"]) |
|
| 1070 |
+ attr() |
|
| 1071 |
+ elif options.targetName in targetList["buildEnvironment"]: |
|
| 1072 |
+ attr = getattr(BuildEnvironmentSetup, configdict["targetName"]) |
|
| 1073 |
+ attr() |
|
| 1074 |
+ elif options.targetName in targetList["cleanup"]: |
|
| 1075 |
+ attr = getattr(CleanUp, configdict["targetName"]) |
|
| 1076 |
+ attr() |
|
| 1077 |
+ elif options.targetName in targetList["tool-checkup"]: |
|
| 1078 |
+ if options.targetName == "check-g++": |
|
| 1079 |
+ CheckTools.check_gplusplus() |
|
| 1080 |
+ else: |
|
| 1081 |
+ attr = getattr(CheckTools, configdict["targetName"]) |
|
| 1082 |
+ attr() |
|
| 1083 |
+ elif options.targetName in targetList["utilities"]: |
|
| 1084 |
+ utility = Utilities() |
|
| 1085 |
+ attr = getattr(utility, configdict["targetName"]) |
|
| 1086 |
+ attr() |
|
| 1087 |
+ else: |
|
| 1088 |
+ rpmBuildTarget = RpmBuildTarget() |
|
| 1089 |
+ rpmBuildTarget.package(options.targetName) |
|
| 1090 |
+ except Exception as e: |
|
| 1091 |
+ print(e) |
|
| 1092 |
+ traceback.print_exc() |
|
| 1093 |
+ sys.exit(1) |
|
| 1094 |
+ sys.exit(0) |
|
| 1095 |
+ |
|
| 1096 |
+ |
|
| 1097 |
+if __name__ == "__main__": |
|
| 1098 |
+ main() |
| 0 | 1099 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,15 @@ |
| 0 |
+{
|
|
| 1 |
+ "photon-build-param" : {
|
|
| 2 |
+ "photon-build-type" : "chroot", |
|
| 3 |
+ "photon-dist-tag" : ".ph3", |
|
| 4 |
+ "photon-release-version" : "3.0", |
|
| 5 |
+ "threads" : 1, |
|
| 6 |
+ "loglevel" : "info", |
|
| 7 |
+ "full-package-list-file" : "build_install_options_all.json", |
|
| 8 |
+ "pkg-build-options" : "pkg_build_options.json", |
|
| 9 |
+ "target": "iso" |
|
| 10 |
+ }, |
|
| 11 |
+ "photon-path" : "", |
|
| 12 |
+ "stage-path" : "" , |
|
| 13 |
+ "spec-path" : "" |
|
| 14 |
+} |
| 0 | 15 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,163 @@ |
| 0 |
+Build config file is a json format with possible parameters: |
|
| 1 |
+ |
|
| 2 |
+ |
|
| 3 |
+"photon-build-param" : |
|
| 4 |
+ |
|
| 5 |
+ "photon-build-type": |
|
| 6 |
+ Default value: "chroot" |
|
| 7 |
+ values: ["chroot", "container"] |
|
| 8 |
+ Example: { "photon-build-param": { "photon-build-type" : "chroot" } }
|
|
| 9 |
+ |
|
| 10 |
+ "photon-dist-tag": |
|
| 11 |
+ Default value: ".ph3" |
|
| 12 |
+ values: [".ph3"] |
|
| 13 |
+ Example: { "photon-build-param": { "photon-dist-tag" : ".ph3" }
|
|
| 14 |
+ |
|
| 15 |
+ "photon-build-no": |
|
| 16 |
+ Default value: "0000000" |
|
| 17 |
+ Example: { "photon-build-param": { "photon-build-no" : "1234567" }
|
|
| 18 |
+ |
|
| 19 |
+ "photon-release-version": |
|
| 20 |
+ Default value: "3.0" |
|
| 21 |
+ Example: { "photon-build-param": { "photon-release-version" : "3.0" } }
|
|
| 22 |
+ |
|
| 23 |
+ "photon-repo-tool": |
|
| 24 |
+ Default value: "createrepo" |
|
| 25 |
+ Example: { "photon-build-param": { "photon-repo-tool" : "createrepo" } }
|
|
| 26 |
+ |
|
| 27 |
+ "threads": |
|
| 28 |
+ Default value: 1 |
|
| 29 |
+ values: [1,2,3...] |
|
| 30 |
+ Example: { "photon-build-param": { "threads" : 32 } }
|
|
| 31 |
+ |
|
| 32 |
+ "loglevel": |
|
| 33 |
+ Default value: "info" |
|
| 34 |
+ values: ["info", "debug"] |
|
| 35 |
+ Example: { "photon-build-param": { "loglevel" : "info" } }
|
|
| 36 |
+ |
|
| 37 |
+ "full-package-list-file": |
|
| 38 |
+ Default value: "build_install_options_all.json" |
|
| 39 |
+ Example: { "photon-build-param": { "full-package-list-file" : "build_install_options_all.json" } }
|
|
| 40 |
+ |
|
| 41 |
+ "rpm-check-flag": |
|
| 42 |
+ Default value: false |
|
| 43 |
+ values: [true, false] |
|
| 44 |
+ Example: { "photon-build-param": { "rpm-check-flag" : false } }
|
|
| 45 |
+ |
|
| 46 |
+ "rpm-check-stop-on-error": |
|
| 47 |
+ Default value: false |
|
| 48 |
+ values: [true, false] |
|
| 49 |
+ Example: { "photon-build-param": { "rpm-check-stop-on-error" : false } }
|
|
| 50 |
+ |
|
| 51 |
+ "publish-build-dependencies": |
|
| 52 |
+ Default value: false |
|
| 53 |
+ values: [true, false] |
|
| 54 |
+ Example: { "photon-build-param": { "publish-build-dependencies" : false } }
|
|
| 55 |
+ |
|
| 56 |
+ "generate-pkg-list": |
|
| 57 |
+ Default value: false |
|
| 58 |
+ values: [true, false] |
|
| 59 |
+ Example: { "photon-build-param": { "generate-pkg-list" : false } }
|
|
| 60 |
+ |
|
| 61 |
+ "kat-build": |
|
| 62 |
+ Default value: null |
|
| 63 |
+ Example: { "photon-build-param": { "kat-build" : null } }
|
|
| 64 |
+ |
|
| 65 |
+ "pkg-build-options": |
|
| 66 |
+ Default value: "pkg_build_options.json" |
|
| 67 |
+ Example: { "photon-build-param": { "pkg-build-options" : "pkg_build_options.json" } }
|
|
| 68 |
+ |
|
| 69 |
+ "base-commit": |
|
| 70 |
+ Default value: null |
|
| 71 |
+ Example: { "photon-build-param": { "base-commit" : [commit-id] } }
|
|
| 72 |
+ |
|
| 73 |
+ "target-arch": |
|
| 74 |
+ Default value: null |
|
| 75 |
+ values: ["aarch64", "x86_64"] |
|
| 76 |
+ Example: { "photon-build-param": { "target-arch" : "aarch64" } }
|
|
| 77 |
+ |
|
| 78 |
+ "target": |
|
| 79 |
+ Default value: [Makefile targets] |
|
| 80 |
+ Example: { "photon-build-param": { "target" : "iso" } }
|
|
| 81 |
+ |
|
| 82 |
+"input-rpms-path": |
|
| 83 |
+ Default: [src-root]/inputRPMS |
|
| 84 |
+ Example: { "input-rpms-path": [input RPMS path] }
|
|
| 85 |
+ |
|
| 86 |
+"photon-path": |
|
| 87 |
+ Default: [takes the config path as cloned repo path] |
|
| 88 |
+ Example: { "photon-path": [cloned repo path containing SPECS dir] }
|
|
| 89 |
+ |
|
| 90 |
+ |
|
| 91 |
+"stage-path": |
|
| 92 |
+ Default: [takes the parent directory of config path as parent for stage directory] |
|
| 93 |
+ Example: { "stage-path": [path where binaries will be created] }
|
|
| 94 |
+ |
|
| 95 |
+ |
|
| 96 |
+"spec-path": |
|
| 97 |
+ Default: [takes the photon path for spec path] |
|
| 98 |
+ Example: { "spec-path": [path uptil parent directory of SPECS directory] }
|
|
| 99 |
+ |
|
| 100 |
+ |
|
| 101 |
+"additional-path": |
|
| 102 |
+ |
|
| 103 |
+ "conf-file": |
|
| 104 |
+ Default value: null |
|
| 105 |
+ values: [path of config file for building images like ova, ami, gce, azure] |
|
| 106 |
+ Example: { "additional-path" : { "conf-file" : [conf-file-path] } }
|
|
| 107 |
+ |
|
| 108 |
+ "pkg-to-be-copied-conf-file": |
|
| 109 |
+ Default value: null |
|
| 110 |
+ value: contains location of the file that contains packages to be copied for the image |
|
| 111 |
+ Example: { "additional-path" : { "pkg-to-be-copied-conf-file" : null } }
|
|
| 112 |
+ |
|
| 113 |
+ "pkg-json-input": |
|
| 114 |
+ Default value: null |
|
| 115 |
+ Example: { "additional-path" : { "pkg-json-input" : null } }
|
|
| 116 |
+ |
|
| 117 |
+ "photon-cache-path": |
|
| 118 |
+ Default value: null |
|
| 119 |
+ Example: { "additional-path" : { "photon-cache-path" : null } }
|
|
| 120 |
+ |
|
| 121 |
+ "photon-sources-path": |
|
| 122 |
+ Default value: null |
|
| 123 |
+ Example: { "additional-path" : { "photon-sources-path" : null } }
|
|
| 124 |
+ |
|
| 125 |
+ "photon-publish-rpms-path": |
|
| 126 |
+ Default value: null |
|
| 127 |
+ Example: { "additional-path" : { "photon-publish-rpms-path" : null } }
|
|
| 128 |
+ |
|
| 129 |
+ "photon-publish-x-rpms-path": |
|
| 130 |
+ Default value: null |
|
| 131 |
+ Example: { "additional-path" : { "photon-publish-x-rpms-path" : null } }
|
|
| 132 |
+ |
|
| 133 |
+ "pkg-black-list-file": |
|
| 134 |
+ Default value: null |
|
| 135 |
+ Example: { "additional-path" : { "pkg-black-list-file" : null } }
|
|
| 136 |
+ |
|
| 137 |
+ |
|
| 138 |
+"utility": |
|
| 139 |
+ |
|
| 140 |
+ "pkg": |
|
| 141 |
+ Default value: null |
|
| 142 |
+ Example: { "utility" : { "pkg" : null } }
|
|
| 143 |
+ |
|
| 144 |
+ "input-type": |
|
| 145 |
+ Default value: "json" |
|
| 146 |
+ values: ["json", "pkg", "remove-upward-deps", "print-upward-deps", "who-needs"] |
|
| 147 |
+ Example: { "utility" : { "input-type" : "json" } }
|
|
| 148 |
+ |
|
| 149 |
+ "file": |
|
| 150 |
+ Default value: "packages_*.json" |
|
| 151 |
+ values: ["packages_*.json", "packages_$(img).json"] |
|
| 152 |
+ Example: { "utility" : { "file" : "packages_*.json" } }
|
|
| 153 |
+ |
|
| 154 |
+ "display-option": |
|
| 155 |
+ Default value: "json" |
|
| 156 |
+ values: ["json", "list", "tree"] |
|
| 157 |
+ Example: { "utility" : { "display-option" : "json" } }
|
|
| 158 |
+ |
|
| 159 |
+ "img": |
|
| 160 |
+ Default value: null |
|
| 161 |
+ values: ["ova", "gce", "ami", "azure"] |
|
| 162 |
+ Example: { "utility" : { "img" : null } }
|
| ... | ... |
@@ -13,9 +13,9 @@ for file in ${SPEC_DIR}/kubernetes/kubernetes-*.spec; do
|
| 13 | 13 |
K8S_VER=`cat ${file} | grep "^Version:" | cut -d: -f2 | tr -d ' '`
|
| 14 | 14 |
K8S_VER_REL=${K8S_VER}-`cat ${file} | grep "^Release:" | cut -d: -f2 | tr -d ' ' | cut -d% -f1`
|
| 15 | 15 |
K8S_RPM=kubernetes-${K8S_VER_REL}${DIST_TAG}.${ARCH}.rpm
|
| 16 |
- K8S_RPM_FILE=../../../stage/RPMS/x86_64/${K8S_RPM}
|
|
| 16 |
+ K8S_RPM_FILE=${STAGE_DIR}/RPMS/x86_64/${K8S_RPM}
|
|
| 17 | 17 |
K8S_PAUSE_RPM=kubernetes-pause-${K8S_VER_REL}${DIST_TAG}.${ARCH}.rpm
|
| 18 |
- K8S_PAUSE_RPM_FILE=../../../stage/RPMS/x86_64/${K8S_PAUSE_RPM}
|
|
| 18 |
+ K8S_PAUSE_RPM_FILE=${STAGE_DIR}/RPMS/x86_64/${K8S_PAUSE_RPM}
|
|
| 19 | 19 |
|
| 20 | 20 |
if [ ! -f ${K8S_RPM_FILE} ]
|
| 21 | 21 |
then |
| ... | ... |
@@ -10,6 +10,7 @@ fi |
| 10 | 10 |
|
| 11 | 11 |
PROGRAM=$0 |
| 12 | 12 |
SRCROOT=$1 |
| 13 |
+STAGE_DIR=$2 |
|
| 13 | 14 |
DOCK_ARCH=`uname -m` |
| 14 | 15 |
|
| 15 | 16 |
cat > ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh << EOF
|
| ... | ... |
@@ -27,20 +28,20 @@ chmod +x ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh
|
| 27 | 27 |
cp ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo.bak
|
| 28 | 28 |
echo "baseurl=file:///RPMS" >> ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo
|
| 29 | 29 |
|
| 30 |
-rm -rf stage/ostree-repo |
|
| 31 |
-mkdir -p stage/ostree-repo |
|
| 30 |
+rm -rf ${STAGE_DIR}/ostree-repo
|
|
| 31 |
+mkdir -p ${STAGE_DIR}/ostree-repo
|
|
| 32 | 32 |
|
| 33 | 33 |
if [ $DOCK_ARCH == "x86_64" ] |
| 34 | 34 |
then |
| 35 |
- sudo docker run --privileged -v ${SRCROOT}:/photon -v $(pwd)/stage/RPMS:/RPMS -v $(pwd)/stage/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" vmware/photon-build:rpm-ostree-3.0 ./mk-ostree-server.sh /
|
|
| 35 |
+ sudo docker run --privileged -v ${SRCROOT}:/photon -v ${STAGE_DIR}/RPMS:/RPMS -v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" vmware/photon-build:rpm-ostree-3.0 ./mk-ostree-server.sh /
|
|
| 36 | 36 |
elif [ $DOCK_ARCH == "aarch64" ] |
| 37 | 37 |
then |
| 38 |
- sudo docker run --privileged -v ${SRCROOT}:/photon -v $(pwd)/stage/RPMS:/RPMS -v $(pwd)/stage/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" vmware/photon-build:rpm-ostree-aarch64-3.0 ./mk-ostree-server.sh /
|
|
| 38 |
+ sudo docker run --privileged -v ${SRCROOT}:/photon -v ${STAGE_DIR}/RPMS:/RPMS -v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" vmware/photon-build:rpm-ostree-aarch64-3.0 ./mk-ostree-server.sh /
|
|
| 39 | 39 |
fi |
| 40 | 40 |
|
| 41 |
-(cd stage/ostree-repo/repo/; tar -zcf ../../ostree-repo.tar.gz .; ) |
|
| 41 |
+(cd ${STAGE_DIR}/ostree-repo/repo/; tar -zcf ../../ostree-repo.tar.gz .; )
|
|
| 42 | 42 |
|
| 43 | 43 |
# Restore file |
| 44 | 44 |
mv -f ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo.bak ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo
|
| 45 | 45 |
sudo rm ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh
|
| 46 |
-sudo rm -rf ${SRCROOT}/stage/ostree-repo
|
|
| 46 |
+sudo rm -rf ${STAGE_DIR}/ostree-repo
|
| ... | ... |
@@ -14,260 +14,59 @@ from PackageManager import PackageManager |
| 14 | 14 |
from SpecData import SPECS |
| 15 | 15 |
from PackageInfo import PackageInfo |
| 16 | 16 |
|
| 17 |
-def main(): |
|
| 18 |
- parser = ArgumentParser() |
|
| 19 |
- parser.add_argument("-s", "--spec-path", dest="specPath", default="../../SPECS")
|
|
| 20 |
- parser.add_argument("-x", "--source-path", dest="sourcePath",
|
|
| 21 |
- default="../../stage/SOURCES") |
|
| 22 |
- parser.add_argument("-r", "--rpm-path", dest="rpmPath",
|
|
| 23 |
- default="../../stage/RPMS") |
|
| 24 |
- parser.add_argument("-i", "--install-package", dest="installPackage",
|
|
| 25 |
- default=False, action="store_true") |
|
| 26 |
- parser.add_argument("-p", "--publish-RPMS-path", dest="publishRPMSPath",
|
|
| 27 |
- default="../../stage/PUBLISHRPMS") |
|
| 28 |
- parser.add_argument("-e", "--publish-XRPMS-path", dest="publishXRPMSPath",
|
|
| 29 |
- default="../../stage/PUBLISHXRPMS") |
|
| 30 |
- parser.add_argument("-l", "--log-path", dest="logPath", default="../../stage/LOGS")
|
|
| 31 |
- parser.add_argument("-y", "--log-level", dest="logLevel", default="error")
|
|
| 32 |
- parser.add_argument("-z", "--top-dir-path", dest="topDirPath", default="/usr/src/photon")
|
|
| 33 |
- parser.add_argument("-b", "--build-root-path", dest="buildRootPath", default="/mnt")
|
|
| 34 |
- parser.add_argument("-t", "--threads", dest="buildThreads",
|
|
| 35 |
- default=1, type=int, help="Number of working threads") |
|
| 36 |
- parser.add_argument("-m", "--tool-chain-stage", dest="toolChainStage", default="None")
|
|
| 37 |
- parser.add_argument("-c", "--pullsources-config", dest="pullsourcesConfig",
|
|
| 38 |
- default="pullsources.conf") |
|
| 39 |
- parser.add_argument("-d", "--dist-tag", dest="dist", default="")
|
|
| 40 |
- parser.add_argument("-k", "--input-RPMS-path", dest="inputRPMSPath", default=None)
|
|
| 41 |
- parser.add_argument("-n", "--build-number", dest="buildNumber", default="0000000")
|
|
| 42 |
- parser.add_argument("-v", "--release-version", dest="releaseVersion", default="NNNnNNN")
|
|
| 43 |
- parser.add_argument("-u", "--enable-rpmcheck", dest="rpmCheck",
|
|
| 44 |
- default=False, action="store_true") |
|
| 45 |
- parser.add_argument("-ss", "--start-scheduler-server", dest="startSchedulerServer",
|
|
| 46 |
- default=False, action="store_true") |
|
| 47 |
- parser.add_argument("-a", "--source-rpm-path", dest="sourceRpmPath",
|
|
| 48 |
- default="../../stage/SRPMS") |
|
| 49 |
- parser.add_argument("-w", "--pkginfo-file", dest="pkgInfoFile",
|
|
| 50 |
- default="../../stage/pkg_info.json") |
|
| 51 |
- parser.add_argument("-g", "--pkg-build-option-file", dest="pkgBuildOptionFile",
|
|
| 52 |
- default="../../common/data/pkg_build_options.json") |
|
| 53 |
- parser.add_argument("-q", "--rpmcheck-stop-on-error", dest="rpmCheckStopOnError",
|
|
| 54 |
- default=False, action="store_true") |
|
| 55 |
- parser.add_argument("-bd", "--publish-build-dependencies", dest="publishBuildDependencies",
|
|
| 56 |
- default=False) |
|
| 57 |
- parser.add_argument("-pw", "--package-weights-path", dest="packageWeightsPath",
|
|
| 58 |
- default="../../common/data/packageWeights.json") |
|
| 59 |
- parser.add_argument("-bt", "--build-type", dest="pkgBuildType", choices=['chroot', 'container'], default="chroot")
|
|
| 60 |
- parser.add_argument("-F", "--enable-katbuild", dest="katBuild", default=False, action="store_true")
|
|
| 61 |
- parser.add_argument("-ct", "--cross-target", dest="targetArch", choices=['x86_64', 'aarch64'], default=None)
|
|
| 62 |
- parser.add_argument("-pj", "--packages-json-input", dest="pkgJsonInput", default=None)
|
|
| 63 |
- parser.add_argument("PackageName", nargs='?')
|
|
| 64 |
- options = parser.parse_args() |
|
| 65 |
- cmdUtils = CommandUtils() |
|
| 66 |
- if not os.path.isdir(options.logPath): |
|
| 67 |
- cmdUtils.runCommandInShell("mkdir -p " + options.logPath)
|
|
| 68 |
- |
|
| 69 |
- logger = Logger.getLogger("Main", options.logPath, options.logLevel)
|
|
| 70 |
- errorFlag = False |
|
| 71 |
- package = None |
|
| 72 |
- pkgInfoJsonFile = options.pkgInfoFile |
|
| 73 |
- if not os.path.isdir(options.sourcePath): |
|
| 74 |
- logger.error("Given Sources Path is not a directory:" + options.sourcePath)
|
|
| 75 |
- errorFlag = True |
|
| 76 |
- if not os.path.isdir(options.specPath): |
|
| 77 |
- logger.error("Given Specs Path is not a directory:" + options.specPath)
|
|
| 78 |
- errorFlag = True |
|
| 79 |
- if not os.path.isdir(options.publishRPMSPath): |
|
| 80 |
- logger.error("Given RPMS Path is not a directory:" + options.publishRPMSPath)
|
|
| 81 |
- errorFlag = True |
|
| 82 |
- if not os.path.isdir(options.publishXRPMSPath): |
|
| 83 |
- logger.error("Given X RPMS Path is not a directory:" + options.publishXRPMSPath)
|
|
| 84 |
- errorFlag = True |
|
| 85 |
- if not os.path.isdir(options.publishRPMSPath + "/" + constants.buildArch): |
|
| 86 |
- logger.error("Given RPMS Path is missing " + constants.buildArch +
|
|
| 87 |
- " sub-directory:"+options.publishRPMSPath) |
|
| 88 |
- errorFlag = True |
|
| 89 |
- if not os.path.isdir(options.publishXRPMSPath+"/" + constants.buildArch): |
|
| 90 |
- logger.error("Given X RPMS Path is missing "+ constants.buildArch +
|
|
| 91 |
- " sub-directory:"+options.publishXRPMSPath) |
|
| 92 |
- errorFlag = True |
|
| 93 |
- if not os.path.isdir(options.publishRPMSPath+"/noarch"): |
|
| 94 |
- logger.error("Given RPMS Path is missing noarch sub-directory:"+
|
|
| 95 |
- options.publishRPMSPath) |
|
| 96 |
- errorFlag = True |
|
| 97 |
- if not os.path.isdir(options.publishXRPMSPath+"/noarch"): |
|
| 98 |
- logger.error("Given X RPMS Path is missing noarch sub-directory:"+
|
|
| 99 |
- options.publishXRPMSPath) |
|
| 100 |
- errorFlag = True |
|
| 101 |
- |
|
| 102 |
- |
|
| 103 |
- if options.inputRPMSPath is not None and not os.path.isdir(options.inputRPMSPath): |
|
| 104 |
- logger.error("Given input RPMS Path is not a directory:"+options.inputRPMSPath)
|
|
| 105 |
- errorFlag = True |
|
| 106 |
- |
|
| 107 |
- if options.packageWeightsPath is not None and not os.path.isfile(options.packageWeightsPath): |
|
| 108 |
- logger.error("Given input Weights file is not a file:"+options.packageWeightsPath)
|
|
| 109 |
- errorFlag = True |
|
| 110 |
- |
|
| 111 |
- if options.pkgJsonInput is not None and not os.path.isfile(options.pkgJsonInput): |
|
| 112 |
- logger.error("Given input packages file is not a file:"+options.pkgJsonInput)
|
|
| 113 |
- errorFlag = True |
|
| 114 |
- |
|
| 115 |
- if options.installPackage: |
|
| 116 |
- if not options.PackageName: |
|
| 117 |
- logger.error("Please provide package name")
|
|
| 118 |
- errorFlag = True |
|
| 119 |
- else: |
|
| 120 |
- package = options.PackageName |
|
| 121 |
- |
|
| 122 |
- if errorFlag: |
|
| 123 |
- logger.error("Found some errors. Please fix input options and re-run it.")
|
|
| 124 |
- return False |
|
| 125 |
- |
|
| 126 |
- if options.targetArch: |
|
| 127 |
- constants.targetArch = options.targetArch |
|
| 128 |
- |
|
| 129 |
- cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/"+constants.buildArch)
|
|
| 130 |
- cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/noarch")
|
|
| 131 |
- if constants.buildArch != constants.targetArch: |
|
| 132 |
- cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/"+constants.targetArch)
|
|
| 133 |
- |
|
| 134 |
- |
|
| 135 |
- if not os.path.isdir(options.sourceRpmPath): |
|
| 136 |
- cmdUtils.runCommandInShell("mkdir -p "+options.sourceRpmPath)
|
|
| 137 |
- |
|
| 138 |
- if not os.path.isdir(options.buildRootPath): |
|
| 139 |
- cmdUtils.runCommandInShell("mkdir -p " + options.buildRootPath)
|
|
| 140 |
- |
|
| 141 |
- logger.debug("Source Path :"+options.sourcePath)
|
|
| 142 |
- logger.debug("Spec Path :" + options.specPath)
|
|
| 143 |
- logger.debug("Rpm Path :" + options.rpmPath)
|
|
| 144 |
- logger.debug("Log Path :" + options.logPath)
|
|
| 145 |
- logger.debug("Log Level :" + options.logLevel)
|
|
| 146 |
- logger.debug("Top Dir Path :" + options.topDirPath)
|
|
| 147 |
- logger.debug("Publish RPMS Path :" + options.publishRPMSPath)
|
|
| 148 |
- logger.debug("Publish X RPMS Path :" + options.publishXRPMSPath)
|
|
| 149 |
- |
|
| 150 |
- if options.installPackage: |
|
| 151 |
- logger.debug("Package to build:" + package)
|
|
| 152 |
- |
|
| 153 |
- get_packages_with_build_options(options.pkgBuildOptionFile) |
|
| 154 |
- |
|
| 155 |
- try: |
|
| 156 |
- |
|
| 157 |
- constants.setSpecPath(options.specPath) |
|
| 158 |
- constants.setSourcePath(options.sourcePath) |
|
| 159 |
- constants.setRpmPath(options.rpmPath) |
|
| 160 |
- constants.setSourceRpmPath(options.sourceRpmPath) |
|
| 161 |
- constants.setTopDirPath(options.topDirPath) |
|
| 162 |
- constants.setLogPath(options.logPath) |
|
| 163 |
- constants.setLogLevel(options.logLevel) |
|
| 164 |
- constants.setDist(options.dist) |
|
| 165 |
- constants.setBuildNumber(options.buildNumber) |
|
| 166 |
- constants.setReleaseVersion(options.releaseVersion) |
|
| 167 |
- constants.setPrevPublishRPMRepo(options.publishRPMSPath) |
|
| 168 |
- constants.setPrevPublishXRPMRepo(options.publishXRPMSPath) |
|
| 169 |
- constants.setBuildRootPath(options.buildRootPath) |
|
| 170 |
- constants.setPullSourcesURL(get_baseurl(options.pullsourcesConfig)) |
|
| 171 |
- constants.setInputRPMSPath(options.inputRPMSPath) |
|
| 172 |
- constants.setRPMCheck(options.rpmCheck) |
|
| 173 |
- constants.setStartSchedulerServer(options.startSchedulerServer) |
|
| 174 |
- constants.setRpmCheckStopOnError(options.rpmCheckStopOnError) |
|
| 175 |
- constants.setPublishBuildDependencies(options.publishBuildDependencies) |
|
| 176 |
- constants.setPackageWeightsPath(options.packageWeightsPath) |
|
| 177 |
- constants.setKatBuild(options.katBuild) |
|
| 178 |
- |
|
| 179 |
- constants.initialize() |
|
| 180 |
- # parse SPECS folder |
|
| 181 |
- SPECS() |
|
| 182 |
- if options.toolChainStage == "stage1": |
|
| 183 |
- pkgManager = PackageManager() |
|
| 184 |
- pkgManager.buildToolChain() |
|
| 185 |
- elif options.toolChainStage == "stage2": |
|
| 186 |
- pkgManager = PackageManager() |
|
| 187 |
- pkgManager.buildToolChainPackages(options.buildThreads) |
|
| 188 |
- else: |
|
| 189 |
- if constants.buildArch != constants.targetArch: |
|
| 190 |
- # It is cross compilation. |
|
| 191 |
- # first build all native packages |
|
| 192 |
- buildPackagesForAllSpecs(options.buildThreads, |
|
| 193 |
- options.pkgBuildType, |
|
| 194 |
- pkgInfoJsonFile, logger) |
|
| 195 |
- # Then do the build to the target |
|
| 196 |
- constants.currentArch = constants.targetArch |
|
| 197 |
- constants.crossCompiling = True |
|
| 198 |
- |
|
| 199 |
- if options.installPackage: |
|
| 200 |
- buildSpecifiedPackages([package], options.buildThreads, options.pkgBuildType) |
|
| 201 |
- elif options.pkgJsonInput: |
|
| 202 |
- buildPackagesInJson(options.pkgJsonInput, options.buildThreads, |
|
| 203 |
- options.pkgBuildType, pkgInfoJsonFile, logger) |
|
| 204 |
- else: |
|
| 205 |
- buildPackagesForAllSpecs(options.buildThreads, options.pkgBuildType, |
|
| 206 |
- pkgInfoJsonFile, logger) |
|
| 207 |
- except Exception as e: |
|
| 208 |
- logger.error("Caught an exception")
|
|
| 209 |
- logger.error(str(e)) |
|
| 210 |
- # print stacktrace |
|
| 211 |
- traceback.print_exc() |
|
| 212 |
- sys.exit(1) |
|
| 213 |
- sys.exit(0) |
|
| 214 |
- |
|
| 215 |
- |
|
| 216 |
-def buildSpecifiedPackages(listPackages, buildThreads, pkgBuildType, pkgInfoJsonFile=None, logger=None): |
|
| 217 |
- if constants.rpmCheck: |
|
| 218 |
- constants.setTestForceRPMS(copy.copy(listPackages)) |
|
| 219 |
- pkgManager = PackageManager(pkgBuildType=pkgBuildType) |
|
| 220 |
- pkgManager.buildPackages(listPackages, buildThreads) |
|
| 221 |
- |
|
| 222 |
- if pkgInfoJsonFile is not None: |
|
| 223 |
- # Generating package info file which is required by installer |
|
| 224 |
- if logger is not None: |
|
| 225 |
- logger.debug("Writing Package info to the file:" + pkgInfoJsonFile)
|
|
| 226 |
- pkgInfo = PackageInfo() |
|
| 227 |
- pkgInfo.loadPackagesData() |
|
| 228 |
- pkgInfo.writePkgListToFile(pkgInfoJsonFile) |
|
| 229 |
- |
|
| 230 |
- |
|
| 231 |
-def buildPackagesInJson(pkgJsonInput, buildThreads, pkgBuildType, pkgInfoJsonFile, logger): |
|
| 232 |
- listPackages = [] |
|
| 233 |
- with open(pkgJsonInput) as jsonData: |
|
| 234 |
- pkg_list_json = json.load(jsonData) |
|
| 235 |
- listPackages = pkg_list_json["packages"] |
|
| 236 |
- buildSpecifiedPackages(listPackages, buildThreads, pkgBuildType, pkgInfoJsonFile, logger) |
|
| 237 |
- |
|
| 238 |
- |
|
| 239 |
-def buildPackagesForAllSpecs(buildThreads, pkgBuildType, pkgInfoJsonFile, logger): |
|
| 240 |
- listPackages = SPECS.getData().getListPackages() |
|
| 241 |
- buildSpecifiedPackages(listPackages, buildThreads, pkgBuildType, pkgInfoJsonFile, logger) |
|
| 242 |
- |
|
| 243 |
- |
|
| 244 |
-def get_packages_with_build_options(pkg_build_options_file): |
|
| 245 |
- if os.path.exists(pkg_build_options_file): |
|
| 246 |
- with open(pkg_build_options_file) as jsonData: |
|
| 247 |
- pkg_build_option_json = json.load(jsonData, object_pairs_hook=collections.OrderedDict) |
|
| 248 |
- constants.setBuildOptions(pkg_build_option_json) |
|
| 249 |
- |
|
| 250 |
-def get_baseurl(conf_file): |
|
| 251 |
- with open(conf_file) as jsonFile: |
|
| 252 |
- config = json.load(jsonFile) |
|
| 253 |
- return config['baseurl'] |
|
| 254 |
- |
|
| 255 |
-def get_all_package_names(build_install_option): |
|
| 256 |
- base_path = os.path.dirname(build_install_option) |
|
| 257 |
- packages = [] |
|
| 258 |
- |
|
| 259 |
- with open(build_install_option) as jsonData: |
|
| 260 |
- option_list_json = json.load(jsonData, object_pairs_hook=collections.OrderedDict) |
|
| 261 |
- options_sorted = option_list_json.items() |
|
| 262 |
- |
|
| 263 |
- for install_option in options_sorted: |
|
| 264 |
- filename = os.path.join(base_path, install_option[1]["file"]) |
|
| 265 |
- with open(filename) as pkgJsonData: |
|
| 266 |
- package_list_json = json.load(pkgJsonData) |
|
| 267 |
- packages = packages + package_list_json["packages"] |
|
| 268 |
- |
|
| 269 |
- return packages |
|
| 270 |
- |
|
| 271 |
- |
|
| 272 |
-if __name__ == "__main__": |
|
| 273 |
- main() |
|
| 17 |
+class Builder: |
|
| 18 |
+ |
|
| 19 |
+ def buildSpecifiedPackages(listPackages, buildThreads, pkgBuildType, pkgInfoJsonFile=None, logger=None): |
|
| 20 |
+ if constants.rpmCheck: |
|
| 21 |
+ constants.setTestForceRPMS(copy.copy(listPackages)) |
|
| 22 |
+ pkgManager = PackageManager(pkgBuildType=pkgBuildType) |
|
| 23 |
+ pkgManager.buildPackages(listPackages, buildThreads) |
|
| 24 |
+ |
|
| 25 |
+ if pkgInfoJsonFile is not None: |
|
| 26 |
+ # Generating package info file which is required by installer |
|
| 27 |
+ if logger is not None: |
|
| 28 |
+ logger.debug("Writing Package info to the file:" + pkgInfoJsonFile)
|
|
| 29 |
+ pkgInfo = PackageInfo() |
|
| 30 |
+ pkgInfo.loadPackagesData() |
|
| 31 |
+ pkgInfo.writePkgListToFile(pkgInfoJsonFile) |
|
| 32 |
+ |
|
| 33 |
+ |
|
| 34 |
+ def buildPackagesInJson(pkgJsonInput, buildThreads, pkgBuildType, pkgInfoJsonFile, logger): |
|
| 35 |
+ listPackages = [] |
|
| 36 |
+ with open(pkgJsonInput) as jsonData: |
|
| 37 |
+ pkg_list_json = json.load(jsonData) |
|
| 38 |
+ listPackages = pkg_list_json["packages"] |
|
| 39 |
+ Builder.buildSpecifiedPackages(listPackages, buildThreads, pkgBuildType, pkgInfoJsonFile, logger) |
|
| 40 |
+ |
|
| 41 |
+ |
|
| 42 |
+ def buildPackagesForAllSpecs(buildThreads, pkgBuildType, pkgInfoJsonFile, logger): |
|
| 43 |
+ listPackages = SPECS.getData().getListPackages() |
|
| 44 |
+ Builder.buildSpecifiedPackages(listPackages, buildThreads, pkgBuildType, pkgInfoJsonFile, logger) |
|
| 45 |
+ |
|
| 46 |
+ |
|
| 47 |
+ def get_packages_with_build_options(pkg_build_options_file): |
|
| 48 |
+ if os.path.exists(pkg_build_options_file): |
|
| 49 |
+ with open(pkg_build_options_file) as jsonData: |
|
| 50 |
+ pkg_build_option_json = json.load(jsonData, object_pairs_hook=collections.OrderedDict) |
|
| 51 |
+ constants.setBuildOptions(pkg_build_option_json) |
|
| 52 |
+ |
|
| 53 |
+ def get_baseurl(conf_file): |
|
| 54 |
+ with open(conf_file) as jsonFile: |
|
| 55 |
+ config = json.load(jsonFile) |
|
| 56 |
+ return config['baseurl'] |
|
| 57 |
+ |
|
| 58 |
+ def get_all_package_names(build_install_option): |
|
| 59 |
+ base_path = os.path.dirname(build_install_option) |
|
| 60 |
+ packages = [] |
|
| 61 |
+ |
|
| 62 |
+ with open(build_install_option) as jsonData: |
|
| 63 |
+ option_list_json = json.load(jsonData, object_pairs_hook=collections.OrderedDict) |
|
| 64 |
+ options_sorted = option_list_json.items() |
|
| 65 |
+ |
|
| 66 |
+ for install_option in options_sorted: |
|
| 67 |
+ filename = os.path.join(base_path, install_option[1]["file"]) |
|
| 68 |
+ with open(filename) as pkgJsonData: |
|
| 69 |
+ package_list_json = json.load(pkgJsonData) |
|
| 70 |
+ packages = packages + package_list_json["packages"] |
|
| 71 |
+ |
|
| 72 |
+ return packages |