wok-current view tazinst/stuff/grub2-support.patch @ rev 25792
Fix openbox menu, label keymap on lxpanel and add miss it translation for tazpkg
| author | Stanislas Leduc <shann@slitaz.org> |
|---|---|
| date | Tue Oct 07 05:55:24 2025 +0000 (2 weeks ago) |
| parents | |
| children |
line source
1 --- a/tazinst
2 +++ b/tazinst
3 @@ -83,7 +83,7 @@
4 # bootloaders (key:help)
5 readonly LST_BOOTLOADER="
6 auto:$(_ 'Automatic selection')
7 -grub:$(_ 'GRUB legacy bootloader')
8 +grub:$(_ 'GRUB2 bootloader')
9 syslinux:$(_ 'Lightweight bootloader')"
11 # predefined iso (key:url:help)
12 @@ -1495,15 +1495,15 @@
13 unset BOOTLOADER
14 printf "%s" "$(list_bootloader)" | \
15 grep -q "syslinux" && BOOTLOADER=syslinux
16 - if [ "$(p_table $ROOT_UUID)" = "msdos" ]; then
17 + if [ "$(p_table $ROOT_UUID)" = "msdos" ] || [ "$(p_table $ROOT_UUID)" = "gpt" ]; then
18 printf "%s" "$(list_bootloader)" | \
19 grep -q " grub" && BOOTLOADER=grub
20 fi
21 fi
22 case "$BOOTLOADER" in
23 grub)
24 - grub_config
25 - grub_install ;;
26 + grub_install
27 + grub_config ;;
28 syslinux)
29 syslinux_config
30 syslinux_install ;;
31 @@ -1511,7 +1511,6 @@
32 syslinux_config
33 log "$(_ 'No bootloader to install.')" ;;
34 esac
35 - [ -d /sys/firmware/efi ] && efiboot_install
36 }
38 # print disk num
39 @@ -1564,128 +1563,98 @@
42 #-----------
43 -# 5.1 grub1
44 +# 5.1 grub2
45 #-----------
47 -grub_password_command()
48 -{
49 - grub --batch 2> /dev/null <<EOT | sed '/^Encrypted/!d;s|^Encrypted: |password --md5 |'
50 -md5crypt
51 -$ROOT_PWD
52 -EOT
53 -}
54 -
55 -# create grub legacy conf
56 +# create grub2 conf
57 grub_config()
58 {
59 - # backup an existing conf
60 - [ -e "$TARGET_ROOT/boot/grub/menu.lst" ] && \
61 - cp $TARGET_ROOT/boot/grub/menu.lst \
62 - $TARGET_ROOT/boot/grub/menu.bak
63 - # create the target GRUB configuration.
64 - mkdir -p $TARGET_ROOT/boot/grub || error8
65 - cat > $TARGET_ROOT/boot/grub/menu.lst <<_EOF_
66 -# /boot/grub/menu.lst: GRUB boot loader configuration.
67 -#
69 -# By default, boot the first entry.
70 -default 0
71 + local efi=""
72 + if [ -d /sys/firmware/efi ]; then
73 + efi="efi/EFI/"
74 + fi
76 -# Boot automatically after 8 secs.
77 -timeout 8
78 + # create the target GRUB configuration.
79 + mkdir -p $TARGET_ROOT/boot/${efi}grub || error8
81 -# Graphical splash image.
82 -splashimage=/boot/grub/splash.xpm.gz
83 + local fs_uuid=$(blkid -s UUID -o value $ROOT_UUID)
84 + # liveboot option
85 + if [ -n "$LIVEBOOT" ]; then
86 + # Copy rootfs.gz for rescue
87 + mv $TARGET_ROOT/boot/tazinst.$$/rootfs.gz $TARGET_ROOT/boot/rootfs-rescue.gz
89 -# Root password is required for edition
90 -$(grub_password_command)
91 + cat >> $TARGET_ROOT/etc/grub.d/40_custom <<_EOF_
93 -# Change the colors.
94 -#color yellow/brown light-green/black
95 +menuentry 'SliTaz GNU/Linux rescue (Kernel $KERNEL)' {
96 + load_video
97 + insmod gzio
98 + insmod part_gpt
99 + insmod ext2
101 -# For booting SliTaz from : $ROOT_UUID
102 -#
103 -title SliTaz GNU/Linux $(cat $TARGET_ROOT/etc/slitaz-release) (Kernel $KERNEL)
104 -root (hd$(disknum $ROOT_UUID),$(partnum $ROOT_UUID))
105 -kernel /boot/$KERNEL root=$(rootdev $ROOT_UUID) $KERNEL_ARGS$(rootdelay)
106 + search --no-floppy --fs-uuid --set=root $fs_uuid
108 -_EOF_
109 + linux /boot/$KERNEL rw root=/dev/null
110 + initrd /boot/rootfs-rescue.gz
111 +}
113 - if [ -n "$LIVEBOOT" ]; then
114 - local rootfs_files="$(cd $TARGET_ROOT/boot/tazinst.$$ ; ls rootfs*)"
115 - log "$(_ 'Enabling live/rescue boot with %s' "$rootfs_files")"
116 - for i in $rootfs_files; do
117 - [ -s $TARGET_ROOT/boot/$i ] &&
118 - mv $TARGET_ROOT/boot/$i $TARGET_ROOT/boot/$i.bak
119 - mv $TARGET_ROOT/boot/tazinst.$$/$i $TARGET_ROOT/boot/
120 - done
121 - cat >> $TARGET_ROOT/boot/grub/menu.lst <<_EOF_
122 -# For booting SliTaz Live from : $ROOT_UUID
123 -#
124 -title SliTaz GNU/Linux rescue $(cat $TARGET_ROOT/etc/slitaz-release) (Kernel $KERNEL)
125 -$(grub_password_command)
126 -root (hd$(disknum $ROOT_UUID),$(partnum $ROOT_UUID))
127 -kernel /boot/$KERNEL $(sed 's|.*gz ||' /proc/cmdline)
128 -initrd /boot/$ROOTFS
129 -
130 _EOF_
131 fi
133 - if [ -n "$WEBBOOT" -a -n "$IPXE" ]; then
134 - log "$(_ 'Enabling Webboot using %s' $IPXE)"
135 - mv -f $TARGET_ROOT/boot/tazinst.$$/$IPXE $TARGET_ROOT/boot/
136 - cat >> $TARGET_ROOT/boot/grub/menu.lst <<_EOF_
137 -# For booting SliTaz Live from the web
138 -#
139 -title SliTaz GNU/Linux web boot
140 -$(grub_password_command)
141 -root (hd$(disknum $ROOT_UUID),$(partnum $ROOT_UUID))
142 -kernel /boot/$IPXE
143 + # webboot option seem not work for current remove it
145 -_EOF_
146 - fi
147 rm -rf $TARGET_ROOT/boot/tazinst.$$ 2> /dev/null
149 + # Need rework winboot option
150 local winpart="$(winboot_uuid)"
151 - if [ -n "$winpart" ]; then
152 - log "$(_ 'Enabling Windows dual-boot')"
153 - cat >> $TARGET_ROOT/boot/grub/menu.lst <<_EOF_
154 -# For booting Windows :
155 -#
156 -title Microsoft Windows
157 - rootnoverify (hd$(disknum $winpart),$(partnum $winpart))
158 - chainloader +1
159 + #if [ -n "$winpart" ]; then
160 + #fi
162 -_EOF_
163 - fi
164 + # mount /proc /dev /sys for grub config
165 + for fs in proc dev sys; do
166 + mount --bind /$fs $TARGET_ROOT/$fs
167 + done
169 + # Generate grub.cfg
170 + chroot $TARGET_ROOT "grub-mkconfig" > $TARGET_ROOT/boot/${efi}grub/grub.cfg
171 +
172 + # Unmount /proc /dev /sys
173 + for fs in proc dev sys; do
174 + umount $TARGET_ROOT/$fs
175 + done
176 +
177 # log
178 - printf "%s\n" "/boot/grub/menu.lst:" >> "$LOG"
179 - printf "%s\n" "--- menu.lst -------------" >> "$LOG"
180 - cat $TARGET_ROOT/boot/grub/menu.lst >> "$LOG"
181 - printf "%s\n\n" "--- menu.lst -------------" >> "$LOG"
182 + printf "%s\n" "/boot/${efi}grub/grub.cfg:" >> "$LOG"
183 + printf "%s\n" "--- grub.cfg -------------" >> "$LOG"
184 + cat $TARGET_ROOT/boot/${efi}grub/grub.cfg >> "$LOG"
185 + printf "%s\n\n" "--- grub.cfg -------------" >> "$LOG"
186 }
188 # GRUB info with disk name used for grub
189 grub_install()
190 {
191 - # install grub
192 local target_disk="$(uuid2disk $ROOT_UUID)"
193 +
194 log "$(_ 'Installing GRUB on: %s' "$target_disk")"
195 /usr/sbin/grub-install --version >> "$LOG" || error 5 "$(_ 'GRUB not found')"
196 - /usr/sbin/grub-install --no-floppy \
197 - --root-directory=$TARGET_ROOT $target_disk >>"$LOG" 2>>"$LOG"
198 +
199 + # if system boot efi install grub-efi else grub
200 + # we use --force in case of nvme device
201 + if [ -d /sys/firmware/efi ]; then
202 + /usr/sbin/grub-install --target=x86_64-efi \
203 + --efi-directory=$TARGET_ROOT/boot/efi \
204 + --boot-directory=$TARGET_ROOT/boot/efi/EFI \
205 + --directory=$TARGET_ROOT/boot/grub/x86_64-efi \
206 + --bootloader-id=grub --removable --force $target_disk >>"$LOG" 2>> "$LOG"
207 + else
208 + /usr/sbin/grub-install --target=i386-pc \
209 + --boot-directory=$TARGET_ROOT/boot --force $target_disk >>"$LOG" 2>> "$LOG"
210 + fi
211 +
212 # set boot flag
213 log "$(_ 'Setting the boot flag')"
214 /usr/sbin/parted "$(uuid2disk $ROOT_UUID)" \
215 set "$(($(partnum $ROOT_UUID)+1))" boot on 2>> "$LOG"
216 - # splash image
217 - if [ -f "$SOURCE_ROOT/boot/grub/splash.xpm.gz" ]; then
218 - log "$(_ 'Copying splash image')"
219 - mkdir -p $TARGET_ROOT/boot/grub
220 - cp $SOURCE_ROOT/boot/grub/splash.xpm.gz \
221 - $TARGET_ROOT/boot/grub
222 - fi
223 }