check_squashfs,memdisk,readme

This commit is contained in:
Marc Beninca 2023-11-21 09:13:18 +01:00
parent cac74aef9d
commit 4f563bcc20
6 changed files with 118 additions and 47 deletions

View file

@ -66,9 +66,10 @@ SIGNED_SHIM='/usr/lib/shim/shimx64.efi.signed'
# variables ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ # variables ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
MEMDISK_ROOT="${ESP_ROOT}/memdisk" MEMDISK_ROOT="${ESP_ROOT}/memdisk"
MEMDISK_DIRECTORY="${MEMDISK_ROOT}/boot/grub" MEMDISK_DIRECTORY="${MEMDISK_ROOT}/grub"
MEMDISK_FILE="${MEMDISK_DIRECTORY}/grub.cfg" MEMDISK_FILE="${MEMDISK_DIRECTORY}/grub.cfg"
MEMDISK_ARCHIVE="${MEMDISK_ROOT}/boot.tar" MEMDISK_FONTS="${MEMDISK_DIRECTORY}/fonts"
MEMDISK_ARCHIVE="${MEMDISK_ROOT}/grub.tar"
UEFI_ROOT="${ESP_ROOT}/efi" UEFI_ROOT="${ESP_ROOT}/efi"
UEFI_DIRECTORY="${UEFI_ROOT}/boot" UEFI_DIRECTORY="${UEFI_ROOT}/boot"
@ -111,14 +112,14 @@ rm --force --recursive \
# memdisk ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ # memdisk ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
echo -n " echo -n "
${MEMDISK_DIRECTORY} ${MEMDISK_FONTS}
" "
mkdir --parents "${MEMDISK_DIRECTORY}" mkdir --parents "${MEMDISK_FONTS}"
echo -n " echo -n "
${MEMDISK_FILE} ${MEMDISK_FILE}
" "
echo -n "\ echo "\
echo \"prefix | \${prefix}\" echo \"prefix | \${prefix}\"
search --no-floppy --set root --fs-uuid '${ESP}' search --no-floppy --set root --fs-uuid '${ESP}'
prefix=\"(\${root})/boot/grub\" prefix=\"(\${root})/boot/grub\"
@ -131,12 +132,12 @@ echo -n "
cat "${GRUB_SHIGNED}" >> "${MEMDISK_FILE}" cat "${GRUB_SHIGNED}" >> "${MEMDISK_FILE}"
echo -n " echo -n "
${MEMDISK_ROOT} ${MEMDISK_DIRECTORY}
${MEMDISK_ARCHIVE} ${MEMDISK_ARCHIVE}
" "
cd "${MEMDISK_ROOT}" cd "${MEMDISK_DIRECTORY}"
tar --create --auto-compress \ tar --create --auto-compress \
--file "${MEMDISK_ARCHIVE}" 'boot' --file "${MEMDISK_ARCHIVE}" 'grub.cfg'
cd - cd -
# uefi ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ # uefi ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
@ -155,6 +156,7 @@ grub-mkimage \
--memdisk "${MEMDISK_ARCHIVE}" \ --memdisk "${MEMDISK_ARCHIVE}" \
--format 'x86_64-efi' \ --format 'x86_64-efi' \
--output "${UEFI_FILE}" \ --output "${UEFI_FILE}" \
--prefix '(memdisk)/' \
"${MODULES[@]}" "${MODULES[@]}"
if [ -f "${SIGNED_SHIM}" ] ; then if [ -f "${SIGNED_SHIM}" ] ; then
echo -n " echo -n "
@ -203,6 +205,7 @@ grub-mkimage \
--memdisk "${MEMDISK_ARCHIVE}" \ --memdisk "${MEMDISK_ARCHIVE}" \
--format 'i386-pc' \ --format 'i386-pc' \
--output "${BIOS_FILE}" \ --output "${BIOS_FILE}" \
--prefix '(memdisk)/' \
"${MODULES[@]}" "${MODULES_BIOS[@]}" "${MODULES[@]}" "${MODULES_BIOS[@]}"
echo -n " echo -n "

View file

@ -8,9 +8,10 @@ menuentry '↑ env →' { menu 'env' }
menuentry '↑ set →' { menu 'set' } menuentry '↑ set →' { menu 'set' }
menuentry '↑ cmd →' { menu 'cmd' } menuentry '↑ cmd →' { menu 'cmd' }
menu_split menu_split
menuentry 'check_squashfs = enforce' { check_squashfs='enforce' }
menuentry 'check_squashfs = no' { check_squashfs='no' }
menu_split
menuentry 'bash / stable / tui' { debsquash '/boot/bash/stable/tui' } menuentry 'bash / stable / tui' { debsquash '/boot/bash/stable/tui' }
menuentry 'bash / stable / gui' { debsquash '/boot/bash/stable/gui' } menuentry 'bash / stable / gui' { debsquash '/boot/bash/stable/gui' }
menuentry 'bash / latest / tui' { debsquash '/boot/bash/latest/tui' } menuentry 'bash / latest / tui' { debsquash '/boot/bash/latest/tui' }
menuentry 'check_signatures = enforce' { check_signatures='enforce' }
menuentry 'check_signatures = no' { check_signatures='no' }
menuentry 'bash / latest / gui' { debsquash '/boot/bash/latest/gui' } menuentry 'bash / latest / gui' { debsquash '/boot/bash/latest/gui' }

View file

@ -11,3 +11,5 @@ menu_split 'split'
menuentry "esp: ${esp} → data: ${data}" { nop } menuentry "esp: ${esp} → data: ${data}" { nop }
menuentry "env: ${env} → env_mod: ${env_mod}" { nop } menuentry "env: ${env} → env_mod: ${env_mod}" { nop }
menuentry "live: ${live}" { nop } menuentry "live: ${live}" { nop }
menu_split
menuentry "check_squashfs: ${check_squashfs}" { nop }

View file

@ -1,24 +1,29 @@
function debsquash { function debsquash {
lmp="${1}" lmp="${1}"
sfs="filesystem.squashfs" sfs="filesystem.squashfs"
chk="(${data})${lmp}/${sfs}"
# #
echo 'verify_detached' if [ "${check_squashfs}" == 'enforce' ] ; then
echo "${chk}" chk="(${data})${lmp}/${sfs}"
if verify_detached "${chk}" "${chk}.sig" ; then echo 'verify_detached'
if [ -f "(${data})${lmp}/vmlinuz" ]; then echo "${chk}"
linux_path="(${data})${lmp}/vmlinuz" if ! verify_detached "${chk}" "${chk}.sig" ; then
initrd_path="(${data})${lmp}/initrd.img" grub_pause
else return 1
linux_path="(squash)/vmlinuz"
initrd_path="(squash)/initrd.img"
loopback "squash" "${lmp}/${sfs}"
fi fi
# fi
echo if [ -f "(${data})${lmp}/vmlinuz" ] ; then
echo 'linux' linux_path="(${data})${lmp}/vmlinuz"
echo "${linux_path}" initrd_path="(${data})${lmp}/initrd.img"
linux \ else
linux_path="(squash)/vmlinuz"
initrd_path="(squash)/initrd.img"
loopback "squash" "${lmp}/${sfs}"
fi
#
echo
echo 'linux'
echo "${linux_path}"
linux \
"${linux_path}" \ "${linux_path}" \
boot="live" \ boot="live" \
elevator="deadline" \ elevator="deadline" \
@ -26,10 +31,9 @@ ip="frommedia" \
live-media-path="${lmp}" \ live-media-path="${lmp}" \
live-media-uuid="${data_uuid}" \ live-media-uuid="${data_uuid}" \
toram="${sfs}" toram="${sfs}"
# #
echo echo
echo 'initrd' echo 'initrd'
echo "${initrd_path}" echo "${initrd_path}"
initrd "${initrd_path}" initrd "${initrd_path}"
fi
} }

View file

@ -1,7 +1,7 @@
function env { function env {
action="${1}" action="${1}"
setparams \ setparams \
'time_out' 'check_squashfs' 'time_out'
if [ "${action}" == 'load' ] ; then if [ "${action}" == 'load' ] ; then
load_env \ load_env \
--skip-sig \ --skip-sig \
@ -48,5 +48,6 @@ function env_mod {
} }
function env_set { function env_set {
check_squashfs='enforce'
time_out=10 time_out=10
} }

View file

@ -58,22 +58,82 @@ Build an ESP File System including:
## Tasks ## Tasks
* bash - [x] comply with secure boot
* mimic grubx64.efi.signed - [x] choose to check squashfs or not
* efi
* bios - [ ] bash
* auto setup bios device - [ ] mimic grubx64.efi.signed ←
* --prefix '(memdisk)' - [ ] efi
* live - [ ] include fonts/unicode
* check squashfs option - [ ] bios
* python - [ ] find & setup bios device
- [ ] rewrite in python
![Graph](todo.svg) ![Graph](todo.svg)
### Later ### Later
* arm - [ ] target arm
* keyboard layouts - [ ] make keyboard layouts
* custom fonts - [ ] make custom fonts
* live-media - [ ] target specific live-media
* -mount-opts - [ ] -mount-opts?
```
/esp
├── bios
│ ├── boot.img
│ ├── core.img
│ └── setup.sh
├── boot
│ ├── grub
│ │ ├── fonts
│ │ │ └── *.pf2
│ │ ├── grub.cfg
│ │ ├── grub.pgp
│ │ ├── grubenv
│ │ ├── i386-pc
│ │ │ ├── *.lst
│ │ │ └── *.mod
│ │ ├── locale
│ │ │ └── *.mo
│ │ ├── themes
│ │ │ ├── breeze
│ │ │ │ ├── theme.txt
│ │ │ │ ├── *.pf2
│ │ │ │ ├── *.pf2.license
│ │ │ │ ├── *.png
│ │ │ │ └── *.png.license
│ │ │ └── starfield
│ │ │ ├── README
│ │ │ ├── theme.txt
│ │ │ ├── *.pf2
│ │ │ ├── *.pf2.license
│ │ │ ├── *.png
│ │ │ └── *.png.license
│ │ └── x86_64-efi
│ │ ├── *.lst
│ │ └── *.mod
│ └── lsgm
│ ├── main.sh
│ ├── menu
│ │ ├── cmd.sh
│ │ ├── env.sh
│ │ ├── gfx.sh
│ │ ├── scan.sh
│ │ └── set.sh
│ └── source
│ ├── boot.sh
│ ├── env.sh
│ ├── menu.sh
│ ├── probe.sh
│ ├── scan.sh
│ └── util.sh
├── efi
│ └── boot
│ ├── bootx64.efi
│ ├── core.efi
│ └── grubx64.efi
└── grub.env
```