Hi L4 hackers,
When I Running hello.iso http://os.inf.tu-dresden.de/fiasco/build.html via *make grub2iso E=hello MODULE_SEARCH_PATH=/path/to/fiasco-build-dir *it failed to generate ISO, xorriso thrown such error:
xorriso : FAILURE : Not a known command: '-f'
xorriso : aborting : -abort_on 'FAILURE' encountered 'FAILURE' Failed to create ISO at tool/lib/L4/Grub.pm line 123. Makefile:598: recipe for target 'grub2iso' failed
so I simply changed the option:
Index: tool/lib/L4/Grub.pm =================================================================== --- tool/lib/L4/Grub.pm (revision 72) +++ tool/lib/L4/Grub.pm (working copy) @@ -116,7 +116,7 @@ close A; }; my $cmd = "$mkr --output="$isofilename" $dir ". - join(' ', @morefiles)." --$opt -f"; + join(' ', @morefiles)." --$opt -follow default"; system("$cmd"); die "Failed to create ISO" if $?; # grub-mkrescue does not propagate internal tool errors
please review my patch, thanks a lot!
Hi,
xorriso : FAILURE : Not a known command: '-f'
This message is issued if xorriso is its native command mode, rather than in its mkisofs emulation mode which would recognize options -f or -follow-links.
- join(' ', @morefiles)." --$opt -f"; + join(' ', @morefiles)." --$opt -follow default";
Command -follow "default" is recognized in native command mode. This mode is active when xorriso starts, gets replaced by emulation mode by command -as "mkisofs", and gets activated again by an argument "--".
So the question is whether it is intentional that xorriso is in native command mode. If not, then one should check whether mkisofs emulation is started by -as "mkisofs" and whether it gets ended by "--" somehow.
I looked for an online presentation of the L4 repository. https://github.com/MIPS/fiasco-l4re/blob/master/src/l4/tool/lib/L4/Grub.pm seems to match Leslie's patch. Obviously xorriso is supposed to run in emulation mode underneath grub-mkrescue.
The $cmd would cause a switch to native mode if $opt was empty.
Given the comment "There are different versions of grub-mkrescue" i assume that the script shall cover both versions of the binary: The one which needs "--" to leave grub-mkrescue option interpretation for adding xorriso emulation options, and the one which forwards any unknown grub-mkrescue option to xorriso mkisofs emulation.
The version which needed "--" was never released but existed for a while in the repos and made its way into Linux distros (e.g. Debian 8). Its life began in november 2013 when the script was translated to C. It ended in march 2015 by https://github.com/coreos/grub/commit/cf47a2fba5852014bc59959c5e357e83139334... "grub-mkrescue: pass all unrecognized options unchanged to xorriso."
One would need to get both versions and find some signature by which they can be distinguished. My local version 2.02~beta2-36 needs "--" before xorriso -as mkisofs options. It does not contain a naked string "--usage" which i would expect from the commit in march 2015 $ strings /usr/bin/grub-mkrescue | grep '^--usage' $ but only as part of the larger help text $ strings /usr/bin/grub-mkrescue | grep '.*--usage' Try '%s --help' or '%s --usage' for more information. $
Leslie: Can you confirm that your local grub-mkrescue contains a match for strings /usr/bin/grub-mkrescue | grep '^--usage' ?
Have a nice day :)
Thomas
Hi Thomas,
在 2017年05月31日 15:01, Thomas Schmitt 写道:
strings /usr/bin/grub-mkrescue | grep '^--usage'
My local is grub2-XXX so strings /usr/bin/grub2-mkrescue | grep '^--usage' --usage
Hi,
i proposed as test for modern released grub-mkrescue binary:
strings /usr/bin/grub-mkrescue | grep '^--usage'
Leslie Zhai wrote:
My local is grub2-XXX so strings /usr/bin/grub2-mkrescue | grep '^--usage' --usage
So this test (or an equivalent one) would tell whether a binary grub-mkrescue needs no argument "--" between its own options and the user provided options for xorriso's mkisofs emulation.
Your proposed patch compensates for the effect of "--" on the modern released version of grub-mkrescue. But i would rather propose to suppress the "--" in this case and to stay in mkisofs emulation mode and option -f. Mixing both modes of xorriso is well possible, but might lead to unexpected results for people who are only used to the behavior of mkisofs.
So the next step propose is to find out which arguments are handed to grub-mkrescue and from where in the Perl code the argument "--" stems. This code part would have to become conditional depending on the detected binary version of grub-mkrescue.
The old script grub-mkrescue needs no argument "--" at the start of the xorriso -as mkisofs options. So it is compatible with the expectations of the modern released binary version. I.e. the current state of Grub.pm could be incompatible with the old script, too.
Have a nice day :)
Thomas
Hi,
i am now pondering over function grub2_mkisofs in Grub.pm (lacking much experience with Perl, i fear).
Do i get it right that this code looks for the shell script variant of grub-mkrescue and prepares for having xorriso re-start mkisofs emulation after it was ended by the "--" part of "--$opt -f" ?
my $opt = ''; open(A, $fp) && do { $opt = " -as mkisofs" if <A> =~ /^#! +/.+sh/; close A; }; my $cmd = "$mkr --output="$isofilename" $dir ". join(' ', @morefiles)." --$opt -f";
If the script is detected, then grub-mkrescue will get arguments equivalent to this pseudo shellcode:
--output="$isofilename" "$dir" -- -as mkisofs -f
whereas the binary grub-mkrescue gets
--output="$isofilename" "$dir" -- -f
which is wrong in case of the modern released binary version.
Although i really do not like the gesture "-- -as mkisofs", this would be the place to test for the modern released binary and to treat it like the old shell script variant.
My proposal is nevertheless to issue "--" only for the intermediate incompatible binary version. I.e. something like
my $opt = '--'; open(A, $fp) && do { $opt = "" if <A> =~ /^#! +/.+sh/; close A; };
# >>> test for modern released binary version and if so: $opt = ""
my $cmd = "$mkr --output="$isofilename" $dir ". join(' ', @morefiles)." $opt -f";
or
my $opt = ''
# >>> test for intermediate unreleased binary version and if so: $opt = "--"
my $cmd = "$mkr --output="$isofilename" $dir ". join(' ', @morefiles)." $opt -f";
Testing for the unreleased version might be more reliable, because this one is not supposed to change its signatures any more.
I understand that the programmer of Grub.pm expected grub-mkrescue to go on with its incompatible CLI change, whereas GRUB developers decided to rather fix the unintended incompatibility before next release. This release has happened meanwile. So _now_ the behavior is supposed to be stable and deviations are to be considered bugs.
Have a nice day :)
Thomas
pretty cool :)
在 2017年05月31日 17:46, Thomas Schmitt 写道:
Hi,
i am now pondering over function grub2_mkisofs in Grub.pm (lacking much experience with Perl, i fear).
Do i get it right that this code looks for the shell script variant of grub-mkrescue and prepares for having xorriso re-start mkisofs emulation after it was ended by the "--" part of "--$opt -f" ?
my $opt = ''; open(A, $fp) && do { $opt = " -as mkisofs" if <A> =~ /^#! +/.+sh/; close A; }; my $cmd = "$mkr --output="$isofilename" $dir ". join(' ', @morefiles)." --$opt -f";
If the script is detected, then grub-mkrescue will get arguments equivalent to this pseudo shellcode:
--output="$isofilename" "$dir" -- -as mkisofs -f
whereas the binary grub-mkrescue gets
--output="$isofilename" "$dir" -- -f
which is wrong in case of the modern released binary version.
Although i really do not like the gesture "-- -as mkisofs", this would be the place to test for the modern released binary and to treat it like the old shell script variant.
My proposal is nevertheless to issue "--" only for the intermediate incompatible binary version. I.e. something like
my $opt = '--'; open(A, $fp) && do { $opt = "" if <A> =~ /^#! +/.+sh/; close A; };
# >>> test for modern released binary version and if so: $opt = ""
my $cmd = "$mkr --output="$isofilename" $dir ". join(' ', @morefiles)." $opt -f";
or
my $opt = ''
# >>> test for intermediate unreleased binary version and if so: $opt = "--"
my $cmd = "$mkr --output="$isofilename" $dir ". join(' ', @morefiles)." $opt -f";
Testing for the unreleased version might be more reliable, because this one is not supposed to change its signatures any more.
I understand that the programmer of Grub.pm expected grub-mkrescue to go on with its incompatible CLI change, whereas GRUB developers decided to rather fix the unintended incompatibility before next release. This release has happened meanwile. So _now_ the behavior is supposed to be stable and deviations are to be considered bugs.
Have a nice day :)
Thomas
Hi,
Jakub Jermar wrote:
I was able to workaround this issue by dropping the test for scriptness of grub[2]-mkrescue:
This will not work with the intermediate form of the binary which existed from november 2013 to may 2015 and went e.g. into Debian 8. This program needs a "--" between its own options and the arguments which it shall forward to xorriso's mkisofs emulation.
The test seems to draw wrong conclusions at least on Fedora 25.
Leslie's local version of grub-mkrescue is obviously the modern released one. It is not easy to distinguish it from the unreleased but nevertheless widespread version. Leslie confirms that this shell gesture strings /usr/bin/grub-mkrescue | grep '^--usage' yields a match with his local binary. I can confirm that it yields no match with the binary in Debian 8.
Another way to find out would be to do it like autotool's ./configure: First run without "--" and retry with "--" if this fails.
The concern here would be if "-follow default" has the same semantics as "-as mkisofs -f".
Good question. Indeed the mkisofs emulation option -f triggers the native command -follow "on". (https://dev.lovelyhq.com/libburnia/libisoburn/raw/master/xorriso/emulators.c line 1101 in function Xorriso_genisofs_fused_options(): ret= Xorriso_option_follow(xorriso, "on", 0); ) -follow "default" is equivalent to not using mkisofs option -f.
But as developer of xorriso i would really, really advise not to hop out of mkisofs emulation in order to perform a native xorriso command. It would work but would also give future developers of Grub.pm something to riddle. I.e. omit "-- -as mkisofs" with script and modern binary version, use "--" with the intermediate binary version.
Have a nice day :)
Thomas
Hi,
i tested with the intermediate grub-mkrescue version of Debian 8.
$ grub-mkrescue --version grub-mkrescue (GRUB) 2.02~beta2-22
Test case is to pack up the grub-mkrescue program as payload of a bootable ISO. grub-mkrescue insists in some payload. One could as well use some /tmp/dummy file instead of $(which grub-mkrescue).
One can see that it is neither the script nor the released binary, because it fails without "--" before option -f :
$ grub-mkrescue --output=/dev/null $(which grub-mkrescue) -f grub-mkrescue: invalid option -- 'f' Try 'grub-mkrescue --help' or 'grub-mkrescue --usage' for more information. $ echo $? 64 $
So the way to operate it is with "--":
$ grub-mkrescue --output=/dev/null $(which grub-mkrescue) -- -f GNU xorriso 1.4.7 : RockRidge filesystem manipulator, libburnia project. ... Written to medium : 4421 sectors at LBA 0 Writing to 'stdio:/dev/null' completed successfully.
$ echo $? 0 $
But the --help text describes the behavior of script and released binary:
$ grub-mkrescue --help ... Generates a bootable CD/USB/floppy image. Arguments other than options to this program are passed to xorriso, and indicate source files, source directories, or any of the mkisofs options listed by the output of `xorriso -as mkisofs -help'.
Option -- switches to native xorriso command mode. ...
The intermediate binary consumes the first "--" and thus does not let xorriso switch to native command mode. The script and the released binary forward all "--" arguments to xorriso, This causes the error message which Leslie experiences, because -f is not a native xorriso command.
Given the pitfalls of program analysis, i deem above direct experiment the most reliable way to determine the need for "--".
Have a nice day :)
Thomas
Hi Thomas,
On 06/01/2017 08:45 AM, Thomas Schmitt wrote:
Jakub Jermar wrote:
I was able to workaround this issue by dropping the test for scriptness of grub[2]-mkrescue:
This will not work with the intermediate form of the binary which existed from november 2013 to may 2015 and went e.g. into Debian 8. This program needs a "--" between its own options and the arguments which it shall forward to xorriso's mkisofs emulation.
Well, it was not clear from the snippet, but the change preserved the use of "--". It only unconditionally added "-as mkisofs", which turns out not to be a good idea on Debian 8.8.
Best, Jakub
Hi Leslie,
On 05/31/2017 05:42 AM, Leslie Zhai wrote:
When I Running hello.iso http://os.inf.tu-dresden.de/fiasco/build.html via *make grub2iso E=hello MODULE_SEARCH_PATH=/path/to/fiasco-build-dir *it failed to generate ISO, xorriso thrown such error:
xorriso : FAILURE : Not a known command: '-f'
xorriso : aborting : -abort_on 'FAILURE' encountered 'FAILURE' Failed to create ISO at tool/lib/L4/Grub.pm line 123. Makefile:598: recipe for target 'grub2iso' failed
I was able to workaround this issue by dropping the test for scriptness of grub[2]-mkrescue:
my $opt = ''; open(A, $mkr) && do { - $opt = " -as mkisofs" if <A> =~ /^#! +/.+sh/; + $opt = " -as mkisofs"; close A; }; my $cmd = "$mkr --output="$isofilename" $dir ".
The test seems to draw wrong conclusions at least on Fedora 25. The fix works fine also on Ubuntu 16.04, besides Fedora.
so I simply changed the option:
Index: tool/lib/L4/Grub.pm
--- tool/lib/L4/Grub.pm (revision 72) +++ tool/lib/L4/Grub.pm (working copy) @@ -116,7 +116,7 @@ close A; }; my $cmd = "$mkr --output="$isofilename" $dir ".
join(' ', @morefiles)." --$opt -f";
system("$cmd"); die "Failed to create ISO" if $?; # grub-mkrescue does not propagate internal tool errorsjoin(' ', @morefiles)." --$opt -follow default";
please review my patch, thanks a lot!
The concern here would be if "-follow default" has the same semantics as "-as mkisofs -f". It would be also useful to know what system are you running this on.
Best, Jakub
Hi Jakub,
The concern here would be if "-follow default" has the same semantics
as "-as mkisofs -f".
Sorry for my monkey patch! and I am using Fedora 24 :)
l4-hackers@os.inf.tu-dresden.de