trivionomicon: athena-bccr: add support for non-Athena driver vendors
This commit is contained in:
parent
62eee95d99
commit
57f673b495
6 changed files with 152 additions and 144 deletions
|
|
@ -6,17 +6,18 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
athena = pkgs.${doctrine.prefix}.athena-bccr.${cfg.release};
|
athena = pkgs.${doctrine.prefix}.athena-bccr.${cfg.release};
|
||||||
|
inherit (athena.card-driver) vendor;
|
||||||
in {
|
in {
|
||||||
environment = {
|
environment = {
|
||||||
etc = {
|
etc = lib.optionalAttrs (vendor == "athena") {
|
||||||
"Athena".source = "${athena.ase-pkcs11}/etc/Athena";
|
"Athena".source = "${athena.card-driver}/etc/Athena";
|
||||||
|
|
||||||
"pkcs11/modules/asep11".text = ''
|
"pkcs11/modules/asep11".text = ''
|
||||||
module: ${athena.libasep11}
|
module: ${athena.pkcs11-module}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
systemPackages = [athena.ase-pkcs11];
|
systemPackages = [athena.card-driver];
|
||||||
};
|
};
|
||||||
|
|
||||||
security = {
|
security = {
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,15 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
pkgsForRelease = release: let
|
pkgsForRelease = release: let
|
||||||
ase-pkcs11 = unwrapped.ase-idprotect.lib;
|
inherit (unwrapped) card-driver bccr-cacerts;
|
||||||
libasep11 = "${ase-pkcs11}/lib/x64-athena/libASEP11.so";
|
|
||||||
unwrapped = overrideUnwrapped {inherit release;} {};
|
unwrapped = overrideUnwrapped {inherit release;} {};
|
||||||
|
pkcs11-module = "${card-driver.lib}/${card-driver.pkcs11-path}";
|
||||||
in {
|
in {
|
||||||
inherit ase-pkcs11 libasep11;
|
inherit card-driver bccr-cacerts pkcs11-module;
|
||||||
inherit (unwrapped) ase-idprotect bccr-cacerts;
|
|
||||||
|
|
||||||
gaudi = callPackage ./gaudi-env.nix {inherit unwrapped;};
|
gaudi = callPackage ./gaudi-env.nix {inherit unwrapped;};
|
||||||
firmador = callPackage ./firmador.nix {inherit libasep11;};
|
firmador = callPackage ./firmador.nix {inherit pkcs11-module;};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
lib.mapAttrs (_: pkgsForRelease) (releases // {latest = releases.${latest};})
|
lib.mapAttrs (_: pkgsForRelease) (releases // {latest = releases.${latest};})
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
maven,
|
maven,
|
||||||
openjdk,
|
openjdk,
|
||||||
wrapGAppsHook3,
|
wrapGAppsHook3,
|
||||||
libasep11 ? null,
|
pkcs11-module ? null,
|
||||||
}: let
|
}: let
|
||||||
jdk = openjdk.override {
|
jdk = openjdk.override {
|
||||||
enableJavaFX = true;
|
enableJavaFX = true;
|
||||||
|
|
@ -34,8 +34,8 @@ in
|
||||||
wrapGAppsHook3
|
wrapGAppsHook3
|
||||||
];
|
];
|
||||||
|
|
||||||
postPatch = lib.optionalString (libasep11 != null) ''
|
postPatch = lib.optionalString (pkcs11-module != null) ''
|
||||||
sed -i 's@/usr/lib/x64-athena/libASEP11.so@${libasep11}@g' src/main/java/cr/libre/firmador/signers/CRSigner.java
|
sed -i 's@/usr/lib/x64-athena/libASEP11.so@${pkcs11-module}@g' src/main/java/cr/libre/firmador/signers/CRSigner.java
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ in
|
||||||
name = "gaudi";
|
name = "gaudi";
|
||||||
|
|
||||||
targetPkgs = pkgs: [
|
targetPkgs = pkgs: [
|
||||||
unwrappedWithGaudi.ase-idprotect.lib
|
unwrappedWithGaudi.card-driver.lib
|
||||||
unwrappedWithGaudi.gaudi
|
unwrappedWithGaudi.gaudi
|
||||||
|
|
||||||
(writeShellScriptBin "launch-gaudi" ''
|
(writeShellScriptBin "launch-gaudi" ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum sfd_ClientesLinux_DEB64_Rev26.zip | cut -d' ' -f1)
|
# nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum sfd_ClientesLinux_DEB64_Rev26.zip | cut -d' ' -f1)
|
||||||
hash = "sha256-ZPWP9TqJQ5coJAPzUSiaXKVItBWlqFM4smCjOf+gqQM=";
|
hash = "sha256-ZPWP9TqJQ5coJAPzUSiaXKVItBWlqFM4smCjOf+gqQM=";
|
||||||
basename = "sfd_ClientesLinux_DEB64_Rev26";
|
basename = "sfd_ClientesLinux_DEB64_Rev26";
|
||||||
|
vendor = "athena";
|
||||||
|
|
||||||
srcPaths = {
|
srcPaths = {
|
||||||
gaudi = "Firma Digital/Agente GAUDI/agente-gaudi_20.0_amd64.deb";
|
gaudi = "Firma Digital/Agente GAUDI/agente-gaudi_20.0_amd64.deb";
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
gaudiHash ? null,
|
gaudiHash ? null,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (release) srcPaths;
|
inherit (release) srcPaths vendor;
|
||||||
|
|
||||||
src = requireFile {
|
src = requireFile {
|
||||||
url = "https://soportefirmadigital.com";
|
url = "https://soportefirmadigital.com";
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
// lib.removeAttrs args ["stdenv" "dpkg" "unzip" "srcPath" "nativeBuildInputs"]);
|
// lib.removeAttrs args ["stdenv" "dpkg" "unzip" "srcPath" "nativeBuildInputs"]);
|
||||||
in {
|
|
||||||
ase-idprotect = {
|
ase-idprotect = {
|
||||||
autoPatchelfHook,
|
autoPatchelfHook,
|
||||||
dpkg,
|
dpkg,
|
||||||
|
|
@ -89,138 +89,144 @@ in {
|
||||||
preFixup = ''
|
preFixup = ''
|
||||||
patchelf --set-rpath $lib/lib/x64-athena $out/bin/*
|
patchelf --set-rpath $lib/lib/x64-athena $out/bin/*
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
passthru.pkcs11-path = "lib/x64-athena/libASEP11.so";
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
gaudi = {
|
||||||
|
autoPatchelfHook,
|
||||||
|
dpkg,
|
||||||
|
makeWrapper,
|
||||||
|
openjdk,
|
||||||
|
pkgs,
|
||||||
|
stdenv,
|
||||||
|
unzip,
|
||||||
|
writeShellScriptBin,
|
||||||
|
update-gaudi,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
jdk = openjdk.override {
|
||||||
|
enableJavaFX = true;
|
||||||
|
openjfx_jdk = pkgs."openjfx${lib.head (lib.splitString "." openjdk.version)}".override {withWebKit = true;};
|
||||||
|
};
|
||||||
|
|
||||||
gaudi = {
|
fakeSudo = writeShellScriptBin "sudo" "";
|
||||||
autoPatchelfHook,
|
gaudiUpdate = gaudiUpdateSrc {inherit update-gaudi;};
|
||||||
dpkg,
|
in
|
||||||
makeWrapper,
|
moduleFromDeb "gaudi" {
|
||||||
openjdk,
|
inherit dpkg stdenv unzip;
|
||||||
pkgs,
|
srcPath = srcPaths.gaudi;
|
||||||
stdenv,
|
|
||||||
unzip,
|
|
||||||
writeShellScriptBin,
|
|
||||||
update-gaudi,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
jdk = openjdk.override {
|
|
||||||
enableJavaFX = true;
|
|
||||||
openjfx_jdk = pkgs."openjfx${lib.head (lib.splitString "." openjdk.version)}".override {withWebKit = true;};
|
|
||||||
};
|
|
||||||
|
|
||||||
fakeSudo = writeShellScriptBin "sudo" "";
|
nativeBuildInputs = [
|
||||||
gaudiUpdate = gaudiUpdateSrc {inherit update-gaudi;};
|
autoPatchelfHook
|
||||||
in
|
jdk
|
||||||
moduleFromDeb "gaudi" {
|
makeWrapper
|
||||||
inherit dpkg stdenv unzip;
|
];
|
||||||
srcPath = srcPaths.gaudi;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
preBuild = lib.optionalString (gaudiHash != null) ''
|
||||||
autoPatchelfHook
|
unzip -o ${gaudiUpdate} -d opt/Agente-GAUDI/lib/app
|
||||||
jdk
|
'';
|
||||||
makeWrapper
|
|
||||||
];
|
|
||||||
|
|
||||||
preBuild = lib.optionalString (gaudiHash != null) ''
|
buildPhase = ''
|
||||||
unzip -o ${gaudiUpdate} -d opt/Agente-GAUDI/lib/app
|
runHook preBuild
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
bccr-cacerts = {
|
||||||
|
openssl,
|
||||||
|
stdenv,
|
||||||
|
unzip,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "bccr-cacerts";
|
||||||
|
version = release.name;
|
||||||
|
|
||||||
|
inherit src;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
openssl
|
||||||
|
unzip
|
||||||
|
];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cp -r Firma\ Digital/Certificados $out
|
||||||
|
openssl x509 -in $out/CA\ RAIZ\ NACIONAL\ -\ COSTA\ RICA\ v2.crt -out $out/root-ca.pem -text
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
update-gaudi = {
|
||||||
|
wget,
|
||||||
|
writeShellScript,
|
||||||
|
zip,
|
||||||
|
bccr-cacerts,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
writeShellScript "update-gaudi" ''
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
temp_dir="$(mktemp -d)"
|
||||||
|
trap 'cd / && rm -rf -- "$temp_dir"' EXIT
|
||||||
|
cd "$temp_dir"
|
||||||
|
|
||||||
|
PATH="${lib.makeBinPath [wget zip]}:$PATH"
|
||||||
|
ca_cert="${bccr-cacerts}/root-ca.pem"
|
||||||
|
base_url="https://www.firmadigital.go.cr/Bccr.Firma.Fva.Actualizador.ClienteFirmadorJava//recursosLiberica17/actualizador"
|
||||||
|
|
||||||
|
wget --ca-certificate="$ca_cert" "$base_url/bccr.cacerts"
|
||||||
|
wget --ca-certificate="$ca_cert" "$base_url/config.properties"
|
||||||
|
wget --ca-certificate="$ca_cert" "$base_url/bccr-firma-fva-clienteMultiplataforma.jar"
|
||||||
|
wget --ca-certificate="$ca_cert" "$base_url/ServicioActualizadorClienteBCCR.jar"
|
||||||
|
|
||||||
|
# https://gist.github.com/stokito/c588b8d6a6a0aee211393d68eea678f2
|
||||||
|
TZ=UTC find . -exec touch --no-dereference -a -m -t 198002010000.00 {} +
|
||||||
|
zip_path="$PWD/gaudi-update-${release.name}.zip"
|
||||||
|
TZ=UTC zip -q --move --recurse-paths --symlinks -X "$zip_path" .
|
||||||
|
TZ=UTC touch -a -m -t 198002010000.00 "$zip_path"
|
||||||
|
|
||||||
|
set -x
|
||||||
|
nix-store --add-fixed sha256 "$zip_path"
|
||||||
|
set +x
|
||||||
|
|
||||||
|
echo -e "\ngaudiHash: $(nix-hash --to-sri --type sha256 $(sha256sum "$zip_path" | cut -d' ' -f1))"
|
||||||
'';
|
'';
|
||||||
|
}
|
||||||
buildPhase = ''
|
// lib.optionalAttrs (vendor == "athena") {
|
||||||
runHook preBuild
|
card-driver = ase-idprotect;
|
||||||
|
}
|
||||||
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
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
bccr-cacerts = {
|
|
||||||
openssl,
|
|
||||||
stdenv,
|
|
||||||
unzip,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
pname = "bccr-cacerts";
|
|
||||||
version = release.name;
|
|
||||||
|
|
||||||
inherit src;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
openssl
|
|
||||||
unzip
|
|
||||||
];
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
cp -r Firma\ Digital/Certificados $out
|
|
||||||
openssl x509 -in $out/CA\ RAIZ\ NACIONAL\ -\ COSTA\ RICA\ v2.crt -out $out/root-ca.pem -text
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
update-gaudi = {
|
|
||||||
wget,
|
|
||||||
writeShellScript,
|
|
||||||
zip,
|
|
||||||
bccr-cacerts,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
writeShellScript "update-gaudi" ''
|
|
||||||
set -o errexit
|
|
||||||
set -o pipefail
|
|
||||||
set -o nounset
|
|
||||||
|
|
||||||
temp_dir="$(mktemp -d)"
|
|
||||||
trap 'cd / && rm -rf -- "$temp_dir"' EXIT
|
|
||||||
cd "$temp_dir"
|
|
||||||
|
|
||||||
PATH="${lib.makeBinPath [wget zip]}:$PATH"
|
|
||||||
ca_cert="${bccr-cacerts}/root-ca.pem"
|
|
||||||
base_url="https://www.firmadigital.go.cr/Bccr.Firma.Fva.Actualizador.ClienteFirmadorJava//recursosLiberica17/actualizador"
|
|
||||||
|
|
||||||
wget --ca-certificate="$ca_cert" "$base_url/bccr.cacerts"
|
|
||||||
wget --ca-certificate="$ca_cert" "$base_url/config.properties"
|
|
||||||
wget --ca-certificate="$ca_cert" "$base_url/bccr-firma-fva-clienteMultiplataforma.jar"
|
|
||||||
wget --ca-certificate="$ca_cert" "$base_url/ServicioActualizadorClienteBCCR.jar"
|
|
||||||
|
|
||||||
# https://gist.github.com/stokito/c588b8d6a6a0aee211393d68eea678f2
|
|
||||||
TZ=UTC find . -exec touch --no-dereference -a -m -t 198002010000.00 {} +
|
|
||||||
zip_path="$PWD/gaudi-update-${release.name}.zip"
|
|
||||||
TZ=UTC zip -q --move --recurse-paths --symlinks -X "$zip_path" .
|
|
||||||
TZ=UTC touch -a -m -t 198002010000.00 "$zip_path"
|
|
||||||
|
|
||||||
set -x
|
|
||||||
nix-store --add-fixed sha256 "$zip_path"
|
|
||||||
set +x
|
|
||||||
|
|
||||||
echo -e "\ngaudiHash: $(nix-hash --to-sri --type sha256 $(sha256sum "$zip_path" | cut -d' ' -f1))"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue