Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
feat: add new flag --assume-image-is hybrid | non-hybrid
Browse files Browse the repository at this point in the history
This new flag will override bootiso assessment of image hybridness in case
of false positives.
  • Loading branch information
jsamr committed Oct 4, 2020
1 parent 549ec91 commit ee15854
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 11 deletions.
35 changes: 27 additions & 8 deletions bootiso
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ typeset -A st_userVars=(
['remote-bootloader']=''
['part-type']=''
['data-part-fs']=''
['assume-image-is']=''
)

# oo.ooooo. .oooo. oooo d8b
Expand Down Expand Up @@ -169,6 +170,7 @@ typeset disableConfirmation
typeset disableHashCheck
typeset disableWimsplit
typeset disableDeviceEjection
typeset assumeImageIs

# oooo
# `888
Expand Down Expand Up @@ -803,6 +805,7 @@ typeset -Ar asrt_userVarsCompatibilityMatrix=(
['part-type']='format install-mount-rsync'
['dd-bs']='install-image-copy'
['data-part-fs']='install-image-copy'
['assume-image-is']='install-auto install-mount-rsync install-image-copy'
)
typeset -Ar ct_userFlagsCompatibilityMatrix=(
['assume-yes']='install-auto install-mount-rsync install-image-copy format'
Expand Down Expand Up @@ -2209,6 +2212,13 @@ function step_parseArguments() {
_setUserVar 'fs' "${2,,}" #lowercased
shift 2
;;
--assume-image-is)
if (($# < 2)); then
ps_failAndExit SYNOPSIS_NONCOMPL "Missing value for '$1' flag. Please provide an image type (one of: hybrid, non-hybrid)."
fi
_setUserVar 'assume-image-is' "${2,,}" #lowercased
shift 2
;;
--data-part-fs)
if (($# < 2)); then
ps_failAndExit SYNOPSIS_NONCOMPL "Missing value for '$1' flag. Please provide a filesystem type."
Expand Down Expand Up @@ -2330,6 +2340,7 @@ function step_assignInternalVariables() {
targetBootloaderVersion=${st_userVars['remote-bootloader']:-'auto'}
targetDDBusSize=${st_userVars['dd-bs']:-'4M'}
targetDataPartFstype=${st_userVars['data-part-fs']:-'vfat'}
assumeImageIs=${st_userVars['assume-image-is']:-''}
# Action-dependent flags
case $targetAction in
install-*)
Expand Down Expand Up @@ -2543,11 +2554,11 @@ function exec_probe() {
}

function exec_installMountRsync() {
if [ "${st_isoInspections[isHybrid]}" == true ]; then
if [[ "${st_isoInspections[isHybrid]}" == true && "${assumeImageIs}" != "non-hybrid" ]]; then
ps_failAndExit ASSERTION_FAILED "You cannot set Mount-Rsync mode with a hybrid image file." \
"Hybrid ISO or disk image files eventually contain multiple partitions and Mount-Rsync mode can only work with one." \
"If you think this image file is not hybrid and this is a bug, please report at " \
"${ct_ticketsURL}."
"${ct_ticketsURL}. You can also use $(term_boldify "--assume-image-is non-hybrid") flag to bypass this check."
fi
st_shouldMakePartition=true
asrt_checkSyslinuxInstall
Expand All @@ -2564,11 +2575,11 @@ function exec_installMountRsync() {
}

function exec_installImageCopy() {
if [ "${st_isoInspections[isHybrid]}" == false ]; then
if [[ "${st_isoInspections[isHybrid]}" == false && "${assumeImageIs}" != "hybrid" ]]; then
ps_failAndExit ASSERTION_FAILED "You cannot set Image-Copy mode with a non-hybrid, 'El-Torito' image file." \
"El-Torito image files don't have a partition table; and thus target device will not be recognized" \
"by any boot system as a boot candidate. If you think this image file is hybrid and this is a bug, please report at " \
"${ct_ticketsURL}."
"${ct_ticketsURL}. You can also use $(term_boldify "--assume-image-is hybrid") flag to bypass this check."
fi
st_shouldMakePartition=false
step_runSecurityAssessments
Expand All @@ -2585,12 +2596,20 @@ function exec_installImageCopy() {
}

function exec_installAuto() {
if [ "${st_isoInspections[isHybrid]}" == true ]; then
term_echogood "Found hybrid image; choosing Image-Copy mode."
if [ "${assumeImageIs}" == "hybrid" ]; then
term_echogood "Assumed image is hybrid; choosing Image-Copy mode."
exec_installImageCopy
else
term_echoinfo "Found non-hybrid image; inspecting image for boot capabilities..."
elif [ "${assumeImageIs}" == "non-hybrid" ]; then
term_echoinfo "Assumed image is non-hybrid; inspecting image for boot capabilities"
exec_installMountRsync
else
if [ "${st_isoInspections[isHybrid]}" == true ]; then
term_echogood "Found hybrid image; choosing Image-Copy mode."
exec_installImageCopy
else
term_echoinfo "Found non-hybrid image; inspecting image for boot capabilities..."
exec_installMountRsync
fi
fi
}

Expand Down
12 changes: 11 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ <h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a><
[<code class="Cm">--hash-file</code> <var class="Ar">hashfile</var>]
[<code class="Cm">--force-hash-check</code>]]
[<code class="Cm">--no-size-check</code>]
[<code class="Cm">--no-usb-check</code>] [<code class="Cm">--</code>]
[<code class="Cm">--no-usb-check</code>]
[<code class="Cm">--assume-image-is</code>
<var class="Ar">image-type</var>] [<code class="Cm">--</code>]
<var class="Ar">imagefile</var></td>
</tr>
</table>
Expand Down Expand Up @@ -218,6 +220,14 @@ <h2 class="Ss" id="Generic_Modifiers"><a class="permalink" href="#Generic_Modifi
Modifiers</a></h2>
Use generic modifiers knowingly as some might override default safe behaviors.
<dl class="Bl-tag">
<dt><a class="permalink" href="#--assume-image-is"><code class="Cm" id="--assume-image-is">--assume-image-is</code></a>
<var class="Ar">image-type</var></dt>
<dd>Override <code class="Nm">bootiso</code> assessment of
<var class="Ar">imagefile</var> hybridness. Use &#x201C;hybrid&#x201D; to
force <code class="Nm">bootiso</code> regard
<var class="Ar">imagefile</var> as hybrid, and &#x201C;non-hybrid&#x201D;
to force <code class="Nm">bootiso</code> regard
<var class="Ar">imagefile</var> as non hybrid.</dd>
<dt><a class="permalink" href="#a,"><code class="Fl" id="a,">-a,</code></a>
<code class="Cm">--autoselect</code></dt>
<dd>Enable &#x201C;autoselect&#x201D; behavior in combination with
Expand Down
9 changes: 7 additions & 2 deletions extra/completions/completions.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bootiso - create a bootable USB drive from an image file
# Copyright (C) 2018-2020 jules randolph <[email protected]>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -136,6 +136,9 @@ __bootiso_handle_files() {
__bootiso_handle_opt_arg() {
if [[ -n "$last_opt_arg" ]]; then
case "$last_opt_arg" in
--assume-image-is)
mapfile -t COMPREPLY < <(compgen -W "hybrid non-hybrid" -- "${cur}")
;;
--dd-bs)
mapfile -t COMPREPLY < <(compgen -W "32k 64k 512k 1M 2M 4M 8M" -- "${cur}")
;;
Expand Down Expand Up @@ -199,6 +202,7 @@ __bootiso_start() {
local -a action_flags=("-f,--format" "-h,--help" "-l,--list-usb-drives" "-v,--version" "-p,--probe" "-i,--inspect")
local -a one_word_format_opts=("-a,--autoselect" "-y,--asume-yes")
local -a two_word_format_opts=("-d,--device")
local -a two_word_install_opts=("--assume-image-is")
local -a one_word_advanced_format_opts=("--gpt")
local -a two_word_advanced_format_opts=("-L,--label" "-F,--fs" "--part-type")
local -a one_word_inspect_opts=("--no-hash-check" "--force-hash-check" "-M,--no-mime-check")
Expand Down Expand Up @@ -264,6 +268,7 @@ __bootiso_start() {
two_word_flags=(
"${two_word_inspect_opts[@]}"
"${two_word_format_opts[@]}"
"${two_word_install_opts[@]}"
)
if [[ "${user_vars[installmode]}" == mrsync ]]; then
one_word_flags+=(
Expand All @@ -280,7 +285,7 @@ __bootiso_start() {
two_word_flags+=(
"${one_word_icopy_install_opts[@]}"
"${two_word_icopy_install_opts[@]}"
)
)
fi
;;
format)
Expand Down
1 change: 1 addition & 0 deletions extra/completions/completions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ typeset _bootiso_inspect_opts=(
typeset _bootiso_install_opts=(
'(--mrsync --dd --icopy)'{--dd,--icopy}"[assert 'Image-Copy' install mode]"
"(--dd --icopy)--mrsync[assert 'Mount-Rsync' install mode]"
"--assume-image-is[override bootiso assessment of image hybridness]:imagetype:(hybrid non-hybrid)"
'(-J --no-eject)'{-J,--no-eject}"[don't eject device after unmounting]"
"--no-size-check[don't assert that selected device size is larger than <imagefile>]"
)
Expand Down
19 changes: 19 additions & 0 deletions extra/man/bootiso.1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ one is printed.
.Oc
.Op Cm --no-size-check
.Op Cm --no-usb-check
.Op Cm --assume-image-is Ar image-type
.Op Cm --
.Ar imagefile
.\" Install Image-Copy mode
Expand Down Expand Up @@ -215,6 +216,24 @@ version then exits.
.Ss Generic Modifiers
Use generic modifiers knowingly as some might override default safe behaviors.
.Bl -tag
.It Cm --assume-image-is Ar image-type
Override
.Nm
assessment of
.Ar imagefile
hybridness. Use
.Dq hybrid
to force
.Nm
regard
.Ar imagefile
as hybrid, and
.Dq non-hybrid
to force
.Nm
regard
.Ar imagefile
as non hybrid.
.It Fl a, Cm --autoselect
Enable
.Dq autoselect
Expand Down

0 comments on commit ee15854

Please sign in to comment.