grub.cfg.sh
This commit is contained in:
parent
04ad78a6e1
commit
c92a114205
10 changed files with 144 additions and 119 deletions
109
build.sh
109
build.sh
|
@ -55,7 +55,7 @@ source "${NAME%.*}.mod"
|
|||
MEMDISK_ROOT='boot'
|
||||
MEMDISK_DIRECTORY="${MEMDISK_ROOT}/grub"
|
||||
MEMDISK_FILE="${MEMDISK_DIRECTORY}/grub.cfg"
|
||||
MEMDISK_PUB="${MEMDISK_DIRECTORY}/grub.pub"
|
||||
MEMDISK_PUB="${MEMDISK_DIRECTORY}/grub.pgp"
|
||||
MEMDISK_ARCHIVE="${MEMDISK_ROOT}.tar"
|
||||
UEFI_ROOT="${ROOT}/efi"
|
||||
UEFI_DIRECTORY="${UEFI_ROOT}/boot"
|
||||
|
@ -70,7 +70,7 @@ COMPRESSION='xz'
|
|||
GRUB_ROOT="${ROOT}/boot/grub"
|
||||
GRUB_CFG="${GRUB_ROOT}/grub.cfg"
|
||||
GRUB_ENV="${ROOT}/grub.env"
|
||||
GRUB_PUB="${GRUB_ROOT}/grub.pub"
|
||||
GRUB_PUB="${GRUB_ROOT}/grub.pgp"
|
||||
|
||||
# wipe ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
|
||||
|
||||
|
@ -175,102 +175,20 @@ mkdir --parents "${GRUB_ROOT}"
|
|||
|
||||
# grub / cfg ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
|
||||
|
||||
echo -n "\
|
||||
function list_vars {
|
||||
echo -n \"\\
|
||||
root | \${root}
|
||||
prefix | \${prefix}
|
||||
check_signatures | \${check_signatures}
|
||||
\"
|
||||
list_trusted
|
||||
}
|
||||
|
||||
clear
|
||||
ls
|
||||
echo -n \"\\
|
||||
---
|
||||
cpu-platform | \${grub_cpu}-\${grub_platform}
|
||||
cmdpath | \${cmdpath}
|
||||
---
|
||||
\"
|
||||
if [ -f '/.disk/info' -o -f '/.disk/mini-info' ] ; then
|
||||
for f in '/.disk/info' '/.disk/mini-info' ; do
|
||||
echo -n ' |'
|
||||
if [ -f \"\${f}\" ] ; then
|
||||
echo -n '*'
|
||||
else
|
||||
echo -n ' '
|
||||
fi
|
||||
echo \"(\${root})\${f}\"
|
||||
done
|
||||
unset f
|
||||
echo ' *'
|
||||
fi
|
||||
list_vars
|
||||
echo ' ---'
|
||||
|
||||
unset cmdroot
|
||||
regexp --set cmdroot '^\((.*)\)' \"\${cmdpath}\"
|
||||
echo \" cmdroot | \${cmdroot}\"
|
||||
if [ \"\${cmdroot}\" != \"\${root}\" ] ; then
|
||||
if [ -d \"(\${cmdroot})/boot/grub/\${grub_cpu}-\${grub_platform}\" ] ; then
|
||||
prefix=\"(\${cmdroot})/boot/grub\"
|
||||
root=\"\${cmdroot}\"
|
||||
fi
|
||||
fi
|
||||
unset cmdroot
|
||||
check_signatures='enforce'
|
||||
trust --skip-sig \"\${prefix}/grub.pub\"
|
||||
|
||||
function set_init {
|
||||
data_uuid='${DATA}'
|
||||
search --no-floppy --set data \\
|
||||
--fs-uuid \"\${data_uuid}\"
|
||||
#
|
||||
unset esp
|
||||
regexp --set esp '^\((.*)\)' \"\${prefix}\"
|
||||
env=\"(\${esp})/grub.env\"
|
||||
live=\"(\${esp})/${PROJECT}/live\"
|
||||
#
|
||||
for file in \${live}/source/*.sh ; do
|
||||
source \"\${file}\"
|
||||
done
|
||||
unset file
|
||||
}
|
||||
|
||||
set_init
|
||||
|
||||
source \"\${live}/main.sh\"
|
||||
|
||||
echo ' *'
|
||||
list_vars
|
||||
echo -n \"\\
|
||||
---
|
||||
escape | \"
|
||||
sleep --interruptible --verbose 1000
|
||||
" > "${GRUB_CFG}"
|
||||
cp "${DIRECTORY}/grub.cfg.sh" "${GRUB_CFG}"
|
||||
|
||||
# grub / env ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
|
||||
|
||||
echo -n "\
|
||||
# GRUB Environment Block
|
||||
#######################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
################################################################\
|
||||
" > "${GRUB_ENV}"
|
||||
grubenv="# GRUB Environment Block
|
||||
live_name=${PROJECT}
|
||||
data_uuid=${DATA}
|
||||
"
|
||||
grublen=${#grubenv}
|
||||
while [ $grublen -lt 1024 ] ; do
|
||||
grubenv="${grubenv}#"
|
||||
grublen=${#grubenv}
|
||||
done
|
||||
echo -n "${grubenv}" > "${GRUB_ENV}"
|
||||
|
||||
# grub / fonts ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
|
||||
|
||||
|
@ -313,7 +231,6 @@ for target in 'x86_64-efi' 'i386-pc' ; do
|
|||
mkdir --parents "${GRUB_ROOT}/${target}"
|
||||
cd "/usr/lib/grub/${target}"
|
||||
for module in *.lst *.mod ; do
|
||||
echo "${target}/${module}"
|
||||
cp "${module}" "${GRUB_ROOT}/${target}"
|
||||
done
|
||||
done
|
||||
|
|
107
grub.cfg.sh
Normal file
107
grub.cfg.sh
Normal file
|
@ -0,0 +1,107 @@
|
|||
function grub_fix {
|
||||
unset cmdroot
|
||||
regexp --set cmdroot '^\((.*)\)' "${cmdpath}"
|
||||
if [ "${cmdroot}" != "${root}" ] ; then
|
||||
echo -n "\
|
||||
|*${cmdpath}
|
||||
"
|
||||
if [ -d "(${cmdroot})/boot/grub/${grub_cpu}-${grub_platform}" ] ; then
|
||||
prefix="(${cmdroot})/boot/grub"
|
||||
root="${cmdroot}"
|
||||
fi
|
||||
fi
|
||||
unset cmdroot
|
||||
check_signatures='enforce'
|
||||
trust --skip-sig "${prefix}/grub.pgp"
|
||||
}
|
||||
|
||||
function grub_list_const {
|
||||
echo -n "\
|
||||
cpu-platform | ${grub_cpu}-${grub_platform}
|
||||
cmdpath | ${cmdpath}
|
||||
"
|
||||
}
|
||||
|
||||
function grub_list_info {
|
||||
if [ -f '/.disk/info' -o -f '/.disk/mini-info' ] ; then
|
||||
for f in '/.disk/info' '/.disk/mini-info' ; do
|
||||
echo -n "\
|
||||
|"
|
||||
if [ -f "${f}" ] ; then
|
||||
echo -n '*'
|
||||
else
|
||||
echo -n ' '
|
||||
fi
|
||||
echo "(${root})${f}"
|
||||
done
|
||||
unset f
|
||||
fi
|
||||
}
|
||||
|
||||
function grub_list_vars {
|
||||
echo -n "\
|
||||
root | ${root}
|
||||
prefix | ${prefix}
|
||||
check_signatures | ${check_signatures}
|
||||
"
|
||||
list_trusted
|
||||
}
|
||||
|
||||
function grub_list_xtra {
|
||||
echo -n "\
|
||||
env | ${env}
|
||||
live | ${live}
|
||||
data | ${data}
|
||||
"
|
||||
}
|
||||
|
||||
function grub_main {
|
||||
ls
|
||||
grub_list_const
|
||||
grub_split
|
||||
if [ ! "${data}" ] ; then
|
||||
grub_list_info
|
||||
grub_list_vars
|
||||
grub_split
|
||||
#
|
||||
grub_fix
|
||||
set_init
|
||||
for file in ${live}/source/*.sh ; do
|
||||
source "${file}"
|
||||
done
|
||||
unset file
|
||||
source "${live}/main.sh"
|
||||
fi
|
||||
grub_list_vars
|
||||
grub_list_xtra
|
||||
grub_split
|
||||
grub_pause
|
||||
}
|
||||
|
||||
function grub_pause {
|
||||
echo -n "\
|
||||
escape | "
|
||||
sleep --interruptible --verbose 1000
|
||||
}
|
||||
|
||||
function grub_split {
|
||||
echo -n "\
|
||||
---
|
||||
"
|
||||
}
|
||||
|
||||
function set_init {
|
||||
regexp --set esp '^\((.*)\)' "${prefix}"
|
||||
#
|
||||
env="(${esp})/grub.env"
|
||||
#
|
||||
load_env --skip-sig --file "${env}" \
|
||||
'live_name' 'data_uuid'
|
||||
#
|
||||
live="(${esp})/${live_name}/live"
|
||||
#
|
||||
search --no-floppy --set data \
|
||||
--fs-uuid "${data_uuid}"
|
||||
}
|
||||
|
||||
grub_main
|
|
@ -1,4 +1,3 @@
|
|||
env_init
|
||||
menu_init
|
||||
|
||||
default='scan'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
env_init
|
||||
menu_init
|
||||
|
||||
menuentry 'halt' { halt }
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
env_init
|
||||
menu_init "${env} → ${env_mod}"
|
||||
|
||||
menuentry 'list file' {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
env_init
|
||||
menu_init
|
||||
|
||||
menuentry 'list' {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
env_init
|
||||
menu_init "${scan}"
|
||||
|
||||
scan "${scan}"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
env_init
|
||||
menu_init
|
||||
|
||||
default='split'
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
function debsquash {
|
||||
lmp="${1}"
|
||||
sfs="filesystem.squashfs"
|
||||
if [ -f "(${data})${lmp}/vmlinuz" ]; then
|
||||
linux_path="(${data})${lmp}/vmlinuz"
|
||||
initrd_path="(${data})${lmp}/initrd.img"
|
||||
else
|
||||
linux_path="(squash)/vmlinuz"
|
||||
initrd_path="(squash)/initrd.img"
|
||||
loopback "squash" "${lmp}/${sfs}"
|
||||
fi
|
||||
chk="(${data})${lmp}/${sfs}"
|
||||
#
|
||||
echo 'linux'
|
||||
echo "${linux_path}"
|
||||
linux \
|
||||
echo 'verify_detached'
|
||||
echo "${chk}"
|
||||
if verify_detached "${chk}" "${chk}.sig" ; then
|
||||
if [ -f "(${data})${lmp}/vmlinuz" ]; then
|
||||
linux_path="(${data})${lmp}/vmlinuz"
|
||||
initrd_path="(${data})${lmp}/initrd.img"
|
||||
else
|
||||
linux_path="(squash)/vmlinuz"
|
||||
initrd_path="(squash)/initrd.img"
|
||||
loopback "squash" "${lmp}/${sfs}"
|
||||
fi
|
||||
#
|
||||
echo
|
||||
echo 'linux'
|
||||
echo "${linux_path}"
|
||||
linux \
|
||||
"${linux_path}" \
|
||||
boot="live" \
|
||||
elevator="deadline" \
|
||||
|
@ -20,10 +26,10 @@ ip="frommedia" \
|
|||
live-media-path="${lmp}" \
|
||||
live-media-uuid="${data_uuid}" \
|
||||
toram="${sfs}"
|
||||
#
|
||||
echo
|
||||
#
|
||||
echo 'initrd'
|
||||
echo "${initrd_path}"
|
||||
initrd "${initrd_path}"
|
||||
#
|
||||
echo
|
||||
echo 'initrd'
|
||||
echo "${initrd_path}"
|
||||
initrd "${initrd_path}"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ function menu_color {
|
|||
}
|
||||
|
||||
function menu_init {
|
||||
env_init
|
||||
if [ "${menu}" ] ; then
|
||||
if [ "${1}" ] ; then
|
||||
menuentry "→ ${menu} → ${1}" { nop }
|
||||
|
|
Loading…
Reference in a new issue