2015-07-04 22:39:28 +01:00
|
|
|
{ stdenv, fetchurl, fetchgit, autogen, flex, bison, python, autoconf, automake
|
2018-07-17 21:11:16 +01:00
|
|
|
, gettext, ncurses, libusb, freetype, qemu, lvm2
|
2015-12-21 19:20:29 +00:00
|
|
|
, for_HP_laptop ? false
|
2015-07-04 22:39:28 +01:00
|
|
|
}:
|
2014-08-24 22:41:00 +01:00
|
|
|
|
2015-07-04 22:39:28 +01:00
|
|
|
with stdenv.lib;
|
|
|
|
let
|
|
|
|
pcSystems = {
|
|
|
|
"i686-linux".target = "i386";
|
|
|
|
"x86_64-linux".target = "i386";
|
|
|
|
};
|
|
|
|
|
2018-08-20 20:11:29 +01:00
|
|
|
inPCSystems = any (system: stdenv.hostPlatform.system == system) (mapAttrsToList (name: _: name) pcSystems);
|
2015-07-04 22:39:28 +01:00
|
|
|
|
2015-12-21 19:20:29 +00:00
|
|
|
version = if for_HP_laptop then "1.2.1" else "1.2.0";
|
2015-07-04 22:39:28 +01:00
|
|
|
|
|
|
|
unifont_bdf = fetchurl {
|
|
|
|
url = "http://unifoundry.com/unifont-5.1.20080820.bdf.gz";
|
|
|
|
sha256 = "0s0qfff6n6282q28nwwblp5x295zd6n71kl43xj40vgvdqxv0fxx";
|
|
|
|
};
|
|
|
|
|
|
|
|
po_src = fetchurl {
|
|
|
|
name = "grub-2.02-beta2.tar.gz";
|
2018-12-01 18:22:13 +00:00
|
|
|
url = "https://alpha.gnu.org/gnu/grub/grub-2.02~beta2.tar.gz";
|
2015-07-04 22:39:28 +01:00
|
|
|
sha256 = "1lr9h3xcx0wwrnkxdnkfjwy08j7g7mdlmmbdip2db4zfgi69h0rm";
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-12-21 19:20:29 +00:00
|
|
|
in
|
2015-07-04 22:39:28 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2015-08-02 21:50:36 +01:00
|
|
|
name = "trustedGRUB2-${version}";
|
2014-08-24 22:41:00 +01:00
|
|
|
|
2015-12-21 19:20:29 +00:00
|
|
|
src = if for_HP_laptop
|
|
|
|
then fetchgit {
|
|
|
|
url = "https://github.com/Sirrix-AG/TrustedGRUB2";
|
|
|
|
rev = "ab483d389bda3115ca0ae4202fd71f2e4a31ad41";
|
2016-06-02 12:26:44 +01:00
|
|
|
sha256 = "1760d9hsnqkdvlag9nn8f613mqhnsxmidgvdkpmb37b0yi7p6lhz";
|
2015-12-21 19:20:29 +00:00
|
|
|
}
|
|
|
|
else fetchgit {
|
|
|
|
url = "https://github.com/Sirrix-AG/TrustedGRUB2";
|
|
|
|
rev = "1ff54a5fbe02ea01df5a7de59b1e0201e08d4f76";
|
2016-06-02 12:26:44 +01:00
|
|
|
sha256 = "0yrfwx67gpg9gij5raq0cfbx3jj769lkg3diqgb7i9n86hgcdh4k";
|
2015-12-21 19:20:29 +00:00
|
|
|
};
|
2014-08-24 22:41:00 +01:00
|
|
|
|
2015-07-04 22:39:28 +01:00
|
|
|
nativeBuildInputs = [ autogen flex bison python autoconf automake ];
|
2018-07-17 21:11:16 +01:00
|
|
|
buildInputs = [ ncurses libusb freetype gettext lvm2 ]
|
2015-07-04 22:39:28 +01:00
|
|
|
++ optional doCheck qemu;
|
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "stackprotector" "pic" ];
|
2016-02-24 16:54:49 +00:00
|
|
|
|
2017-01-26 01:55:20 +00:00
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-error"; # generated code redefines yyfree
|
|
|
|
|
2015-07-04 22:39:28 +01:00
|
|
|
preConfigure =
|
|
|
|
'' for i in "tests/util/"*.in
|
|
|
|
do
|
2019-01-15 22:41:31 +00:00
|
|
|
sed -i "$i" -e's|/bin/bash|${stdenv.shell}|g'
|
2015-07-04 22:39:28 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# Apparently, the QEMU executable is no longer called
|
|
|
|
# `qemu-system-i386', even on i386.
|
|
|
|
#
|
|
|
|
# In addition, use `-nodefaults' to avoid errors like:
|
|
|
|
#
|
|
|
|
# chardev: opening backend "stdio" failed
|
|
|
|
# qemu: could not open serial device 'stdio': Invalid argument
|
|
|
|
#
|
|
|
|
# See <http://www.mail-archive.com/qemu-devel@nongnu.org/msg22775.html>.
|
|
|
|
sed -i "tests/util/grub-shell.in" \
|
|
|
|
-e's/qemu-system-i386/qemu-system-x86_64 -nodefaults/g'
|
|
|
|
'';
|
|
|
|
|
|
|
|
prePatch =
|
|
|
|
'' tar zxf ${po_src} grub-2.02~beta2/po
|
|
|
|
rm -rf po
|
|
|
|
mv grub-2.02~beta2/po po
|
|
|
|
sh autogen.sh
|
|
|
|
gunzip < "${unifont_bdf}" > "unifont.bdf"
|
|
|
|
sed -i "configure" \
|
|
|
|
-e "s|/usr/src/unifont.bdf|$PWD/unifont.bdf|g"
|
|
|
|
'';
|
|
|
|
|
|
|
|
patches = [ ./fix-bash-completion.patch ];
|
|
|
|
|
|
|
|
# save target that grub is compiled for
|
|
|
|
grubTarget = if inPCSystems
|
2018-08-20 20:11:29 +01:00
|
|
|
then "${pcSystems.${stdenv.hostPlatform.system}.target}-pc"
|
2015-07-04 22:39:28 +01:00
|
|
|
else "";
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
enableParallelBuilding = true;
|
2014-08-24 22:41:00 +01:00
|
|
|
|
2015-07-04 22:39:28 +01:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "GRUB 2.0 extended with TCG (TPM) support for integrity measured boot process (trusted boot)";
|
|
|
|
homepage = https://github.com/Sirrix-AG/TrustedGRUB2;
|
|
|
|
license = licenses.gpl3Plus;
|
2018-04-30 23:43:54 +01:00
|
|
|
platforms = platforms.gnu ++ platforms.linux;
|
2014-08-24 22:41:00 +01:00
|
|
|
};
|
2015-12-21 19:20:29 +00:00
|
|
|
}
|