summary refs log tree commit diff
path: root/pkgs/development/web/protege-distribution
diff options
context:
space:
mode:
authorTomas Antonio Lopez <entropy.overseer@entropic.network>2021-06-25 01:10:37 +0900
committerTomas Antonio Lopez <entropy.overseer@entropic.network>2021-06-25 01:10:37 +0900
commitc6b756d7deb868c0cb01b1c599039772e03d5801 (patch)
treed1e6130898a76f39ed36ac1181bdaa6b0baab3b4 /pkgs/development/web/protege-distribution
parent14afd6e5f98a105ba9c5ce66186564d908c56ee1 (diff)
downloadnixpkgs-c6b756d7deb868c0cb01b1c599039772e03d5801.tar
nixpkgs-c6b756d7deb868c0cb01b1c599039772e03d5801.tar.gz
nixpkgs-c6b756d7deb868c0cb01b1c599039772e03d5801.tar.bz2
nixpkgs-c6b756d7deb868c0cb01b1c599039772e03d5801.tar.lz
nixpkgs-c6b756d7deb868c0cb01b1c599039772e03d5801.tar.xz
nixpkgs-c6b756d7deb868c0cb01b1c599039772e03d5801.tar.zst
nixpkgs-c6b756d7deb868c0cb01b1c599039772e03d5801.zip
protege-distribution: rewrite patching mechanism
Part of the launcher script and configuration were patched via sed
commands; make the process clearer by using unified-style patches.
Diffstat (limited to 'pkgs/development/web/protege-distribution')
-rw-r--r--pkgs/development/web/protege-distribution/default.nix24
-rw-r--r--pkgs/development/web/protege-distribution/disable-console-log.patch28
-rw-r--r--pkgs/development/web/protege-distribution/static-path.patch16
3 files changed, 55 insertions, 13 deletions
diff --git a/pkgs/development/web/protege-distribution/default.nix b/pkgs/development/web/protege-distribution/default.nix
index 49d28cb17ee..d614c815588 100644
--- a/pkgs/development/web/protege-distribution/default.nix
+++ b/pkgs/development/web/protege-distribution/default.nix
@@ -11,21 +11,19 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ unzip copyDesktopItems ];
 
-  postPatch = ''
-    # Delete all those commands meant to change directory to the source directory
-    sed -i -e '3,9d' run.sh
-
-    # Change directory to where the application is stored to avoid heavy patching
-    # of searchpaths
-    sed -i -e "2a\
-    cd $out/protege" run.sh
+  patches = [
+    # Replace logic for searching the install directory with a static cd into $out
+    ./static-path.patch
+    # Disable console logging, maintaining only file-based logging
+    ./disable-console-log.patch
+  ];
 
-    # Set the correct Java executable (Protege is a JRE 8 application)
+  postPatch = ''
+    # Resolve @out@ (introduced by "static-path.patch") to $out, and set the
+    # correct Java executable (Protege is a JRE 8 application)
     substituteInPlace run.sh \
-      --replace "java -X" "exec ${jre8.outPath}/bin/java -X" \
-
-    # Silence console logs, since these are not shown in graphical environments
-    sed -i -e '4,8d;21d' conf/logback.xml
+      --subst-var-by out $out \
+      --replace "java -X" "exec ${jre8.outPath}/bin/java -X"
   '';
 
   dontConfigure = true;
diff --git a/pkgs/development/web/protege-distribution/disable-console-log.patch b/pkgs/development/web/protege-distribution/disable-console-log.patch
new file mode 100644
index 00000000000..edd6277ffa3
--- /dev/null
+++ b/pkgs/development/web/protege-distribution/disable-console-log.patch
@@ -0,0 +1,28 @@
+--- a/conf/logback.xml	2021-06-25 00:49:10.446416341 +0900
++++ b/conf/logback.xml	2021-06-25 00:50:32.889120465 +0900
+@@ -1,13 +1,6 @@
+ <?xml version="1.0" encoding="UTF-8"?>
+ <configuration scan="true" scanPeriod="10 seconds">
+ 
+-    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
+-        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+-            <Pattern>%highlight(%msg) %n</Pattern>
+-        </encoder>
+-    </appender>
+-
+-
+     <appender name="files" class="ch.qos.logback.core.FileAppender">
+         <file>${user.home}/.Protege/logs/protege.log</file>
+         <append>true</append>
+@@ -18,9 +11,8 @@
+ 
+ 
+     <root level="info">
+-        <appender-ref ref="stdout" />
+         <appender-ref ref="files"/>
+     </root>
+ 
+ 
+-</configuration>
+\ No newline at end of file
++</configuration>
diff --git a/pkgs/development/web/protege-distribution/static-path.patch b/pkgs/development/web/protege-distribution/static-path.patch
new file mode 100644
index 00000000000..66762f70ca9
--- /dev/null
+++ b/pkgs/development/web/protege-distribution/static-path.patch
@@ -0,0 +1,16 @@
+--- a/run.sh	2021-06-24 22:30:20.764897745 +0900
++++ b/run.sh	2021-06-24 22:29:47.211210142 +0900
+@@ -1,12 +1,6 @@
+ #!/usr/bin/env bash
+ 
+-SOURCE="${BASH_SOURCE[0]}"
+-while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
+-  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+-  SOURCE="$(readlink "$SOURCE")"
+-  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+-done
+-cd "$( cd -P "$( dirname "$SOURCE" )" && pwd )"
++cd @out@/protege
+ 
+ java -Xmx500M -Xms200M \
+      -Xss16M \