uefi-shell: Add UEFI Shell

Signed-off-by: Sebastian Czapla <sebastian.czapla@3mdeb.com>
This commit is contained in:
Sebastian Czapla
2025-04-11 16:31:19 +02:00
parent 46a72379e2
commit c1a2834deb
5 changed files with 101 additions and 0 deletions
+1
View File
@@ -1 +1,2 @@
dts/dts-base-image-v*.wic
uefi-shell/edk2
+11
View File
@@ -0,0 +1,11 @@
# UEFI Shell application
Due to security concerns, UEFI Shell is no longer shipped with Dasharo
as built-in component. Instead, to keep usefulness of UEFI Shell, we
provide it on the OS drive, in the EFI partition, and add it to bootmanager.
This way, menu traversal to reach UEFI Shell does not change, instead we
have to install it as part of platform setup.
This subdirectory contains two scripts:
generate-shell-efi.sh - Builds edk2 ShellPkg and places resulting file as Shell.efi
deploy-shell-efi.sh - Takes Shell.efi as param, and installs it on a system
Binary file not shown.
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
set -e
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root" >&2
exit 1
fi
if [[ $# -ne 1 ]]; then
echo "Usage: $0 /path/to/Shell.efi"
exit 1
fi
SHELL_EFI_SRC="$1"
if [[ ! -f "$SHELL_EFI_SRC" ]]; then
echo "Error: File not found: $SHELL_EFI_SRC"
exit 1
fi
ESP=$(findmnt -no TARGET /boot/efi 2>/dev/null || true)
if [[ -z "$ESP" ]]; then
echo "Could not detect mounted EFI System Partition."
exit 1
fi
echo "EFI partition mounted at: $ESP"
DEST_DIR="${ESP}/EFI/Shell"
DEST_EFI="${DEST_DIR}/Shell.efi"
echo "Installing to: $DEST_EFI"
mkdir -p "$DEST_DIR"
cp "$SHELL_EFI_SRC" "$DEST_EFI"
PART_DEV=$(findmnt -no SOURCE "$ESP")
DISK=$(lsblk -no PKNAME "$PART_DEV" | head -n1)
PART_NUM=$(echo "$PART_DEV" | sed 's/[^0-9]*//g')
DISK_DEV="/dev/$DISK"
echo "Registering UEFI boot entry..."
efibootmgr --create --disk "$DISK_DEV" --part "$PART_NUM" \
--label "UEFI Shell" --loader '\EFI\Shell\Shell.efi'
echo "UEFI Shell boot entry created."
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
set -e
# SDK and config
IMAGE="ghcr.io/tianocore/containers/fedora-39-build:b4ea0a6"
TARGET_ARCH="X64"
TOOLCHAIN="GCC5"
# Script paths
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
EDK2_DIR="${SCRIPT_DIR}/edk2"
GENERATED_FILE="${EDK2_DIR}/Build/Shell/RELEASE_GCC5/X64/ShellPkg/Application/Shell/Shell/OUTPUT/Shell.efi"
if [ -d ${EDK2_DIR} ]; then
cd ${EDK2_DIR}
rm -r ${EDK2_DIR}/Build
git pull
else
git clone https://github.com/Dasharo/edk2.git ${EDK2_DIR}
cd ${EDK2_DIR}
fi
git submodule update --init
docker run --rm -it \
-v "${EDK2_DIR}:/home/edk2" \
-w /home/edk2 \
--user "$(id -u):$(id -g)" \
"$IMAGE" \
bash -c "
set -e
source edksetup.sh
make -C BaseTools -j
build -a ${TARGET_ARCH} -t ${TOOLCHAIN} -b RELEASE -p ShellPkg/ShellPkg.dsc
"
if [[ -f "$GENERATED_FILE" ]]; then
cp ${GENERATED_FILE} ${SCRIPT_DIR}/Shell.efi
echo "UEFI Shell built successfully: $SCRIPT_DIR/Shell.efi"
else
echo "UEFI Shell binary not found!"
exit 1
fi