* updated pyxdg (0.19 -> 0.28)
[t2sde.git] / package / boot / kboot / stone_mod_kboot.sh
blob6ee0d4ce2a8cf5d40601df9b2d085611a0b1bebf
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/kboot/stone_mod_kboot.sh
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
12 # [MAIN] 70 kboot kBoot Loader Setup
13 # [SETUP] 90 kboot
15 cmdline="console= $(< /proc/cmdline)"
16 cmdline=${cmdline##*console=} cmdline=${cmdline%%[ ,]*}
17 if [ -z "$cmdline" ]; then
18 cmdline="`grep -a -H Y /sys/class/tty/*/console`"
19 cmdline="${cmdline%%/console*}" cmdline=${cmdline##*/}
22 create_kernel_list() {
23 first=1
24 for x in `(cd /boot/; ls vmlinux-* ) | sort -r`; do
25 if [ $first = 1 ]; then
26 label=t2sde first=0
27 else
28 label=t2sde-${x/vmlinux-/}
30 ver=${x/vmlinux-}
31 cat << EOT
32 $label='$bootpath/$x initrd=$bootpath/initrd-${ver} root=$rootdev ${cmdline:+ console=}$cmdline'
33 # video=ps3fb:mode:13
34 EOT
35 done
38 create_kboot_conf() {
39 mkdir -p $etcpath/etc/
40 create_kernel_list > $etcpath/etc/kboot.conf
42 gui_message "This is the new $etcpath/etc/kboot.conf file:
44 $(< $etcpath/etc/kboot.conf)"
47 device4() {
48 local dev="`sed -n "s,\([^ ]*\) $1 .*,\1,p" /proc/mounts | tail -n 1`"
49 if [ ! "$dev" ]; then # try the higher dentry
50 local try="`dirname $1`"
51 dev="`grep \" $try \" /proc/mounts | tail -n 1 | \
52 cut -d ' ' -f 1`"
54 if [ -h "$dev" ]; then
55 echo "/dev/`readlink $dev`"
56 else
57 echo $dev
61 realpath() {
62 dir="`dirname $1`"
63 file="`basename $1`"
64 dir="`dirname $dir`/`readlink $dir`"
65 dir="`echo $dir | sed 's,[^/]*/\.\./,,g'`"
66 echo $dir/$file
69 main() {
70 rootdev="`device4 /`"
71 bootdev="`device4 /boot`"
73 [ "$rootdev" != "$bootdev" ] && etcpath=/boot || bootpath=/boot
75 if [ ! -f /boot/etc/kboot.conf ]; then
76 if gui_yesno "kBoot does not appear to be configured.
77 Automatically configure kboot now?"; then
78 create_kboot_conf
82 while
84 gui_menu kboot 'kBoot Loader Setup' \
85 "Following settings only for expert use: (default)" ""\
86 "Root Device ........... $rootdev" "" \
87 "Boot Device ........... $bootdev" "" \
88 '' '' \
89 "(Re-)Create default $etcpath/etc/kboot.conf" 'create_kboot_conf' \
90 '' '' \
91 "Edit $etcpath/etc/kboot.conf (Config file)" \
92 "gui_edit 'kBoot Configuration' $etcpath/etc/kboot.conf"
93 do : ; done