gnuk: refactor, mark broken (#353217)

This commit is contained in:
Austin Horstman 2024-11-06 20:56:00 -06:00 committed by GitHub
commit fe81678220
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 69 additions and 59 deletions

View File

@ -1,11 +1,73 @@
{ callPackage, fetchgit, ... } @ args:
{
lib,
stdenv,
fetchFromGitLab,
gcc-arm-embedded,
binutils-arm-embedded,
makeWrapper,
python3Packages,
callPackage ./generic.nix (args // {
version = "1.2.14";
# Default FSIJ IDs
vid ? "234b",
pid ? "0000",
}:
src = fetchgit {
url = "git://git.gniibe.org/gnuk/gnuk.git";
rev = "177ef67edfa2306c2a369a037362385c354083e1";
sha256 = "16wa3xsaq4r8caw6c24hnv4j78bklacix4in2y66j35h68ggr3j1";
stdenv.mkDerivation (finalAttrs: {
pname = "gnuk";
version = "2.2";
src = fetchFromGitLab {
domain = "salsa.debian.org";
owner = "gnuk-team";
repo = "gnuk/gnuk";
rev = "release/${finalAttrs.version}";
hash = "sha256-qY/dwkcPJiPx/+inSxH7w7a0v3cWUQDX+NYJwUjnkMY=";
fetchSubmodules = true;
};
nativeBuildInputs = [
gcc-arm-embedded
binutils-arm-embedded
makeWrapper
];
buildInputs = with python3Packages; [
python
pyusb
colorama
];
sourceRoot = "${finalAttrs.src.name}/src";
configureFlags = [ "--vidpid=${vid}:${pid}" ];
# TODO: Check how many of these patches are actually needed.
installPhase = ''
mkdir -p $out/bin
find . -name gnuk.bin -exec cp {} $out \;
#sed -i 's,Exception as e,IOError as e,' ../tool/stlinkv2.py
sed -i ../tool/stlinkv2.py \
-e "1a import array" \
-e "s,\(data_received =\) (),\1 array.array('B'),g" \
-e "s,\(data_received\) = data_received + \(.*\),\1.extend(\2),g"
cp ../tool/stlinkv2.py $out/bin/stlinkv2
wrapProgram $out/bin/stlinkv2 --prefix PYTHONPATH : "$PYTHONPATH"
# Some useful helpers
echo "#! ${stdenv.shell} -e" | tee $out/bin/{unlock,flash}
echo "$out/bin/stlinkv2 -u \$@" >> $out/bin/unlock
echo "$out/bin/stlinkv2 -b \$@ $out/gnuk.bin" >> $out/bin/flash
chmod +x $out/bin/{unlock,flash}
'';
meta = {
homepage = "https://www.fsij.org/category/gnuk.html";
description = "Implementation of USB cryptographic token for gpg";
license = lib.licenses.gpl3;
platforms = lib.platforms.linux;
maintainers = [ ];
broken = true; # Needs Picolib, which is not packaged in Nixpkgs.
};
})

View File

@ -1,52 +0,0 @@
{ lib, stdenv, gcc-arm-embedded, binutils-arm-embedded, makeWrapper
, python3Packages
# Extra options
, device ? "fsij", vid ? "234b", pid ? "0000"
# Version specific options
, version, src
, ...
}:
stdenv.mkDerivation {
pname = "gnuk-${device}";
inherit version src;
nativeBuildInputs = [ gcc-arm-embedded binutils-arm-embedded makeWrapper ];
buildInputs = with python3Packages; [ python pyusb colorama ];
configurePhase = ''
cd src
patchShebangs configure
./configure --vidpid=${vid}:${pid}
'';
installPhase = ''
mkdir -p $out/bin
find . -name gnuk.bin -exec cp {} $out \;
#sed -i 's,Exception as e,IOError as e,' ../tool/stlinkv2.py
sed -i ../tool/stlinkv2.py \
-e "1a import array" \
-e "s,\(data_received =\) (),\1 array.array('B'),g" \
-e "s,\(data_received\) = data_received + \(.*\),\1.extend(\2),g"
cp ../tool/stlinkv2.py $out/bin/stlinkv2
wrapProgram $out/bin/stlinkv2 --prefix PYTHONPATH : "$PYTHONPATH"
# Some useful helpers
echo "#! ${stdenv.shell} -e" | tee $out/bin/{unlock,flash}
echo "$out/bin/stlinkv2 -u \$@" >> $out/bin/unlock
echo "$out/bin/stlinkv2 -b \$@ $out/gnuk.bin" >> $out/bin/flash
chmod +x $out/bin/{unlock,flash}
'';
meta = with lib; {
homepage = "https://www.fsij.org/doc-gnuk/";
description = "Implementation of USB cryptographic token for gpg";
license = licenses.gpl3;
platforms = with platforms; linux;
};
}