grub-install C rewrite
RFC 1/1 grub-install C rewrite
Hello, all. Recently I made some order in hostdisk.c and getroot.c involving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.
I'd like to know the opinion of other people on possible switchover. If switched then it'll have to be all grub-install, grub-mkrescue, grub-mknetdir and grub-mkstandalone.
I'd like to hear from other people.
=== modified file 'Makefile.util.def'
Makefile.util.def +27 -5
@@ -159,6 +159,7 @@ mansection = 1; common = util/grub-mkimage.c; + common = util/mkimage.c; common = util/resolve.c; common = grub-core/kern/emu/argp_common.c;
@@ -222,6 +223,7 @@ common = util/grub-mkpasswd-pbkdf2.c; common = grub-core/kern/emu/argp_common.c; + common = util/random.c; ldadd = libgrubmods.a; ldadd = libgrubgcry.a;
@@ -307,6 +309,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_bios.c; common = grub-core/kern/emu/argp_common.c; common = grub-core/lib/reed_solomon.c;
@@ -315,7 +318,7 @@ ldadd = libgrubgcry.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_BIOS=1'; + cppflags = '-DGRUB_SETUP_FUNC=grub_bios_setup'; }; program = {
@@ -323,6 +326,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_sparc.c; common = grub-core/kern/emu/argp_common.c; common = grub-core/lib/reed_solomon.c; common = util/ieee1275/ofpath.c;
@@ -332,7 +336,7 @@ ldadd = libgrubgcry.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_SPARC64=1'; + cppflags = '-DGRUB_SETUP_FUNC=grub_sparc_setup'; }; program = {
@@ -463,14 +467,32 @@ common = util/grub-mkstandalone.in; }; -script = { +program = { mansection = 8; installdir = sbin; name = grub-install; - common = util/grub-install_header; - common = util/grub-install.in; + common = util/mkimage.c; + common = util/grub-install.c; + common = util/grub-install-common.c; + common = util/setup_bios.c; + common = util/setup_sparc.c; + common = grub-core/lib/reed_solomon.c; + common = util/random.c; + common = util/ieee1275/ofpath.c; + + common = grub-core/kern/arm/dl_helper.c; + + common = util/resolve.c; enable = noemu; + common = grub-core/kern/emu/argp_common.c; + + ldadd = '$(LIBLZMA)'; + ldadd = libgrubmods.a; + ldadd = libgrubgcry.a; + ldadd = libgrubkern.a; + ldadd = grub-core/gnulib/libgnu.a; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; script = {
=== modified file 'grub-core/disk/cryptodisk.c'
disk/cryptodisk.c +13 -11
@@ -746,31 +746,33 @@ }void -grub_util_cryptodisk_print_abstraction (grub_disk_t disk) +grub_util_cryptodisk_get_abstraction (grub_disk_t disk, +void (*cb) (const char *val)) {grub_cryptodisk_t dev = (grub_cryptodisk_t ) disk->data; -grub_printf ("cryptodisk %s " , dev->modname); +cb ("cryptodisk" ); +cb (dev->modname);if (dev->cipher) -grub_printf ("%s " , dev->cipher->cipher->modname); +cb (dev->cipher->cipher->modname);if (dev->secondary_cipher) -grub_printf ("%s " , dev->secondary_cipher->cipher->modname); +cb (dev->secondary_cipher->cipher->modname);if (dev->essiv_cipher) -grub_printf ("%s " , dev->essiv_cipher->cipher->modname); +cb (dev->essiv_cipher->cipher->modname);if (dev->hash) -grub_printf ("%s " , dev->hash->modname); +cb (dev->hash->modname);if (dev->essiv_hash) -grub_printf ("%s " , dev->essiv_hash->modname); +cb (dev->essiv_hash->modname);if (dev->iv_hash) -grub_printf ("%s " , dev->iv_hash->modname); +cb (dev->iv_hash->modname); } -void -grub_util_cryptodisk_print_uuid (grub_disk_t disk) +const char * +grub_util_cryptodisk_get_uuid (grub_disk_t disk) {grub_cryptodisk_t dev = (grub_cryptodisk_t ) disk->data; -grub_printf ("%s " , dev->uuid); +return dev->uuid; }#endif
=== modified file 'grub-core/disk/diskfilter.c'
disk/diskfilter.c +3 -2
@@ -353,7 +353,8 @@ }void -grub_diskfilter_print_partmap (grub_disk_t disk) +grub_diskfilter_get_partmap (grub_disk_t disk, +void (*cb) (const char *pm)) {struct grub_diskfilter_lv *lv = disk->data;struct grub_diskfilter_pv *pv;
@@ -375,7 +376,7 @@continue ; }for (s =0 ; pv->partmaps[s]; s++) -grub_printf ("%s " , pv->partmaps[s]); +cb (pv->partmaps[s]); } }
=== modified file 'include/grub/crypto.h'
grub/crypto.h +4 -0
@@ -406,6 +406,10 @@#ifdef GRUB_UTIL void grub_gcry_init_all (void );void grub_gcry_fini_all (void ); + +int +grub_get_random (void *out,grub_size_t len); +#endif #endif
=== modified file 'include/grub/cryptodisk.h'
grub/cryptodisk.h +3 -1
@@ -144,7 +144,9 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, grub_disk_t source, const char *cheat);void -grub_util_cryptodisk_print_abstraction (grub_disk_t disk); +grub_util_cryptodisk_get_abstraction (grub_disk_t disk, +void (*cb) (const char *val)); +char *grub_util_get_geli_uuid (const char *dev);#endif
=== modified file 'include/grub/diskfilter.h'
grub/diskfilter.h +2 -1
@@ -201,7 +201,8 @@ grub_diskfilter_get_pv_from_disk (grub_disk_t disk, struct grub_diskfilter_vg **vg);void -grub_diskfilter_print_partmap (grub_disk_t disk); +grub_diskfilter_get_partmap (grub_disk_t disk, +void (*cb) (const char *val));#endif #endif /* ! GRUB_RAID_H */
=== modified file 'include/grub/emu/getroot.h'
grub/emu/getroot.h +2 -0
@@ -79,6 +79,8 @@#include <sys/types.h> pid_t grub_util_exec_pipe (char **argv,int *fd); +void +grub_util_exec (char **argv);#endif void grub_util_pull_lvm_by_command (const char *os_dev);
=== modified file 'include/grub/emu/hostdisk.h'
grub/emu/hostdisk.h +2 -1
@@ -65,7 +65,8 @@ssize_t grub_util_fd_write (grub_util_fd_t fd,const char *buf,size_t len);grub_err_t grub_cryptodisk_cheat_mount (const char *sourcedev,const char *cheat); -void grub_util_cryptodisk_print_uuid (grub_disk_t disk); +const char * +grub_util_cryptodisk_get_uuid (grub_disk_t disk);char *grub_util_get_ldm (grub_disk_t disk,grub_disk_addr_t start);int
=== added file 'include/grub/util/install.h'
grub/util/install.h +169 -0
169 lines not on this page · raw message
=== modified file 'util/getroot_unix.c'
getroot_unix.c +26 -0
@@ -143,6 +143,32 @@return path; } +void +grub_util_exec (char **argv) +{ +pid_t mdadm_pid; + + mdadm_pid =fork (); +if (mdadm_pid <0 ) +grub_util_error (_ ("Unable to fork: %s" ),strerror (errno)); +else if (mdadm_pid ==0 ) + { +/* Child. */ + +/* Close fd's. */ +grub_util_devmapper_cleanup (); +grub_diskfilter_fini (); + +/* Ensure child is not localised. */ +setenv ("LC_ALL" ,"C" ,1 ); + +execvp (argv[0 ], argv); +exit (127 ); + } +else +return ; +} +pid_t grub_util_exec_pipe (char **argv,int *fd) {
=== added file 'util/grub-install-common.c'
grub-install-common.c +796 -0
796 lines not on this page · raw message
=== added file 'util/grub-install.c'
grub-install.c +1469 -0
1,469 lines not on this page · raw message
=== modified file 'util/grub-mkimage.c'
grub-mkimage.c +21 -1809
348 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-mkimagexx.c'
grub-mkimagexx.c +12 -12
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-mkpasswd-pbkdf2.c'
grub-mkpasswd-pbkdf2.c +0 -47
47 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-probe.c'
grub-probe.c +12 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-setup.c'
grub-setup.c +14 -926
940 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/mkimage.c'
mkimage.c +1861 -0
1,861 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/random.c'
random.c +5 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== added file 'util/random_unix.c'
random_unix.c +53 -0
53 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/random_windows.c'
random_windows.c +55 -0
55 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/setup.c'
setup.c +983 -0
983 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/setup_bios.c'
setup_bios.c +2 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== added file 'util/setup_sparc.c'
setup_sparc.c +2 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 18 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.
Quoted 4 lines
I'd like to know the opinion of other people on possible switchover. If switched then it'll have to be all grub-install, grub-mkrescue, grub-mknetdir and grub-mkstandalone.
I'd like to hear from other people.
Given the number of times I have had to edit grub-install in the past to get it to work right on a powerpc machine (I think it is now working OK), I would hate to have had that be C code. After all it really is mainly a wrapper around other grub tools.
I think windows not having bash is a rather low priority to most people compared to actually be able to work with grub on the platforms where it is pretty much the only choice.
So personally, based on my experience, I hate this idea.
Signature · 1 line
Len Sorensen
Quoted 24 lines · Lennart Sorensen
Quoted 18 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.Quoted 4 lines
I'd like to know the opinion of other people on possible switchover. If switched then it'll have to be all grub-install, grub-mkrescue, grub-mknetdir and grub-mkstandalone.
I'd like to hear from other people.
Quoted 5 lines
Given the number of times I have had to edit grub-install in the past to get it to work right on a powerpc machine (I think it is now working OK), I would hate to have had that be C code. After all it really is mainly a wrapper around other grub tools.
What kind of changes was it? Could we make them into some (possibly hidden) options?
Quoted 4 lines
I think windows not having bash is a rather low priority to most people compared to actually be able to work with grub on the platforms where it is pretty much the only choice.
windows is low priority and more of a bonus. The problems of handling anything that looks like a list (e.g. list of devices where / resides on in case of btrfs) and code becoming hairy to handle those cases is bigger reason.
Quoted 2 lines
So personally, based on my experience, I hate this idea.
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko
What kind of changes was it? Could we make them into some (possibly hidden) options?
Well for quite a while the logic was assuming apple powerpc, and it needed rework to make it work on the IBM powerpc systems.
To some extent I think grub-install as a script is a great source of info on what steps have to be taken to install grub, so you can do it manually if something isn't working.
Quoted 4 lines
windows is low priority and more of a bonus. The problems of handling anything that looks like a list (e.g. list of devices where / resides on in case of btrfs) and code becoming hairy to handle those cases is bigger reason.
Sure lists can be a hassle.
I didn't check lately, but does grub-install understand a list of devices to install to yet?
ie: grub-install /dev/sda /dev/sdb
After all if I have software raid, both those devices contain /boot and are valid to boot from. And since on things like IBM powerpc, grub-install likes to update the firmware with the list of boot devices, they do all have to be specified at once or you end up with the wrong list (which so far I have worked around by manually fixing the firmware settings after updating grub, which doesn't happen very often lately).
So calling grub-install for each device in turn (as I believe Debian does on x86 if you tell it multiple boot devices), does not actually give the correct result.
Of course when grub-install is a script, it is easy to fiddle with it to make it handle such a case.
So really my main objection is that it is much harder to debug and fix C code than it is to fix a script calling a bunch of external commands.
At the very least a C version of grub-install must have an option to list every command it is attempting to execute externally. Certainly adding 'set -x' to grub-install has often been helpful.
Signature · 1 line
Len Sorensen
В Thu, 26 Sep 2013 15:08:54 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 9 lines
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.
If we agree on bash as common denominator, bash has arrays which make this straightforward. Unless we want to continue support for bash 1.x.
Quoted 13 lines
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.
I'd like to know the opinion of other people on possible switchover. If switched then it'll have to be all grub-install, grub-mkrescue, grub-mknetdir and grub-mkstandalone.
I'd like to hear from other people.
Quoted 5 lines
If we agree on bash as common denominator, bash has arrays which make this straightforward. Unless we want to continue support for bash 1.x.
This would step up the requirements. BSDs commonly have no bash installed. AROS probably has no bash available at all.
AROS uses GRUB as its bootloader but currently use their own code in C to install.
Ditto here. I'd prefer it stay *sh.
--S
Quoted 42 lines · Lennart Sorensen
Quoted 18 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.Quoted 4 lines
I'd like to know the opinion of other people on possible switchover. If switched then it'll have to be all grub-install, grub-mkrescue, grub-mknetdir and grub-mkstandalone.
I'd like to hear from other people.Given the number of times I have had to edit grub-install in the past to get it to work right on a powerpc machine (I think it is now working OK), I would hate to have had that be C code. After all it really is mainly a wrapper around other grub tools.
I think windows not having bash is a rather low priority to most people compared to actually be able to work with grub on the platforms where it is pretty much the only choice.
So personally, based on my experience, I hate this idea.
Signature · 6 lines
Len Sorensen _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 19 lines · Lennart Sorensen
Quoted 4 lines
windows is low priority and more of a bonus. The problems of handling anything that looks like a list (e.g. list of devices where / resides on in case of btrfs) and code becoming hairy to handle those cases is bigger reason.
Sure lists can be a hassle.
I didn't check lately, but does grub-install understand a list of devices to install to yet?
ie: grub-install
/dev/sda/dev/sdbAfter all if I have software raid, both those devices contain /boot and are valid to boot from. And since on things like IBM powerpc, grub-install likes to update the firmware with the list of boot devices, they do all have to be specified at once or you end up with the wrong list (which so far I have worked around by manually fixing the firmware settings after updating grub, which doesn't happen very often lately).
Quoted 4 lines
So calling grub-install for each device in turn (as I believe Debian does on x86 if you tell it multiple boot devices), does not actually give the correct result.
This is interesting testcase which wasn't brought before. This would potentially involve creating several core.img or forcing UUID when using multiple devices. Again, pretty easy in C and hairy in bash due to list handling.
Quoted 6 lines
So really my main objection is that it is much harder to debug and fix C code than it is to fix a script calling a bunch of external commands.
At the very least a C version of grub-install must have an option to list every command it is attempting to execute externally. Certainly adding 'set -x' to grub-install has often been helpful.
It's surely sth we can do. grub-install does only following that is affecting system:
1) mkdir -p
2) copy files. We can write exact copy commands
3) grub-mkimage. We can do the same.
4) grub-setup. Ditto
5) Create load.cfg. Ditto.
6) calling external commands.
We can have 4 levels of verbosity:
0) quiet,
1) write to stderr the commands
2) like 1 but show grub_util_info
3) additionally show grub_dprintf
It's also possible to have options --dry-run (doesn't really do the changes, except, perhaps, "mkdir -p") and --gen-script which would generate a list of commands which when executed would do exactly as if grub-install was run. So you can do
grub-install --dry-run --gen-script=/tmp/myinstall ... <change /tmp/myinstall to will>/tmp/myinstall
This has additional advantage of see which commands are really executed without having to understand the whole command flow.
Quoted 3 lines · Seth Goldberg
Ditto here. I'd prefer it stay *sh.
Even if it would mean to go with bash?
Solaris was one of the worst platforms for making grub-install work there due to its very limited shell and standard tools behaving differently. Frankly I wouldn't be surprised if it got broken for solaris again.
I see Solaris as one of platforms which can benefit a lot from this move.
Quoted 53 lines
--S
Quoted 29 lines · Lennart Sorensen
Quoted 18 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.Quoted 4 lines
I'd like to know the opinion of other people on possible switchover. If switched then it'll have to be all grub-install, grub-mkrescue, grub-mknetdir and grub-mkstandalone.
I'd like to hear from other people.Given the number of times I have had to edit grub-install in the past to get it to work right on a powerpc machine (I think it is now working OK), I would hate to have had that be C code. After all it really is mainly a wrapper around other grub tools.
Quoted 13 lines
I think windows not having bash is a rather low priority to most people compared to actually be able to work with grub on the platforms where it is pretty much the only choice.
So personally, based on my experience, I hate this idea.
Signature · 6 lines
Len Sorensen _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Seth Goldberg
Ditto here. I'd prefer it stay *sh.
Even if it would mean to go with bash?
Solaris was one of the worst platforms for making grub-install work there due to its very limited shell and standard tools behaving differently. Frankly I wouldn't be surprised if it got broken for solaris again.
I see Solaris as one of platforms which can benefit a lot from this move.
bash is always installed on Solaris 11 onwards (11.1 is when it moved from legacy GRUB to GRU2) - not least of which because it is root's login shell.
Signature · 1 line
Darren J Moffat
Quoting Vladimir 'φ-coder/phcoder' Serbinenko, who wrote the following on...:
Quoted 10 lines · Seth Goldberg
Quoted 3 lines
Ditto here. I'd prefer it stay *sh.
Even if it would mean to go with bash?
Solaris was one of the worst platforms for making grub-install work there due to its very limited shell and standard tools behaving differently. Frankly I wouldn't be surprised if it got broken for solaris again.
I see Solaris as one of platforms which can benefit a lot from this move.
My motivation was mainly from a maintenance perspective, but it really
depends on how well-structured the C is. In the past, some essential code (*cough* relocator) was implemented monolithically and was extremely difficult to understand. There are certainly a lot of positives to implementing it in C (the tons of forks from the file-copies can be eliminated, for example).
NB: bash is a first-class shell on Solaris these days, so I'm not too
concerned about that.
Thanks,
--S
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko
This is interesting testcase which wasn't brought before. This would potentially involve creating several core.img or forcing UUID when using multiple devices. Again, pretty easy in C and hairy in bash due to list handling.
No, one core.img is fine. The boot disk is the boot disk in each case (so on x86 device 0x80). The same core.img gets inserted too all the devices, so that if it happens to be the boot disk, it works. Since the partition is raid1, the same UUID is everywhere. I do not expect booting from a raid5 device to be possible as the boot partition (althoug hperhaps grub is smart enough to read the kernel from an md raid5 device these days).
Quoted 23 lines
It's surely sth we can do. grub-install does only following that is affecting system:
1) mkdir -p
2) copy files. We can write exact copy commands
3) grub-mkimage. We can do the same.
4) grub-setup. Ditto
5) Create load.cfg. Ditto.
6) calling external commands.
We can have 4 levels of verbosity:
0) quiet,
1) write to stderr the commands
2) like 1 but showgrub_util_info
3) additionally showgrub_dprintfIt's also possible to have options --dry-run (doesn't really do the changes, except, perhaps, "mkdir -p") and --gen-script which would generate a list of commands which when executed would do exactly as if grub-install was run. So you can do
grub-install --dry-run --gen-script=/tmp/myinstall ... <change/tmp/myinstallto will>/tmp/myinstall
This has additional advantage of see which commands are really executed without having to understand the whole command flow.
Signature · 1 line
Len Sorensen
Quoted 8 lines · Lennart Sorensen
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko
This is interesting testcase which wasn't brought before. This would potentially involve creating several core.img or forcing UUID when using multiple devices. Again, pretty easy in C and hairy in bash due to list handling.
No, one core.img is fine. The boot disk is the boot disk in each case (so on x86 device
0x80).
We don't rely on it being 0x80 and it may not be 0x80 at all.
Quoted 2 lines
Since the
partition is raid1, the same UUID is everywhere.
UUID would be the same but for whole other reason. It's the same because even with different install device you still have same device for $grubdir. The problem comes from the possibility to avoid UUID entirely on some devices but not others.
Quoted 2 lines
I do not expect
booting from a raid5 device to be possible as the boot partition
This works. Your expectations are too low.
Quoted 25 lines
Quoted 24 lines
It's surely sth we can do. grub-install does only following that is affecting system:
1) mkdir -p
2) copy files. We can write exact copy commands
3) grub-mkimage. We can do the same.
4) grub-setup. Ditto
5) Create load.cfg. Ditto.
6) calling external commands.
We can have 4 levels of verbosity:
0) quiet,
1) write to stderr the commands
2) like 1 but showgrub_util_info
3) additionally showgrub_dprintfIt's also possible to have options --dry-run (doesn't really do the changes, except, perhaps, "mkdir -p") and --gen-script which would generate a list of commands which when executed would do exactly as if grub-install was run. So you can do
grub-install --dry-run --gen-script=/tmp/myinstall ... <change/tmp/myinstallto will>/tmp/myinstall
This has additional advantage of see which commands are really executed without having to understand the whole command flow.
Quoted 6 lines · Lennart Sorensen
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko
This is interesting testcase which wasn't brought before. This would potentially involve creating several core.img or forcing UUID when using multiple devices. Again, pretty easy in C and hairy in bash due to list handling.
Quoted 7 lines
No, one core.img is fine. The boot disk is the boot disk in each case (so on x86 device
0x80). The same core.img gets inserted too all the devices, so that if it happens to be the boot disk, it works. Since the partition is raid1, the same UUID is everywhere. I do not expect booting from a raid5 device to be possible as the boot partition (althoug hperhaps grub is smart enough to read the kernel from an md raid5 device these days).
It is. Even raid6 is possible. The limitation is the BIOS being able to present all member devices to grub for it to assemble the raid in order to find /boot. But I don't know if it can work on a degraded array by rebuilding parity. If not, I see no point in /boot on raid5/6.
The case of btrfs raid0/1/10 is interesting. It's possible to boot all of these with GRUB2, I've tried up to 4 disks for those raid levels, and includes support for subvolumes/snapshots. I haven't extensively tried to break it with many snapshots, deletions, etc. So I don't know how resilient it is. The ability to boot raid1/10 with a missing member is useful. And it's actually a more complex setup to incorporate md raid and ext4 on those same disks for a separate /boot; or possibly losing ability to boot if /boot is on a single disk, which also complicates the layout. For such a layout, core.img is needed for each disk.
Open question is if on BIOS hardware, if a 1MB BIOSBoot is preferred over the 64KB Btrfs bootloader pad? I don't know off hand if each member disk, or subsequently added disks, each have this 64KB pad or just the first member.
Chris Murphy
Quoted 17 lines · Chris Murphy
Quoted 6 lines · Lennart Sorensen
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko
This is interesting testcase which wasn't brought before. This would potentially involve creating several core.img or forcing UUID when using multiple devices. Again, pretty easy in C and hairy in bash due to list handling.
Quoted 7 lines
No, one core.img is fine. The boot disk is the boot disk in each case (so on x86 device
0x80). The same core.img gets inserted too all the devices, so that if it happens to be the boot disk, it works. Since the partition is raid1, the same UUID is everywhere. I do not expect booting from a raid5 device to be possible as the boot partition (althoug hperhaps grub is smart enough to read the kernel from an md raid5 device these days).
Quoted 6 lines
It is. Even raid6 is possible. The limitation is the BIOS being able to present all member devices to grub for it to assemble the raid in order to find /boot. But I don't know if it can work on a degraded array by rebuilding parity. If not, I see no point in /boot on raid5/6.
The case of btrfs raid0/1/10 is interesting. It's possible to boot all of these with GRUB2, I've tried up to 4 disks for those raid levels, and includes support for subvolumes/snapshots. I haven't extensively tried to break it with many snapshots, deletions, etc. So I don't know how resilient it is. The ability to boot raid1/10 with a missing member is useful. And it's actually a more complex setup to incorporate md raid and ext4 on those same disks for a separate /boot; or possibly losing ability to boot if /boot is on a single disk, which also complicates the layout. For such a layout, core.img is needed for each disk.
Open question is if on BIOS hardware, if a 1MB BIOSBoot is preferred over the 64KB Btrfs bootloader pad? I don't know off hand if each member disk, or subsequently added disks, each have this 64KB pad or just the first member.
This is besides the point. I'm fine to discuss such things but in a separate thread.
Quoted 7 lines
Chris Murphy
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
В Thu, 26 Sep 2013 20:49:52 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 20 lines · Lennart Sorensen
Quoted 19 lines
Quoted 4 lines
windows is low priority and more of a bonus. The problems of handling anything that looks like a list (e.g. list of devices where / resides on in case of btrfs) and code becoming hairy to handle those cases is bigger reason.
Sure lists can be a hassle.
I didn't check lately, but does grub-install understand a list of devices to install to yet?
ie: grub-install
/dev/sda/dev/sdbAfter all if I have software raid, both those devices contain /boot and are valid to boot from. And since on things like IBM powerpc, grub-install likes to update the firmware with the list of boot devices, they do all have to be specified at once or you end up with the wrong list (which so far I have worked around by manually fixing the firmware settings after updating grub, which doesn't happen very often lately).
Quoted 4 lines
Quoted 4 lines
So calling grub-install for each device in turn (as I believe Debian does on x86 if you tell it multiple boot devices), does not actually give the correct result.
This will break in blocklist install because every time core.img is recreated, but I do not see why it should not work if embedding is possible. Challenge is to atomically detect whether this is possible or not for all devices before you have clobbered half of them.
Although right now we first rewrite /boot/grub and then try to install; if installation fails, /boot/grub no more matches embedded core.img anyway.
Quoted 4 lines
This is interesting testcase which wasn't brought before. This would potentially involve creating several core.img or forcing UUID when using multiple devices. Again, pretty easy in C and hairy in bash due to list handling.
Why it would require separate core.img? core.img needs to know how access /boot/grub, and /boot/grub remains the same. Same with UUID. Or do I miss something here?
Quoted 11 lines
It's also possible to have options --dry-run (doesn't really do the changes, except, perhaps, "mkdir -p") and --gen-script which would generate a list of commands which when executed would do exactly as if grub-install was run. So you can do
grub-install --dry-run --gen-script=/tmp/myinstall ... <change/tmp/myinstallto will>/tmp/myinstall
This has additional advantage of see which commands are really executed without having to understand the whole command flow.
That would definitely be useful irrespectively of which language is used to implement. In particular, this would allow to see list of modules required for a system.
Quoted 9 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.
Quoted 8 lines
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.
Attached is the second iteration of this patch. Now the biggest problem is in reading /etc/default/grub and getting GRUB_DISTRIBUTOR and GRUB_ENABLE_CRYPTODISK. Trouble is that now this file is simply included in bash script and e.g. Debian uses it to determine GRUB_DISTRIBUTOR based on lsb_release output. Does anyone have an elegant solution for this?
=== modified file 'Makefile.util.def'
Makefile.util.def +28 -5
@@ -159,6 +159,7 @@ mansection = 1; common = util/grub-mkimage.c; + common = util/mkimage.c; common = util/resolve.c; common = grub-core/kern/emu/argp_common.c;
@@ -208,6 +209,7 @@ mansection = 1; common = util/grub-editenv.c; + common = util/editenv.c; ldadd = libgrubmods.a; ldadd = libgrubgcry.a;
@@ -308,6 +310,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_bios.c; common = grub-core/kern/emu/argp_common.c; common = grub-core/lib/reed_solomon.c;
@@ -316,7 +319,7 @@ ldadd = libgrubgcry.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_BIOS=1'; + cppflags = '-DGRUB_SETUP_FUNC=grub_bios_setup'; }; program = {
@@ -324,6 +327,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_sparc.c; common = grub-core/kern/emu/argp_common.c; common = grub-core/lib/reed_solomon.c; common = util/ieee1275/ofpath.c;
@@ -333,7 +337,7 @@ ldadd = libgrubgcry.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - cppflags = '-DGRUB_SETUP_SPARC64=1'; + cppflags = '-DGRUB_SETUP_FUNC=grub_sparc_setup'; }; program = {
@@ -464,14 +468,33 @@ common = util/grub-mkstandalone.in; }; -script = { +program = { mansection = 8; installdir = sbin; name = grub-install; - common = util/grub-install_header; - common = util/grub-install.in; + common = util/mkimage.c; + common = util/grub-install.c; + common = util/grub-install-common.c; + common = util/setup_bios.c; + common = util/setup_sparc.c; + common = grub-core/lib/reed_solomon.c; + common = util/random.c; + common = util/ieee1275/ofpath.c; + common = util/editenv.c; + + common = grub-core/kern/arm/dl_helper.c; + + common = util/resolve.c; enable = noemu; + common = grub-core/kern/emu/argp_common.c; + + ldadd = '$(LIBLZMA)'; + ldadd = libgrubmods.a; + ldadd = libgrubgcry.a; + ldadd = libgrubkern.a; + ldadd = grub-core/gnulib/libgnu.a; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; script = {
=== modified file 'configure.ac'
configure.ac +13 -4
@@ -73,14 +73,10 @@ TARGET_CFLAGS="$TARGET_CFLAGS -Os" fi -BUILD_CPPFLAGS="$BUILD_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\"" - # Default HOST_CPPFLAGS HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W" HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1" -HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\"" -HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\"" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
@@ -1344,6 +1340,19 @@ AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin]) AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x]) +test "x$prefix" = xNONE && prefix="$ac_default_prefix" +test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" +datarootdir="$(eval echo "$datarootdir")" +grub_libdir="$(eval echo "$libdir")" +grub_localedir="$(eval echo "$localedir")" +grub_datadir="$(eval echo "$datadir")" +grub_sysconfdir="$(eval echo "$sysconfdir")" +AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir]) +AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir]) +AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir]) +AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$sysconfdir", [Configuration dir]) + + # Output files. cpudir="${target_cpu}" if test x${cpudir} = xmipsel; then
=== added file 'include/grub/util/install.h'
grub/util/install.h +189 -0
189 lines not on this page · raw message
=== added file 'util/editenv.c'
editenv.c +66 -0
66 lines not on this page · raw message
=== modified file 'util/getroot_unix.c'
getroot_unix.c +76 -1
93 lines not on this page · raw message
=== modified file 'util/grub-editenv.c'
grub-editenv.c +3 -35
@@ -23,6 +23,7 @@#include <grub/util/misc.h> #include <grub/lib/envblk.h> #include <grub/i18n.h> +#include <grub/util/install.h> #include <stdio.h> #include <unistd.h>
@@ -32,7 +33,6 @@#include "progname.h" -#define DEFAULT_ENVBLK_SIZE 1024#define DEFAULT_ENVBLK_PATH DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFGstatic struct argp_option options[] = {
@@ -108,38 +108,6 @@ NULL, help_filter, NULL }; -static void -create_envblk_file (const char *name) -{ -FILE *fp; -char *buf; -char *namenew; - - buf =xmalloc (DEFAULT_ENVBLK_SIZE ); - - namenew =xasprintf ("%s.new" , name); - fp =fopen (namenew,"wb" ); -if (! fp) -grub_util_error (_ ("cannot open `%s': %s" ), namenew, -strerror (errno)); - -memcpy (buf,GRUB_ENVBLK_SIGNATURE ,sizeof (GRUB_ENVBLK_SIGNATURE ) -1 ); -memset (buf +sizeof (GRUB_ENVBLK_SIGNATURE ) -1 ,'#' , -DEFAULT_ENVBLK_SIZE -sizeof (GRUB_ENVBLK_SIGNATURE ) +1 ); - -if (fwrite (buf,1 ,DEFAULT_ENVBLK_SIZE , fp) !=DEFAULT_ENVBLK_SIZE ) -grub_util_error (_ ("cannot write to `%s': %s" ), namenew, -strerror (errno)); - -fsync (fileno (fp)); -free (buf); -fclose (fp); - -if (rename (namenew, name) <0 ) -grub_util_error (_ ("cannot rename the file %s to %s" ), namenew, name); -free (namenew); -} -static grub_envblk_t open_envblk_file (const char *name) {
@@ -152,7 +120,7 @@if (! fp) {/* Create the file implicitly. */ -create_envblk_file (name); +grub_install_create_envblk_file (name); fp =fopen (name,"rb" );if (! fp) grub_util_error (_("cannot open `%s': %s"), name,
@@ -300,7 +268,7 @@ }if (strcmp (command,"create" ) ==0 ) -create_envblk_file (filename); +grub_install_create_envblk_file (filename);else if (strcmp (command,"list" ) ==0 )list_variables (filename);else if (strcmp (command,"set" ) ==0 )
=== added file 'util/grub-install-common.c'
grub-install-common.c +810 -0
810 lines not on this page · raw message
=== added file 'util/grub-install.c'
grub-install.c +1684 -0
1,661 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-mkimage.c'
grub-mkimage.c +21 -1809
1,830 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-mkimagexx.c'
grub-mkimagexx.c +12 -12
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-setup.c'
grub-setup.c +14 -926
940 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/mkimage.c'
mkimage.c +1861 -0
1,861 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/setup.c'
setup.c +987 -0
987 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== added file 'util/setup_bios.c'
setup_bios.c +2 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== added file 'util/setup_sparc.c'
setup_sparc.c +2 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
В Sun, 06 Oct 2013 16:54:08 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 21 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.Quoted 8 lines
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.
Attached is the second iteration of this patch.
Makefile.util.def line 313
Quoted 4 lines
Makefile.util.def +1
-0@@ -308,6 +310,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_bios.c;
+ extra_dist = util/setup.c;
Makefile.util.def line 330
Quoted 5 lines
Makefile.util.def +1
-0@@ -324,6 +327,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_sparc.c;
+ extra_dist = util/setup.c;
Makefile.util.def line 480
Quoted 12 lines
Makefile.util.def +6
-2+program = { mansection = 8; installdir = sbin; name = grub-install; - common = util/grub-install_header; - common = util/grub-install.in; + common = util/mkimage.c; + common = util/grub-install.c; + common = util/grub-install-common.c; + common = util/setup_bios.c; + common = util/setup_sparc.c;
+ extra_dist = util/setup.c;
Quoted 6 lines
Now the biggest problem
is in reading/etc/default/gruband gettingGRUB_DISTRIBUTORandGRUB_ENABLE_CRYPTODISK. Trouble is that now this file is simply included in bash script and e.g. Debian uses it to determineGRUB_DISTRIBUTORbased onlsb_releaseoutput. Does anyone have an elegant solution for this?
If declaring this as unsupported is not an option, the only solution is wrapper, something like
sh -c '/etc/default/grub; printf GRUB_DISTRIBUTOR=%s\\nGRUB_ENABLE_CRYPTODISK=%s\\n "$GRUB_DISTRIBUTOR" "$GRUB_ENABLE_CRYPTODISK"'
Quoted 59 lines · Andrey Borzenkov
В Sun, 06 Oct 2013 16:54:08 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 21 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines
Hello, all. Recently I made some order in
hostdisk.candgetroot.cinvolving splitting in OS-specific parts.
In the same time I added WinAPI version of getroot/hostdisk allowing grub-probe to work on windows natively
Also on-going is AROS-specific parts.
Windows and AROS are not friendly with bash.
The attempt to make both multiple files of same type work and handling whitespaces/newlines/... in filenames would result in very ugly code with loads of evals.Quoted 8 lines
Current code may have subtle assumptions on behaviour of common tools like sed and on locale (E.g. "[a-z]" doesn't cover u if locale is Estonian). So to check viability I rewrote grub-install in C. This is mostly proof of concept with loads of FIXMEs but I could boot i386-pc install made with it. In many aspects (static variables, some tests, general structure) it's reminiscent of sh version of grub-install it's based on. Some functionality is likely to stay OS-specific, e.g. executing compressors or determining firmware.
Attached is the second iteration of this patch.
Makefile.util.def line 313
Quoted 4 lines
Makefile.util.def +1
-0@@ -308,6 +310,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_bios.c;+
extra_dist=util/setup.c;Makefile.util.def line 330
Quoted 5 lines
Makefile.util.def +1
-0@@ -324,6 +327,7 @@ installdir = sbin; mansection = 8; common = util/grub-setup.c; + common = util/setup_sparc.c;+
extra_dist=util/setup.c;Makefile.util.def line 480
Quoted 12 lines
Makefile.util.def +6
-2+program = { mansection = 8; installdir = sbin; name = grub-install; - common = util/grub-install_header; - common = util/grub-install.in; + common = util/mkimage.c; + common = util/grub-install.c; + common = util/grub-install-common.c; + common = util/setup_bios.c; + common = util/setup_sparc.c;+
extra_dist=util/setup.c;Quoted 6 lines
Now the biggest problem
is in reading/etc/default/gruband gettingGRUB_DISTRIBUTORandGRUB_ENABLE_CRYPTODISK. Trouble is that now this file is simply included in bash script and e.g. Debian uses it to determineGRUB_DISTRIBUTORbased onlsb_releaseoutput. Does anyone have an elegant solution for this?
Quoted 6 lines
If declaring this as unsupported is not an option, the only solution is wrapper, something like
sh -c '
/etc/default/grub; printf GRUB_DISTRIBUTOR=%s\\nGRUB_ENABLE_CRYPTODISK=%s\\n "$GRUB_DISTRIBUTOR" "$GRUB_ENABLE_CRYPTODISK"'
Rather
sh -c '. /etc/default/grub; printf GRUB_DISTRIBUTOR=%s\\nGRUB_ENABLE_CRYPTODISK=%s\\n "$GRUB_DISTRIBUTOR" "$GRUB_ENABLE_CRYPTODISK"' This is probably the best way to do it on Unix-like systems with fallback for simple parser for other systems.
Quoted 7 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel