Dash:
[t2.git] / package / boot / yaboot / stone_mod_yaboot.sh
blobba9d0e36e0aeee80aac5689d031f48f2023798c1
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/*/yaboot/stone_mod_yaboot.sh
5 # Copyright (C) 2004 - 2021 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 # [MAIN] 70 yaboot Yaboot Boot Loader Setup
17 # [SETUP] 90 yaboot
19 create_kernel_list() {
20 first=1
21 for x in `(cd /boot/ ; ls vmlinux-*) | sort -r` ; do
22 if [ $first = 1 ] ; then
23 label=linux ; first=0
24 else
25 label=linux-${x/vmlinux-/}
27 ver=${x/vmlinux-}
28 cat << EOT
30 image=$bootpath/$x
31 label=$label
32 root=$rootdev
33 initrd=$bootpath/initrd-${ver}
34 read-only
35 EOT
36 done
39 create_yaboot_conf() {
40 cat << EOT > /etc/yaboot.conf
42 # /etc/yaboot.conf created with the T2 SDE Yaboot STONE module
44 # The bootstrap partition
45 boot=$bootstrapdev
47 device=hd:
49 # The partition with the yaboot binaries
50 partition=$yabootpart
52 # Initial multi-boot menu delay
53 delay=5
55 # Second yaboot image chooser delay
56 timeout=80
58 install=$yabootpath/lib/yaboot/yaboot
59 magicboot=$yabootpath/lib/yaboot/ofboot
61 #fgcolor=black
62 #bgcolor=green
64 enablecdboot
65 enablenetboot
66 enableofboot
67 EOT
69 [ "$macosxpart" ] && \
70 echo -e "\nmacosx=$macosxdev\n" \
71 >> /etc/yaboot.conf
73 create_kernel_list >> /etc/yaboot.conf
75 gui_message "This is the new /etc/yaboot.conf file:
77 $( cat /etc/yaboot.conf )"
80 yaboot_install()
82 # format the boostrap if not already done
83 if hmount $bootstrapdev > /dev/null ; then
84 humount
85 else
86 if gui_yesno "The boostrap device \
87 $bootstrapdev is not yet HFS formated. \
88 Format now?" ; then
89 hformat $bootstrapdev
90 else
91 return 1
95 # maybe an unpatched yaboot and no devfsd (e.g. during install)
96 [ ! -c /dev/nvram ] && ln -s /dev/misc/nvram /dev/nvram
98 yaboot_install_doit
101 yaboot_install_doit() {
102 gui_cmd 'Installing Yaboot' "echo 'calling ybin' ; ybin"
105 device4() {
106 local dev="`sed -n "s,\([^ ]*\) $1 .*,\1,p" /proc/mounts | tail -n 1`"
107 if [ ! "$dev" ] ; then # try the higher dentry
108 local try="`dirname $1`"
109 dev="`grep \" $try \" /proc/mounts | tail -n 1 | \
110 cut -d ' ' -f 1`"
112 if [ -h "$dev" ] ; then
113 echo "/dev/`readlink $dev`"
114 else
115 echo $dev
119 realpath() {
120 dir="`dirname $1`"
121 file="`basename $1`"
122 dir="`dirname $dir`/`readlink $dir`"
123 dir="`echo $dir | sed 's,[^/]*/\.\./,,g'`"
124 echo $dir/$file
127 main() {
128 rootdev="`device4 /`"
129 dev="${rootdev%%[0-9]*}"
130 bootdev="`device4 /boot`"
131 yabootdev="`device4 /usr`"
133 bootstrappart="`parted $dev print | grep bootstrap | sed 's/ *\([[:digit:]]\+\) .*/\1/'`"
134 bootstrapdev="$dev$bootstrappart"
136 macosxpart="`parted $dev print | grep "hfs+.*OS X" | head -n 1 | sed 's/ .*//'`"
137 [ "$macosxpart" ] && macosxdev="$dev$macosxpart"
139 if [ "$rootdev" = "$bootdev" ]
140 then bootpath=/boot ; else bootpath="" ; fi
142 if [ "$rootdev" = "$yabootdev" ]
143 then yabootpath=/usr ; else yabootpath="" ; fi
144 yabootpart="`echo $yabootdev | sed 's/[^0-9]*//'`"
146 if [ ! -f /etc/yaboot.conf ] ; then
147 if gui_yesno "Yaboot does not appear to be configured.
148 Automatically install yaboot now?"; then
149 create_yaboot_conf
150 if ! yaboot_install; then
151 gui_message "There was an error while installing yaboot."
156 while
158 gui_menu yaboot 'Yaboot Boot Loader Setup' \
159 "Following settings only for expert use: (default)" ""\
160 "Bootstrap Device ...... $bootstrapdev" "" \
161 "Yaboot partition:path . $yabootpart:$yabootpath" "" \
162 "Root Device ........... $rootdev" "" \
163 "Boot Device ........... $bootdev" "" \
164 "MacOS X partition ..... $macosxdev" "" \
165 '' '' \
166 '(Re-)Create default /etc/yaboot.conf' 'create_yaboot_conf' \
167 '(Re-)Install the yaboot boot chrp script and binary' 'yaboot_install' \
168 '' '' \
169 "Edit /etc/yaboot.conf (Config file)" \
170 "gui_edit 'Yaboot Configuration' /etc/yaboot.conf"
171 do : ; done