grub: build grub2_pvhgrub_image together with grub2_pvgrub_image
This enables the GRUB package to be built for the `xen_pvh` platform, which is needed to generate a corresponding GRUB image and boot PVH DomUs. Also, modifications made to the original `grub2_pvgrub_image` package: - Use split phases and avoid overriding `buildCommand` during the build. - Remove logic that excludes `all_video.mod` (already ironed out by upstream). - Fix `lib.platforms` and remove platforms that cannot build. - Update the description. - Add maintainer information of the Xen Project team. Signed-off-by: Hongbo <hehongbo@mail.com> Reviewed-by: Fernando Rodrigues <alpha@sigmasquadron.net> Co-authored-by: William Johansson <radar@radhuset.org>
This commit is contained in:
co-authored by
William Johansson
parent
2c3ce3eb31
commit
47881f96c7
@@ -1,54 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
grub2_xen,
|
||||
}:
|
||||
|
||||
let
|
||||
efiSystemsBuild = {
|
||||
i686-linux.target = "i386";
|
||||
x86_64-linux.target = "x86_64";
|
||||
armv7l-linux.target = "arm";
|
||||
aarch64-linux.target = "aarch64";
|
||||
riscv32-linux.target = "riscv32";
|
||||
riscv64-linux.target = "riscv64";
|
||||
};
|
||||
|
||||
in
|
||||
(
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "pvgrub-image";
|
||||
|
||||
configs = ./configs;
|
||||
|
||||
buildInputs = [ grub2_xen ];
|
||||
|
||||
buildCommand = ''
|
||||
cp "${configs}"/* .
|
||||
tar -cf memdisk.tar grub.cfg
|
||||
# We include all modules except all_video.mod as otherwise grub will fail printing "no symbol table"
|
||||
# if we include it.
|
||||
grub-mkimage -O "${
|
||||
efiSystemsBuild.${stdenv.hostPlatform.system}.target
|
||||
}-xen" -c grub-bootstrap.cfg \
|
||||
-m memdisk.tar -o "grub-${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen.bin" \
|
||||
$(ls "${grub2_xen}/lib/grub/${
|
||||
efiSystemsBuild.${stdenv.hostPlatform.system}.target
|
||||
}-xen/" |grep 'mod''$'|grep -v '^all_video\.mod''$')
|
||||
mkdir -p "$out/lib/grub-xen"
|
||||
cp "grub-${efiSystemsBuild.${stdenv.hostPlatform.system}.target}-xen.bin" $out/lib/grub-xen/
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "PvGrub image for use for booting PV Xen guests";
|
||||
|
||||
longDescription = ''
|
||||
This package provides a PvGrub image for booting Para-Virtualized (PV)
|
||||
Xen guests
|
||||
'';
|
||||
|
||||
platforms = platforms.gnu ++ platforms.linux;
|
||||
};
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
grub2_xen,
|
||||
grub2_xen_pvh,
|
||||
grubPlatform ? "xen_pvh",
|
||||
}:
|
||||
|
||||
assert lib.assertOneOf "grubPlatform" grubPlatform [
|
||||
"xen"
|
||||
"xen_pvh"
|
||||
];
|
||||
let
|
||||
targets = {
|
||||
i686-linux.target = "i386";
|
||||
x86_64-linux.target = if grubPlatform == "xen_pvh" then "i386" else "x86_64";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "grub2_${grubPlatform}_image";
|
||||
|
||||
env = {
|
||||
GRUB_CONFIGS = "${./configs}";
|
||||
GRUB_FORMAT = "${targets.${stdenv.buildPlatform.system}.target}-${grubPlatform}";
|
||||
};
|
||||
|
||||
buildInputs =
|
||||
lib.optional (grubPlatform == "xen") grub2_xen
|
||||
++ lib.optional (grubPlatform == "xen_pvh") grub2_xen_pvh;
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
buildPhase = ''
|
||||
cp "$GRUB_CONFIGS"/* .
|
||||
tar -cf memdisk.tar grub.cfg
|
||||
grub-mkimage \
|
||||
-O "$GRUB_FORMAT" \
|
||||
-c grub-bootstrap.cfg \
|
||||
-m memdisk.tar \
|
||||
-o grub-"$GRUB_FORMAT".bin \
|
||||
${if grubPlatform == "xen_pvh" then grub2_xen_pvh else grub2_xen}/lib/grub/"$GRUB_FORMAT"/*.mod
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/lib/grub-${grubPlatform}"
|
||||
cp grub-"$GRUB_FORMAT".bin $out/lib/grub-${grubPlatform}/
|
||||
'';
|
||||
|
||||
dontFixup = true;
|
||||
|
||||
meta = {
|
||||
description = "PvGrub2 image for booting ${
|
||||
if grubPlatform == "xen_pvh" then "PVH" else "PV"
|
||||
} Xen guests";
|
||||
|
||||
longDescription =
|
||||
if (grubPlatform == "xen_pvh") then
|
||||
''
|
||||
This package provides a prebuilt PvGrub2 image for booting PVH Xen
|
||||
guests (also commonly referred to as PvhGrub2), which searches for
|
||||
`grub.cfg` on the guest disk and interprets it to load the kernel,
|
||||
eliminating the need to copy the guest kernel to the Dom0.
|
||||
|
||||
You will need `pkgs.grub2_xen_pvh` to build a customized PvhGrub2
|
||||
image. See [PvGrub2](https://wiki.xenproject.org/wiki/PvGrub2) for
|
||||
more explanations.
|
||||
''
|
||||
else
|
||||
''
|
||||
This package provides a prebuilt PvGrub2 image for booting PV Xen
|
||||
guests, which searches for `grub.cfg` on the guest disk and interprets
|
||||
it to load the kernel, eliminating the need to copy the guest kernel
|
||||
to the Dom0.
|
||||
|
||||
You will need `pkgs.grub2_xen` to build a customized PvGrub2 image.
|
||||
See [PvGrub2](https://wiki.xenproject.org/wiki/PvGrub2) for more
|
||||
explanations.
|
||||
'';
|
||||
|
||||
teams = [ lib.teams.xen ];
|
||||
platforms = lib.attrNames targets;
|
||||
};
|
||||
}
|
||||
@@ -3142,6 +3142,10 @@ with pkgs;
|
||||
xenPvhSupport = true;
|
||||
};
|
||||
|
||||
grub2_pvgrub_image = grub2_pvhgrub_image.override {
|
||||
grubPlatform = "xen";
|
||||
};
|
||||
|
||||
grub4dos = callPackage ../tools/misc/grub4dos {
|
||||
stdenv = stdenv_32bit;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user