Browse code

Package builder cleanup

1. Move packageWeights from build infra to package builder.
2. Cleanup PullSources class.
3. Moved openssl fips logic into spec files.
4. Redesigned package build options logic.
5. Incremental build - do full build iff HEAD commit touches support folder.
6. Makefile: replaces spaces by tabs

Change-Id: I1b16bd8b3636841f367d3b11e39ea016119b948a
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5911
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Reviewed-by: Srivatsa S. Bhat <srivatsab@vmware.com>

Alexey Makhalov authored on 2018/10/12 04:50:20
Showing 12 changed files
... ...
@@ -72,9 +72,15 @@ PUBLISH_BUILD_DEPENDENCIES :=
72 72
 endif
73 73
 
74 74
 ifdef WEIGHTS
75
-PACKAGE_WEIGHTS_PATH = --package-weights-path $(WEIGHTS)
75
+PACKAGE_WEIGHTS = --package-weights-path $(SRCROOT)/common/data/packageWeights.json
76 76
 else
77
-PACKAGE_WEIGHTS_PATH =
77
+PACKAGE_WEIGHTS =
78
+endif
79
+
80
+ifdef PKG_BUILD_OPTIONS
81
+PACKAGE_BUILD_OPTIONS = --pkg-build-option-file $(PKG_BUILD_OPTIONS)
82
+else
83
+PACKAGE_BUILD_OPTIONS =
78 84
 endif
79 85
 
80 86
 TOOLS_BIN := $(SRCROOT)/tools/bin
... ...
@@ -115,192 +121,192 @@ packages-minimal: check-tools $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SO
115 115
 	@echo "Building all minimal RPMS..."
116 116
 	@echo ""
117 117
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
118
-        $(PHOTON_PACKAGE_BUILDER) \
119
-                --spec-path $(PHOTON_SPECS_DIR) \
120
-                --rpm-path $(PHOTON_RPMS_DIR) \
121
-                --source-path $(PHOTON_SRCS_DIR) \
122
-                --build-root-path $(PHOTON_CHROOT_PATH) \
123
-                --packages-json-input $(PHOTON_DATA_DIR)/packages_minimal.json \
124
-                --log-path $(PHOTON_LOGS_DIR) \
125
-                --log-level $(LOGLEVEL) \
126
-                --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
127
-                --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
128
-                --dist-tag $(PHOTON_DIST_TAG) \
129
-                --build-number $(PHOTON_BUILD_NUMBER) \
130
-                --release-version $(PHOTON_RELEASE_VERSION) \
131
-                $(PHOTON_RPMCHECK_FLAGS) \
118
+	$(PHOTON_PACKAGE_BUILDER) \
119
+		--spec-path $(PHOTON_SPECS_DIR) \
120
+		--rpm-path $(PHOTON_RPMS_DIR) \
121
+		--source-path $(PHOTON_SRCS_DIR) \
122
+		--build-root-path $(PHOTON_CHROOT_PATH) \
123
+		--packages-json-input $(PHOTON_DATA_DIR)/packages_minimal.json \
124
+		--log-path $(PHOTON_LOGS_DIR) \
125
+		--log-level $(LOGLEVEL) \
126
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
127
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
128
+		--dist-tag $(PHOTON_DIST_TAG) \
129
+		--build-number $(PHOTON_BUILD_NUMBER) \
130
+		--release-version $(PHOTON_RELEASE_VERSION) \
131
+		$(PHOTON_RPMCHECK_FLAGS) \
132 132
 		$(PUBLISH_BUILD_DEPENDENCIES) \
133
-		$(PACKAGE_WEIGHTS_PATH) \
134
-                --threads ${THREADS}
133
+		$(PACKAGE_WEIGHTS) \
134
+		--threads ${THREADS}
135 135
 
136 136
 packages: check-docker-py check-tools $(PHOTON_STAGE) $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) check-spec-files generate-dep-lists
137 137
 	@echo "Building all RPMS..."
138 138
 	@echo ""
139 139
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
140
-        $(PHOTON_PACKAGE_BUILDER) \
141
-                --build-type $(PHOTON_BUILD_TYPE) \
142
-                --spec-path $(PHOTON_SPECS_DIR) \
143
-                --rpm-path $(PHOTON_RPMS_DIR) \
144
-                --source-rpm-path $(PHOTON_SRPMS_DIR) \
145
-                --source-path $(PHOTON_SRCS_DIR) \
146
-                --build-root-path $(PHOTON_CHROOT_PATH) \
147
-                --log-path $(PHOTON_LOGS_DIR) \
148
-                --log-level $(LOGLEVEL) \
149
-                --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
150
-                --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
151
-                --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
152
-                --dist-tag $(PHOTON_DIST_TAG) \
153
-                --build-number $(PHOTON_BUILD_NUMBER) \
154
-                --release-version $(PHOTON_RELEASE_VERSION) \
155
-                --pkginfo-file $(PHOTON_STAGE)/pkg_info.json \
156
-                --pkg-build-option-file $(PHOTON_DATA_DIR)/pkg_build_options.json \
157
-                $(PHOTON_RPMCHECK_FLAGS) \
158
-		        $(PHOTON_KAT_BUILD_FLAGS) \
159
-		        $(PUBLISH_BUILD_DEPENDENCIES) \
160
-		        $(PACKAGE_WEIGHTS_PATH) \
161
-                --threads ${THREADS}
140
+	$(PHOTON_PACKAGE_BUILDER) \
141
+		--build-type $(PHOTON_BUILD_TYPE) \
142
+		--spec-path $(PHOTON_SPECS_DIR) \
143
+		--rpm-path $(PHOTON_RPMS_DIR) \
144
+		--source-rpm-path $(PHOTON_SRPMS_DIR) \
145
+		--source-path $(PHOTON_SRCS_DIR) \
146
+		--build-root-path $(PHOTON_CHROOT_PATH) \
147
+		--log-path $(PHOTON_LOGS_DIR) \
148
+		--log-level $(LOGLEVEL) \
149
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
150
+		--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
151
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
152
+		--dist-tag $(PHOTON_DIST_TAG) \
153
+		--build-number $(PHOTON_BUILD_NUMBER) \
154
+		--release-version $(PHOTON_RELEASE_VERSION) \
155
+		--pkginfo-file $(PHOTON_STAGE)/pkg_info.json \
156
+		$(PACKAGE_BUILD_OPTIONS) \
157
+		$(PHOTON_RPMCHECK_FLAGS) \
158
+		$(PHOTON_KAT_BUILD_FLAGS) \
159
+		$(PUBLISH_BUILD_DEPENDENCIES) \
160
+		$(PACKAGE_WEIGHTS) \
161
+		--threads ${THREADS}
162 162
 
163 163
 packages-docker: check-docker-py check-docker-service check-tools $(PHOTON_STAGE) $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
164 164
 	@echo "Building all RPMS..."
165 165
 	@echo ""
166 166
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
167
-        $(PHOTON_PACKAGE_BUILDER) \
168
-                --build-type $(PHOTON_BUILD_TYPE) \
169
-                --spec-path $(PHOTON_SPECS_DIR) \
170
-                --rpm-path $(PHOTON_RPMS_DIR) \
171
-                --source-rpm-path $(PHOTON_SRPMS_DIR) \
172
-                --source-path $(PHOTON_SRCS_DIR) \
173
-                --build-root-path $(PHOTON_CHROOT_PATH) \
174
-                --log-path $(PHOTON_LOGS_DIR) \
175
-                --log-level $(LOGLEVEL) \
176
-                --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
177
-                --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
178
-                --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
179
-                --dist-tag $(PHOTON_DIST_TAG) \
180
-                --build-number $(PHOTON_BUILD_NUMBER) \
181
-                --release-version $(PHOTON_RELEASE_VERSION) \
182
-                --pkginfo-file $(PHOTON_STAGE)/pkg_info.json \
183
-                --pkg-build-option-file $(PHOTON_DATA_DIR)/pkg_build_options.json \
184
-                $(PHOTON_RPMCHECK_FLAGS) \
185
-		        $(PUBLISH_BUILD_DEPENDENCIES) \
186
-		        $(PACKAGE_WEIGHTS_PATH) \
187
-                --threads ${THREADS}
167
+	$(PHOTON_PACKAGE_BUILDER) \
168
+		--build-type $(PHOTON_BUILD_TYPE) \
169
+		--spec-path $(PHOTON_SPECS_DIR) \
170
+		--rpm-path $(PHOTON_RPMS_DIR) \
171
+		--source-rpm-path $(PHOTON_SRPMS_DIR) \
172
+		--source-path $(PHOTON_SRCS_DIR) \
173
+		--build-root-path $(PHOTON_CHROOT_PATH) \
174
+		--log-path $(PHOTON_LOGS_DIR) \
175
+		--log-level $(LOGLEVEL) \
176
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
177
+		--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
178
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
179
+		--dist-tag $(PHOTON_DIST_TAG) \
180
+		--build-number $(PHOTON_BUILD_NUMBER) \
181
+		--release-version $(PHOTON_RELEASE_VERSION) \
182
+		--pkginfo-file $(PHOTON_STAGE)/pkg_info.json \
183
+		$(PACKAGE_BUILD_OPTIONS) \
184
+		$(PHOTON_RPMCHECK_FLAGS) \
185
+		$(PUBLISH_BUILD_DEPENDENCIES) \
186
+		$(PACKAGE_WEIGHTS) \
187
+		--threads ${THREADS}
188 188
 
189 189
 updated-packages: check-tools $(PHOTON_STAGE) $(PHOTON_PUBLISH_XRPMS) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
190 190
 	@echo "Building only updated RPMS..."
191 191
 	@echo ""
192 192
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
193
-        $(PHOTON_PACKAGE_BUILDER) \
194
-                --spec-path $(PHOTON_SPECS_DIR) \
195
-                --rpm-path $(PHOTON_UPDATED_RPMS_DIR) \
196
-                --source-path $(PHOTON_SRCS_DIR) \
197
-                --build-root-path $(PHOTON_CHROOT_PATH) \
198
-                --log-path $(PHOTON_LOGS_DIR) \
199
-                --log-level $(LOGLEVEL) \
200
-                --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
201
-                --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
202
-                --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
203
-                --dist-tag $(PHOTON_DIST_TAG) \
204
-                --build-number $(PHOTON_BUILD_NUMBER) \
205
-                --release-version $(PHOTON_RELEASE_VERSION) \
206
-                --input-RPMS-path $(PHOTON_INPUT_RPMS_DIR) \
207
-                $(PHOTON_KAT_BUILD_FLAGS) \
208
-                $(PHOTON_RPMCHECK_FLAGS) \
209
-		        $(PUBLISH_BUILD_DEPENDENCIES) \
210
-		        $(PACKAGE_WEIGHTS_PATH) \
211
-                --threads ${THREADS}
193
+	$(PHOTON_PACKAGE_BUILDER) \
194
+		--spec-path $(PHOTON_SPECS_DIR) \
195
+		--rpm-path $(PHOTON_UPDATED_RPMS_DIR) \
196
+		--source-path $(PHOTON_SRCS_DIR) \
197
+		--build-root-path $(PHOTON_CHROOT_PATH) \
198
+		--log-path $(PHOTON_LOGS_DIR) \
199
+		--log-level $(LOGLEVEL) \
200
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
201
+		--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
202
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
203
+		--dist-tag $(PHOTON_DIST_TAG) \
204
+		--build-number $(PHOTON_BUILD_NUMBER) \
205
+		--release-version $(PHOTON_RELEASE_VERSION) \
206
+		--input-RPMS-path $(PHOTON_INPUT_RPMS_DIR) \
207
+		$(PHOTON_KAT_BUILD_FLAGS) \
208
+		$(PHOTON_RPMCHECK_FLAGS) \
209
+		$(PUBLISH_BUILD_DEPENDENCIES) \
210
+		$(PACKAGE_WEIGHTS) \
211
+		--threads ${THREADS}
212 212
 
213 213
 tool-chain-stage1: check-tools $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
214 214
 	@echo "Building all RPMS..."
215 215
 	@echo ""
216 216
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
217
-        $(PHOTON_PACKAGE_BUILDER) \
218
-                --spec-path $(PHOTON_SPECS_DIR) \
219
-                --rpm-path $(PHOTON_RPMS_DIR) \
220
-                --source-rpm-path $(PHOTON_SRPMS_DIR) \
221
-                --source-path $(PHOTON_SRCS_DIR) \
222
-                --build-root-path $(PHOTON_CHROOT_PATH) \
223
-                --log-path $(PHOTON_LOGS_DIR) \
224
-                --log-level $(LOGLEVEL) \
225
-                --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
226
-                --threads ${THREADS} \
227
-                --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
228
-                --dist-tag $(PHOTON_DIST_TAG) \
229
-                --build-number $(PHOTON_BUILD_NUMBER) \
230
-                --release-version $(PHOTON_RELEASE_VERSION) \
231
-                $(PHOTON_RPMCHECK_FLAGS) \
232
-                --tool-chain-stage stage1
217
+	$(PHOTON_PACKAGE_BUILDER) \
218
+		--spec-path $(PHOTON_SPECS_DIR) \
219
+		--rpm-path $(PHOTON_RPMS_DIR) \
220
+		--source-rpm-path $(PHOTON_SRPMS_DIR) \
221
+		--source-path $(PHOTON_SRCS_DIR) \
222
+		--build-root-path $(PHOTON_CHROOT_PATH) \
223
+		--log-path $(PHOTON_LOGS_DIR) \
224
+		--log-level $(LOGLEVEL) \
225
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
226
+		--threads ${THREADS} \
227
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
228
+		--dist-tag $(PHOTON_DIST_TAG) \
229
+		--build-number $(PHOTON_BUILD_NUMBER) \
230
+		--release-version $(PHOTON_RELEASE_VERSION) \
231
+		$(PHOTON_RPMCHECK_FLAGS) \
232
+		--tool-chain-stage stage1
233 233
 
234 234
 tool-chain-stage2: check-tools $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
235 235
 	@echo "Building all RPMS..."
236 236
 	@echo ""
237 237
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
238
-        $(PHOTON_PACKAGE_BUILDER) \
239
-                --spec-path $(PHOTON_SPECS_DIR) \
240
-                --rpm-path $(PHOTON_RPMS_DIR) \
241
-                --source-rpm-path $(PHOTON_SRPMS_DIR) \
242
-                --source-path $(PHOTON_SRCS_DIR) \
243
-                --build-root-path $(PHOTON_CHROOT_PATH) \
244
-                --log-path $(PHOTON_LOGS_DIR) \
245
-                --log-level $(LOGLEVEL) \
246
-                --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
247
-                --threads ${THREADS} \
248
-                --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
249
-                --dist-tag $(PHOTON_DIST_TAG) \
250
-                --build-number $(PHOTON_BUILD_NUMBER) \
251
-                --release-version $(PHOTON_RELEASE_VERSION) \
252
-                $(PHOTON_RPMCHECK_FLAGS) \
253
-                --tool-chain-stage stage2
238
+	$(PHOTON_PACKAGE_BUILDER) \
239
+		--spec-path $(PHOTON_SPECS_DIR) \
240
+		--rpm-path $(PHOTON_RPMS_DIR) \
241
+		--source-rpm-path $(PHOTON_SRPMS_DIR) \
242
+		--source-path $(PHOTON_SRCS_DIR) \
243
+		--build-root-path $(PHOTON_CHROOT_PATH) \
244
+		--log-path $(PHOTON_LOGS_DIR) \
245
+		--log-level $(LOGLEVEL) \
246
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
247
+		--threads ${THREADS} \
248
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
249
+		--dist-tag $(PHOTON_DIST_TAG) \
250
+		--build-number $(PHOTON_BUILD_NUMBER) \
251
+		--release-version $(PHOTON_RELEASE_VERSION) \
252
+		$(PHOTON_RPMCHECK_FLAGS) \
253
+		--tool-chain-stage stage2
254 254
 
255 255
 %: check-tools $(PHOTON_PUBLISH_RPMS) $(PHOTON_PUBLISH_XRPMS) $(PHOTON_SOURCES) $(CONTAIN) check-spec-files $(eval PKG_NAME = $@)
256 256
 	$(eval PKG_NAME = $@)
257 257
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
258
-        $(PHOTON_PACKAGE_BUILDER) --install-package $(PKG_NAME)\
259
-                  --build-type $(PHOTON_BUILD_TYPE) \
260
-                  --build-root-path $(PHOTON_CHROOT_PATH) \
261
-                  --spec-path $(PHOTON_SPECS_DIR) \
262
-                  --rpm-path $(PHOTON_RPMS_DIR) \
263
-                  --source-rpm-path $(PHOTON_SRPMS_DIR) \
264
-                  --source-path $(PHOTON_SRCS_DIR) \
265
-                  --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
266
-                  --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
267
-                  --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
268
-                  --log-level $(LOGLEVEL) \
269
-                  --dist-tag $(PHOTON_DIST_TAG) \
270
-                  --build-number $(PHOTON_BUILD_NUMBER) \
271
-                  --release-version $(PHOTON_RELEASE_VERSION) \
272
-                  --pkg-build-option-file $(PHOTON_DATA_DIR)/pkg_build_options.json \
273
-                  $(PHOTON_RPMCHECK_FLAGS) \
274
-                  $(PHOTON_KAT_BUILD_FLAGS) \
275
-                  --log-path $(PHOTON_LOGS_DIR) \
276
-                  --threads ${THREADS}
258
+	$(PHOTON_PACKAGE_BUILDER) --install-package $(PKG_NAME)\
259
+		--build-type $(PHOTON_BUILD_TYPE) \
260
+		--build-root-path $(PHOTON_CHROOT_PATH) \
261
+		--spec-path $(PHOTON_SPECS_DIR) \
262
+		--rpm-path $(PHOTON_RPMS_DIR) \
263
+		--source-rpm-path $(PHOTON_SRPMS_DIR) \
264
+		--source-path $(PHOTON_SRCS_DIR) \
265
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
266
+		--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
267
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
268
+		--log-level $(LOGLEVEL) \
269
+		--dist-tag $(PHOTON_DIST_TAG) \
270
+		--build-number $(PHOTON_BUILD_NUMBER) \
271
+		--release-version $(PHOTON_RELEASE_VERSION) \
272
+		$(PACKAGE_BUILD_OPTIONS) \
273
+		$(PHOTON_RPMCHECK_FLAGS) \
274
+		$(PHOTON_KAT_BUILD_FLAGS) \
275
+		--log-path $(PHOTON_LOGS_DIR) \
276
+		--threads ${THREADS}
277 277
 
278 278
 check: packages
279
-    ifeq ($(RPMCHECK),enable_stop_on_error)
280
-	    $(eval rpmcheck_stop_on_error = -q)
281
-    endif
279
+	ifeq ($(RPMCHECK),enable_stop_on_error)
280
+		$(eval rpmcheck_stop_on_error = -q)
281
+	endif
282 282
 	@echo "Testing all RPMS ..."
283 283
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
284
-        $(PHOTON_PACKAGE_BUILDER) \
285
-                --build-type $(PHOTON_BUILD_TYPE) \
286
-                --spec-path $(PHOTON_SPECS_DIR) \
287
-                --rpm-path $(PHOTON_RPMS_DIR) \
288
-                --source-rpm-path $(PHOTON_SRPMS_DIR) \
289
-                --source-path $(PHOTON_SRCS_DIR) \
290
-                --build-root-path $(PHOTON_CHROOT_PATH) \
291
-                --log-path $(PHOTON_LOGS_DIR) \
292
-                --log-level $(LOGLEVEL) \
293
-                --publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
294
-                --publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
295
-                --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
296
-                --dist-tag $(PHOTON_DIST_TAG) \
297
-                --build-number $(PHOTON_BUILD_NUMBER) \
298
-                --release-version $(PHOTON_RELEASE_VERSION) \
299
-                --pkginfo-file $(PHOTON_STAGE)/pkg_info.json \
300
-                --pkg-build-option-file $(PHOTON_DATA_DIR)/pkg_build_options.json \
301
-                --enable-rpmcheck \
302
-                $(rpmcheck_stop_on_error) \
303
-                --threads ${THREADS}
284
+	$(PHOTON_PACKAGE_BUILDER) \
285
+		--build-type $(PHOTON_BUILD_TYPE) \
286
+		--spec-path $(PHOTON_SPECS_DIR) \
287
+		--rpm-path $(PHOTON_RPMS_DIR) \
288
+		--source-rpm-path $(PHOTON_SRPMS_DIR) \
289
+		--source-path $(PHOTON_SRCS_DIR) \
290
+		--build-root-path $(PHOTON_CHROOT_PATH) \
291
+		--log-path $(PHOTON_LOGS_DIR) \
292
+		--log-level $(LOGLEVEL) \
293
+		--publish-RPMS-path $(PHOTON_PUBLISH_RPMS_DIR) \
294
+		--publish-XRPMS-path $(PHOTON_PUBLISH_XRPMS_DIR) \
295
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
296
+		--dist-tag $(PHOTON_DIST_TAG) \
297
+		--build-number $(PHOTON_BUILD_NUMBER) \
298
+		--release-version $(PHOTON_RELEASE_VERSION) \
299
+		--pkginfo-file $(PHOTON_STAGE)/pkg_info.json \
300
+		$(PACKAGE_BUILD_OPTIONS) \
301
+		--enable-rpmcheck \
302
+		$(rpmcheck_stop_on_error) \
303
+		--threads ${THREADS}
304 304
 
305 305
 #-------------------------------------------------------------------------------
306 306
 
... ...
@@ -311,37 +317,37 @@ all: iso photon-docker-image k8s-docker-images cloud-image-all src-iso
311 311
 iso: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES)
312 312
 	@echo "Building Photon Full ISO..."
313 313
 	@cd $(PHOTON_INSTALLER_DIR) && \
314
-        sudo $(PHOTON_INSTALLER) \
315
-                --iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
316
-                --debug-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
317
-                --working-directory $(PHOTON_STAGE)/photon_iso \
318
-                --log-path $(PHOTON_STAGE)/LOGS \
319
-                --log-level $(LOGLEVEL) \
320
-                --rpm-path $(PHOTON_STAGE)/RPMS \
321
-                --srpm-path $(PHOTON_STAGE)/SRPMS \
322
-                --package-list-file $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
323
-                --output-data-path $(PHOTON_STAGE)/common/data \
324
-                --pkg-to-rpm-map-file $(PHOTON_STAGE)/pkg_info.json \
325
-                --json-data-path $(PHOTON_DATA_DIR) \
326
-                --force > \
327
-                $(PHOTON_LOGS_DIR)/installer.log 2>&1
314
+	sudo $(PHOTON_INSTALLER) \
315
+		--iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
316
+		--debug-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
317
+		--working-directory $(PHOTON_STAGE)/photon_iso \
318
+		--log-path $(PHOTON_STAGE)/LOGS \
319
+		--log-level $(LOGLEVEL) \
320
+		--rpm-path $(PHOTON_STAGE)/RPMS \
321
+		--srpm-path $(PHOTON_STAGE)/SRPMS \
322
+		--package-list-file $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
323
+		--output-data-path $(PHOTON_STAGE)/common/data \
324
+		--pkg-to-rpm-map-file $(PHOTON_STAGE)/pkg_info.json \
325
+		--json-data-path $(PHOTON_DATA_DIR) \
326
+		--force > \
327
+		$(PHOTON_LOGS_DIR)/installer.log 2>&1
328 328
 
329 329
 src-iso: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES)
330 330
 	@echo "Building Photon Full Source ISO..."
331 331
 	@cd $(PHOTON_INSTALLER_DIR) && \
332
-        sudo $(PHOTON_INSTALLER) \
333
-                --src-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).src.iso \
334
-                --working-directory $(PHOTON_STAGE)/photon_iso \
335
-                --log-path $(PHOTON_STAGE)/LOGS \
336
-                --log-level $(LOGLEVEL) \
337
-                --rpm-path $(PHOTON_STAGE)/RPMS \
338
-                --srpm-path $(PHOTON_STAGE)/SRPMS \
339
-                --package-list-file $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
340
-                --output-data-path $(PHOTON_STAGE)/common/data \
341
-                --pkg-to-rpm-map-file $(PHOTON_STAGE)/pkg_info.json \
342
-                --json-data-path $(PHOTON_DATA_DIR) \
343
-                --force > \
344
-                $(PHOTON_LOGS_DIR)/sourceiso-installer.log 2>&1
332
+	sudo $(PHOTON_INSTALLER) \
333
+		--src-iso-path $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).src.iso \
334
+		--working-directory $(PHOTON_STAGE)/photon_iso \
335
+		--log-path $(PHOTON_STAGE)/LOGS \
336
+		--log-level $(LOGLEVEL) \
337
+		--rpm-path $(PHOTON_STAGE)/RPMS \
338
+		--srpm-path $(PHOTON_STAGE)/SRPMS \
339
+		--package-list-file $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
340
+		--output-data-path $(PHOTON_STAGE)/common/data \
341
+		--pkg-to-rpm-map-file $(PHOTON_STAGE)/pkg_info.json \
342
+		--json-data-path $(PHOTON_DATA_DIR) \
343
+		--force > \
344
+		$(PHOTON_LOGS_DIR)/sourceiso-installer.log 2>&1
345 345
 
346 346
 cloud-image: check-kpartx $(PHOTON_STAGE) $(VIXDISKUTIL) $(IMGCONVERTER) $(PHOTON_PACKAGES)
347 347
 	@echo "Building cloud image $(IMG_NAME)..."
... ...
@@ -392,9 +398,9 @@ k8s-docker-images: start-docker photon-docker-image
392 392
 packages-cached:
393 393
 	@echo "Using cached RPMS..."
394 394
 	@$(RM) -f $(PHOTON_RPMS_DIR_NOARCH)/* && \
395
-     $(RM) -f $(PHOTON_RPMS_DIR_ARCH)/* && \
396
-     $(CP) -f $(PHOTON_CACHE_PATH)/RPMS/noarch/* $(PHOTON_RPMS_DIR_NOARCH)/ && \
397
-     $(CP) -f $(PHOTON_CACHE_PATH)/RPMS/$(ARCH)/* $(PHOTON_RPMS_DIR_ARCH)/
395
+	$(RM) -f $(PHOTON_RPMS_DIR_ARCH)/* && \
396
+	$(CP) -f $(PHOTON_CACHE_PATH)/RPMS/noarch/* $(PHOTON_RPMS_DIR_NOARCH)/ && \
397
+	$(CP) -f $(PHOTON_CACHE_PATH)/RPMS/$(ARCH)/* $(PHOTON_RPMS_DIR_ARCH)/
398 398
 
399 399
 sources:
400 400
 	@$(MKDIR) -p $(PHOTON_SRCS_DIR)
... ...
@@ -417,13 +423,13 @@ publish-rpms-cached:
417 417
 	@echo "Using cached toolchain rpms..."
418 418
 	@$(MKDIR) -p $(PHOTON_PUBLISH_RPMS_DIR)/{$(ARCH),noarch} && \
419 419
 	cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \
420
-        $(PHOTON_PULL_PUBLISH_RPMS) $(PHOTON_PUBLISH_RPMS_DIR) $(PHOTON_PUBLISH_RPMS_PATH)
420
+	$(PHOTON_PULL_PUBLISH_RPMS) $(PHOTON_PUBLISH_RPMS_DIR) $(PHOTON_PUBLISH_RPMS_PATH)
421 421
 
422 422
 publish-x-rpms-cached:
423 423
 	@echo "Using cached X toolchain rpms..."
424 424
 	@$(MKDIR) -p $(PHOTON_PUBLISH_XRPMS_DIR)/{$(ARCH),noarch} && \
425 425
 	cd $(PHOTON_PULL_PUBLISH_RPMS_DIR) && \
426
-        $(PHOTON_PULL_PUBLISH_X_RPMS) $(PHOTON_PUBLISH_XRPMS_DIR) $(PHOTON_PUBLISH_XRPMS_PATH)
426
+	$(PHOTON_PULL_PUBLISH_X_RPMS) $(PHOTON_PUBLISH_XRPMS_DIR) $(PHOTON_PUBLISH_XRPMS_PATH)
427 427
 
428 428
 $(PHOTON_STAGE):
429 429
 	@echo "Creating staging folder..."
... ...
@@ -543,47 +549,47 @@ generate-dep-lists:
543 543
 pkgtree:
544 544
 	@cd $(PHOTON_SPECDEPS_DIR) && \
545 545
 		$(PHOTON_SPECDEPS) \
546
-        --spec-path $(PHOTON_SPECS_DIR) \
547
-        --log-level $(LOGLEVEL) \
548
-        --input-type pkg \
549
-        --pkg $(pkg)
546
+	--spec-path $(PHOTON_SPECS_DIR) \
547
+	--log-level $(LOGLEVEL) \
548
+	--input-type pkg \
549
+	--pkg $(pkg)
550 550
 
551 551
 imgtree:
552 552
 	@cd $(PHOTON_SPECDEPS_DIR) && \
553 553
 		$(PHOTON_SPECDEPS) \
554
-        --spec-path $(PHOTON_SPECS_DIR) \
555
-        --log-level $(LOGLEVEL) \
556
-        --input-type json \
557
-        --file $(PHOTON_DATA_DIR)/build_install_options_$(img).json
554
+	--spec-path $(PHOTON_SPECS_DIR) \
555
+	--log-level $(LOGLEVEL) \
556
+	--input-type json \
557
+	--file $(PHOTON_DATA_DIR)/build_install_options_$(img).json
558 558
 
559 559
 who-needs:
560 560
 	@cd $(PHOTON_SPECDEPS_DIR) && \
561 561
 		$(PHOTON_SPECDEPS) \
562
-        --spec-path $(PHOTON_SPECS_DIR) \
563
-        --log-level $(LOGLEVEL) \
564
-        --input-type who-needs \
565
-        --pkg $(pkg)
562
+	--spec-path $(PHOTON_SPECS_DIR) \
563
+	--log-level $(LOGLEVEL) \
564
+	--input-type who-needs \
565
+	--pkg $(pkg)
566 566
 
567 567
 print-upward-deps:
568 568
 	@cd $(PHOTON_SPECDEPS_DIR) && \
569 569
 		$(PHOTON_SPECDEPS) \
570
-        --spec-path $(PHOTON_SPECS_DIR) \
571
-        --input-type print-upward-deps \
572
-        --pkg $(pkg)
570
+	--spec-path $(PHOTON_SPECS_DIR) \
571
+	--input-type print-upward-deps \
572
+	--pkg $(pkg)
573 573
 
574 574
 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
575 575
 
576 576
 generate-yaml-files: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES)
577 577
 	@echo "Generating yaml files for packages ..."
578 578
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
579
-        $(PHOTON_GENERATE_OSS_FILES) --generate-yaml-files \
580
-                              --spec-path $(PHOTON_SPECS_DIR) \
581
-                              --source-rpm-path $(PHOTON_SRPMS_DIR) \
582
-                              --log-path $(PHOTON_LOGS_DIR) \
583
-                              --dist-tag $(PHOTON_DIST_TAG) \
584
-                              --log-level $(LOGLEVEL) \
585
-                              --pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
586
-                              --pkg-blacklist-file $(PHOTON_PKG_BLACKLIST_FILE)
579
+	$(PHOTON_GENERATE_OSS_FILES) --generate-yaml-files \
580
+		--spec-path $(PHOTON_SPECS_DIR) \
581
+		--source-rpm-path $(PHOTON_SRPMS_DIR) \
582
+		--log-path $(PHOTON_LOGS_DIR) \
583
+		--dist-tag $(PHOTON_DIST_TAG) \
584
+		--log-level $(LOGLEVEL) \
585
+		--pullsources-config $(PHOTON_PULLSOURCES_CONFIG) \
586
+		--pkg-blacklist-file $(PHOTON_PKG_BLACKLIST_FILE)
587 587
 
588 588
 # Input args: BASE_COMMIT= (optional)
589 589
 #
... ...
@@ -597,5 +603,5 @@ generate-yaml-files: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES)
597 597
 # - local changes (if no commits specified)
598 598
 clean-stage-for-incremental-build:
599 599
 	@test -n "$$(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 ' ' :) ||:
600
-	@test -n "$$(git diff --name-only $(BASE_COMMIT) @ | grep '^support')" && $(RM) -rf $(PHOTON_RPMS_DIR) ||:
600
+	@test -n "$$(git diff --name-only @~1 @ | grep '^support')" && { echo "Remove all staged RPMs"; $(RM) -rf $(PHOTON_RPMS_DIR); } ||:
601 601
 
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        Management tools and libraries relating to cryptography
2 2
 Name:           openssl
3 3
 Version:        1.0.2p
4
-Release:        1%{?dist}
4
+Release:        2%{?dist}
5 5
 License:        OpenSSL
6 6
 URL:            http://www.openssl.org
7 7
 Group:          System Environment/Security
... ...
@@ -10,6 +10,10 @@ Distribution:   Photon
10 10
 Source0:        http://www.openssl.org/source/%{name}-%{version}.tar.gz
11 11
 %define sha1    openssl=f34b5322e92415755c7d58bf5d0d5cf37666382c
12 12
 Source1:        rehash_ca_certificates.sh
13
+%if 0%{?with_fips:1}
14
+Source100:      openssl-fips-2.0.9-lin64.tar.gz
15
+%define sha1    openssl-fips=e834d3678fb190f9483f48f037fb17041abba6a1
16
+%endif
13 17
 Patch0:         c_rehash.patch
14 18
 Patch1:         openssl-ipv6apps.patch
15 19
 Patch2:         openssl-init-conslidate.patch
... ...
@@ -21,7 +25,7 @@ Requires:       bash glibc libgcc
21 21
 
22 22
 %description
23 23
 The OpenSSL package contains management tools and libraries relating
24
-to cryptography. These are useful for providing cryptography 
24
+to cryptography. These are useful for providing cryptography
25 25
 functions to other packages, such as OpenSSH, email applications and
26 26
 web browsers (for accessing HTTPS sites).
27 27
 
... ...
@@ -59,19 +63,26 @@ Perl scripts that convert certificates and keys to various formats.
59 59
 %patch3 -p1
60 60
 
61 61
 %build
62
+%if 0%{?with_fips:1}
63
+tar xf %{SOURCE100} --no-same-owner -C ..
64
+# Do not package it to src.rpm
65
+:> %{SOURCE100}
66
+%endif
62 67
 export CFLAGS="%{optflags}"
63 68
 ./config \
64
-    --prefix=%{_prefix} \
69
+    --prefix=/usr \
65 70
     --libdir=lib \
66 71
     --openssldir=/%{_sysconfdir}/ssl \
67 72
     shared \
68 73
     zlib-dynamic \
69
-    %{?_with_fips} \
74
+%if 0%{?with_fips:1}
75
+    fips --with-fipsdir=%{_builddir}/openssl-fips-2.0.9 \
76
+%endif
70 77
     -Wa,--noexecstack "${CFLAGS}" "${LDFLAGS}"
71 78
 # does not support -j yet
72 79
 make
73 80
 %install
74
-[ %{buildroot} != "/"] && rm -rf %{buildroot}/*
81
+[ %{buildroot} != "/" ] && rm -rf %{buildroot}/*
75 82
 make INSTALL_PREFIX=%{buildroot} MANDIR=/usr/share/man MANSUFFIX=ssl install
76 83
 install -p -m 755 -D %{SOURCE1} %{buildroot}%{_bindir}/
77 84
 ln -sf libssl.so.1.0.0 %{buildroot}%{_libdir}/libssl.so.1.0.2
... ...
@@ -118,6 +129,8 @@ rm -rf %{buildroot}/*
118 118
 /%{_bindir}/rehash_ca_certificates.sh
119 119
 
120 120
 %changelog
121
+*   Wed Oct 17 2018 Alexey Makhalov <amakhalov@vmware.com> 1.0.2p-2
122
+-   Move fips logic to spec file
121 123
 *   Fri Aug 17 2018 Him Kalyan Bordoloi <bordoloih@vmware.com> 1.0.2p-1
122 124
 -   Upgrade to 1.0.2p
123 125
 *   Wed Mar 21 2018 Dheeraj Shetty <dheerajs@vmware.com> 1.0.2n-2
... ...
@@ -1,12 +1,16 @@
1 1
 Summary:        Perl extension for using OpenSSL
2 2
 Name:           perl-Net-SSLeay
3 3
 Version:        1.85
4
-Release:        1%{?dist}
4
+Release:        2%{?dist}
5 5
 License:        Perl Artistic License 2.0
6 6
 Group:          Development/Libraries
7 7
 URL:            http://search.cpan.org/~mikem/Net-SSLeay-%{version}/
8 8
 Source:         https://cpan.metacpan.org/authors/id/M/MI/MIKEM/Net-SSLeay-%{version}.tar.gz
9 9
 %define sha1 Net-SSLeay=5f1c7b6ccac81efd5b78b1e076c694f96ca5c439
10
+%if 0%{?with_fips:1}
11
+Source100:      openssl-fips-2.0.9-lin64.tar.gz
12
+%define sha1    openssl-fips=e834d3678fb190f9483f48f037fb17041abba6a1
13
+%endif
10 14
 Vendor:         VMware, Inc.
11 15
 Distribution:   Photon
12 16
 Requires:       perl >= 5.28.0
... ...
@@ -27,6 +31,12 @@ Net::SSLeay module basically comprise of:
27 27
 %setup -q -n Net-SSLeay-%{version}
28 28
 
29 29
 %build
30
+%if 0%{?with_fips:1}
31
+tar xf %{SOURCE100} --no-same-owner -C ..
32
+# Do not package it to src.rpm
33
+:> %{SOURCE100}
34
+cp ../openssl-fips-2.0.9/include/openssl/fips.h /usr/include/openssl/
35
+%endif
30 36
 env PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
31 37
 make %{?_smp_mflags}
32 38
 
... ...
@@ -44,6 +54,8 @@ make test
44 44
 %{_mandir}/man?/*
45 45
 
46 46
 %changelog
47
+*   Wed Oct 17 2018 Alexey Makhalov <amakhalov@vmware.com> 1.85-2
48
+-   Move fips logic to spec file
47 49
 *   Fri Sep 21 2018 Dweep Advani <dadvani@vmware.com> 1.85-1
48 50
 -   Update to version 1.85
49 51
 *   Fri Oct 13 2017 Alexey Makhalov <amakhalov@vmware.com> 1.81-2
50 52
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+{
1
+  "ceph": 83.7,
2
+  "mesos": 75,
3
+  "linux": 41.2,
4
+  "linux-secure": 32,
5
+  "openjdk8": 21.55,
6
+  "kubernetes": 21.3,
7
+  "llvm": 20.267,
8
+  "linux-esx": 16.73,
9
+  "falco": 13.85,
10
+  "guile": 11.52,
11
+  "clang": 11.3
12
+}
... ...
@@ -1,9 +1,6 @@
1 1
 {
2 2
     "dummy_package": { 
3
-        "files": [
4
-                     {"src": "path_to_file1_to_be_copied", "dst": "file1_destination"}, 
5
-                     {"src": "path_to_file2_to_be_copied", "dst": "file2_destination"}
6
-        ], 
3
+        "pullsources": ["url1", "url2"],
7 4
         "macros": ["macro1 value1","macro2 value2"]
8 5
     }
9 6
 }
... ...
@@ -81,7 +81,7 @@ def main():
81 81
         constants.setSourceRpmPath(options.sourceRpmPath)
82 82
         constants.setLogPath(options.logPath)
83 83
         constants.setLogLevel(options.logLevel)
84
-        constants.setPullSourcesConfig(options.pullsourcesConfig)
84
+        constants.setPullSourcesURL(get_baseurl(options.pullsourcesConfig))
85 85
         constants.initialize()
86 86
 
87 87
         # parse SPECS folder
... ...
@@ -102,6 +102,11 @@ def main():
102 102
     sys.exit(0)
103 103
 
104 104
 
105
+def get_baseurl(self, conf_file):
106
+    with open(conf_file) as jsonFile:
107
+        config = json.load(jsonFile)
108
+    return config['baseurl']
109
+
105 110
 def buildPackagesList(csvFilename):
106 111
     with open(csvFilename, "w") as csvFile:
107 112
         csvFile.write("Package,Version,License,URL,Sources,Patches\n")
... ...
@@ -163,7 +168,7 @@ def buildSourcesList(yamlDir, blackListPkgs, logger, singleFile=True):
163 163
                 sha1 = SPECS.getData().getSHA1(package, version, sourceName)
164 164
                 if sha1 is not None:
165 165
                     PullSources.get(package, sourceName, sha1, yamlSourceDir,
166
-                                    constants.pullsourcesConfig, logger)
166
+                                    constants.getPullSourcesURLs(package), logger)
167 167
 
168 168
             if not singleFile:
169 169
                 yamlFile = open(yamlSourceDir + "/" + ossname + "-" + version + ".yaml", "w")
... ...
@@ -97,14 +97,15 @@ class PackageUtils(object):
97 97
         chrootCmd = self.runInChrootCommand + " " + chrootID
98 98
         shutil.copyfile(specFile, chrootID + chrootSpecPath + specName)
99 99
 
100
+        sources_urls, macros = self._getAdditionalBuildOptions(package)
101
+        self.logger.debug("Extra macros for " + package + ": " + str(macros))
102
+        self.logger.debug("Extra source URLs for " + package + ": " + str(sources_urls))
103
+        constants.setExtraSourcesURLs(package, sources_urls)
104
+
100 105
         # FIXME: some sources are located in SPECS/.. how to mount?
101 106
         #        if os.geteuid()==0:
102 107
         self._copySourcesTobuildroot(listSourcesFiles, package, version, chrootSourcePath)
103 108
         self._copySourcesTobuildroot(listPatchFiles, package, version, chrootSourcePath)
104
-        macros = []
105
-
106
-        listAdditionalFiles, macros = self._getAdditionalBuildFiles(package)
107
-        self._copyAdditionalBuildFiles(listAdditionalFiles, chrootID)
108 109
 
109 110
         #Adding rpm macros
110 111
         listRPMMacros = constants.userDefinedMacros
... ...
@@ -338,15 +339,16 @@ class PackageUtils(object):
338 338
             self.logger.error("Error copying source SPEC file to container")
339 339
             raise Exception("Failed copying source SPEC to container")
340 340
 
341
+        macros = []
342
+        sources_urls, macros = self._getAdditionalBuildOptions(package)
343
+        constants.setExtraSourcesURLs(package, sources_urls)
344
+
341 345
         #FIXME: some sources are located in SPECS/.. how to mount?
342 346
         #        if os.geteuid()==0:
343 347
         #TODO: mount it in, don't copy
344
-        macros = []
345 348
         self._copySourcesToContainer(listSourcesFiles, package, version, containerID, sourcePath)
346 349
         #TODO: mount it in, don't copy
347 350
         self._copySourcesToContainer(listPatchFiles, package, version, containerID, sourcePath)
348
-        listAdditionalFiles, macros = self._getAdditionalBuildFiles(package)
349
-        self._copyAdditionalBuildFilesToContainer(listAdditionalFiles, containerID)
350 351
 
351 352
         # Add rpm macros
352 353
         listRPMMacros = constants.userDefinedMacros
... ...
@@ -437,7 +439,7 @@ class PackageUtils(object):
437 437
         sha1 = SPECS.getData().getSHA1(package, version, source)
438 438
         if sha1 is not None:
439 439
             PullSources.get(package, source, sha1, constants.sourcePath,
440
-                            constants.pullsourcesConfig, self.logger)
440
+                            constants.getPullSourcesURLs(package), self.logger)
441 441
 
442 442
         sourcePath = cmdUtils.findFile(source, constants.sourcePath)
443 443
         if not sourcePath:
... ...
@@ -467,30 +469,14 @@ class PackageUtils(object):
467 467
                              " Source filename: " + sourcePath[0])
468 468
             shutil.copy2(sourcePath[0], destDir)
469 469
 
470
-    def _copyAdditionalBuildFiles(self, listAdditionalFiles, chrootID):
471
-        cmdUtils = CommandUtils()
472
-        for additionalFile in listAdditionalFiles:
473
-            source = additionalFile["src"]
474
-            destDir = chrootID + additionalFile["dst"]
475
-            self.logger.debug("Copying additional Source build files :" + source)
476
-            if os.path.exists(source):
477
-                if os.path.isfile(source):
478
-                    shutil.copy(source, destDir)
479
-                else:
480
-                    shutil.copytree(source, destDir)
481
-
482
-    def _getAdditionalBuildFiles(self, package):
483
-        listAdditionalFiles = []
470
+    def _getAdditionalBuildOptions(self, package):
471
+        pullsources_urls = []
484 472
         macros = []
485 473
         if package in constants.buildOptions.keys():
486 474
             pkg = constants.buildOptions[package]
487
-            filelist = pkg["files"]
488
-            for f in filelist:
489
-                listAdditionalFiles.append(f)
490
-            macrolist = pkg["macros"]
491
-            for macro in macrolist:
492
-                macros.append(macro)
493
-        return listAdditionalFiles, macros
475
+            pullsources_urls.extend(pkg["pullsources"])
476
+            macros.extend(pkg["macros"])
477
+        return pullsources_urls, macros
494 478
 
495 479
 
496 480
     def _buildRPM(self, specFile, logFile, chrootCmd, package, macros):
... ...
@@ -565,28 +551,6 @@ class PackageUtils(object):
565 565
             copyCmd = "docker cp " + sourcePath[0] + " " + containerID.short_id + ":" + destDir
566 566
             cmdUtils.runCommandInShell(copyCmd)
567 567
 
568
-    def _copyAdditionalBuildFilesToContainer(self, listAdditionalFiles, containerID):
569
-        cmdUtils = CommandUtils()
570
-        #self.logger.debug("VDBG-PU-copyAdditionalBuildFilesToContainer id: " +
571
-        #                  containerID.short_id)
572
-        #self.logger.debug(listAdditionalFiles)
573
-        for additionalFile in listAdditionalFiles:
574
-            source = additionalFile["src"]
575
-            destDir = additionalFile["dst"]
576
-            destPath = containerID.short_id + ":" + destDir
577
-            #TODO: exit status of exec_run
578
-            containerID.exec_run("mkdir -p " + destDir)
579
-            if os.path.exists(source):
580
-                copyCmd = "docker cp " + source
581
-                if os.path.isfile(source):
582
-                    self.logger.debug("Copying additional source file: " + source)
583
-                    copyCmd += " " + destPath
584
-                else:
585
-                    self.logger.debug("Copying additional source file tree: " + source)
586
-                    copyCmd += "/. " + destPath
587
-                #TODO: cmd error code
588
-                cmdUtils.runCommandInShell(copyCmd)
589
-
590 568
     def _getRPMPathInContainer(self, rpmFile, containerID):
591 569
         rpmName = os.path.basename(rpmFile)
592 570
         #TODO: Container path from constants
... ...
@@ -10,7 +10,8 @@ import json
10 10
 import os
11 11
 import hashlib
12 12
 import requests
13
-from requests.auth import HTTPBasicAuth
13
+import string
14
+import random
14 15
 from CommandUtils import CommandUtils
15 16
 
16 17
 def getFileHash(filepath):
... ...
@@ -22,7 +23,7 @@ def getFileHash(filepath):
22 22
         f.close()
23 23
     return sha1.hexdigest()
24 24
 
25
-def get(package, source, sha1, sourcesPath, configs, logger):
25
+def get(package, source, sha1, sourcesPath, URLs, logger):
26 26
     cmdUtils = CommandUtils()
27 27
     sourcePath = cmdUtils.findFile(source, sourcesPath)
28 28
     if sourcePath is not None and len(sourcePath) > 0:
... ...
@@ -35,70 +36,53 @@ def get(package, source, sha1, sourcesPath, configs, logger):
35 35
         else:
36 36
             logger.info("sha1 of " + sourcePath[0] + " does not match. " + sha1 +
37 37
                         " vs " + getFileHash(sourcePath[0]))
38
-    configFiles = configs.split(":")
39
-    for config in configFiles:
40
-        p = pullSources(config, logger)
41
-        package_path = os.path.join(sourcesPath, source)
38
+    for baseurl in URLs:
39
+        #form url: https://dl.bintray.com/vmware/photon_sources/1.0/<filename>.
40
+        url = '%s/%s' % (baseurl, source)
41
+        destfile = os.path.join(sourcesPath, source)
42
+        logger.debug("Downloading: " + url)
42 43
         try:
43
-            p.downloadFileHelper(package, source, package_path, sha1)
44
+            downloadFile(url, destfile)
45
+            if sha1 != getFileHash(destfile):
46
+                raise Exception('Invalid sha1 for package %s file %s' % package, source)
44 47
             return
48
+        except requests.exceptions.HTTPError as e:
49
+            logger.exception(e)
50
+            # on any HTTP errors - try next config
51
+            continue
45 52
         except Exception as e:
46 53
             logger.exception(e)
47 54
     raise Exception("Missing source: " + source)
48 55
 
49
-class pullSources:
50
-
51
-    def __init__(self, conf_file, logger):
52
-        self._config = {}
53
-        self.logger = logger
54
-        self.loadConfig(conf_file)
55
-
56
-        # generate the auth
57
-        self._auth = None
58
-        if ('user' in self._config and len(self._config['user']) > 0 and
59
-                'apikey' in self._config and len(self._config['apikey'])) > 0:
60
-            self._auth = HTTPBasicAuth(self._config['user'], self._config['apikey'])
61
-
62
-    def loadConfig(self, conf_file):
63
-        with open(conf_file) as jsonFile:
64
-            self._config = json.load(jsonFile)
56
+def downloadFile(url, destfile):
57
+    # We need to provide atomicity for file downloads. That is,
58
+    # the file should be visible in its canonical location only
59
+    # when the download is complete. To achieve that, first
60
+    # download to a temporary location (on the same filesystem)
61
+    # and then rename it to the final destination filename.
65 62
 
66
-    def downloadFile(self, package, filename, file_path):
67
-        #form url: https://dl.bintray.com/vmware/photon_sources/1.0/<filename>.
68
-        url = '%s/%s' % (self._config['baseurl'], filename)
69
-
70
-        self.logger.debug("Downloading: " + url)
71
-
72
-        # We need to provide atomicity for file downloads. That is,
73
-        # the file should be visible in its canonical location only
74
-        # when the download is complete. To achieve that, first
75
-        # download to a temporary location (on the same filesystem)
76
-        # and then rename it to the final destination filename.
63
+    temp_file = destfile + "-" + \
64
+                "".join([random.choice(
65
+                    string.ascii_letters + string.digits) for _ in range(6)])
77 66
 
78
-        temp_file_path = file_path + "-" + package
67
+    response = requests.get(url, stream=True)
79 68
 
80
-        with open(temp_file_path, 'wb') as handle:
81
-            response = requests.get(url, auth=self._auth, stream=True)
69
+    if not response.ok:
70
+        # Something went wrong
71
+        response.raise_for_status()
82 72
 
83
-            if not response.ok:
84
-                # Something went wrong
85
-                raise Exception(response.text)
73
+    with open(temp_file, 'wb') as handle:
74
+        for block in response.iter_content(1024):
75
+            if not block:
76
+                break
77
+            handle.write(block)
78
+        handle.flush()
79
+    response.close()
86 80
 
87
-            for block in response.iter_content(1024):
88
-                if not block:
89
-                    break
90
-                handle.write(block)
91
-            handle.flush()
92
-            response.close()
93
-
94
-        if os.path.exists(file_path):
95
-            os.remove(temp_file_path)
96
-        else:
97
-            os.rename(temp_file_path, file_path)
81
+    if os.path.exists(destfile):
82
+        os.remove(temp_file)
83
+    else:
84
+        os.rename(temp_file, destfile)
98 85
 
99
-        return file_path
86
+    return destfile
100 87
 
101
-    def downloadFileHelper(self, package, filename, file_path, package_sha1=None):
102
-        self.downloadFile(package, filename, file_path)
103
-        if package_sha1 != getFileHash(file_path):
104
-            raise Exception('Invalid sha1 for package %s file %s' % package, filename)
... ...
@@ -129,13 +129,16 @@ class SpecParser(object):
129 129
             raise Exception("Given string is not a conditional macro")
130 130
 
131 131
         def _is_macro_defined(macro):
132
-            return (macro in self.defs.keys()) or (macro in constants.userDefinedMacros.keys())
132
+            return (macro in self.defs.keys()) or (macro in constants.userDefinedMacros.keys()) \
133
+                or (macro in constants.getAdditionalMacros(self.packages["default"].name).keys())
133 134
 
134 135
         def _get_macro(macro):
135 136
             if macro in self.defs.keys():
136 137
                 return self.defs[macro]
137 138
             elif macro in constants.userDefinedMacros.keys():
138 139
                 return constants.userDefinedMacros[macro]
140
+            elif macro in constants.getAdditionalMacros(self.packages["default"].name).keys():
141
+                return constants.getAdditionalMacros(self.packages["default"].name)[macro]
139 142
             raise Exception("Unknown macro: " + macro)
140 143
 
141 144
         def _macro_repl(match):
... ...
@@ -1,5 +1,3 @@
1 1
 {
2
-  "baseurl":"https://dl.bintray.com/vmware/photon_sources/1.0",
3
-  "user":"",
4
-  "apikey":""
2
+  "baseurl":"https://dl.bintray.com/vmware/photon_sources/1.0"
5 3
 }
... ...
@@ -161,7 +161,7 @@ def main():
161 161
         constants.setPrevPublishRPMRepo(options.publishRPMSPath)
162 162
         constants.setPrevPublishXRPMRepo(options.publishXRPMSPath)
163 163
         constants.setBuildRootPath(options.buildRootPath)
164
-        constants.setPullSourcesConfig(options.pullsourcesConfig)
164
+        constants.setPullSourcesURL(get_baseurl(options.pullsourcesConfig))
165 165
         constants.setInputRPMSPath(options.inputRPMSPath)
166 166
         constants.setRPMCheck(options.rpmCheck)
167 167
         constants.setRpmCheckStopOnError(options.rpmCheckStopOnError)
... ...
@@ -229,6 +229,11 @@ def get_packages_with_build_options(pkg_build_options_file):
229 229
             pkg_build_option_json = json.load(jsonData, object_pairs_hook=collections.OrderedDict)
230 230
             constants.setBuildOptions(pkg_build_option_json)
231 231
 
232
+def get_baseurl(conf_file):
233
+    with open(conf_file) as jsonFile:
234
+        config = json.load(jsonFile)
235
+    return config['baseurl']
236
+
232 237
 def get_all_package_names(build_install_option):
233 238
     base_path = os.path.dirname(build_install_option)
234 239
     packages = []
... ...
@@ -10,7 +10,8 @@ class constants(object):
10 10
     buildRootPath = "/mnt"
11 11
     prevPublishRPMRepo = ""
12 12
     prevPublishXRPMRepo = ""
13
-    pullsourcesConfig = ""
13
+    pullsourcesURL = ""
14
+    extrasourcesURLs = {}
14 15
     buildPatch = False
15 16
     inputRPMSPath = ""
16 17
     rpmCheck = False
... ...
@@ -541,8 +542,19 @@ class constants(object):
541 541
         constants.buildRootPath = buildRootPath
542 542
 
543 543
     @staticmethod
544
-    def setPullSourcesConfig(pullSourcesConfig):
545
-        constants.pullsourcesConfig = pullSourcesConfig
544
+    def setPullSourcesURL(url):
545
+        constants.pullsourcesURL = url
546
+
547
+    @staticmethod
548
+    def setExtraSourcesURLs(packageName, urls):
549
+        constants.extrasourcesURLs[packageName] = urls
550
+
551
+    @staticmethod
552
+    def getPullSourcesURLs(packageName):
553
+        urls=[]
554
+        urls.append(constants.pullsourcesURL)
555
+        urls.extend(constants.extrasourcesURLs[packageName])
556
+        return urls
546 557
 
547 558
     @staticmethod
548 559
     def setInputRPMSPath(inputRPMSPath):
... ...
@@ -615,3 +627,13 @@ class constants(object):
615 615
     @staticmethod
616 616
     def setBuildOptions(options):
617 617
         constants.buildOptions = options
618
+
619
+    @staticmethod
620
+    def getAdditionalMacros(package):
621
+        macros = {}
622
+        if package in constants.buildOptions.keys():
623
+            pkg = constants.buildOptions[package]
624
+            for m in pkg["macros"]:
625
+                k, v = m.split(' ', 1)
626
+                macros[k] = v
627
+        return macros