Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

avrdude: use either vendored libelf or elfutils instead of abandoned upstream

authored by philiptaron.tngl.sh and committed by Sandro Jäckel 55ddcaf7 98e8fbee

+60 -2
+24 -2
pkgs/development/embedded/avrdude/default.nix
··· 1 - { lib, stdenv, fetchFromGitHub, cmake, bison, flex, libusb1, libelf 1 + { lib, callPackage, stdenv, fetchFromGitHub, cmake, bison, flex, libusb1, elfutils 2 2 , libftdi1, readline, hidapi, libserialport 3 3 # Documentation building doesn't work on Darwin. It fails with: 4 4 # Undefined subroutine &Locale::Messages::dgettext called in ... texi2html 5 5 # 6 6 # https://github.com/NixOS/nixpkgs/issues/224761 7 7 , docSupport ? (!stdenv.hostPlatform.isDarwin), texliveMedium, texinfo, texi2html, unixtools }: 8 + 9 + let 10 + useElfutils = lib.meta.availableOn stdenv.hostPlatform elfutils; 11 + in 8 12 9 13 stdenv.mkDerivation rec { 10 14 pname = "avrdude"; ··· 24 28 texi2html 25 29 ]; 26 30 27 - buildInputs = [ hidapi libusb1 libelf libftdi1 libserialport readline ]; 31 + buildInputs = [ 32 + (if useElfutils then elfutils else finalAttrs.finalPackage.passthru.libelf) 33 + hidapi 34 + libusb1 35 + libftdi1 36 + libserialport 37 + readline 38 + ]; 39 + 40 + postPatch = lib.optionalString (!useElfutils) '' 41 + # vendored libelf is a static library 42 + sed -i "s/PREFERRED_LIBELF elf/PREFERRED_LIBELF libelf.a elf/" CMakeLists.txt 43 + ''; 28 44 29 45 # Not used: 30 46 # ··· 38 54 postInstall = lib.optionalString docSupport '' 39 55 rm $out/share/doc/${pname}/*.ps 40 56 ''; 57 + 58 + passthru = { 59 + # Vendored and mutated copy of libelf for avrdudes use. 60 + # Produces a static library only. 61 + libelf = callPackage ./libelf.nix { }; 62 + }; 41 63 42 64 meta = with lib; { 43 65 description = "Command-line tool for programming Atmel AVR microcontrollers";
+36
pkgs/development/embedded/avrdude/libelf.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + cmake, 5 + fetchFromGitHub, 6 + }: 7 + 8 + stdenv.mkDerivation { 9 + pname = "libelf"; 10 + version = "0.8.13-unstable-2023-01-14"; 11 + 12 + src = fetchFromGitHub { 13 + owner = "avrdudes"; 14 + repo = "libelf"; 15 + rev = "0c55bfe1d3020a20bddf6ce57c0d9d98ccb12586"; 16 + hash = "sha256-jz7Ef0Eg673IJVZvVNklY40s13LCuMVAc7FGrRI7scQ="; 17 + }; 18 + 19 + nativeBuildInputs = [ cmake ]; 20 + 21 + installPhase = '' 22 + runHook preInstall 23 + mkdir -p $out/lib 24 + cp liblibelf.a $out/lib/libelf.a 25 + cp -r $src/include $out/include 26 + runHook postInstall 27 + ''; 28 + 29 + meta = { 30 + description = "ELF object file access library (vendored by avrdudes)"; 31 + homepage = "https://github.com/avrdudes/libelf"; 32 + license = lib.licenses.lgpl2Plus; 33 + platforms = lib.platforms.all; 34 + maintainers = [ lib.maintainers.bjornfor ]; 35 + }; 36 + }