Skip to content

Commit

Permalink
pdf-parser: 0.7.4 -> 0.7.9 (#342003)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbsds authored Sep 18, 2024
2 parents f2826b1 + f23cdfe commit d4e6815
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions pkgs/tools/misc/pdf-parser/default.nix
Original file line number Diff line number Diff line change
@@ -1,35 +1,64 @@
{ lib, python3Packages, fetchzip }:
{
lib,
python3Packages,
fetchzip,
writeScript,
}:

python3Packages.buildPythonApplication {
python3Packages.buildPythonApplication rec {
pname = "pdf-parser";
version = "0.7.4";
version = "0.7.9";
pyproject = false;

src = fetchzip {
url = "https://didierstevens.com/files/software/pdf-parser_V0_7_4.zip";
sha256 = "1j39yww2yl4cav8xgd4zfl5jchbbkvffnrynkamkzvz9dd5np2mh";
url = "https://didierstevens.com/files/software/pdf-parser_V${
lib.replaceStrings [ "." ] [ "_" ] version
}.zip";
hash = "sha256-1mFThtTe1LKkM/MML44RgskGv3FZborNVBsTqSKanks=";
};

format = "other";
postPatch = ''
# quote regular expressions correctly
substituteInPlace pdf-parser.py \
--replace-fail \
"re.sub('" \
"re.sub(r'" \
--replace-fail \
"re.match('" \
"re.match(r'"
'';

installPhase = ''
install -Dm555 pdf-parser.py $out/bin/pdf-parser.py
'';

preFixup = ''
substituteInPlace $out/bin/pdf-parser.py \
--replace '/usr/bin/python' '${python3Packages.python}/bin/python'
--replace-fail '/usr/bin/python' '${python3Packages.python}/bin/python'
'';

passthru.updateScript = writeScript "update-pdf-parser" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts curl pcre2
set -eu -o pipefail
version="$(curl -s https://blog.didierstevens.com/programs/pdf-tools/ |
pcre2grep -O '$1.$2.$3' '\bpdf-parser_V(\d+)_(\d+)_(\d+)\.zip\b.*')"
update-source-version "$UPDATE_NIX_ATTR_PATH" "$version"
'';

meta = with lib; {
meta = {
description = "Parse a PDF document";
longDescription = ''
This tool will parse a PDF document to identify the fundamental elements used in the analyzed file.
It will not render a PDF document.
'';
homepage = "https://blog.didierstevens.com/programs/pdf-tools/";
license = licenses.publicDomain;
maintainers = [ maintainers.lightdiscord ];
platforms = platforms.all;
license = lib.licenses.publicDomain;
maintainers = [ lib.maintainers.lightdiscord ];
platforms = lib.platforms.all;
mainProgram = "pdf-parser.py";
};
}

0 comments on commit d4e6815

Please sign in to comment.