Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_disk: Use target EFI binaries #901

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ fi
# Initialize the ostree setup; TODO replace this with
# https://github.com/ostreedev/ostree/pull/1894
# `ostree admin init-fs --modern`
ostree_commit=$(ostree --repo="${ostree}" rev-parse "${ref}")
mkdir -p rootfs/ostree
chcon $(matchpathcon -n /ostree) rootfs/ostree
mkdir -p rootfs/ostree/{repo,deploy}
Expand All @@ -219,6 +220,9 @@ do
done
ostree admin deploy "${deploy_ref}" --sysroot rootfs --os "$os_name" $kargsargs

deploy_root="rootfs/ostree/deploy/${os_name}/deploy/${ostree_commit}.0"
test -d "${deploy_root}"

# This will allow us to track the version that an install
# originally used; if we later need to understand something
# like "exactly what mkfs.xfs version was used" we can do
Expand All @@ -234,7 +238,6 @@ ostree admin deploy "${deploy_ref}" --sysroot rootfs --os "$os_name" $kargsargs
# convenient to have here as a strong cross-reference.
# imgid: The full image name, the same as will end up in the
# `images` dict in `meta.json`.
ostree_commit=$(ostree --repo="${ostree}" rev-parse "${ref}")
cat > rootfs/.coreos-aleph-version.json << EOF
{
"build": "${buildid}",
Expand All @@ -259,19 +262,26 @@ bootloader_backend=none

# Helper to install UEFI on supported architectures
install_uefi() {
mkdir -p rootfs/boot/efi/EFI/{BOOT,fedora}
mkdir -p rootfs/boot/grub2
ext="X64"
if [ "${arch}" = aarch64 ]; then
ext="AA64"
fi
cp "/boot/efi/EFI/BOOT/BOOT${ext}.EFI" "rootfs/boot/efi/EFI/BOOT/BOOT${ext}.EFI"
cp "/boot/efi/EFI/fedora/grub${ext,,}.efi" "rootfs/boot/efi/EFI/BOOT/grub${ext,,}.efi"
cat > rootfs/boot/efi/EFI/fedora/grub.cfg << 'EOF'
# See also https://github.com/ostreedev/ostree/pull/1873#issuecomment-524439883
# In the future it'd be better to get this stuff out of the OSTree commit and
# change our build process to download+extract it separately.
local source_efidir="${deploy_root}/usr/lib/ostree-boot/efi"
local target_efi="rootfs/boot/efi"
local target_efiboot="${target_efi}/EFI/BOOT"
mkdir -p "${target_efiboot}"
cp -a --reflink=auto "${source_efidir}/EFI/BOOT/BOOT"* "${target_efiboot}"
local src_grubefi=$(find "${source_efidir}"/EFI/ -name 'grub*.efi')
cp -a --reflink=auto "${src_grubefi}" "${target_efiboot}"

local vendor_id="$(basename $(dirname ${src_grubefi}))"
local vendordir="${target_efi}/EFI/${vendor_id}"
mkdir -p "${vendordir}"
cat > ${vendordir}/grub.cfg << 'EOF'
search --label boot --set prefix
set prefix=($prefix)/grub2
normal
EOF
mkdir -p rootfs/boot/grub2
# copy the grub config and any other files we might need
cp $grub_script rootfs/boot/grub2/grub.cfg
}
Expand Down