diff options
| author | Alejandro Soto <alejandro@34project.org> | 2025-07-06 15:14:43 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2025-07-06 16:29:43 -0600 |
| commit | c839b6adb914e8af57317389ceb8eb68c31f3e22 (patch) | |
| tree | 55f6db5e632ce39e085e47bbbd17c208399ffeb9 /pkgs/athena-bccr | |
| parent | 8d81cc1edb68363502315a848d7074435da1e963 (diff) | |
pkgs/athena-bccr: initial commit
Diffstat (limited to 'pkgs/athena-bccr')
| -rw-r--r-- | pkgs/athena-bccr/0001-Remove-CheckUpdatePlugin-from-default-list.patch | 25 | ||||
| -rw-r--r-- | pkgs/athena-bccr/LaunchGaudi.java | 18 | ||||
| -rw-r--r-- | pkgs/athena-bccr/default.nix | 23 | ||||
| -rw-r--r-- | pkgs/athena-bccr/fhs-env.nix | 12 | ||||
| -rw-r--r-- | pkgs/athena-bccr/firmador.nix | 58 | ||||
| -rw-r--r-- | pkgs/athena-bccr/releases.nix | 12 | ||||
| -rw-r--r-- | pkgs/athena-bccr/unwrapped.nix | 134 |
7 files changed, 282 insertions, 0 deletions
diff --git a/pkgs/athena-bccr/0001-Remove-CheckUpdatePlugin-from-default-list.patch b/pkgs/athena-bccr/0001-Remove-CheckUpdatePlugin-from-default-list.patch new file mode 100644 index 0000000..e7fc5d5 --- /dev/null +++ b/pkgs/athena-bccr/0001-Remove-CheckUpdatePlugin-from-default-list.patch @@ -0,0 +1,25 @@ +From 5e7eb46f46af6a29a2aea19db722ebc28baede25 Mon Sep 17 00:00:00 2001 +From: Alejandro Soto <alejandro@34project.org> +Date: Sat, 21 Jun 2025 22:37:19 -0600 +Subject: [PATCH] Remove CheckUpdatePlugin from default list + +--- + src/main/java/cr/libre/firmador/Settings.java | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/main/java/cr/libre/firmador/Settings.java b/src/main/java/cr/libre/firmador/Settings.java +index e5ddf01..a028d6e 100644 +--- a/src/main/java/cr/libre/firmador/Settings.java ++++ b/src/main/java/cr/libre/firmador/Settings.java +@@ -81,7 +81,7 @@ public class Settings { + + public Settings() { + activePlugins.add("cr.libre.firmador.plugins.DummyPlugin"); +- activePlugins.add("cr.libre.firmador.plugins.CheckUpdatePlugin"); ++ // activePlugins.add("cr.libre.firmador.plugins.CheckUpdatePlugin"); + availablePlugins.add("cr.libre.firmador.plugins.DummyPlugin"); + availablePlugins.add("cr.libre.firmador.plugins.CheckUpdatePlugin"); + } +-- +2.49.0 + diff --git a/pkgs/athena-bccr/LaunchGaudi.java b/pkgs/athena-bccr/LaunchGaudi.java new file mode 100644 index 0000000..5457086 --- /dev/null +++ b/pkgs/athena-bccr/LaunchGaudi.java @@ -0,0 +1,18 @@ +// Los del BCCR no se molestaron en ponerle un main al Agente Gaudi porque el +// actualizador (que a su vez sí tiene main) carga el jar en memoria y crea una +// instancia de Inicializador usando reflexión. El actualizador no es relevante +// en Nix. En todo caso, dicho actualizador es sumamente frágil y me daría +// demasiada pereza arreglarlo, así que en su lugar usamos este stub para +// launchear Gaudi. + +import InicializadorCliente.Inicializador; + +public class LaunchGaudi { + public static void main(String[] args) { + // new Inicializador(0); + + j.e log = new j.e(); + System.setProperty("log_dir", log.a()); + Tray.ConsolaControlador.Instancia().run(); + } +} diff --git a/pkgs/athena-bccr/default.nix b/pkgs/athena-bccr/default.nix new file mode 100644 index 0000000..16e2e36 --- /dev/null +++ b/pkgs/athena-bccr/default.nix @@ -0,0 +1,23 @@ +{ callPackage +, lib +}: +let + latest = "deb64-rev26"; + + releases = lib.mapAttrs (name: release: release // { name = name; }) (import ./releases.nix); + unwrappedFor = release: lib.mapAttrs (_: pkg: callPackage pkg { }) (callPackage ./unwrapped.nix { inherit release; }); + + pkgsForRelease = release: + let + libasep11 = "${unwrapped.ase-idprotect}/lib/x64-athena/libASEP11.so"; + unwrapped = unwrappedFor release; + in + { + inherit libasep11; + inherit (unwrapped) ase-idprotect; + + shell = callPackage ./fhs-env.nix { inherit unwrapped; }; + firmador = callPackage ./firmador.nix { inherit libasep11; }; + }; +in +lib.mapAttrs (_: pkgsForRelease) (releases // { latest = releases.${latest}; }) diff --git a/pkgs/athena-bccr/fhs-env.nix b/pkgs/athena-bccr/fhs-env.nix new file mode 100644 index 0000000..a9bbf90 --- /dev/null +++ b/pkgs/athena-bccr/fhs-env.nix @@ -0,0 +1,12 @@ +{ buildFHSEnv + +, unwrapped +}: +buildFHSEnv { + name = "athena-bccr"; + + targetPkgs = pkgs: [ + unwrapped.ase-idprotect + unwrapped.gaudi + ]; +} diff --git a/pkgs/athena-bccr/firmador.nix b/pkgs/athena-bccr/firmador.nix new file mode 100644 index 0000000..eef413b --- /dev/null +++ b/pkgs/athena-bccr/firmador.nix @@ -0,0 +1,58 @@ +{ fetchgit +, lib +, makeWrapper +, maven +, openjdk +, wrapGAppsHook + +, libasep11 ? null +}: +let + jdk = openjdk.override { + enableJavaFX = true; + }; + + version = "1.9.8"; +in +maven.buildMavenPackage { + pname = "firmador"; + inherit version; + + src = fetchgit { + url = "https://codeberg.org/firmador/firmador"; + rev = version; + hash = "sha256-xdiVPjihRADPK4nG+WQHWsDzVYLCeN6ouQ6SDtjf1qQ="; + }; + + patches = [ + ./0001-Remove-CheckUpdatePlugin-from-default-list.patch + ]; + + mvnHash = "sha256-h1zoStTgaE7toWWKq0Y0ahOORyltChwjmaMYjLgs1VE="; + + nativeBuildInputs = [ + makeWrapper + wrapGAppsHook + ]; + + postPatch = lib.optionalString (libasep11 != null) '' + sed -i 's@/usr/lib/x64-athena/libASEP11.so@${libasep11}@g' src/main/java/cr/libre/firmador/CRSigner.java + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin $out/share/java + install -Dm644 target/firmador.jar $out/share/java + + makeWrapper ${jdk}/bin/java $out/bin/firmador \ + --add-flags "-jar $out/share/java/firmador.jar" + + runHook postInstall + ''; + + meta = { + homepage = "https://firmador.libre.cr"; + license = lib.licenses.gpl3Plus; + }; +} diff --git a/pkgs/athena-bccr/releases.nix b/pkgs/athena-bccr/releases.nix new file mode 100644 index 0000000..e965172 --- /dev/null +++ b/pkgs/athena-bccr/releases.nix @@ -0,0 +1,12 @@ +{ + "deb64-rev26" = { + # nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum sfd_ClientesLinux_DEB64_Rev26.zip | cut -d' ' -f1) + hash = "sha256-ZPWP9TqJQ5coJAPzUSiaXKVItBWlqFM4smCjOf+gqQM="; + basename = "sfd_ClientesLinux_DEB64_Rev26"; + + srcPaths = { + gaudi = "Firma Digital/Agente GAUDI/agente-gaudi_20.0_amd64.deb"; + idprotect = "Firma Digital/PinTool/IDProtect PINTool 7.24.02/DEB/idprotectclient_7.24.02-0_amd64.deb"; + }; + }; +} diff --git a/pkgs/athena-bccr/unwrapped.nix b/pkgs/athena-bccr/unwrapped.nix new file mode 100644 index 0000000..244bebc --- /dev/null +++ b/pkgs/athena-bccr/unwrapped.nix @@ -0,0 +1,134 @@ +{ lib + +, release +}: +let + inherit (release) srcPaths; + + moduleFromDeb = name: args@{ stdenv, dpkg, requireFile, unzip, srcPath, ... }: + stdenv.mkDerivation ({ + pname = "${name}-unwrapped"; + version = release.name; + + src = requireFile { + url = "https://soportefirmadigital.com"; + name = "${release.basename}.zip"; + + inherit (release) hash; + }; + + nativeBuildInputs = [ dpkg unzip ] ++ (args.nativeBuildInputs or [ ]); + + postUnpack = '' + dpkg -x ${lib.escapeShellArg "${release.basename}/${srcPath}"} ${lib.escapeShellArg release.basename} + ''; + } // lib.removeAttrs args [ "stdenv" "dpkg" "requireFile" "unzip" "srcPath" "nativeBuildInputs" ]); +in +{ + ase-idprotect = + { autoPatchelfHook + , dpkg + , fontconfig + , freetype + , pcsclite + , requireFile + , stdenv + , unzip + , xorg + , zlib + }: + moduleFromDeb "ase-idprotect" { + inherit dpkg requireFile stdenv unzip; + srcPath = srcPaths.idprotect; + + buildInputs = [ + fontconfig + freetype + pcsclite + stdenv.cc.cc.lib + xorg.libX11 + xorg.libXext + zlib + ]; + + nativeBuildInputs = [ + autoPatchelfHook + ]; + + installPhase = '' + runHook preInstall + + install -m755 -d $out/{bin,etc,lib/x64-athena} + install -m755 usr/bin/IDProtect{_Manager,PINTool} $out/bin/ + install -m755 usr/lib/x64-athena/* $out/lib/x64-athena + cp -r etc/Athena $out/etc/Athena + + runHook postInstall + ''; + + preFixup = '' + patchelf --set-rpath $out/lib/x64-athena $out/bin/* + ''; + }; + + gaudi = + { autoPatchelfHook + , dpkg + , makeWrapper + , openjdk + , requireFile + , stdenv + , unzip + , writeShellScriptBin + }: + let + jdk = openjdk.override { + enableJavaFX = true; + }; + + fakeSudo = writeShellScriptBin "sudo" ""; + in + moduleFromDeb "gaudi" { + inherit dpkg requireFile stdenv unzip; + srcPath = srcPaths.gaudi; + + nativeBuildInputs = [ + autoPatchelfHook + jdk + makeWrapper + ]; + + buildPhase = '' + install -m755 -d $out/{bin,opt/Firmador-BCCR/lib} + cp -r opt/Agente-GAUDI/lib/app $out/opt/Firmador-BCCR/lib/app + + # Preserves the original filename and avoids <hash>-LaunchGaudi.java + ln -s ${./LaunchGaudi.java} LaunchGaudi.java + + javac \ + -cp opt/Agente-GAUDI/lib/app/bccr-firma-fva-clienteMultiplataforma.jar \ + -d $out/opt/Firmador-BCCR/lib/app \ + LaunchGaudi.java + ''; + + installPhase = '' + runHook preInstall + + install -m755 -d $out/{share,opt/Firmador-BCCR/lib/runtime/lib} + install -m755 -D opt/Agente-GAUDI/bin/Agente-GAUDI $out/opt/Firmador-BCCR/bin/Agente-GAUDI + install -m755 -D opt/Agente-GAUDI/lib/libapplauncher.so $out/opt/Firmador-BCCR/lib/libapplauncher.so + + ln -s ../opt/Firmador-BCCR/lib/app $out/share/java + ln -s Firmador-BCCR $out/opt/Agente-GAUDI + ln -s ${jdk}/lib/openjdk/lib/libjli.so $out/opt/Firmador-BCCR/lib/runtime/lib/libjli.so + + makeWrapper ${jdk}/bin/java $out/bin/gaudi \ + --prefix PATH : ${fakeSudo}/bin \ + --add-flags "-cp $out/share/java:$out/share/java/bccr-firma-fva-clienteMultiplataforma.jar" \ + --add-flags "-Djavax.net.ssl.trustStore=$out/opt/Firmador-BCCR/lib/app/bccr.cacerts" \ + --add-flags "LaunchGaudi" + + runHook postInstall + ''; + }; +} |
