milkv/pioneer: fix u-root cross-compilation
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
This commit is contained in:
parent
f4a07223a3
commit
218ab789fd
|
@ -1,54 +1,73 @@
|
||||||
{ buildGoModule
|
{ buildPackages
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, fetchpatch
|
, fetchpatch
|
||||||
, linux-firmware
|
, linux-firmware
|
||||||
|
, buildGoModule
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# Based on
|
# Based on
|
||||||
# https://github.com/sophgo/bootloader-riscv/blob/e0839852d571df106db622611f4786ae17e8df0f/scripts/envsetup.sh#L809-L819
|
# https://github.com/sophgo/bootloader-riscv/blob/e0839852d571df106db622611f4786ae17e8df0f/scripts/envsetup.sh#L809-L819
|
||||||
|
let
|
||||||
buildGoModule rec {
|
u-root = buildPackages.buildGoModule rec {
|
||||||
pname = "u-root";
|
pname = "u-root";
|
||||||
version = "0.14.0";
|
version = "0.14.0";
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "u-root";
|
owner = "u-root";
|
||||||
repo = "u-root";
|
repo = "u-root";
|
||||||
rev = "v${version}";
|
rev = "v${version}";
|
||||||
hash = "sha256-8zA3pHf45MdUcq/MA/mf0KCTxB1viHieU/oigYwIPgo=";
|
hash = "sha256-8zA3pHf45MdUcq/MA/mf0KCTxB1viHieU/oigYwIPgo=";
|
||||||
};
|
};
|
||||||
vendorHash = null;
|
vendorHash = null;
|
||||||
patches = [
|
patches = [
|
||||||
(
|
(fetchpatch {
|
||||||
fetchpatch {
|
|
||||||
url = "https://github.com/sophgo/bootloader-riscv/commit/322c3305763872a9b88a1c85d79bca63b8fbe7a6.patch";
|
url = "https://github.com/sophgo/bootloader-riscv/commit/322c3305763872a9b88a1c85d79bca63b8fbe7a6.patch";
|
||||||
hash = "sha256-l5r3DbcMqRYD5FhRBqtEIEscZAdDvjmQJE4BIAtWYWE=";
|
hash = "sha256-l5r3DbcMqRYD5FhRBqtEIEscZAdDvjmQJE4BIAtWYWE=";
|
||||||
stripLen = 1;
|
stripLen = 1;
|
||||||
}
|
})
|
||||||
)
|
];
|
||||||
];
|
|
||||||
|
|
||||||
# We only build the u-root binary in the build phase and the initrd in the
|
postInstall = ''
|
||||||
# postBuild hook.
|
cp -r . $out/src
|
||||||
subPackages = [ "." ];
|
'';
|
||||||
postBuild = ''
|
|
||||||
GOROOT="$(go env GOROOT)" $GOPATH/bin/u-root \
|
# We only build the u-root binary in the build phase and the initrd in the
|
||||||
|
# postBuild hook.
|
||||||
|
subPackages = [ "." ];
|
||||||
|
|
||||||
|
# Tests time out after 10min for native riscv64 builds on the pioneer.
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
buildGoModule {
|
||||||
|
name = "linuxboot-initrd";
|
||||||
|
src = null;
|
||||||
|
vendorHash = null;
|
||||||
|
dontUnpack = true;
|
||||||
|
nativeBuildInputs = [ u-root ];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
pushd ${u-root}/src
|
||||||
|
mkdir -p $out
|
||||||
|
GOROOT="$(go env GOROOT)" u-root \
|
||||||
-build bb \
|
-build bb \
|
||||||
-uinitcmd=boot \
|
-uinitcmd=boot \
|
||||||
-files "${linux-firmware}/lib/firmware/amdgpu/:lib/firmware/amdgpu/" \
|
-files "${linux-firmware}/lib/firmware/amdgpu/:lib/firmware/amdgpu/" \
|
||||||
-files "${linux-firmware}/lib/firmware/radeon/:lib/firmware/radeon/" \
|
-files "${linux-firmware}/lib/firmware/radeon/:lib/firmware/radeon/" \
|
||||||
-o initramfs.cpio \
|
-o $out/initramfs.cpio \
|
||||||
core boot
|
core boot
|
||||||
|
popd
|
||||||
|
|
||||||
# The vendor does not compress the initrd. We do since we include more
|
# The vendor does not compress the initrd. We do since we include more
|
||||||
# firmware files. CRC32 is required by the kernel's decompressor.
|
# firmware files. CRC32 is required by the kernel's decompressor.
|
||||||
xz --check=crc32 initramfs.cpio
|
xz --check=crc32 $out/initramfs.cpio
|
||||||
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
install -D initramfs.cpio.xz $out/initrd.img
|
runHook preInstall
|
||||||
|
mv $out/initramfs.cpio.xz $out/initrd.img
|
||||||
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Tests time out after 10min for native riscv64 builds on the pioneer.
|
|
||||||
doCheck = false;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue