Hello community, here is the log from the commit of package WoeUSB for openSUSE:Factory checked in at 2018-09-14 00:01:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/WoeUSB (Old) and /work/SRC/openSUSE:Factory/.WoeUSB.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "WoeUSB" Fri Sep 14 00:01:50 2018 rev:7 rq:635481 version:3.2.4 Changes: -------- --- /work/SRC/openSUSE:Factory/WoeUSB/WoeUSB.changes 2018-08-20 16:19:41.476845385 +0200 +++ /work/SRC/openSUSE:Factory/.WoeUSB.new/WoeUSB.changes 2018-09-14 00:01:55.273929430 +0200 @@ -1,0 +2,10 @@ +Thu Sep 13 07:43:30 UTC 2018 - Yunhe Guo <[email protected]> + +- Version 3.2.4 + * This release features a major cleanup to the code, be sure to + report any regressions you've encountered. +- Version 3.2.3 + * This release fixes a bug that will make woeusb bailout when the + ISO filename contains a valid token of a regular expression. + +------------------------------------------------------------------- Old: ---- WoeUSB-3.2.2.tar.gz New: ---- WoeUSB-3.2.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ WoeUSB.spec ++++++ --- /var/tmp/diff_new_pack.Sg96AV/_old 2018-09-14 00:01:55.845928992 +0200 +++ /var/tmp/diff_new_pack.Sg96AV/_new 2018-09-14 00:01:55.845928992 +0200 @@ -17,7 +17,7 @@ Name: WoeUSB -Version: 3.2.2 +Version: 3.2.4 Release: 0 Summary: Windows USB installation media creator License: GPL-3.0-or-later ++++++ WoeUSB-3.2.2.tar.gz -> WoeUSB-3.2.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WoeUSB-3.2.2/src/woeusb new/WoeUSB-3.2.4/src/woeusb --- old/WoeUSB-3.2.2/src/woeusb 2018-08-14 03:07:12.000000000 +0200 +++ new/WoeUSB-3.2.4/src/woeusb 2018-09-12 15:45:13.000000000 +0200 @@ -1,7 +1,7 @@ #!/usr/bin/env bash # A Linux program to create bootable Windows USB stick from a real Windows DVD or an image # Copyright © 2013 Colin GILLE / congelli501 -# Copyright © 2017 slacka et. al. +# Copyright © 2018 slacka et. al. # # This file is part of WoeUSB. # @@ -19,17 +19,18 @@ # along with WoeUSB If not, see <http://www.gnu.org/licenses/>. # # Notes: -# * Use --strip instead of --no-symlinks for compatibility of Ubuntu 14.04(EoL: April 2019) +# * Use `--strip` instead of `--no-symlinks` for realpath(1) for compatibility of Ubuntu 14.04(EoL: April 2019) # # We use indirections and primitive variables, which is false positive of this rule # shellcheck disable=SC2034 ## Makes debuggers' life easier - Unofficial Bash Strict Mode ## BASHDOC: Shell Builtin Commands - Modifying Shell Behavior - The Set Builtin -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail +set \ + -o errexit \ + -o errtrace \ + -o nounset \ + -o pipefail ## Enable aliases for easy access to functions shopt -s expand_aliases @@ -44,7 +45,7 @@ ## Non-overridable Primitive Variables ## BASHDOC: Shell Variables » Bash Variables ## BASHDOC: Basic Shell Features » Shell Parameters » Special Parameters -if [ -v "BASH_SOURCE[0]" ]; then +if [ -v 'BASH_SOURCE[0]' ]; then RUNTIME_EXECUTABLE_PATH="$(realpath --strip "${BASH_SOURCE[0]}")" RUNTIME_EXECUTABLE_FILENAME="$(basename "${RUNTIME_EXECUTABLE_PATH}")" RUNTIME_EXECUTABLE_NAME="${RUNTIME_EXECUTABLE_FILENAME%.*}" @@ -52,11 +53,11 @@ RUNTIME_COMMANDLINE_BASECOMMAND="${0}" # Keep these partially unused variables declared # shellcheck disable=SC2034 - declare -r\ - RUNTIME_EXECUTABLE_PATH\ - RUNTIME_EXECUTABLE_FILENAME\ - RUNTIME_EXECUTABLE_NAME\ - RUNTIME_EXECUTABLE_DIRECTORY\ + declare -r \ + RUNTIME_EXECUTABLE_PATH \ + RUNTIME_EXECUTABLE_FILENAME \ + RUNTIME_EXECUTABLE_NAME \ + RUNTIME_EXECUTABLE_DIRECTORY \ RUNTIME_COMMANDLINE_BASECOMMAND fi declare -ar RUNTIME_COMMANDLINE_PARAMETERS=("${@}") @@ -65,38 +66,38 @@ ## Only set parameters global when there's no other way around(like passing in function as a function argument), usually when the variable is directly or indirectly referenced by traps ## Even when the parameter is set global, you should pass it in as function argument when it's possible for better code reusability. ## TODO: Global parameter cleanup -## TODO: Use Y/N or true/false instead 1(true)/0(false) as boolean value so it won't confuse with the regular bash intepretation of 0(true)/non-zero(false) -### Doing GUI-specific stuff when set to 1, set by --only-for-gui +### Doing GUI-specific stuff when set to `true`, set by --only-for-gui ### Requires to be set to global due to indirectly referenced by trap -declare -i global_only_for_gui=0 +declare global_only_for_gui=false ### Increase verboseness, provide more information when required -declare -i verbose=0 +declare verbose=false -### Disable message coloring when set to 1, set by --no-color -declare -i no_color=0 +### Disable message coloring when set to `true`, set by --no-color +declare no_color=false declare -ir DD_BLOCK_SIZE="((4 * 1024 * 1024))" # 4MiB ## NOTE: Need to pass to traps, so need to be global -declare\ - source_fs_mountpoint\ - target_fs_mountpoint\ +declare \ + source_fs_mountpoint \ + target_fs_mountpoint \ target_device ## FIXME: No documentation for this non-trivial parameter declare -i pulse_current_pid=0 ## Execution state for cleanup functions to determine if clean up is required +## VALUE: Dash-seperated, lowercased words, no quoting ## NOTE: Need to pass to traps, so need to be global -declare current_state='pre-init' +declare current_state=pre-init ## For some reason alias won't be recognized in function if it's definition's LINENO is greater then it's reference in function, so we define it here: -alias\ - echo_with_color=util_echo_with_color\ - switch_terminal_text_color=util_switch_terminal_text_color\ - shift_array=util_shift_array\ - is_target_busy=check_is_target_device_busy\ +alias \ + echo_with_color=util_echo_with_color \ + switch_terminal_text_color=util_switch_terminal_text_color \ + shift_array=util_shift_array \ + is_target_busy=check_is_target_device_busy \ printf_with_color=util_printf_with_color declare temp_directory; temp_directory=$( @@ -120,28 +121,28 @@ declare -r DEFAULT_NEW_FS_LABEL='Windows USB' - current_state='enter-init' + current_state=enter-init - local\ - flag_print_help=N\ - flag_print_version=N\ - flag_print_about=N\ + local \ + flag_print_help=false \ + flag_print_version=false \ + flag_print_about=false \ local -r \ - application_site_url='https://github.com/slacka/WoeUSB'\ - application_copyright_declaration="Copyright © Colin GILLE / congelli501 2013\\nCopyright © slacka et.al. 2017"\ + application_site_url='https://github.com/slacka/WoeUSB' \ + application_copyright_declaration="Copyright © Colin GILLE / congelli501 2013\\nCopyright © slacka et.al. 2017" \ application_copyright_notice="${application_name} is free software licensed under the GNU General Public License version 3(or any later version of your preference) that gives you THE 4 ESSENTIAL FREEDOMS\\nhttps://www.gnu.org/philosophy/" local install_mode # source_media may be a optical disk drive or a disk image # target_media may be an entire usb storage device or just a partition - local\ - source_media\ + local \ + source_media \ target_media local target_partition - local workaround_bios_boot_flag='N' + local workaround_bios_boot_flag=false local target_filesystem_type='FAT' @@ -150,185 +151,185 @@ # Parameters that needs to be determined in runtime # due to different names in distributions - declare\ - command_mkdosfs\ - command_mkntfs\ - command_grubinstall\ + declare \ + command_mkdosfs \ + command_mkntfs \ + command_grubinstall \ name_grub_prefix declare new_file_system_label="${DEFAULT_NEW_FS_LABEL}" - if ! check_runtime_dependencies\ - "${application_name}"\ - command_mkdosfs\ - command_mkntfs\ - command_grubinstall\ + if ! check_runtime_dependencies \ + "${application_name}" \ + command_mkdosfs \ + command_mkntfs \ + command_grubinstall \ name_grub_prefix; then exit 1 fi - if !\ - process_commandline_parameters\ - application_name\ - flag_print_help\ - flag_print_version\ - flag_print_about\ - install_mode\ - source_media\ - target_media\ - new_file_system_label\ - workaround_bios_boot_flag\ - target_filesystem_type\ + if ! \ + process_commandline_parameters \ + application_name \ + flag_print_help \ + flag_print_version \ + flag_print_about \ + install_mode \ + source_media \ + target_media \ + new_file_system_label \ + workaround_bios_boot_flag \ + target_filesystem_type \ global_only_for_gui; then - print_help\ - "${application_name}"\ - "${application_version}"\ + print_help \ + "${application_name}" \ + "${application_version}" \ "${runtime_executable_name}" exit 1 fi - process_miscellaneous_requests\ - "${flag_print_help}"\ - "${flag_print_version}"\ - "${flag_print_about}"\ - "${application_name}"\ - "${application_version}"\ - "${application_site_url}"\ - "${application_copyright_declaration}"\ - "${application_copyright_notice}"\ + process_miscellaneous_requests \ + "${flag_print_help}" \ + "${flag_print_version}" \ + "${flag_print_about}" \ + "${application_name}" \ + "${application_version}" \ + "${application_site_url}" \ + "${application_copyright_declaration}" \ + "${application_copyright_notice}" \ "${runtime_executable_name}" - printf --\ - '%s\n%s\n'\ - "${application_name} v${application_version}"\ + printf -- \ + '%s\n%s\n' \ + "${application_name} v${application_version}" \ '==============================' - check_permission\ + check_permission \ "${application_name}" - if ! check_runtime_parameters\ - install_mode\ - source_media\ - target_media\ + if ! check_runtime_parameters \ + install_mode \ + source_media \ + target_media \ "${new_file_system_label}"; then - print_help\ - "${application_name}"\ - "${application_version}"\ + print_help \ + "${application_name}" \ + "${application_version}" \ "${runtime_executable_name}" exit 1 fi # FIXME: Why `trigger_wxGenericProgressDialog_pulse on` here? - trigger_wxGenericProgressDialog_pulse\ - on\ + trigger_wxGenericProgressDialog_pulse \ + on \ "${only_for_gui_ref}" - determine_target_parameters\ - "${install_mode}"\ - "${target_media}"\ - target_device\ + determine_target_parameters \ + "${install_mode}" \ + "${target_media}" \ + target_device \ target_partition - check_source_and_target_not_busy\ - "${install_mode}"\ - "${source_media}"\ - "${target_device}"\ + check_source_and_target_not_busy \ + "${install_mode}" \ + "${source_media}" \ + "${target_device}" \ "${target_partition}" current_state=mount-source-filesystem - if ! mount_source_filesystem\ - "${source_media}"\ + if ! mount_source_filesystem \ + "${source_media}" \ "${source_fs_mountpoint}"; then echo_with_color red 'Error: Unable to mount source filesystem' exit 1 fi - if [ "${target_filesystem_type}" == 'FAT' ]; then - if ! check_fat32_filesize_limitation\ + if [ "${target_filesystem_type}" == FAT ]; then + if ! check_fat32_filesize_limitation \ "${source_fs_mountpoint}"; then exit 1 fi fi - if [ "${install_mode}" = 'device' ]; then - wipe_existing_partition_table_and_filesystem_signatures\ + if [ "${install_mode}" = device ]; then + wipe_existing_partition_table_and_filesystem_signatures \ "${target_device}" - create_target_partition_table\ - "${target_device}"\ - 'legacy' - create_target_partition\ - "${target_partition}"\ - "${target_filesystem_type}"\ - "${new_file_system_label}"\ - "${command_mkdosfs}"\ + create_target_partition_table \ + "${target_device}" \ + legacy + create_target_partition \ + "${target_partition}" \ + "${target_filesystem_type}" \ + "${new_file_system_label}" \ + "${command_mkdosfs}" \ "${command_mkntfs}" - if [ "${target_filesystem_type}" == 'NTFS' ]; then - create_uefi_ntfs_support_partition\ + if [ "${target_filesystem_type}" == NTFS ]; then + create_uefi_ntfs_support_partition \ "${target_device}" - install_uefi_ntfs_support_partition\ - "${target_device}2"\ - "${temp_directory}"\ + install_uefi_ntfs_support_partition \ + "${target_device}2" \ + "${temp_directory}" \ "${target_device}" fi fi - if [ "${install_mode}" = 'partition' ]; then - check_target_partition\ - "${target_partition}"\ - "${install_mode}"\ + if [ "${install_mode}" = partition ]; then + check_target_partition \ + "${target_partition}" \ + "${install_mode}" \ "${target_device}" fi current_state=mount-target-filesystem - if ! mount_target_filesystem\ - "${target_partition}"\ - "${target_fs_mountpoint}" \ + if ! mount_target_filesystem \ + "${target_partition}" \ + "${target_fs_mountpoint}" \ "${target_filesystem_type}"; then echo_with_color red 'Error: Unable to mount target filesystem' exit 1 fi - check_target_filesystem_free_space\ - "${target_fs_mountpoint}"\ - "${source_fs_mountpoint}"\ + check_target_filesystem_free_space \ + "${target_fs_mountpoint}" \ + "${source_fs_mountpoint}" \ || exit 1 - current_state='copying-filesystem' + current_state=copying-filesystem - workaround_linux_make_writeback_buffering_not_suck\ + workaround_linux_make_writeback_buffering_not_suck \ apply - copy_filesystem_files\ - "${source_fs_mountpoint}"\ - "${target_fs_mountpoint}"\ + copy_filesystem_files \ + "${source_fs_mountpoint}" \ + "${target_fs_mountpoint}" \ "${only_for_gui_ref}" - workaround_support_windows_7_uefi_boot\ - "${source_fs_mountpoint}"\ + workaround_support_windows_7_uefi_boot \ + "${source_fs_mountpoint}" \ "${target_fs_mountpoint}" - install_legacy_pc_bootloader_grub\ - "${target_fs_mountpoint}"\ - "${target_device}"\ + install_legacy_pc_bootloader_grub \ + "${target_fs_mountpoint}" \ + "${target_device}" \ "${command_grubinstall}" - install_legacy_pc_bootloader_grub_config\ - "${target_fs_mountpoint}"\ + install_legacy_pc_bootloader_grub_config \ + "${target_fs_mountpoint}" \ "${name_grub_prefix}" - if [ "${workaround_bios_boot_flag}" == 'Y' ]; then - workaround_buggy_motherboards_that_ignore_disks_without_boot_flag_toggled\ + if [ "${workaround_bios_boot_flag}" == true ]; then + workaround_buggy_motherboards_that_ignore_disks_without_boot_flag_toggled \ "${target_device}" fi - current_state='finished' + current_state=finished - trigger_wxGenericProgressDialog_pulse\ - off\ + trigger_wxGenericProgressDialog_pulse \ + off \ "${only_for_gui_ref}" exit 0 @@ -410,8 +411,8 @@ local -r application_version="$1" - printf --\ - '%s\n'\ + printf -- \ + '%s\n' \ "${application_version}" }; declare -fr print_version @@ -445,48 +446,48 @@ local -n only_for_gui_ref="${1}" if [ "${#RUNTIME_COMMANDLINE_PARAMETERS[@]}" -eq 0 ]; then - flag_print_help_ref=Y + flag_print_help_ref=true return 0 fi local -a parameters=("${RUNTIME_COMMANDLINE_PARAMETERS[@]}") - local\ - enable_debug=N\ - enable_device=N\ - enable_partition=N\ - enable_label=N\ - enable_workaround_bios_boot_flag=N\ - enable_debugging_internal_function_call=N\ - enable_target_filesystem=N + local \ + enable_debug=false \ + enable_device=false \ + enable_partition=false \ + enable_label=false \ + enable_workaround_bios_boot_flag=false \ + enable_debugging_internal_function_call=false \ + enable_target_filesystem=false while [ "${#parameters[@]}" -ne 0 ]; do case "${parameters[0]}" in - --help\ + --help \ |-h) - flag_print_help_ref=Y + flag_print_help_ref=true return 0 ;; - --version\ + --version \ |-V) - flag_print_version_ref=Y + flag_print_version_ref=true return 0 ;; - --about\ + --about \ |-ab) - flag_print_about_ref=Y + flag_print_about_ref=true return 0 ;; --debug) - enable_debug="Y" + enable_debug=true ;; - --partition\ + --partition \ |-p) - enable_partition=Y - install_mode_ref='partition' + enable_partition=true + install_mode_ref=partition shift_array parameters if [ "${#parameters[@]}" -lt 2 ]; then - echo_with_color\ - 'red'\ + echo_with_color \ + red \ "${FUNCNAME[0]}: Error: --partition option requires 2 arguments!" return 1 fi @@ -494,17 +495,17 @@ shift_array parameters target_media_ref="${parameters[0]}" ;; - --device\ + --device \ |-d) - enable_device=Y + enable_device=true # Limitation of ShellCheck to detect usage of indirection variables # https://github.com/koalaman/shellcheck/wiki/SC2034 # shellcheck disable=SC2034 - install_mode_ref='device' + install_mode_ref=device shift_array parameters if [ "${#parameters[@]}" -lt 2 ]; then - echo_with_color\ - 'red'\ + echo_with_color \ + red \ "${FUNCNAME[0]}: Error: --device option requires 2 arguments!" return 1 fi @@ -513,58 +514,58 @@ target_media_ref="${parameters[0]}" ;; --verbose|-v) - verbose='1' + verbose=true ;; --for-gui) - no_color='1' - only_for_gui_ref='1' + no_color=true + only_for_gui_ref=true ;; --no-color) - no_color='1' + no_color=true ;; --label|-l) - enable_label=Y + enable_label=true shift_array parameters if [ ${#parameters[@]} -lt 1 ]; then - printf_with_color\ - red\ - '%s: %s\n'\ - "${FUNCNAME[0]}"\ - 'ERROR: --label option requires at least 1 argument.' + printf_with_color \ + red \ + '%s: %s\n' \ + "${FUNCNAME[0]}" \ + 'ERROR: --label option requires 1 argument.' return 1 fi new_file_system_label_ref="${parameters[0]}" ;; --workaround-bios-boot-flag) - enable_workaround_bios_boot_flag=Y - workaround_bios_boot_flag_ref='Y' + enable_workaround_bios_boot_flag=true + workaround_bios_boot_flag_ref=true ;; --debugging-internal-function-call) - enable_debugging_internal_function_call=Y + enable_debugging_internal_function_call=true shift_array parameters if [ ${#parameters[@]} -lt 1 ]; then - printf_with_color\ - red\ - '%s: %s\n'\ - "${FUNCNAME[0]}"\ + printf_with_color \ + red \ + '%s: %s\n' \ + "${FUNCNAME[0]}" \ 'ERROR: --debugging-internal-function-call option requires at least 1 argument.' return 1 fi "${parameters[@]}" exit ${?} ;; - --target-filesystem\ + --target-filesystem \ |--tgt-fs) - enable_target_filesystem=Y + enable_target_filesystem=true shift_array parameters if [ ${#parameters[@]} -lt 1 ]; then - printf_with_color\ - red\ - '%s: %s\n'\ - "${FUNCNAME[0]}"\ - 'ERROR: --target-filesystem option requires at least 1 argument.' + printf_with_color \ + red \ + '%s: %s\n' \ + "${FUNCNAME[0]}" \ + 'ERROR: --target-filesystem option requires 1 argument.' return 1 fi target_filesystem_type_ref="${parameters[0]}" @@ -579,38 +580,38 @@ # None useful action is specified if \ - [ "${enable_device}" == N ] \ - && [ "${enable_partition}" == N ] \ - && [ "${enable_debugging_internal_function_call}" == N ]; then + [ "${enable_device}" == false ] \ + && [ "${enable_partition}" == false ] \ + && [ "${enable_debugging_internal_function_call}" == false ]; then # intentionally don't mention about the internal function call option - echo_with_color\ - red\ + echo_with_color \ + red \ "${FUNCNAME[0]}: Error: No creation method specified!" >&2 return 1 - elif\ - [ "${enable_device}" == Y ] \ - && [ "${enable_partition}" == Y ]; then + elif \ + [ "${enable_device}" == false ] \ + && [ "${enable_partition}" == true ]; then echo_with_color red "${FUNCNAME[0]}: Error: --device and --partition creation method are mutual-exclusive." >&2 return 1 fi # --label option is no use with --partition creation method if \ - [ "${enable_partition}" == Y ] \ - && [ "${enable_label}" == Y ]; then + [ "${enable_partition}" == true ] \ + && [ "${enable_label}" == true ]; then echo_with_color red "${FUNCNAME[0]}: Error: --label option only can be used with --device creation method" return 1 fi ## --target-filesystem option is no use with --partition creation method if \ - [ "${enable_target_filesystem}" == Y ] \ - && [ "${enable_partition}" == Y ]; then + [ "${enable_target_filesystem}" == true ] \ + && [ "${enable_partition}" == true ]; then echo_with_color red "${FUNCNAME[0]}: Error: --target-filesystem option only can be used with --device creation method" return 1 fi - if [ "${verbose}" = '1' ] && [ "${enable_debug}" != 'Y' ]; then + if [ "${verbose}" = true ] && [ "${enable_debug}" != true ]; then trap 'trap_return "${FUNCNAME[0]}"' RETURN # Disabled due to FIXME @@ -618,7 +619,7 @@ fi # Always be the last condition so that less debug message from this function will be printed - if [ "${enable_debug}" = 'Y' ]; then + if [ "${enable_debug}" = true ]; then set -o xtrace fi return 0 @@ -636,26 +637,26 @@ local -r application_copyright_notice="${1}"; shift local -r runtime_executable_name="${1}"; shift - if [ "${flag_print_help}" == 'Y' ]; then - print_help\ - "${application_name}"\ - "${application_version}"\ + if [ "${flag_print_help}" == true ]; then + print_help \ + "${application_name}" \ + "${application_version}" \ "${runtime_executable_name}" exit 0 fi - if [ "${flag_print_version}" == 'Y' ]; then - print_version\ + if [ "${flag_print_version}" == true ]; then + print_version \ "${application_version}" exit 0 fi - if [ "${flag_print_about}" == 'Y' ]; then - print_application_info\ - "${application_name}"\ - "${application_version}"\ - "${application_site_url}"\ - "${application_copyright_declaration}"\ + if [ "${flag_print_about}" == true ]; then + print_application_info \ + "${application_name}" \ + "${application_version}" \ + "${application_site_url}" \ + "${application_copyright_declaration}" \ "${application_copyright_notice}" exit 0 fi @@ -670,27 +671,27 @@ local -n command_grubinstall_ref="$1"; shift local -n name_grub_prefix_ref="$1" - local result='unknown' + local result=unknown - for required_command in\ - awk\ - blockdev\ - dd\ - df\ - du\ - find\ - grep\ - id\ - lsblk\ - mkdir\ - mktemp\ - mount\ - parted\ - partprobe\ - readlink\ - rm\ - stat\ - wget\ + for required_command in \ + awk \ + blockdev \ + dd \ + df \ + du \ + find \ + grep \ + id \ + lsblk \ + mkdir \ + mktemp \ + mount \ + parted \ + partprobe \ + readlink \ + rm \ + stat \ + wget \ wipefs do if ! command -v "${required_command}" >/dev/null; then @@ -699,45 +700,45 @@ fi done; unset required_command - if command -v 'mkdosfs' &> /dev/null; then - command_mkdosfs_ref='mkdosfs' - elif command -v 'mkfs.msdos' &> /dev/null; then - command_mkdosfs_ref='mkfs.msdos' - elif command -v 'mkfs.vfat' &>/dev/null; then - command_mkdosfs_ref='mkfs.vfat' - elif command -v 'mkfs.fat' &>/dev/null; then - command_mkdosfs_ref='mkfs.fat' + if command -v mkdosfs &> /dev/null; then + command_mkdosfs_ref=mkdosfs + elif command -v mkfs.msdos &> /dev/null; then + command_mkdosfs_ref=mkfs.msdos + elif command -v mkfs.vfat &>/dev/null; then + command_mkdosfs_ref=mkfs.vfat + elif command -v mkfs.fat &>/dev/null; then + command_mkdosfs_ref=mkfs.fat else - echo_with_color red\ + echo_with_color red \ "${FUNCNAME[0]}: Error: mkdosfs/mkfs.msdos/mkfs.vfat/mkfs.fat command not found!" >&2 - echo_with_color red\ + echo_with_color red \ "${FUNCNAME[0]}: Error: Please make sure that dosfstools is properly installed!" >&2 result='failed' fi - if command -v 'mkntfs' &>/dev/null; then - command_mkntfs_ref='mkntfs' + if command -v mkntfs &>/dev/null; then + command_mkntfs_ref=mkntfs else - printf_with_color red\ - '%s\n%s\n'\ - "${FUNCNAME[0]}: Error: mkntfs command not found!"\ + printf_with_color red \ + '%s\n%s\n' \ + "${FUNCNAME[0]}: Error: mkntfs command not found!" \ "${FUNCNAME[0]}: Error: Please make sure that ntfs-3g is properly installed!" - result='failed' + result=failed fi - if command -v 'grub-install' &> /dev/null; then - command_grubinstall_ref='grub-install' - name_grub_prefix_ref='grub' - elif command -v 'grub2-install' &> /dev/null; then - command_grubinstall_ref='grub2-install' - name_grub_prefix_ref='grub2' + if command -v grub-install &> /dev/null; then + command_grubinstall_ref=grub-install + name_grub_prefix_ref=grub + elif command -v grub2-install &> /dev/null; then + command_grubinstall_ref=grub2-install + name_grub_prefix_ref=grub2 else echo_with_color red "${FUNCNAME[0]}: Error: grub-install or grub2-install command not found!" >&2 echo_with_color red "${FUNCNAME[0]}: Error: Please make sure that GNU GRUB is properly installed!" >&2 - result='failed' + result=failed fi - if [ "${result}" == 'failed' ]; then + if [ "${result}" == failed ]; then return 1 else return 0 @@ -749,10 +750,10 @@ local -r application_name="$1" if [ ! "$(id --user)" = 0 ]; then - printf_with_color\ - yellow\ - '%s\n%s\n'\ - "Warning: You are not running ${application_name} as root!"\ + printf_with_color \ + yellow \ + '%s\n%s\n' \ + "Warning: You are not running ${application_name} as root!" \ 'Warning: This might be the reason of the following failure.' >&2 fi return 0 @@ -799,7 +800,7 @@ local -n target_device_ref="${1}"; shift local -n target_partition_ref="${1}"; shift - if [ "${install_mode}" = 'partition' ]; then + if [ "${install_mode}" = partition ]; then target_partition_ref="${target_media}" # BASHDOC: Basic Shell Features » Shell Expansions » Shell Parameter Expansion(`${PARAMETER/PATTERN/STRING}') target_device_ref="${target_media/%[0-9]/}" @@ -808,7 +809,7 @@ target_partition_ref="${target_device}1" fi - if [ "${verbose}" = '1' ]; then + if [ "${verbose}" = true ]; then echo "${FUNCNAME[0]}: Info: Target device is '${target_device_ref}'." echo "${FUNCNAME[0]}: Info: Target partition is '${target_partition_ref}'." fi @@ -819,7 +820,12 @@ util_check_function_parameters_quantity 1 $# local device="${1}" - if [ "$(mount | grep -c "${device}")" -ne 0 ]; then + if [ "$(mount \ + | grep \ + --count \ + --fixed-strings\ + "${device}" + )" -ne 0 ]; then return 0 else return 1 @@ -833,13 +839,23 @@ local target_device="$1"; shift local target_partition="$1" - if [ "$(mount | grep -c "${source_media}")" != 0 ]; then + if [ "$(mount\ + | grep\ + --count\ + --fixed-strings\ + "${source_media}" + )" != 0 ]; then echo_with_color red "Error: Source media is currently mounted, unmount the partition then try again" exit 1 fi - if [ "${install_mode}" = "partition" ]; then - if [ "$(mount | grep -c "${target_partition}")" != 0 ]; then + if [ "${install_mode}" = partition ]; then + if [ "$(mount\ + | grep\ + --count\ + --fixed-strings\ + "${target_partition}" + )" != 0 ]; then echo_with_color red "Error: Target partition is currently mounted, unmount the partition then try again" exit 1 fi @@ -882,7 +898,9 @@ "${target_device}"\ | grep\ --count\ - ' TYPE="part"')" -ne 0 ]; then + --fixed-strings\ + ' TYPE="part"' + )" -ne 0 ]; then printf_with_color\ red\ 'Error: %s: Partition is still detected after wiping all signatures, this indicates that the drive might be locked into readonly mode due to end of lifespan.\n'\ @@ -904,10 +922,10 @@ case "${partition_table_type}" in legacy|msdos|mbr|pc) - parted_partiton_table_argument='msdos' + parted_partiton_table_argument=msdos ;; gpt|guid) - parted_partiton_table_argument='gpt' + parted_partiton_table_argument=gpt echo_with_color\ red\ "${FUNCNAME[0]}: Error: Currently GUID partition table is not supported." @@ -960,10 +978,10 @@ local parted_mkpart_fs_type case "${filesystem_type}" in FAT|vfat) - parted_mkpart_fs_type='fat32' + parted_mkpart_fs_type=fat32 ;; NTFS|ntfs) - parted_mkpart_fs_type='ntfs' + parted_mkpart_fs_type=ntfs ;; *) echo_with_color red "${FUNCNAME[0]}: Error: Filesystem not supported" @@ -1176,6 +1194,7 @@ --noheadings\ "${target_device}"\ | grep\ + --fixed-strings\ --silent\ 'UEFI_NTFS'; then printf_with_color yellow\ @@ -1283,14 +1302,18 @@ df\ --block-size=1\ "${target_fs_mountpoint}"\ - | grep "${target_fs_mountpoint}"\ + | grep\ + --fixed-strings\ + "${target_fs_mountpoint}"\ | awk '{print $4}' ) free_space_human_readable=$( df\ --human-readable\ "${target_fs_mountpoint}"\ - | grep "${target_fs_mountpoint}"\ + | grep\ + --fixed-strings\ + "${target_fs_mountpoint}"\ | awk '{print $4}' ) needed_space=$( @@ -1354,7 +1377,7 @@ if [ -d "${source_file}" ]; then mkdir --parents "${dest_file}" elif [ -f "${source_file}" ]; then - if [ "${verbose}" = 1 ]; then + if [ "${verbose}" = true ]; then echo -e "\\nINFO: Copying \"${source_file}\"..." fi if [ "${source_file_size}" -lt "${DD_BLOCK_SIZE}" ]; then @@ -1478,7 +1501,7 @@ )" if [ -z "${test_efi_directory}" ]; then efi_directory="${target_fs_mountpoint}/efi" - if [ "${verbose}" = '1' ]; then + if [ "${verbose}" = true ]; then printf --\ "%s: DEBUG: Can't find efi directory, use %s.\\n"\ "${FUNCNAME[0]}"\ @@ -1486,7 +1509,7 @@ fi else # efi directory(case don't care) exists efi_directory="${test_efi_directory}" - if [ "${verbose}" = '1' ]; then + if [ "${verbose}" = true ]; then printf --\ '%s: DEBUG: %s detected.\n'\ "${FUNCNAME[0]}"\ @@ -1505,7 +1528,7 @@ )" if [ -z "${test_efi_boot_directory}" ]; then efi_boot_directory="${efi_directory}/boot" - if [ "${verbose}" = '1' ]; then + if [ "${verbose}" = true ]; then printf --\ "%s: DEBUG: Can't find efi/boot directory, use %s.\\n"\ "${FUNCNAME[0]}"\ @@ -1513,7 +1536,7 @@ fi else # boot directory(case don't care) exists efi_boot_directory="${test_efi_boot_directory}" - if [ "${verbose}" = '1' ]; then + if [ "${verbose}" = true ]; then printf --\ '%s: DEBUG: %s detected.\n'\ "${FUNCNAME[0]}"\ @@ -1617,7 +1640,8 @@ --raw\ --output UUID,MOUNTPOINT\ | grep\ - "${target_fs_mountpoint}\$"\ + --extended-regexp\ + "${target_fs_mountpoint}"$\ | cut\ --fields=1\ --delimiter=' ' @@ -1637,7 +1661,7 @@ cleanup_mountpoint(){ util_check_function_parameters_quantity 2 "${#}" local -r fs_mountpoint="${1}"; shift - local -ir only_for_gui="${1}"; shift + local -r only_for_gui="${1}"; shift # In copy_filesystem_files, we use `pushd` to changed the working directory into source_fs_mountpoint in order to get proper source and target file path, proactively `popd` to ensure we are not in source_fs_mountpoint and preventing source filesystem to unmount popd &>/dev/null\ @@ -1678,9 +1702,9 @@ util_check_function_parameters_quantity 2 $# local switch="$1"; shift - local -ir only_for_gui="$1" + local -r only_for_gui="$1" - if [ "${only_for_gui}" -eq 0 ]; then + if [ "${only_for_gui}" = false ]; then return 0 fi @@ -1693,7 +1717,7 @@ while true; do sleep 0.05 - echo 'pulse' + echo pulse done & pulse_current_pid="$!" disown @@ -1796,7 +1820,7 @@ --recursive\ "${temp_directory}" - if [ "${current_state}" = 'finished' ]; then + if [ "${current_state}" = finished ]; then echo_with_color green 'Done :)' echo_with_color green 'The target device should be bootable now' fi @@ -1842,10 +1866,10 @@ done case "$(type -t "${command_base}")" in - 'file') + file) echo_with_color green "${FUNCNAME[0]}: INFO: Executing ${command_to_be_executed}" ;; - 'function') + function) echo_with_color green "${FUNCNAME[0]}: INFO: Calling ${command_base}" ;; *) @@ -1864,7 +1888,7 @@ local command_output local -i command_exit_status if command_output="$( "${command[@]}" 2>&1 )"; then - command_exit_status='0' + command_exit_status=0 else command_exit_status="$?" fi @@ -1875,15 +1899,15 @@ local -r read_prompt="Read command output (Y/n)?" printf '%s' "${read_prompt}" - local answer='y' + local answer=y while true; do read -r answer - if [ "${answer}" == 'y' ] || [ "${answer}" == 'Y' ]; then + if [ "${answer}" == y ] || [ "${answer}" == Y ]; then echo "${command_output}" break - elif [ "${answer}" == 'n' ] || [ "${answer}" == 'N' ]; then + elif [ "${answer}" == n ] || [ "${answer}" == N ]; then break else printf '%s' "${read_prompt}" @@ -1942,7 +1966,7 @@ local -r message_color="${1}"; shift local -r message_body="${1}" - if [ "${no_color}" -eq 1 ]; then + if [ "${no_color}" = true ]; then echo -e "${message_body}" else switch_terminal_text_color "${message_color}" @@ -1954,13 +1978,13 @@ ## Print formatted message with color util_printf_with_color(){ if [ ${#} -lt 2 ]; then - if [ "${no_color}" == 0 ]; then + if [ "${no_color}" == false ]; then switch_terminal_text_color red fi printf --\ 'Fatal: %s: Parameter quantity illegal, please report bug.\n'\ "${FUNCNAME[0]}" - if [ "${no_color}" == 0 ]; then + if [ "${no_color}" == false ]; then switch_terminal_text_color none fi exit 1 @@ -1968,12 +1992,12 @@ local -r color="${1}"; shift local -ar printf_parameters=("${@}") - if [ "${no_color}" == 1 ]; then + if [ "${no_color}" == true ]; then # False positive: not format string(ShellCheck #1028) # shellcheck disable=SC2059 printf --\ "${printf_parameters[@]}" - else # no_color = 0 + else # no_color = false switch_terminal_text_color "${color}" # False positive: not format string(ShellCheck #1028) # shellcheck disable=SC2059
