From d553d6efe7519fbe2bd918081c0204387d5437a7 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Fri, 5 Jul 2024 16:29:23 +0200 Subject: [PATCH] fix(stirling-pdf): Vendor patches and update version --- machines/compute01/stirling-pdf.nix | 30 ---------- .../compute01/stirling-pdf/01-spotless.patch | 35 ++++++++++++ .../compute01/stirling-pdf/02-propsfile.patch | 12 ++++ .../stirling-pdf/03-jar-timestamps.patch | 16 ++++++ .../stirling-pdf/04-local-maven-deps.patch | 25 ++++++++ .../stirling-pdf/05-java-output-test.patch | 22 +++++++ machines/compute01/stirling-pdf/default.nix | 57 +++++++++++++++++++ 7 files changed, 167 insertions(+), 30 deletions(-) delete mode 100644 machines/compute01/stirling-pdf.nix create mode 100644 machines/compute01/stirling-pdf/01-spotless.patch create mode 100644 machines/compute01/stirling-pdf/02-propsfile.patch create mode 100644 machines/compute01/stirling-pdf/03-jar-timestamps.patch create mode 100644 machines/compute01/stirling-pdf/04-local-maven-deps.patch create mode 100644 machines/compute01/stirling-pdf/05-java-output-test.patch create mode 100644 machines/compute01/stirling-pdf/default.nix diff --git a/machines/compute01/stirling-pdf.nix b/machines/compute01/stirling-pdf.nix deleted file mode 100644 index 7c83fe1..0000000 --- a/machines/compute01/stirling-pdf.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ nixpkgs, ... }: - -let - dgn-id = "57ac2e06a00384772bf63f055874ce2fefe4eb0a"; -in - -{ - services.stirling-pdf = { - enable = true; - - package = nixpkgs.unstable.stirling-pdf.overrideAttrs (old: { - patches = (old.patches or [ ]) ++ [ - (builtins.fetchurl "https://git.dgnum.eu/DGNum/Stirling-PDF/commit/${dgn-id}.patch") - ]; - }); - - domain = "pdf.dgnum.eu"; - port = 8084; - - nginx = { - enableACME = true; - forceSSL = true; - }; - - environment = { - UI_APP_NAME = "DGNum PDF"; - SYSTEM_DEFAULT_LOCALE = "fr-FR"; - }; - }; -} diff --git a/machines/compute01/stirling-pdf/01-spotless.patch b/machines/compute01/stirling-pdf/01-spotless.patch new file mode 100644 index 0000000..ada86c2 --- /dev/null +++ b/machines/compute01/stirling-pdf/01-spotless.patch @@ -0,0 +1,35 @@ +diff --git a/build.gradle b/build.gradle +index 78901d8e..3a14ceee 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -70,20 +70,6 @@ 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 + implementation 'ch.qos.logback:logback-classic:1.5.3' +@@ -171,9 +157,6 @@ dependencies { + annotationProcessor 'org.projectlombok:lombok:1.18.32' + } + +-tasks.withType(JavaCompile).configureEach { +- dependsOn 'spotlessApply' +-} + compileJava { + options.compilerArgs << '-parameters' + } diff --git a/machines/compute01/stirling-pdf/02-propsfile.patch b/machines/compute01/stirling-pdf/02-propsfile.patch new file mode 100644 index 0000000..0c01ccc --- /dev/null +++ b/machines/compute01/stirling-pdf/02-propsfile.patch @@ -0,0 +1,12 @@ +diff --git a/build.gradle b/build.gradle +index 78901d8e..2e7ff96b 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -166,6 +166,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/machines/compute01/stirling-pdf/03-jar-timestamps.patch b/machines/compute01/stirling-pdf/03-jar-timestamps.patch new file mode 100644 index 0000000..f4df198 --- /dev/null +++ b/machines/compute01/stirling-pdf/03-jar-timestamps.patch @@ -0,0 +1,16 @@ +diff --git a/build.gradle b/build.gradle +index 2e7ff96b..f3a4a15c 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -21,6 +21,11 @@ repositories { + mavenCentral() + } + ++tasks.withType(AbstractArchiveTask) { ++ preserveFileTimestamps = false ++ reproducibleFileOrder = true ++} ++ + licenseReport { + renderers = [new JsonReportRenderer()] + } diff --git a/machines/compute01/stirling-pdf/04-local-maven-deps.patch b/machines/compute01/stirling-pdf/04-local-maven-deps.patch new file mode 100644 index 0000000..cb97da1 --- /dev/null +++ b/machines/compute01/stirling-pdf/04-local-maven-deps.patch @@ -0,0 +1,25 @@ +diff --git a/build.gradle b/build.gradle +index f3a4a15c..61fbd74e 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -18,7 +18,7 @@ version = '0.26.1' + sourceCompatibility = '17' + + repositories { +- mavenCentral() ++ maven { url '@deps@' } + } + + tasks.withType(AbstractArchiveTask) { +diff --git a/settings.gradle b/settings.gradle +index f8139930..2c87f3cc 100644 +--- a/settings.gradle ++++ b/settings.gradle +@@ -1 +1,7 @@ ++pluginManagement { ++ repositories { ++ maven { url '@deps@' } ++ } ++} ++ + rootProject.name = 'Stirling-PDF' diff --git a/machines/compute01/stirling-pdf/05-java-output-test.patch b/machines/compute01/stirling-pdf/05-java-output-test.patch new file mode 100644 index 0000000..861cb39 --- /dev/null +++ b/machines/compute01/stirling-pdf/05-java-output-test.patch @@ -0,0 +1,22 @@ +diff --git a/src/test/java/stirling/software/SPDF/utils/ProcessExecutorTest.java b/src/test/java/stirling/software/SPDF/utils/ProcessExecutorTest.java +index cab78313..192922f3 100644 +--- a/src/test/java/stirling/software/SPDF/utils/ProcessExecutorTest.java ++++ b/src/test/java/stirling/software/SPDF/utils/ProcessExecutorTest.java +@@ -19,7 +19,7 @@ public class ProcessExecutorTest { + processExecutor = ProcessExecutor.getInstance(ProcessExecutor.Processes.LIBRE_OFFICE); + } + +- @Test ++ /* @Test + public void testRunCommandWithOutputHandling() throws IOException, InterruptedException { + // Mock the command to execute + List command = new ArrayList<>(); +@@ -32,7 +32,7 @@ public class ProcessExecutorTest { + // Check the exit code and output messages + assertEquals(0, result.getRc()); + assertNotNull(result.getMessages()); // Check if messages are not null +- } ++ } */ + + @Test + public void testRunCommandWithOutputHandling_Error() { diff --git a/machines/compute01/stirling-pdf/default.nix b/machines/compute01/stirling-pdf/default.nix new file mode 100644 index 0000000..f356d0b --- /dev/null +++ b/machines/compute01/stirling-pdf/default.nix @@ -0,0 +1,57 @@ +{ pkgs, nixpkgs, ... }: + +let + dgn-id = "5891e1bbda792e0546f8d785cdd4d3f570a01579"; +in + +{ + services.stirling-pdf = { + enable = true; + + package = nixpkgs.unstable.stirling-pdf.overrideAttrs (old: rec { + version = "0.26.1"; + + src = pkgs.fetchFromGitHub { + owner = "Stirling-Tools"; + repo = "Stirling-PDF"; + rev = "v${version}"; + hash = "sha256-msxP2n8Varc7/h9RVwYRBuD253JZu6/p7zQC1lmNmqc="; + }; + + deps = old.deps.overrideAttrs (_: { + patches = [ + ./01-spotless.patch + ./05-java-output-test.patch + ]; + + doCheck = false; + outputHash = "sha256-i2PJmsuJ8jqTUNwj4HoiWynaK4LlLrqjIZ67rSSYypc="; + }); + + patches = [ + ./01-spotless.patch + ./02-propsfile.patch + ./03-jar-timestamps.patch + (pkgs.substituteAll { + src = ./04-local-maven-deps.patch; + inherit deps; + }) + ./05-java-output-test.patch + (builtins.fetchurl "https://git.dgnum.eu/DGNum/Stirling-PDF/commit/${dgn-id}.patch") + ]; + }); + + domain = "pdf.dgnum.eu"; + port = 8084; + + nginx = { + enableACME = true; + forceSSL = true; + }; + + environment = { + UI_APP_NAME = "DGNum PDF"; + SYSTEM_DEFAULT_LOCALE = "fr-FR"; + }; + }; +}