diff options
author | Pol Dellaiera <pol.dellaiera@protonmail.com> | 2024-04-03 07:39:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 07:39:17 +0200 |
commit | 146761d532bf29b60e3b79fa71ab27b8c9fd7c86 (patch) | |
tree | c063053a455d19a6ab12570008f887b285ca9cb5 | |
parent | 08b9151ed40350725eb40b1fe96b0b86304a654b (diff) | |
parent | 86258a598932eed7efdbfdbd800b879e9321de23 (diff) |
Merge pull request #283305 from TomaSajt/stirling-pdf
stirling-pdf: init at 0.22.3
-rw-r--r-- | pkgs/by-name/st/stirling-pdf/disable-spotless.patch | 34 | ||||
-rw-r--r-- | pkgs/by-name/st/stirling-pdf/fix-jar-timestamp.patch | 16 | ||||
-rw-r--r-- | pkgs/by-name/st/stirling-pdf/package.nix | 118 | ||||
-rw-r--r-- | pkgs/by-name/st/stirling-pdf/remove-props-file-timestamp.patch | 12 | ||||
-rw-r--r-- | pkgs/by-name/st/stirling-pdf/use-fod-maven-repo.patch | 25 |
5 files changed, 205 insertions, 0 deletions
diff --git a/pkgs/by-name/st/stirling-pdf/disable-spotless.patch b/pkgs/by-name/st/stirling-pdf/disable-spotless.patch new file mode 100644 index 000000000000..8b58207b963f --- /dev/null +++ b/pkgs/by-name/st/stirling-pdf/disable-spotless.patch @@ -0,0 +1,34 @@ +diff --git a/build.gradle b/build.gradle +index c206e2f..b1fda33 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -69,19 +69,7 @@ launch4j { + messagesInstanceAlreadyExists="Stirling-PDF is already running." + } + +-spotless { +- java { +- target project.fileTree('src/main/java') + +- googleJavaFormat('1.19.1').aosp().reorderImports(false) +- +- importOrder('java', 'javax', 'org', 'com', 'net', 'io') +- toggleOffOn() +- trimTrailingWhitespace() +- indentWithSpaces() +- endWithNewline() +- } +-} + + dependencies { + //security updates +@@ -163,9 +151,6 @@ dependencies { + annotationProcessor 'org.projectlombok:lombok:1.18.28' + } + +-tasks.withType(JavaCompile) { +- dependsOn 'spotlessApply' +-} + compileJava { + options.compilerArgs << '-parameters' + } diff --git a/pkgs/by-name/st/stirling-pdf/fix-jar-timestamp.patch b/pkgs/by-name/st/stirling-pdf/fix-jar-timestamp.patch new file mode 100644 index 000000000000..dd94b8514f76 --- /dev/null +++ b/pkgs/by-name/st/stirling-pdf/fix-jar-timestamp.patch @@ -0,0 +1,16 @@ +diff --git a/build.gradle b/build.gradle +index 7025b2b..d063da3 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -20,6 +20,11 @@ repositories { + } + + ++tasks.withType(AbstractArchiveTask) { ++ preserveFileTimestamps = false ++ reproducibleFileOrder = true ++} ++ + + licenseReport { + renderers = [new JsonReportRenderer()] diff --git a/pkgs/by-name/st/stirling-pdf/package.nix b/pkgs/by-name/st/stirling-pdf/package.nix new file mode 100644 index 000000000000..66e9a50a4282 --- /dev/null +++ b/pkgs/by-name/st/stirling-pdf/package.nix @@ -0,0 +1,118 @@ +{ + lib, + stdenv, + fetchFromGitHub, + substituteAll, + gradle_7, + perl, + makeWrapper, + jre, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "stirling-pdf"; + version = "0.22.3"; + + src = fetchFromGitHub { + owner = "Stirling-Tools"; + repo = "Stirling-PDF"; + rev = "v${finalAttrs.version}"; + hash = "sha256-8zXTapFAXw4+KLLirxBeEBmqNw6ILFHtbsaBSP3Ehyg="; + }; + + patches = [ + # disable spotless because it tries to fetch files not in the FOD + # and also because it slows down the build process + ./disable-spotless.patch + # remove timestamp from the header of a generated .properties file + ./remove-props-file-timestamp.patch + # use gradle's built-in method of zeroing out timestamps, + # because stripJavaArchivesHook can't patch signed JAR files + ./fix-jar-timestamp.patch + # set the FOD as the only repository gradle can resolve from + (substituteAll { + src = ./use-fod-maven-repo.patch; + inherit (finalAttrs) deps; + }) + ]; + + # fake build to pre-download deps into fixed-output derivation + deps = stdenv.mkDerivation { + name = "${finalAttrs.pname}-${finalAttrs.version}-deps"; + inherit (finalAttrs) src; + + patches = [ ./disable-spotless.patch ]; + + nativeBuildInputs = [ + gradle_7 + perl + ]; + + buildPhase = '' + runHook preBuild + + export GRADLE_USER_HOME=$(mktemp -d) + gradle --no-daemon --console=plain build + + runHook postBuild + ''; + + # perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar) + installPhase = '' + runHook preInstall + + find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ + | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ + | sh + + # Mimic existence of okio-3.6.0.jar, originally known as okio-jvm-3.6.0 (and renamed). + # Gradle doesn't detect such renames and only fetches the latter. + # Whenever this package gets updated, please check if this hack is obsolete. + ln -s $out/com/squareup/okio/okio-jvm/3.6.0/okio-jvm-3.6.0.jar $out/com/squareup/okio/okio/3.6.0/okio-3.6.0.jar + + runHook postInstall + ''; + + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = "sha256-zUzKSa7zuIoXE77Hk/Xr5iMF4CEumV9horW2BTFRdtE="; + }; + + nativeBuildInputs = [ + gradle_7 + makeWrapper + ]; + + buildPhase = '' + runHook preBuild + + export GRADLE_USER_HOME=$(mktemp -d) + gradle --offline --no-daemon --console=plain build + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + install -Dm644 build/libs/Stirling-PDF-*.jar $out/share/stirling-pdf/Stirling-PDF.jar + makeWrapper ${jre}/bin/java $out/bin/Stirling-PDF \ + --add-flags "-jar $out/share/stirling-pdf/Stirling-PDF.jar" + + runHook postInstall + ''; + + meta = { + changelog = "https://github.com/Stirling-Tools/Stirling-PDF/releases/tag/${finalAttrs.src.rev}"; + description = "A locally hosted web application that allows you to perform various operations on PDF files"; + homepage = "https://github.com/Stirling-Tools/Stirling-PDF"; + license = lib.licenses.gpl3Only; + mainProgram = "Stirling-PDF"; + maintainers = with lib.maintainers; [ tomasajt ]; + platforms = jre.meta.platforms; + sourceProvenance = with lib.sourceTypes; [ + fromSource + binaryBytecode # deps + ]; + }; +}) diff --git a/pkgs/by-name/st/stirling-pdf/remove-props-file-timestamp.patch b/pkgs/by-name/st/stirling-pdf/remove-props-file-timestamp.patch new file mode 100644 index 000000000000..8602345ac1d7 --- /dev/null +++ b/pkgs/by-name/st/stirling-pdf/remove-props-file-timestamp.patch @@ -0,0 +1,12 @@ +diff --git a/build.gradle b/build.gradle +index e12cbd3..094a219 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -173,6 +173,7 @@ task writeVersion { + def props = new Properties() + props.setProperty('version', version) + props.store(propsFile.newWriter(), null) ++ propsFile.text = propsFile.readLines().tail().join('\n') + } + + swaggerhubUpload { diff --git a/pkgs/by-name/st/stirling-pdf/use-fod-maven-repo.patch b/pkgs/by-name/st/stirling-pdf/use-fod-maven-repo.patch new file mode 100644 index 000000000000..f26074a0598f --- /dev/null +++ b/pkgs/by-name/st/stirling-pdf/use-fod-maven-repo.patch @@ -0,0 +1,25 @@ +diff --git a/build.gradle b/build.gradle +index c206e2f..cdaddf7 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -16,7 +16,7 @@ version = '0.22.3' + sourceCompatibility = '17' + + repositories { +- mavenCentral() ++ maven { url '@deps@' } + } + + +diff --git a/settings.gradle b/settings.gradle +index f813993..2c87f3c 100644 +--- a/settings.gradle ++++ b/settings.gradle +@@ -1 +1,7 @@ ++pluginManagement { ++ repositories { ++ maven { url '@deps@' } ++ } ++} ++ + rootProject.name = 'Stirling-PDF' |