From 6fc909a1cc89b32c9bc27d69da6333b8a0d4b87e Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Sat, 30 Jul 2022 15:42:22 +0200 Subject: makeInitrdNG: make stripping fully optional Now the tool will only strip binaries if a strip executable is passed via the STRIP environment variable. This is exposed via the strip option for makeInitrdNG and the NixOS option boot.initrd.systemd.strip. --- pkgs/build-support/kernel/make-initrd-ng-tool.nix | 7 ------- pkgs/build-support/kernel/make-initrd-ng.nix | 13 +++++++++---- pkgs/build-support/kernel/make-initrd-ng/src/main.rs | 18 ++++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'pkgs/build-support/kernel') diff --git a/pkgs/build-support/kernel/make-initrd-ng-tool.nix b/pkgs/build-support/kernel/make-initrd-ng-tool.nix index 654b1036781..67488168cf2 100644 --- a/pkgs/build-support/kernel/make-initrd-ng-tool.nix +++ b/pkgs/build-support/kernel/make-initrd-ng-tool.nix @@ -6,11 +6,4 @@ rustPlatform.buildRustPackage { src = ./make-initrd-ng; cargoLock.lockFile = ./make-initrd-ng/Cargo.lock; - - nativeBuildInputs = [ makeWrapper ]; - - postInstall = '' - wrapProgram $out/bin/make-initrd-ng \ - --prefix PATH : ${lib.makeBinPath [ patchelf glibc binutils ]} - ''; } diff --git a/pkgs/build-support/kernel/make-initrd-ng.nix b/pkgs/build-support/kernel/make-initrd-ng.nix index 5f0a70f8a96..23ed9f3f74e 100644 --- a/pkgs/build-support/kernel/make-initrd-ng.nix +++ b/pkgs/build-support/kernel/make-initrd-ng.nix @@ -8,10 +8,12 @@ let # compression type and filename extension. compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1; in -{ stdenvNoCC, perl, cpio, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, patchelf, runCommand +{ stdenvNoCC, perl, cpio, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, patchelf, binutils, runCommand # Name of the derivation (not of the resulting file!) , name ? "initrd" +, strip ? true + # Program used to compress the cpio archive; use "cat" for no compression. # This can also be a function which takes a package set and returns the path to the compressor, # such as `pkgs: "${pkgs.lzop}/bin/lzop"`. @@ -59,7 +61,7 @@ in # If this isn't guessed, you may want to complete the metadata above and send a PR :) , uInitrdCompression ? _compressorMeta.ubootName or (throw "Unrecognised compressor ${_compressorName}, please specify uInitrdCompression") -}: runCommand name { +}: runCommand name ({ compress = "${_compressorExecutable} ${lib.escapeShellArgs _compressorArgsReal}"; passthru = { compressorExecutableFunction = _compressorFunction; @@ -72,8 +74,11 @@ in passAsFile = ["contents"]; contents = lib.concatMapStringsSep "\n" ({ object, symlink, ... }: "${object}\n${if symlink == null then "" else symlink}") contents + "\n"; - nativeBuildInputs = [makeInitrdNGTool patchelf cpio] ++ lib.optional makeUInitrd ubootTools; -} '' + nativeBuildInputs = [makeInitrdNGTool patchelf cpio] ++ lib.optional makeUInitrd ubootTools ++ lib.optional strip binutils; + +} // lib.optionalAttrs strip { + STRIP = "${(binutils.nativeDrv or binutils).targetPrefix}strip"; +}) '' mkdir ./root make-initrd-ng "$contentsPath" ./root mkdir "$out" diff --git a/pkgs/build-support/kernel/make-initrd-ng/src/main.rs b/pkgs/build-support/kernel/make-initrd-ng/src/main.rs index de1e3ee724a..89a7c08fda7 100644 --- a/pkgs/build-support/kernel/make-initrd-ng/src/main.rs +++ b/pkgs/build-support/kernel/make-initrd-ng/src/main.rs @@ -104,14 +104,16 @@ fn copy_file + AsRef, S: AsRef + AsRef>( fs::set_permissions(&target, permissions)?; // Strip further than normal - if !Command::new("strip") - .arg("--strip-all") - .arg(OsStr::new(&target)) - .output()? - .status - .success() - { - println!("{:?} was not successfully stripped.", OsStr::new(&target)); + if let Ok(strip) = env::var("STRIP") { + if !Command::new(strip) + .arg("--strip-all") + .arg(OsStr::new(&target)) + .output()? + .status + .success() + { + println!("{:?} was not successfully stripped.", OsStr::new(&target)); + } } }; -- cgit 1.4.1