Browse code

Added fix for generating the json files for cloud images

Harish Udaiya Kumar authored on 2015/08/15 08:52:26
Showing 4 changed files
... ...
@@ -34,6 +34,11 @@ PHOTON_MICRO_DEPLIST := micro-dep-list
34 34
 PHOTON_FULL_DEPLIST := full-dep-list
35 35
 PREPARE_OUT_DATADIR := prepare-out-datadir
36 36
 
37
+MINIMAL_PACKAGE_LIST_FILE := build_install_options_minimal.json
38
+MICRO_PACKAGE_LIST_FILE := build_install_options_micro.json
39
+FULL_PACKAGE_LIST_FILE := build_install_options_all.json
40
+CLOUDALL_PACKAGE_LIST_FILE := build_install_options_cloudall.json
41
+
37 42
 ifdef PHOTON_PUBLISH_RPMS_PATH
38 43
 PHOTON_PUBLISH_RPMS := publish-rpms-cached
39 44
 else
... ...
@@ -61,7 +66,8 @@ micro-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MICRO) $(PHOTON_MICRO_DEPLIST
61 61
                 -w $(PHOTON_STAGE)/photon_iso \
62 62
                 -l $(PHOTON_STAGE)/LOGS \
63 63
                 -r $(PHOTON_STAGE)/RPMS \
64
-                -p $(PHOTON_DATA_DIR)/build_install_options_micro.json \
64
+                -p $(PHOTON_DATA_DIR)/$(MICRO_PACKAGE_LIST_FILE) \
65
+                -o $(PHOTON_STAGE)/common/data \
65 66
                 -f > \
66 67
                 $(PHOTON_LOGS_DIR)/installer.log 2>&1
67 68
 
... ...
@@ -71,7 +77,7 @@ $(PHOTON_MICRO_DEPLIST): check $(PREPARE_OUT_DATADIR)
71 71
 		$(PHOTON_SPECDEPS) \
72 72
 		-s $(PHOTON_SPECS_DIR) \
73 73
 		-t $(PHOTON_STAGE) \
74
-		--input-type=json --file packages_micro.json -d json -t $(PHOTON_STAGE) -a $(PHOTON_DATA_DIR)
74
+		--input-type=json --file $(MICRO_PACKAGE_LIST_FILE) -d json -t $(PHOTON_STAGE) -a $(PHOTON_DATA_DIR)
75 75
 	@echo "generated the json file with all dependencies for micro installation"
76 76
 
77 77
 deptree-micro:
... ...
@@ -79,7 +85,7 @@ deptree-micro:
79 79
 		$(PHOTON_SPECDEPS) \
80 80
 		-s $(PHOTON_SPECS_DIR) \
81 81
 		-t $(PHOTON_STAGE) \
82
-		-i json -f packages_micro.json -a $(PHOTON_DATA_DIR)
82
+		-i json -f $(MICRO_PACKAGE_LIST_FILE) -a $(PHOTON_DATA_DIR)
83 83
 
84 84
 packages-micro: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
85 85
 	@echo "Building all Micro RPMS..."
... ...
@@ -91,7 +97,7 @@ packages-micro: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
91 91
                 -b $(PHOTON_CHROOT_PATH) \
92 92
                 -l $(PHOTON_LOGS_DIR) \
93 93
                 -p $(PHOTON_PUBLISH_RPMS_DIR) \
94
-                -j $(PHOTON_DATA_DIR)/build_install_options_micro.json \
94
+                -j $(PHOTON_DATA_DIR)/$(MICRO_PACKAGE_LIST_FILE) \
95 95
 		-c $(PHOTON_BINTRAY_CONFIG) \
96 96
 		-d $(PHOTON_DIST_TAG) \
97 97
                 -t ${THREADS}
... ...
@@ -104,7 +110,7 @@ deptree-minimal:
104 104
 		$(PHOTON_SPECDEPS) \
105 105
 		-s $(PHOTON_SPECS_DIR) \
106 106
 		-t $(PHOTON_STAGE) \
107
-		-i json -f packages_minimal.json -a $(PHOTON_DATA_DIR) 
107
+		-i json -f $(MINIMAL_PACKAGE_LIST_FILE) -a $(PHOTON_DATA_DIR) 
108 108
 
109 109
 minimal-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) $(PHOTON_MINIMAL_DEPLIST)
110 110
 	@echo "Building Photon Minimal ISO..."
... ...
@@ -113,7 +119,8 @@ minimal-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) $(PHOTON_MINIMAL_D
113 113
                 -w $(PHOTON_STAGE)/photon_iso \
114 114
                 -l $(PHOTON_STAGE)/LOGS \
115 115
                 -r $(PHOTON_STAGE)/RPMS \
116
-                -p $(PHOTON_DATA_DIR)/build_install_options_minimal.json \
116
+                -p $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) \
117
+                -o $(PHOTON_STAGE)/common/data \
117 118
                 -f > \
118 119
                 $(PHOTON_LOGS_DIR)/installer.log 2>&1
119 120
 
... ...
@@ -125,6 +132,7 @@ ostree-host-iso: check $(PHOTON_STAGE) ostree-repo
125 125
                 -l $(PHOTON_STAGE)/LOGS \
126 126
                 -r $(PHOTON_STAGE)/RPMS \
127 127
                 -p $(PHOTON_DATA_DIR)/build_install_options_ostreehost.json \
128
+                -o $(PHOTON_STAGE)/common/data \
128 129
                 -f > \
129 130
                 $(PHOTON_LOGS_DIR)/installer.log 2>&1
130 131
 
... ...
@@ -136,6 +144,7 @@ live-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) minimal-iso
136 136
                 -l $(PHOTON_STAGE)/LOGS \
137 137
                 -r $(PHOTON_STAGE)/RPMS \
138 138
                 -p $(PHOTON_GENERATED_DATA_DIR)/build_install_options_livecd.json \
139
+                -o $(PHOTON_STAGE)/common/data \
139 140
                 -f > \
140 141
                 $(PHOTON_LOGS_DIR)/installer.log 2>&1                
141 142
 
... ...
@@ -145,7 +154,7 @@ $(PHOTON_MINIMAL_DEPLIST): $(PREPARE_OUT_DATADIR)
145 145
 		$(PHOTON_SPECDEPS) \
146 146
 		-s $(PHOTON_SPECS_DIR) \
147 147
 		-t $(PHOTON_STAGE) \
148
-		--input-type=json --file packages_minimal.json -d json -a $(PHOTON_DATA_DIR)
148
+		--input-type=json --file $(MINIMAL_PACKAGE_LIST_FILE) -d json -a $(PHOTON_DATA_DIR)
149 149
 	@echo "generated the json file with all dependencies for minimal installation"
150 150
 
151 151
 packages-minimal: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
... ...
@@ -158,7 +167,7 @@ packages-minimal: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
158 158
                 -b $(PHOTON_CHROOT_PATH) \
159 159
                 -l $(PHOTON_LOGS_DIR) \
160 160
                 -p $(PHOTON_PUBLISH_RPMS_DIR) \
161
-                -j $(PHOTON_DATA_DIR)/build_install_options_minimal.json \
161
+                -j $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) \
162 162
 		-c $(PHOTON_BINTRAY_CONFIG) \
163 163
 		-d $(PHOTON_DIST_TAG) \
164 164
                 -t ${THREADS}
... ...
@@ -170,8 +179,8 @@ iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES) ostree-repo $(PHOTON_FULL_DEPLIST)
170 170
                 -w $(PHOTON_STAGE)/photon_iso \
171 171
                 -l $(PHOTON_STAGE)/LOGS \
172 172
                 -r $(PHOTON_STAGE)/RPMS \
173
-                -p $(PHOTON_DATA_DIR)/build_install_options_all.json \
174
-				-o $(PHOTON_STAGE)/common/data \
173
+                -p $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
174
+		        -o $(PHOTON_STAGE)/common/data \
175 175
                 -f > \
176 176
                 $(PHOTON_LOGS_DIR)/installer.log 2>&1
177 177
 
... ...
@@ -181,7 +190,7 @@ $(PHOTON_FULL_DEPLIST): $(PHOTON_MINIMAL_DEPLIST)
181 181
 		$(PHOTON_SPECDEPS) \
182 182
 		-s $(PHOTON_SPECS_DIR) \
183 183
 		-t $(PHOTON_STAGE) \
184
-		--input-type=json --file packages_full.json -d json -a $(PHOTON_DATA_DIR)
184
+		--input-type=json --file $(FULL_PACKAGE_LIST_FILE) -d json -a $(PHOTON_DATA_DIR)
185 185
 	@echo "generated the json file with all dependencies for full installation"
186 186
 
187 187
 deptree-full:
... ...
@@ -189,7 +198,7 @@ deptree-full:
189 189
 		$(PHOTON_SPECDEPS) \
190 190
 		-s $(PHOTON_SPECS_DIR) \
191 191
 		-t $(PHOTON_STAGE) \
192
-		-i json -f packages_full.json -a $(PHOTON_DATA_DIR)
192
+		-i json -f $(FULL_PACKAGE_LIST_FILE) -a $(PHOTON_DATA_DIR)
193 193
 
194 194
 deptree:
195 195
 	@cd $(PHOTON_SPECDEPS_DIR) && \
... ...
@@ -209,7 +218,7 @@ packages: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN)
209 209
                 -b $(PHOTON_CHROOT_PATH) \
210 210
                 -l $(PHOTON_LOGS_DIR) \
211 211
                 -p $(PHOTON_PUBLISH_RPMS_DIR) \
212
-                -j $(PHOTON_DATA_DIR)/build_install_options_all.json \
212
+                -j $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
213 213
 		-c $(PHOTON_BINTRAY_CONFIG) \
214 214
 		-d $(PHOTON_DIST_TAG) \
215 215
                 -t ${THREADS}
... ...
@@ -224,7 +233,7 @@ tool-chain-stage1: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN)
224 224
                 -b $(PHOTON_CHROOT_PATH) \
225 225
                 -l $(PHOTON_LOGS_DIR) \
226 226
                 -p $(PHOTON_PUBLISH_RPMS_DIR) \
227
-                -j $(PHOTON_DATA_DIR)/build_install_options_all.json \
227
+                -j $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
228 228
                 -t ${THREADS} \
229 229
 		-c $(PHOTON_BINTRAY_CONFIG) \
230 230
 		-d $(PHOTON_DIST_TAG) \
... ...
@@ -240,7 +249,7 @@ tool-chain-stage2: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN)
240 240
                 -b $(PHOTON_CHROOT_PATH) \
241 241
                 -l $(PHOTON_LOGS_DIR) \
242 242
                 -p $(PHOTON_PUBLISH_RPMS_DIR) \
243
-                -j $(PHOTON_DATA_DIR)/build_install_options_all.json \
243
+                -j $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
244 244
                 -t ${THREADS} \
245 245
 		-c $(PHOTON_BINTRAY_CONFIG) \
246 246
 		-d $(PHOTON_DIST_TAG) \
... ...
@@ -371,6 +380,13 @@ photon-vagrant-local: check-packer check-vagrant
371 371
 	fi
372 372
 
373 373
 cloud-image: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso
374
+	@echo "Generating the install time dependency list for "$(IMG_NAME)
375
+	@cd $(PHOTON_SPECDEPS_DIR) && \
376
+		$(PHOTON_SPECDEPS) \
377
+		-s $(PHOTON_SPECS_DIR) \
378
+		-t $(PHOTON_STAGE) \
379
+		--input-type=json --file build_install_options_$(IMG_NAME).json -d json -a $(PHOTON_DATA_DIR)
380
+	@echo "generated the json file with all dependencies for "$(IMG_NAME)
374 381
 	@echo "Building cloud image $(IMG_NAME)..."
375 382
 	@cd $(PHOTON_CLOUD_IMAGE_BUILDER_DIR)
376 383
 	@if [ -e $(PHOTON_STAGE)/photon.iso ]; then \
... ...
@@ -383,6 +399,13 @@ cloud-image: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso
383 383
 
384 384
 
385 385
 cloud-image-all: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso
386
+	@echo "Generating the install time dependency list for full installation"
387
+	@cd $(PHOTON_SPECDEPS_DIR) && \
388
+		$(PHOTON_SPECDEPS) \
389
+		-s $(PHOTON_SPECS_DIR) \
390
+		-t $(PHOTON_STAGE) \
391
+		--input-type=json --file $(CLOUDALL_PACKAGE_LIST_FILE) -d json -a $(PHOTON_DATA_DIR)
392
+	@echo "generated the json file with all dependencies for full installation"
386 393
 	@echo "Building cloud images - gce, ami, azure and ova..."
387 394
 	@cd $(PHOTON_CLOUD_IMAGE_BUILDER_DIR)
388 395
 	@if [ -e $(PHOTON_STAGE)/photon.iso ]; then \
389 396
new file mode 100644
... ...
@@ -0,0 +1,38 @@
0
+{
1
+    "iso" : {
2
+        "title" : "ISO Packages",
3
+        "file" : "packages_iso.json",
4
+        "visible" : false,
5
+        "include" : []
6
+    },
7
+    "minimal" : {
8
+        "title" : "Photon Minimal",
9
+        "file" : "packages_minimal.json",
10
+        "visible" : true,
11
+        "include" : []
12
+    },
13
+    "ami" : {
14
+        "title" : "Photon AMI packages",
15
+        "file" : "packages_ami.json",
16
+        "visible" : false,
17
+        "include" : ["minimal"]
18
+    },
19
+    "azure" : {
20
+        "title" : "Photon Azure packages",
21
+        "file" : "packages_azure.json",
22
+        "visible" : false,
23
+        "include" : ["minimal"]
24
+    },
25
+    "gce" : {
26
+        "title" : "Photon GCE packages",
27
+        "file" : "packages_gce.json",
28
+        "visible" : false,
29
+        "include" : ["minimal"]
30
+    },
31
+    "minimal_ova" : {
32
+        "title" : "Photon Minimal",
33
+        "file" : "packages_minimal_ova.json",
34
+        "visible" : false,
35
+        "include" : []
36
+    }
37
+}
... ...
@@ -9,6 +9,7 @@ from SpecData import SerializedSpecObjects
9 9
 import sys
10 10
 import os
11 11
 from optparse import OptionParser
12
+from jsonwrapper import JsonWrapper
12 13
 
13 14
 DEFAULT_INPUT_TYPE = "pkg"
14 15
 DEFAULT_DISPLAY_OPTION = "tree"
... ...
@@ -26,8 +27,14 @@ def main():
26 26
 	parser.add_option("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR)
27 27
 	parser.add_option("-t", "--stage-dir", dest="stage_dir", default="../../stage")
28 28
 	parser.add_option("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/")
29
-
30 29
 	(options,  args) = parser.parse_args() 
30
+
31
+
32
+	if(False == options.input_data_dir.endswith('/')):
33
+		options.input_data_dir += '/'
34
+	
35
+		
36
+
31 37
 	specDeps = SerializedSpecObjects(options.input_data_dir, options.stage_dir)
32 38
 	displayOption = options.display_option
33 39
 	abs_path = os.path.abspath(__file__)
... ...
@@ -39,7 +46,13 @@ def main():
39 39
 	elif(options.input_type == "json"):
40 40
 		targetName = options.json_file
41 41
 
42
-	specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, targetName, displayOption)
42
+	 # Generate the package dependencies based on package_list_file
43
+	json_wrapper_option_list = JsonWrapper(options.input_data_dir + options.json_file)
44
+	option_list_json = json_wrapper_option_list.read()
45
+	options_sorted = option_list_json.items()
46
+	for install_option in options_sorted:
47
+		if install_option[1]["file"] != "iso":
48
+			specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, install_option[1]["file"], displayOption)
43 49
 	
44 50
 	sys.exit(0)
45 51
 
46 52
new file mode 100644
... ...
@@ -0,0 +1,25 @@
0
+#!/usr/bin/python2
1
+#
2
+#    Copyright (C) 2015 vmware inc.
3
+#
4
+#    Author: Sharath George <sharathg@vmware.com>
5
+
6
+
7
+import json
8
+import collections
9
+
10
+class JsonWrapper(object):
11
+
12
+    def __init__(self,  filename):
13
+        self.filename = filename
14
+
15
+    def read(self):
16
+        json_data = open(self.filename)
17
+        self.data = json.load(json_data, object_pairs_hook=collections.OrderedDict)
18
+        json_data.close()
19
+        return self.data
20
+
21
+    def write(self,  data):
22
+        self.data = data
23
+        outfile = open(self.filename,  'wb')
24
+        json.dump(data,  outfile)