Change-Id: I489f6e5df3897f2d1d3fc253a44fdf57aad1658b
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4575
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-#! /usr/bin/python2 |
|
1 |
+#! /usr/bin/python3 |
|
2 | 2 |
# |
3 | 3 |
# Copyright (C) 2015 vmware inc. |
4 | 4 |
# |
... | ... |
@@ -43,7 +43,9 @@ def create_vmdk_and_partition(config, vmdk_path): |
43 | 43 |
firmware = "bios" |
44 | 44 |
if 'boot' in config and config['boot'] == 'efi': |
45 | 45 |
firmware = "efi" |
46 |
- process = subprocess.Popen(['./mk-setup-vmdk.sh', '-rp', config['size']['root'], '-sp', config['size']['swap'], '-n', vmdk_path, '-fm', firmware, '-m'], stdout=subprocess.PIPE) |
|
46 |
+ process = subprocess.Popen(['./mk-setup-vmdk.sh', '-rp', config['size']['root'], '-sp', |
|
47 |
+ config['size']['swap'], '-n', vmdk_path, '-fm', firmware, '-m'], |
|
48 |
+ stdout=subprocess.PIPE) |
|
47 | 49 |
count = 0 |
48 | 50 |
for line in iter(process.stdout.readline, ''): |
49 | 51 |
sys.stdout.write(line) |
... | ... |
@@ -57,7 +59,8 @@ def create_vmdk_and_partition(config, vmdk_path): |
57 | 57 |
count += 1 |
58 | 58 |
|
59 | 59 |
if count == 2: |
60 |
- partitions_data['partitions'] = [{'path': partitions_data['root'], 'mountpoint': '/', 'filesystem': 'ext4'}] |
|
60 |
+ partitions_data['partitions'] = [{'path': partitions_data['root'], 'mountpoint': '/', |
|
61 |
+ 'filesystem': 'ext4'}] |
|
61 | 62 |
|
62 | 63 |
return partitions_data, count == 2 |
63 | 64 |
|
... | ... |
@@ -83,7 +86,8 @@ def create_pkg_list_to_copy_to_iso(build_install_option, output_data_path): |
83 | 83 |
#copy_flags 1: add the rpm file for the package |
84 | 84 |
# 2: add debuginfo rpm file for the package. |
85 | 85 |
# 4: add src rpm file for the package |
86 |
-def create_rpm_list_to_be_copied_to_iso(pkg_to_rpm_map_file, build_install_option, copy_flags, output_data_path): |
|
86 |
+def create_rpm_list_to_be_copied_to_iso(pkg_to_rpm_map_file, build_install_option, copy_flags, |
|
87 |
+ output_data_path): |
|
87 | 88 |
packages = [] |
88 | 89 |
if build_install_option is None: |
89 | 90 |
packages = [] |
... | ... |
@@ -112,7 +116,9 @@ def create_additional_file_list_to_copy_in_iso(base_path, build_install_option): |
112 | 112 |
file_list = [] |
113 | 113 |
for install_option in options_sorted: |
114 | 114 |
if "additional-files" in install_option[1]: |
115 |
- file_list = file_list + map(lambda filename: os.path.join(base_path, filename), install_option[1].get("additional-files")) |
|
115 |
+ file_list = file_list + list(map( |
|
116 |
+ lambda filename: os.path.join(base_path, filename), |
|
117 |
+ install_option[1].get("additional-files"))) |
|
116 | 118 |
return file_list |
117 | 119 |
|
118 | 120 |
def get_live_cd_status_string(build_install_option): |
... | ... |
@@ -165,31 +171,40 @@ def make_debug_iso(working_directory, debug_iso_path, rpm_list): |
165 | 165 |
if __name__ == '__main__': |
166 | 166 |
usage = "Usage: %prog [options] <config file> <tools path>" |
167 | 167 |
parser = ArgumentParser(usage) |
168 |
- parser.add_argument("-i", "--iso-path", dest="iso_path") |
|
169 |
- parser.add_argument("-j", "--src-iso-path", dest="src_iso_path") |
|
170 |
- parser.add_argument("-k", "--debug-iso-path", dest="debug_iso_path") |
|
168 |
+ parser.add_argument("-i", "--iso-path", dest="iso_path") |
|
169 |
+ parser.add_argument("-j", "--src-iso-path", dest="src_iso_path") |
|
170 |
+ parser.add_argument("-k", "--debug-iso-path", dest="debug_iso_path") |
|
171 | 171 |
parser.add_argument("-v", "--vmdk-path", dest="vmdk_path") |
172 |
- parser.add_argument("-w", "--working-directory", dest="working_directory", default="/mnt/photon-root") |
|
173 |
- parser.add_argument("-l", "--log-path", dest="log_path", default="../stage/LOGS") |
|
174 |
- parser.add_argument("-r", "--rpm-path", dest="rpm_path", default="../stage/RPMS") |
|
175 |
- parser.add_argument("-x", "--srpm-path", dest="srpm_path", default="../stage/SRPMS") |
|
176 |
- parser.add_argument("-o", "--output-data-path", dest="output_data_path", default="../stage/common/data/") |
|
172 |
+ parser.add_argument("-w", "--working-directory", dest="working_directory", |
|
173 |
+ default="/mnt/photon-root") |
|
174 |
+ parser.add_argument("-l", "--log-path", dest="log_path", |
|
175 |
+ default="../stage/LOGS") |
|
176 |
+ parser.add_argument("-r", "--rpm-path", dest="rpm_path", default="../stage/RPMS") |
|
177 |
+ parser.add_argument("-x", "--srpm-path", dest="srpm_path", default="../stage/SRPMS") |
|
178 |
+ parser.add_argument("-o", "--output-data-path", dest="output_data_path", |
|
179 |
+ default="../stage/common/data/") |
|
177 | 180 |
parser.add_argument("-f", "--force", action="store_true", dest="force", default=False) |
178 |
- parser.add_argument("-p", "--package-list-file", dest="package_list_file", default="../common/data/build_install_options_all.json") |
|
181 |
+ parser.add_argument("-p", "--package-list-file", dest="package_list_file", |
|
182 |
+ default="../common/data/build_install_options_all.json") |
|
179 | 183 |
parser.add_argument("-m", "--stage-path", dest="stage_path", default="../stage") |
180 |
- parser.add_argument("-s", "--json-data-path", dest="json_data_path", default="../stage/common/data/") |
|
181 |
- parser.add_argument("-d", "--pkg-to-rpm-map-file", dest="pkg_to_rpm_map_file", default="../stage/pkg_info.json") |
|
184 |
+ parser.add_argument("-s", "--json-data-path", dest="json_data_path", |
|
185 |
+ default="../stage/common/data/") |
|
186 |
+ parser.add_argument("-d", "--pkg-to-rpm-map-file", dest="pkg_to_rpm_map_file", |
|
187 |
+ default="../stage/pkg_info.json") |
|
182 | 188 |
parser.add_argument("-c", "--pkg-to-be-copied-conf-file", dest="pkg_to_be_copied_conf_file") |
183 | 189 |
parser.add_argument('configfile', nargs='?') |
184 | 190 |
options = parser.parse_args() |
185 | 191 |
# Cleanup the working directory |
186 | 192 |
if not options.force: |
187 |
- proceed = query_yes_no("This will remove everything under {0}. Are you sure?".format(options.working_directory)) |
|
193 |
+ proceed = query_yes_no("This will remove everything under {0}. " + |
|
194 |
+ "Are you sure?".format(options.working_directory)) |
|
188 | 195 |
if not proceed: |
189 | 196 |
sys.exit(0) |
190 | 197 |
|
191 | 198 |
if options.src_iso_path: |
192 |
- rpm_list = create_rpm_list_to_be_copied_to_iso(options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 4, options.output_data_path) |
|
199 |
+ rpm_list = create_rpm_list_to_be_copied_to_iso(options.pkg_to_rpm_map_file, |
|
200 |
+ options.pkg_to_be_copied_conf_file, 4, |
|
201 |
+ options.output_data_path) |
|
193 | 202 |
make_src_iso(options.working_directory, options.src_iso_path, rpm_list) |
194 | 203 |
|
195 | 204 |
else: |
... | ... |
@@ -234,7 +249,10 @@ if __name__ == '__main__': |
234 | 234 |
if config['password']['crypted']: |
235 | 235 |
config['password'] = config['password']['text'] |
236 | 236 |
else: |
237 |
- config['password'] = crypt.crypt(config['password']['text'], "$6$" + "".join([random.choice(string.ascii_letters + string.digits) for _ in range(16)])) |
|
237 |
+ config['password'] = crypt.crypt( |
|
238 |
+ config['password']['text'], |
|
239 |
+ "$6$" + "".join([random.choice( |
|
240 |
+ string.ascii_letters + string.digits) for _ in range(16)])) |
|
238 | 241 |
|
239 | 242 |
# Check the installation type |
240 | 243 |
json_wrapper_option_list = JsonWrapper(options.package_list_file) |
... | ... |
@@ -242,33 +260,48 @@ if __name__ == '__main__': |
242 | 242 |
options_sorted = option_list_json.items() |
243 | 243 |
|
244 | 244 |
packages = [] |
245 |
- packages = PackageSelector.get_packages_to_install(options_sorted, config['type'], options.output_data_path) |
|
245 |
+ packages = PackageSelector.get_packages_to_install(options_sorted, config['type'], |
|
246 |
+ options.output_data_path) |
|
246 | 247 |
|
247 | 248 |
config['packages'] = packages |
248 | 249 |
|
249 |
- if (os.path.isdir(options.working_directory)): |
|
250 |
+ if os.path.isdir(options.working_directory): |
|
250 | 251 |
process = subprocess.Popen(['rm', '-rf', options.working_directory]) |
251 | 252 |
retval = process.wait() |
252 | 253 |
|
253 |
- process = subprocess.Popen(['mkdir', '-p', os.path.join(options.working_directory, "photon-chroot")]) |
|
254 |
+ process = subprocess.Popen(['mkdir', '-p', |
|
255 |
+ os.path.join(options.working_directory, "photon-chroot")]) |
|
254 | 256 |
retval = process.wait() |
255 | 257 |
|
256 | 258 |
config['working_directory'] = options.working_directory |
257 | 259 |
|
258 | 260 |
# Run the installer |
259 |
- package_installer = Installer(config, rpm_path = options.rpm_path, log_path = options.log_path) |
|
261 |
+ package_installer = Installer(config, rpm_path=options.rpm_path, |
|
262 |
+ log_path=options.log_path) |
|
260 | 263 |
package_installer.install(None) |
261 | 264 |
|
262 | 265 |
# Making the iso if needed |
263 | 266 |
if options.iso_path: |
264 |
- 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)) |
|
265 |
- files_to_copy = " ".join(create_additional_file_list_to_copy_in_iso(os.path.abspath(options.stage_path), options.package_list_file)) |
|
267 |
+ rpm_list = " ".join( |
|
268 |
+ create_rpm_list_to_be_copied_to_iso( |
|
269 |
+ options.pkg_to_rpm_map_file, |
|
270 |
+ options.pkg_to_be_copied_conf_file, 1, options.output_data_path)) |
|
271 |
+ files_to_copy = " ".join( |
|
272 |
+ create_additional_file_list_to_copy_in_iso( |
|
273 |
+ os.path.abspath(options.stage_path), options.package_list_file)) |
|
274 |
+ |
|
266 | 275 |
live_cd = get_live_cd_status_string(options.package_list_file) |
267 |
- 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]) |
|
276 |
+ process = subprocess.Popen(['./mk-install-iso.sh', '-w', |
|
277 |
+ options.working_directory, options.iso_path, |
|
278 |
+ options.rpm_path, options.package_list_file, |
|
279 |
+ rpm_list, options.stage_path, files_to_copy, |
|
280 |
+ live_cd, options.json_data_path]) |
|
268 | 281 |
retval = process.wait() |
269 | 282 |
|
270 | 283 |
if options.debug_iso_path: |
271 |
- 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) |
|
284 |
+ debug_rpm_list = create_rpm_list_to_be_copied_to_iso( |
|
285 |
+ options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 2, |
|
286 |
+ options.output_data_path) |
|
272 | 287 |
make_debug_iso(options.working_directory, options.debug_iso_path, debug_rpm_list) |
273 | 288 |
|
274 | 289 |
# Cleaning up for vmdk |
... | ... |
@@ -277,6 +310,6 @@ if __name__ == '__main__': |
277 | 277 |
process.wait() |
278 | 278 |
|
279 | 279 |
#Clean up the working directories |
280 |
- if (options.iso_path or options.vmdk_path or options.debug_iso_path): |
|
280 |
+ if options.iso_path or options.vmdk_path or options.debug_iso_path: |
|
281 | 281 |
process = subprocess.Popen(['rm', '-rf', options.working_directory]) |
282 | 282 |
retval = process.wait() |