lsb-release: Fix/replace with a custom Bash script (#64258)

See #64258 for more details and some discussion.
Fix #22729.

tl;dr: This fixes the behaviour at run-time but uses "n/a" defaults
inside the Nix build sandbox (build-time).

There might still be a few minor regressions, we might have to tweak
the behaviour over time (e.g. the implementation from Debian also
differs from the original version), and we could refactor the script,
but it should work well enough for now.
This commit is contained in:
Michael Weiss
2019-07-31 00:20:00 +02:00
committed by GitHub
parent c0fe97b12e
commit 63f93407b9
2 changed files with 203 additions and 26 deletions
+13 -26
View File
@@ -1,34 +1,21 @@
{ stdenv, fetchurl, perl, coreutils, getopt, makeWrapper }:
{ substituteAll, lib
, coreutils, getopt
}:
stdenv.mkDerivation rec {
version = "1.4";
name = "lsb-release-${version}";
substituteAll {
name = "lsb_release";
src = fetchurl {
url = "mirror://sourceforge/lsb/${name}.tar.gz";
sha256 = "0wkiy7ymfi3fh2an2g30raw6yxh6rzf6nz2v90fplbnnz2414clr";
};
src = ./lsb_release.sh;
preConfigure = ''
substituteInPlace help2man \
--replace /usr/bin/perl ${perl}/bin/perl
'';
dir = "bin";
isExecutable = true;
installFlags = [ "prefix=$(out)" ];
inherit coreutils getopt;
nativeBuildInputs = [ makeWrapper perl ];
buildInputs = [ coreutils getopt ];
# Ensure utilities used are available
preFixup = ''
wrapProgram $out/bin/lsb_release --prefix PATH : ${stdenv.lib.makeBinPath [ coreutils getopt ]}
'';
meta = {
meta = with lib; {
description = "Prints certain LSB (Linux Standard Base) and Distribution information";
homepage = http://www.linuxfoundation.org/collaborate/workgroups/lsb;
license = [ stdenv.lib.licenses.gpl2Plus stdenv.lib.licenses.gpl3Plus ];
platforms = stdenv.lib.platforms.linux;
license = [ licenses.mit ];
maintainers = with maintainers; [ primeos ];
platforms = platforms.linux;
};
}