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

This commit is contained in:
Philip Taron 2024-04-11 12:57:48 -07:00 committed by Sandro Jäckel
parent 98e8fbee79
commit 55ddcaf70d
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5
2 changed files with 60 additions and 2 deletions

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, cmake, bison, flex, libusb1, libelf
{ lib, callPackage, stdenv, fetchFromGitHub, cmake, bison, flex, libusb1, elfutils
, libftdi1, readline, hidapi, libserialport
# Documentation building doesn't work on Darwin. It fails with:
# Undefined subroutine &Locale::Messages::dgettext called in ... texi2html
@ -6,6 +6,10 @@
# https://github.com/NixOS/nixpkgs/issues/224761
, docSupport ? (!stdenv.hostPlatform.isDarwin), texliveMedium, texinfo, texi2html, unixtools }:
let
useElfutils = lib.meta.availableOn stdenv.hostPlatform elfutils;
in
stdenv.mkDerivation rec {
pname = "avrdude";
version = "7.3";
@ -24,7 +28,19 @@ stdenv.mkDerivation rec {
texi2html
];
buildInputs = [ hidapi libusb1 libelf libftdi1 libserialport readline ];
buildInputs = [
(if useElfutils then elfutils else finalAttrs.finalPackage.passthru.libelf)
hidapi
libusb1
libftdi1
libserialport
readline
];
postPatch = lib.optionalString (!useElfutils) ''
# vendored libelf is a static library
sed -i "s/PREFERRED_LIBELF elf/PREFERRED_LIBELF libelf.a elf/" CMakeLists.txt
'';
# Not used:
#
@ -39,6 +55,12 @@ stdenv.mkDerivation rec {
rm $out/share/doc/${pname}/*.ps
'';
passthru = {
# Vendored and mutated copy of libelf for avrdudes use.
# Produces a static library only.
libelf = callPackage ./libelf.nix { };
};
meta = with lib; {
description = "Command-line tool for programming Atmel AVR microcontrollers";
mainProgram = "avrdude";

View File

@ -0,0 +1,36 @@
{
lib,
stdenv,
cmake,
fetchFromGitHub,
}:
stdenv.mkDerivation {
pname = "libelf";
version = "0.8.13-unstable-2023-01-14";
src = fetchFromGitHub {
owner = "avrdudes";
repo = "libelf";
rev = "0c55bfe1d3020a20bddf6ce57c0d9d98ccb12586";
hash = "sha256-jz7Ef0Eg673IJVZvVNklY40s13LCuMVAc7FGrRI7scQ=";
};
nativeBuildInputs = [ cmake ];
installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp liblibelf.a $out/lib/libelf.a
cp -r $src/include $out/include
runHook postInstall
'';
meta = {
description = "ELF object file access library (vendored by avrdudes)";
homepage = "https://github.com/avrdudes/libelf";
license = lib.licenses.lgpl2Plus;
platforms = lib.platforms.all;
maintainers = [ lib.maintainers.bjornfor ];
};
}