Browse code

Added support to build debug iso

Change-Id: I9bdc12608bcddbdf5a392e917b096b51275d005f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2176
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Xiaolin Li <xiaolinl@vmware.com>

dthaluru authored on 2017/03/25 02:31:04
Showing 2 changed files
... ...
@@ -79,6 +79,7 @@ micro-iso: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES_MICRO)
79 79
 	@cd $(PHOTON_INSTALLER_DIR) && \
80 80
         $(PHOTON_INSTALLER) \
81 81
                 -i $(PHOTON_STAGE)/photon-micro-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
82
+                -k $(PHOTON_STAGE)/photon-micro-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
82 83
                 -w $(PHOTON_STAGE)/photon_iso \
83 84
                 -l $(PHOTON_STAGE)/LOGS \
84 85
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -115,6 +116,7 @@ minimal-iso: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL)
115 115
 	@cd $(PHOTON_INSTALLER_DIR) && \
116 116
         $(PHOTON_INSTALLER) \
117 117
                 -i $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
118
+                -k $(PHOTON_STAGE)/photon-minimal-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
118 119
                 -w $(PHOTON_STAGE)/photon_iso \
119 120
                 -l $(PHOTON_STAGE)/LOGS \
120 121
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -146,6 +148,7 @@ live-iso: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) minimal-iso
146 146
 	@cd $(PHOTON_INSTALLER_DIR) && \
147 147
         $(PHOTON_INSTALLER) \
148 148
                 -i $(PHOTON_STAGE)/photon-live-iso-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
149
+                -k $(PHOTON_STAGE)/photon-live-iso-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
149 150
                 -w $(PHOTON_STAGE)/photon_iso \
150 151
                 -l $(PHOTON_STAGE)/LOGS \
151 152
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -179,6 +182,7 @@ iso: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES) ostree-repo
179 179
 	@cd $(PHOTON_INSTALLER_DIR) && \
180 180
         sudo $(PHOTON_INSTALLER) \
181 181
                 -i $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).iso \
182
+                -k $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER).debug.iso \
182 183
                 -w $(PHOTON_STAGE)/photon_iso \
183 184
                 -l $(PHOTON_STAGE)/LOGS \
184 185
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -195,6 +199,7 @@ custom-iso: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES)
195 195
 	@cd $(PHOTON_INSTALLER_DIR) && \
196 196
         sudo $(PHOTON_INSTALLER) \
197 197
                 -i $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER)-custom.iso \
198
+                -k $(PHOTON_STAGE)/photon-$(PHOTON_RELEASE_VERSION)-$(PHOTON_BUILD_NUMBER)-custom.debug.iso \
198 199
                 -w $(PHOTON_STAGE)/photon_iso \
199 200
                 -l $(PHOTON_STAGE)/LOGS \
200 201
                 -r $(PHOTON_STAGE)/RPMS \
... ...
@@ -99,7 +99,7 @@ def create_rpm_list_to_be_copied_to_iso(pkg_to_rpm_map_file, build_install_optio
99 99
                 rpm_list.append(get_file_name_with_last_folder(filename))
100 100
             if not pkg_to_rpm_map[k]['debugrpm'] is None and bool(copy_flags & 2):
101 101
                 filename = pkg_to_rpm_map[k]['debugrpm']
102
-                rpm_list.append(get_file_name_with_last_folder(filename))
102
+                rpm_list.append(pkg_to_rpm_map[k]['debugrpm'])
103 103
             if not pkg_to_rpm_map[k]['sourcerpm'] is None and bool(copy_flags & 4):
104 104
                 rpm_list.append(pkg_to_rpm_map[k]['sourcerpm'])
105 105
     return rpm_list
... ...
@@ -140,11 +140,33 @@ def make_src_iso(working_directory, src_iso_path, rpm_list):
140 140
     process = subprocess.Popen(['rm', '-rf', options.working_directory])
141 141
     retval = process.wait()
142 142
 
143
+def make_debug_iso(working_directory, debug_iso_path, rpm_list):
144
+    if os.path.isdir(working_directory):
145
+        process = subprocess.Popen(['rm', '-rf', working_directory])
146
+        retval = process.wait()
147
+    process = subprocess.Popen(['mkdir', '-p', os.path.join(working_directory, "DEBUGRPMS")])
148
+    retval = process.wait()
149
+    for aaa in rpm_list:
150
+        if os.path.isfile(aaa):
151
+            dirname = os.path.dirname(aaa)
152
+            lastfolder = os.path.basename(dirname)
153
+            dest_working_directory = os.path.join(working_directory, "DEBUGRPMS", lastfolder)
154
+            if not os.path.isdir(dest_working_directory):
155
+                process = subprocess.Popen(['mkdir', dest_working_directory])
156
+                retval = process.wait()
157
+            process = subprocess.Popen(['cp', aaa, dest_working_directory])
158
+            retval = process.wait()
159
+    process = subprocess.Popen(['mkisofs', '-r', '-o', debug_iso_path, working_directory])
160
+    retval = process.wait()
161
+    process = subprocess.Popen(['rm', '-rf', options.working_directory])
162
+    retval = process.wait()
163
+
143 164
 if __name__ == '__main__':
144 165
     usage = "Usage: %prog [options] <config file> <tools path>"
145 166
     parser = ArgumentParser(usage)
146 167
     parser.add_argument("-i", "--iso-path",  dest="iso_path")
147 168
     parser.add_argument("-j", "--src-iso-path",  dest="src_iso_path")
169
+    parser.add_argument("-k", "--debug-iso-path",  dest="debug_iso_path")
148 170
     parser.add_argument("-v", "--vmdk-path", dest="vmdk_path")
149 171
     parser.add_argument("-w",  "--working-directory",  dest="working_directory", default="/mnt/photon-root")
150 172
     parser.add_argument("-l",  "--log-path",  dest="log_path", default="../stage/LOGS")
... ...
@@ -237,18 +259,22 @@ if __name__ == '__main__':
237 237
 
238 238
         # Making the iso if needed
239 239
         if options.iso_path:
240
-            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))
240
+            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))
241 241
             files_to_copy = " ".join(create_additional_file_list_to_copy_in_iso(os.path.abspath(options.stage_path), options.package_list_file))
242 242
             live_cd = get_live_cd_status_string(options.package_list_file)
243 243
             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])
244 244
             retval = process.wait()
245 245
 
246
+        if options.debug_iso_path:
247
+            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)
248
+            make_debug_iso(options.working_directory, options.debug_iso_path, debug_rpm_list)
249
+
246 250
         # Cleaning up for vmdk
247 251
         if 'vmdk_install' in config and config['vmdk_install']:
248 252
             process = subprocess.Popen(['./mk-clean-vmdk.sh', config['disk']['disk']])
249 253
             process.wait()
250 254
 
251 255
         #Clean up the working directories
252
-        if (options.iso_path or options.vmdk_path):
256
+        if (options.iso_path or options.vmdk_path or options.debug_iso_path):
253 257
             process = subprocess.Popen(['rm', '-rf', options.working_directory])
254 258
             retval = process.wait()