Hi, Core people!
One more post about grub2 and TinyCore. Using multiple TC versions, building custom rootfs-es, kernels, having need for different bootcodes' batches makes someone tired of constant editing (manual!) of grub,cfg according to the newly appeared environments. Trying to avoid grub.cfg manual editing I've made a universal grub.cfg, which, once stored in /EFI/BOOT/grub directory, don't need to be cared and make all the job of creating grub2 menu entries during boot process by itself lonely. Of course this assumes, that the structure and content of the boot device follows certain rules.
Boot device contains a directory tree with distribution files (vmlinuz, vmlinuz64, rootfs.gz, rootfs64.gz, modules.gz, modules64.gz) placed in various directories. Also boot device directory tree contains "bootcodes" files. The normal way to use "bootcodes" files is to place the single
BOOTCODES="<something>"
definition, which will be sourced to the grub2 shell while creating the corresponding menu entry.
Boot menu entries are created only for the terminal nodes - dirctories, which doesn't have subdirs. Each terminal node has unique path from the root directory. Distribution files are collected along this path exclusively, means if on the way from / to /10/4/6/7 more than one "vmlinuz" will be found, the latest (closest to the terminal node) will be used. "bootcodes" assignments are accumulated in BOOTCODES_FULL variable, which immediately is used for creating menu entry itself.
For every terminal node entries tried to be created depends on the set of distribution files collected along the path and CPU bitness.
Directory names, visible for script, can only be natural numbers (see NATURALS constant in the source code). Directories alternatively named don't influence on entries cretion process.
First subdir in BOOT_ROOT is considered to be the version number and all the down-level subdirs' created entries will share the same TCE<version> working directory. So distribution files of TC10.0 version, placed in /10/0 and TC10.1 files placed in /10/1 will share the same /TCE10 directory for roots and /TCE10-64 for rootfs64. Boot and TCE devices may be separate ones.
So final grub.cfg is "cat"-ed of the definition header (grub.cfg.def) and grub.cfg.template and is placed in /EFI/BOOT/grub/ on the EFI device, according to initial Juanito's post.
Additional tool for making menu entries understandable are "title" files. For example, if /10/1 contains 32-bit distributionn files, /10/1/2 contains "bootcodes" with
BOOTCODES="noswap nodhcp"
then corresponding boot menu entry will be named "core-10-1-2". But if You'll place in /10/1/2 the file "title", containing
TITLE="mysettings1"
then corresponding entry becomes named "core-10-1-mysettings1".
Important note: TITLE value string must not contain spaces.
This is brief description of the grub.cfg.template possibilities. Of course, it is not fully tested, so You can use it with care.
Have a nice Core!