Browse code

Added support to build debug iso

Change-Id: I59b23199b1c782daad1f670ef1ad269c43972c79
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2227
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

dthaluru authored on 2017/03/25 02:31:04
Showing 2 changed files
... ...
@@ -68,6 +68,7 @@ micro-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MICRO)
68 68
 	@cd $(PHOTON_INSTALLER_DIR) && \
69 69
         $(PHOTON_INSTALLER) \
70 70
                 -i $(PHOTON_STAGE)/photon-micro-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
71
+                -k $(PHOTON_STAGE)/photon-micro-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
71 72
                 -w $(PHOTON_STAGE)/photon_iso \
72 73
                 -l $(PHOTON_STAGE)/LOGS \
73 74
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -104,6 +105,7 @@ minimal-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL)
104 104
 	@cd $(PHOTON_INSTALLER_DIR) && \
105 105
         $(PHOTON_INSTALLER) \
106 106
                 -i $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
107
+                -k $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
107 108
                 -w $(PHOTON_STAGE)/photon_iso \
108 109
                 -l $(PHOTON_STAGE)/LOGS \
109 110
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -135,6 +137,7 @@ live-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) minimal-iso
135 135
 	@cd $(PHOTON_INSTALLER_DIR) && \
136 136
         $(PHOTON_INSTALLER) \
137 137
                 -i $(PHOTON_STAGE)/photon-live-iso-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
138
+                -k $(PHOTON_STAGE)/photon-live-iso-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
138 139
                 -w $(PHOTON_STAGE)/photon_iso \
139 140
                 -l $(PHOTON_STAGE)/LOGS \
140 141
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -168,6 +171,7 @@ iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES) ostree-repo
168 168
 	@cd $(PHOTON_INSTALLER_DIR) && \
169 169
         sudo $(PHOTON_INSTALLER) \
170 170
                 -i $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
171
+                -k $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
171 172
                 -w $(PHOTON_STAGE)/photon_iso \
172 173
                 -l $(PHOTON_STAGE)/LOGS \
173 174
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -184,6 +188,7 @@ custom-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES)
184 184
 	@cd $(PHOTON_INSTALLER_DIR) && \
185 185
         sudo $(PHOTON_INSTALLER) \
186 186
                 -i $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER)-custom.iso \
187
+                -k $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER)-custom.debug.iso \
187 188
                 -w $(PHOTON_STAGE)/photon_iso \
188 189
                 -l $(PHOTON_STAGE)/LOGS \
189 190
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -126,7 +126,7 @@ def create_rpm_list_to_be_copied_to_iso(pkg_to_rpm_map_file, build_install_optio
126 126
                 rpm_list.append(get_file_name_with_last_folder(filename))
127 127
             if not pkg_to_rpm_map[k]['debugrpm'] is None and bool(copy_flags & 2):
128 128
                 filename = pkg_to_rpm_map[k]['debugrpm']
129
-                rpm_list.append(get_file_name_with_last_folder(filename))
129
+                rpm_list.append(pkg_to_rpm_map[k]['debugrpm'])
130 130
             if not pkg_to_rpm_map[k]['sourcerpm'] is None and bool(copy_flags & 4):
131 131
                 rpm_list.append(pkg_to_rpm_map[k]['sourcerpm'])
132 132
     return rpm_list
... ...
@@ -167,12 +167,34 @@ def make_src_iso(working_directory, src_iso_path, rpm_list):
167 167
     process = subprocess.Popen(['rm', '-rf', options.working_directory])
168 168
     retval = process.wait()
169 169
 
170
+def make_debug_iso(working_directory, debug_iso_path, rpm_list):
171
+    if os.path.isdir(working_directory):
172
+        process = subprocess.Popen(['rm', '-rf', working_directory])
173
+        retval = process.wait()
174
+    process = subprocess.Popen(['mkdir', '-p', os.path.join(working_directory, "DEBUGRPMS")])
175
+    retval = process.wait()
176
+    for aaa in rpm_list:
177
+        if os.path.isfile(aaa):
178
+            dirname = os.path.dirname(aaa)
179
+            lastfolder = os.path.basename(dirname)
180
+            dest_working_directory = os.path.join(working_directory, "DEBUGRPMS", lastfolder)
181
+            if not os.path.isdir(dest_working_directory):
182
+                process = subprocess.Popen(['mkdir', dest_working_directory])
183
+                retval = process.wait()
184
+            process = subprocess.Popen(['cp', aaa, dest_working_directory])
185
+            retval = process.wait()
186
+    process = subprocess.Popen(['mkisofs', '-r', '-o', debug_iso_path, working_directory])
187
+    retval = process.wait()
188
+    process = subprocess.Popen(['rm', '-rf', options.working_directory])
189
+    retval = process.wait()
190
+
170 191
 if __name__ == '__main__':
171 192
     usage = "Usage: %prog [options] <config file> <tools path>"
172 193
     parser = OptionParser(usage)
173 194
 
174 195
     parser.add_option("-i", "--iso-path",  dest="iso_path")
175 196
     parser.add_option("-j", "--src-iso-path",  dest="src_iso_path")
197
+    parser.add_option("-k", "--debug-iso-path",  dest="debug_iso_path")
176 198
     parser.add_option("-v", "--vmdk-path", dest="vmdk_path")
177 199
     parser.add_option("-w",  "--working-directory",  dest="working_directory", default="/mnt/photon-root")
178 200
     parser.add_option("-l",  "--log-path",  dest="log_path", default="../stage/LOGS")
... ...
@@ -265,18 +287,22 @@ if __name__ == '__main__':
265 265
 
266 266
         # Making the iso if needed
267 267
         if options.iso_path:
268
-            rpm_list = " ".join(create_rpm_list_to_be_copied_to_iso(options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 3, options.output_data_path))
268
+            rpm_list = " ".join(create_rpm_list_to_be_copied_to_iso(options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 1, options.output_data_path))
269 269
             files_to_copy = " ".join(create_additional_file_list_to_copy_in_iso(os.path.abspath(options.stage_path), options.package_list_file))
270 270
             live_cd = get_live_cd_status_string(options.package_list_file)
271 271
             process = subprocess.Popen(['./mk-install-iso.sh', '-w', options.working_directory, options.iso_path, options.rpm_path, options.package_list_file, rpm_list, options.stage_path, files_to_copy, live_cd, options.json_data_path])
272 272
             retval = process.wait()
273 273
 
274
+        if options.debug_iso_path:
275
+            debug_rpm_list = create_rpm_list_to_be_copied_to_iso(options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 2, options.output_data_path)
276
+            make_debug_iso(options.working_directory, options.debug_iso_path, debug_rpm_list)
277
+
274 278
         # Cleaning up for vmdk
275 279
         if 'vmdk_install' in config and config['vmdk_install']:
276 280
             process = subprocess.Popen(['./mk-clean-vmdk.sh', config['disk']['disk']])
277 281
             process.wait()
278 282
 
279 283
         #Clean up the working directories
280
-        if (options.iso_path or options.vmdk_path):
284
+        if (options.iso_path or options.vmdk_path or options.debug_iso_path):
281 285
             process = subprocess.Popen(['rm', '-rf', options.working_directory])
282 286
             retval = process.wait()