diff --git a/overview.txt b/overview.txt index e69de29..027832e 100644 --- a/overview.txt +++ b/overview.txt @@ -0,0 +1 @@ +Cubic is a live ISO creator. When using it to create a live server ISO, I found some issues and fixed them. This repo is to track those issues so I can submit them in a bug report and keep them when the bug report does not get fixed :) diff --git a/transitions.py b/transitions.py index 91da2a3..9371d73 100644 --- a/transitions.py +++ b/transitions.py @@ -855,7 +855,8 @@ def transition__from__existing_project_page__to__manage_linux_kernels_page(threa # .../squashfs-root/boot/vmlinuz-*; initrd.img-* directory_1 = os.path.join(model.custom_squashfs_directory, 'boot') # .../original-iso-mount/casper/vmlinuz.efi; initrd.lz - directory_2 = os.path.join(model.original_iso_image_mount_point, 'casper') + casper_dir = utilities.get_casper_dir() + directory_2 = os.path.join(model.original_iso_image_mount_point, casper_dir) vmlinuz_version_details_list = utilities.create_vmlinuz_version_details_list(directory_1, directory_2) # [2] Prepare and display the new page. @@ -965,7 +966,8 @@ def transition__from__existing_project_page__to__manage_linux_kernels_page(threa # .../squashfs-root/boot/vmlinuz-*; initrd.img-* directory_1 = os.path.join(model.custom_squashfs_directory, 'boot') # .../original-iso-mount/casper/vmlinuz.efi; initrd.lz - directory_2 = os.path.join(model.original_iso_image_mount_point, 'casper') + casper_dir = utilities.get_casper_dir() + directory_2 = os.path.join(model.original_iso_image_mount_point, casper_dir) vmlinuz_version_details_list = utilities.create_vmlinuz_version_details_list(directory_1, directory_2) # [2] Prepare and display the new page. @@ -1531,7 +1533,8 @@ def transition__from__terminal_page__to__manage_linux_kernels_page(thread): # .../squashfs-root/boot/vmlinuz-*; initrd.img-* directory_1 = os.path.join(model.custom_squashfs_directory, 'boot') # .../original-iso-mount/casper/vmlinuz.efi; initrd.lz - directory_2 = os.path.join(model.original_iso_image_mount_point, 'casper') + casper_dir = utilities.get_casper_dir() + directory_2 = os.path.join(model.original_iso_image_mount_point, casper_dir) vmlinuz_version_details_list = utilities.create_vmlinuz_version_details_list(directory_1, directory_2) # [2] Prepare and display the new page. diff --git a/utilities.py b/utilities.py index a18f353..f2d33e1 100644 --- a/utilities.py +++ b/utilities.py @@ -66,7 +66,6 @@ from urllib.parse import urlparse time_zone = 'America/New_York' # cat /etc/timezone - ################################################################################ # Execute Functions ################################################################################ @@ -119,6 +118,21 @@ def execute_synchronous_popen_no_output(thread, command): return returncode, error +################################################################################ +# EXTRA Functions +################################################################################ +def get_casper_dir(): + logger.log_note('Getting squash dir (casper)') + + desktop_path = os.path.join(model.original_iso_image_mount_point, 'casper') + server_path = os.path.join(model.original_iso_image_mount_point, 'install') + if (os.path.exists(desktop_path)): + logger.log_data('The casper path is', desktop_path) + return 'casper' + elif (os.path.exists(server_path)): + logger.log_data('The casper path is', server_path) + return 'install' + ################################################################################ # File Functions @@ -654,6 +668,8 @@ def copy_file(thread, filepath, file_number, target_directory, total_files): def copy_original_iso_files(thread, is_new_project): logger.log_note('Copying the original iso files') + casper_dir = get_casper_dir() + source_path = os.path.join(model.original_iso_image_mount_point, '') logger.log_data('The source path is', source_path) @@ -673,7 +689,7 @@ def copy_original_iso_files(thread, is_new_project): # Do not copy: /casper/vmlinuz.efi # command = 'rsync --delete --archive --exclude=md5sum.txt --exclude=/casper/filesystem.manifest --exclude=/casper/filesystem.size --exclude=/casper/filesystem.squashfs --progress "%s" "%s"' % (source_path, target_path) - command = 'rsync --delete --archive --exclude=md5sum.txt --include=/casper/filesystem.manifest-remove --exclude=/casper/* --progress "%s" "%s"' % (source_path, target_path) + command = 'rsync --delete --archive --exclude=md5sum.txt --include=/%s/filesystem.manifest-remove --exclude=/%s/* --progress "%s" "%s"' % (casper_dir, casper_dir, source_path, target_path) else: # Copy all files from the original iso. # Exclude or copy the following files as indicated. @@ -687,7 +703,7 @@ def copy_original_iso_files(thread, is_new_project): # Do not copy: /casper/vmlinuz.efi # command = 'rsync --delete --archive --exclude=md5sum.txt --exclude=/casper/filesystem.manifest --exclude=/casper/filesystem.manifest-remove --exclude=/casper/filesystem.size --exclude=/casper/filesystem.squashfs --progress "%s" "%s"' % (source_path, target_path) - command = 'rsync --delete --archive --exclude=md5sum.txt --exclude=/casper/* --progress "%s" "%s"' % (source_path, target_path) + command = 'rsync --delete --archive --exclude=md5sum.txt --exclude=/%s/* --progress "%s" "%s"' % (casper_dir, source_path, target_path) execute_asynchronous(thread, command) progress_initial = 0 @@ -717,6 +733,8 @@ def copy_original_iso_files(thread, is_new_project): def extract_squashfs(thread): + casper_dir = get_casper_dir() + # Delete custom squashfs directory, if it exists. delete_file(thread, model.custom_squashfs_directory) @@ -725,7 +743,7 @@ def extract_squashfs(thread): target_path = model.custom_squashfs_directory logger.log_data('The target path is', target_path) - source_path = os.path.join(model.original_iso_image_mount_point, 'casper', 'filesystem.squashfs') + source_path = os.path.join(model.original_iso_image_mount_point, casper_dir, 'filesystem.squashfs') logger.log_data('The source path is', source_path) command = 'unsquashfs -force -dest %s %s' % (target_path, source_path) @@ -1141,6 +1159,10 @@ def get_vmlinuz_version_from_file(filepath): elif os.path.exists(os.path.join(directory, vmlinuz_filename.replace('vmlinuz', 'initrd.img'))): initrd_filename = vmlinuz_filename.replace('vmlinuz', 'initrd.img') + # The server ISO uses the '.gz' variant. + elif os.path.exists(os.path.join(directory, vmlinuz_filename.replace('vmlinuz', 'initrd.gz'))): + initrd_filename = vmlinuz_filename.replace('vmlinuz', 'initrd.gz') + note ='' is_selected = False is_remove = False # This is currently not used, and is for future use. @@ -1190,12 +1212,13 @@ def _get_vmlinuz_version_name_from_file_contents(filepath): def create_filesystem_manifest_file(thread): logger.log_note('Creating the filesystem manifest') + casper_dir = get_casper_dir() # Create the filesystem.manifest file. command = 'chroot %s dpkg-query -W' % model.custom_squashfs_directory execute_asynchronous(thread, command) line = thread.process.read() - filepath = os.path.join(model.custom_live_iso_directory, 'casper', 'filesystem.manifest') + filepath = os.path.join(model.custom_live_iso_directory, casper_dir, 'filesystem.manifest') with open(filepath, 'w') as file: file.write('%s' % line) # Count the number of installed packages. @@ -1206,10 +1229,11 @@ def create_filesystem_manifest_file(thread): def get_installed_packages_list(): logger.log_note('Creating the list of installed packages') + casper_dir = get_casper_dir() # Installed packages. installed_packages_list = [] - filepath = os.path.join(model.custom_live_iso_directory, 'casper', 'filesystem.manifest') + filepath = os.path.join(model.custom_live_iso_directory, casper_dir, 'filesystem.manifest') with open(filepath, 'r') as file: installed_packages_list = file.read().splitlines() return installed_packages_list @@ -1217,9 +1241,13 @@ def get_installed_packages_list(): def get_removable_packages_list(): # Packages to remove. + casper_dir = get_casper_dir() removable_packages_list = [] - filepath = os.path.join(model.custom_live_iso_directory, 'casper', 'filesystem.manifest-remove') - with open(filepath, 'r') as file: removable_packages_list = file.read().splitlines() + filepath = os.path.join(model.custom_live_iso_directory, casper_dir, 'filesystem.manifest-remove') + # Check if the file exists before reading it. The server ISO does not + # have this by default. + if os.path.isfile(filepath): + with open(filepath, 'r') as file: removable_packages_list = file.read().splitlines() return removable_packages_list @@ -1264,7 +1292,8 @@ def create_removable_packages_list(): def create_filesystem_manifest_remove_file(removable_packages_list): - filepath = os.path.join(model.custom_live_iso_directory, 'casper', 'filesystem.manifest-remove') + casper_dir = get_casper_dir() + filepath = os.path.join(model.custom_live_iso_directory, casper_dir, 'filesystem.manifest-remove') with open(filepath, 'w') as file: first_line = True for packages_name in removable_packages_list: @@ -1276,6 +1305,7 @@ def create_filesystem_manifest_remove_file(removable_packages_list): def copy_boot_files(thread): logger.log_note('Copying boot files') + casper_dir = get_casper_dir() liststore = model.builder.get_object('manage_linux_kernels_page__kernel_details_liststore') for selected, version_details in enumerate(liststore): @@ -1299,7 +1329,7 @@ def copy_boot_files(thread): target_filename = 'vmlinuz.efi' source_path = os.path.join(directory, filename) - target_path = os.path.join(model.custom_live_iso_directory, 'casper', target_filename) + target_path = os.path.join(model.custom_live_iso_directory, casper_dir, target_filename) logger.log_data('The vmlinuz source file is', source_path) logger.log_data('The vmlinuz target file is', target_path) copy_boot_file(thread, source_path, 0, target_path, 2) @@ -1309,8 +1339,10 @@ def copy_boot_files(thread): # initrd # 0:version_name, 1:vmlinuz_filename, 2:initrd_filename, 3:directory, 4:note, 5:is_selected, 6:is_remove filename = liststore[selected][2] + logger.log_data('copy boot file file: ', filename) + logger.log_data('copy boot file dir: ', directory) source_path = os.path.join(directory, filename) - target_path = os.path.join(model.custom_live_iso_directory, 'casper', 'initrd.lz') + target_path = os.path.join(model.custom_live_iso_directory, casper_dir, 'initrd.lz') copy_boot_file(thread, source_path, 1, target_path, 2) logger.log_data('The initrd source file is', source_path) logger.log_data('The initrd target file is', target_path) @@ -1365,11 +1397,12 @@ def copy_boot_file(thread, source_path, file_number, target_path, total_files): def create_squashfs(thread): logger.log_note('Creating squashfs') + casper_dir = get_casper_dir() source_path = model.custom_squashfs_directory logger.log_data('The source path is', source_path) - target_path = os.path.join(model.custom_live_iso_directory, 'casper', 'filesystem.squashfs') + target_path = os.path.join(model.custom_live_iso_directory, casper_dir, 'filesystem.squashfs') logger.log_data('The target path is', target_path) command = 'mksquashfs %s %s -noappend -comp xz' % (source_path, target_path) @@ -1403,12 +1436,13 @@ def create_squashfs(thread): def update_filesystem_size(thread): logger.log_note('Updating the filesystem size') + casper_dir = get_casper_dir() command = 'du -sx --block-size=1 %s' % model.custom_squashfs_directory execute_asynchronous(thread, command) line = thread.process.read() - filepath = os.path.join(model.custom_live_iso_directory, 'casper', 'filesystem.size') + filepath = os.path.join(model.custom_live_iso_directory, casper_dir, 'filesystem.size') size = re.search(r'^([0-9]+)\s', line).group(1) with open(filepath, 'w') as file: file.write('%s' % size)