grub2: bring back build of aros-side grub2 tools
[AROS.git] / arch / all-pc / boot / grub2-aros / docs / autoiso.cfg
blob9ce51c692528ecd4c0aef1099119e1e2a6a628b3
1 # Sample GRUB script to autodetect operating systems
3 # Copyright (C) 2010  Free Software Foundation, Inc.
5 # GRUB is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # GRUB is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18 function pathname { regexp -s 2:"$2" '^(\(.*\))?(/.*)$' "$1"; }
19 function devname  { regexp -s "$2" '^(\(.*\)).*$' "$1"; }
21 function loopback_iso_entry {
22     realdev="$1"
23     isopath="$2"
24     loopdev="$3"
26     if test -f /boot/grub/loopback.cfg; then
27         cfgpath=/boot/grub/loopback.cfg
28     elif test -f /grub/loopback.cfg; then
29         cfgpath=/grub/loopback.cfg
30     else
31         return 1;
32     fi
34     echo loopback.cfg $isopath: yes
35     menuentry "Boot GRUB Loopback Config from ${realdev}${isopath}" "$realdev" "$isopath" "$cfgpath" {
36         set device="$2"
37         set iso_path="$3"
38         set cfg_path="$4"
40         export iso_path
41         loopback loopdev_cfg "${device}${iso_path}"
42         set root=(loopdev_cfg)
43         configfile $cfg_path
44         loopback -d loopdev_cfg
45     }
46     return 0
49 function grml_iso_entry {
50     realdev="$1"
51     isopath="$2"
52     loopdev="$3"
54     result=1
55     for dir in /boot/grml /boot/grmlsmall /boot/grmlmedium; do
56         if ! test -f ${dir}/linux26 -a -f ${dir}/initrd.gz; then continue; fi
58         echo grml $isopath: yes
59         result=0
60         menuentry "GRML Linux from ${realdev}${isopath}" \
61             "$realdev" "$isopath" "$dir" {
62             set device="$2"
63             set isopath="$3"
64             set grmldir="$4"
66             loopback loopdev_grml "${device}${isopath}"
67             set root=(loopdev_grml)
68             linux $grmldir/linux26 findiso="$isopath" apm=power-off quiet \
69                 boot=live nomce
70             initrd $grmldir/initrd.gz
71             loopback -d loopdev_grml
72         }
73     done
74     return $result
77 function pmagic_iso_entry {
78     realdev="$1"
79     isopath="$2"
80     loopdev="$3"
82     if ! test -f /pmagic/bzImage -a -f /pmagic/initramfs; then return 1; fi
84     echo pmagic $isopath: yes
85     menuentry "Parted Magic from ${realdev}${isopath}" "$realdev" "$isopath" {
86         set device="$2"
87         set isopath="$3"
89         loopback loopdev_pmagic "${device}${isopath}"
90         set root=(loopdev_pmagic)
91         linux /pmagic/bzImage iso_filename="$isopath" edd=off noapic \
92             load_ramdisk=1 prompt_ramdisk=0 rw sleep=10 loglevel=0 \
93             keymap=$langcode
94         initrd /pmagic/initramfs
95         loopback -d loopdev_pmagic
96     }
97     return 0
100 function sidux_iso_entry {
101     realdev="$1"
102     isopath="$2"
103     loopdev="$3"
105     result=1
106     for kernel in /boot/vmlinuz-*-sidux-*; do
107         if ! test -f "$kernel"; then continue; fi
108         regexp -s 1:v1 -s 2:v2 '/boot/vmlinuz-(.*)-sidux-(.*)' "$kernel"
110         initrd="/boot/initrd.img-$v1-sidux-$v2"
111         if ! test -f "$initrd"; then continue; fi
113         result=0
114         echo sidux $isopath: yes
115         menuentry "Sidux vmlinux-$v1-sidux-$v2 from ${realdev}${isopath}" "$realdev" "$isopath" "$kernel" "$initrd" {
116             set device="$2"
117             set isopath="$3"
118             set kernel="$4"
119             set initrd="$5"
121             loopback loopdev_sidux "${device}${isopath}"
122             set root=(loopdev_sidux)
123             linux $kernel fromiso=$isopath boot=fll quiet
124             initrd $initrd
125             loopback -d loopdev_sidux
126         }
127     done
128     return $result
131 function slax_iso_entry {
132     realdev="$1"
133     isopath="$2"
134     loopdev="$3"
136     if ! test -f /boot/vmlinuz -a -f /boot/initrd.gz; then return 1; fi
138     echo slax $isopath: yes
139     menuentry "Slax Linux from ${realdev}${isopath}" "$realdev" "$isopath" {
140         set device="$2"
141         set isopath="$3"
143         loopback loopdev_slax "${device}${isopath}"
144         set root=(loopdev_slax)
145         linux /boot/vmlinuz from=$isopath ramdisk_size=6666 root=/dev/ram0 rw
146         initrd /boot/initrd.gz
147         loopback -d loopdev_slax
148     }
149     return 0
152 function tinycore_iso_entry {
153     realpath="$1"
154     isopath="$2"
155     loopdev="$3"
157     if ! test -f /boot/bzImage -a -f /boot/tinycore.gz; then return 1; fi
159     echo tinycore $isopath: yes
160     menuentry "Tinycore Linux from ${realdev}${isopath}" "$realdev" "$isopath" {
161         set device="$2"
162         set isopath="$3"
164         loopback loopdev_tiny "${device}${isopath}"
165         set root=(loopdev_tiny)
166         linux /boot/bzImage
167         initrd /boot/tinycore.gz
168         loopback -d loopdev_tiny
169     }
170     return 0
173 function casper_iso_entry {
174     realpath="$1"
175     isopath="$2"
176     loopdev="$3"
178     if ! test -f /casper/vmlinuz; then return 1; fi
179     initrd=
180     for f in /casper/initrd.*z; do
181         if ! test -f "$f"; then continue; fi
182         pathname "$f" initrd
183     done
184     if test -z "$initrd"; then return 1; fi
186     echo casper $isopath: yes
187     menuentry "Casper based Linux from ${realdev}${isopath}" "$realdev" "$isopath" "$initrd" {
188         set device="$2"
189         set isopath="$3"
190         set initrd="$4"
192         loopback loopdev_casper "${device}${isopath}"
193         set root=(loopdev_casper)
194         linux /casper/vmlinuz boot=casper iso-scan/filename="$isopath" quiet splash noprompt keyb="$langcode" \
195             debian-installer/language="$langcode" console-setup/layoutcode?="$langcode" --
196         initrd $initrd
197         loopback -d loopdev_casper
198     }
199     return 0
202 function scan_isos {
203     isodirs="$1"
205     for dev in (*); do
206         for dir in $isodirs; do
207             for file in ${dev}${dir}/*.iso ${dev}${dir}/*.ISO; do
208                 if ! test -f "$file"; then continue; fi
210                 pathname $file isopath
211                 if test -z "$dev" -o -z "$isopath"; then continue; fi
213                 if ! loopback loopdev_scan "$file"; then continue; fi
214                 saved_root=$root
215                 set root=(loopdev_scan)
217                 if   loopback_iso_entry $dev $isopath (loopdev_scan); then true;
218                 elif grml_iso_entry     $dev $isopath (loopdev_scan); then true;
219                 elif pmagic_iso_entry   $dev $isopath (loopdev_scan); then true;
220                 elif sidux_iso_entry    $dev $isopath (loopdev_scan); then true;
221                 elif slax_iso_entry     $dev $isopath (loopdev_scan); then true;
222                 elif tinycore_iso_entry $dev $isopath (loopdev_scan); then true;
223                 elif casper_iso_entry   $dev $isopath (loopdev_scan); then true;
224                 else true; fi
226                 set root=$saved_root
227                 loopback -d loopdev_scan
228             done
229         done
230     done
231     return 0
234 # XXX Remove later
235 insmod serial
236 serial
237 terminal_output --append serial
238 # terminal_input --append serial
240 langcode="$lang"
242 insmod regexp
243 scan_isos /iso /boot/iso