Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsignpdf.sh is not posix compliant, fails in automated CI with busybox (patch included) #168

Open
denydias opened this issue Sep 7, 2023 · 0 comments

Comments

@denydias
Copy link

denydias commented Sep 7, 2023

When running JSignPdf in automated CI environments with busybox shell, it fails with the following messages:

$> /opt/jsignpdf-2.2.2/jsignpdf.sh --version
readlink: unrecognized option: e
BusyBox v1.35.0 (2022-11-19 10:13:10 UTC) multi-call binary.

Usage: readlink [-fnv] FILE

Display the value of a symlink

	-f	Canonicalize by following all symlinks
	-n	Don't add newline
	-v	Verbose
Error: Could not find or load main class net.sf.jsignpdf.JavaVersion
Caused by: java.lang.ClassNotFoundException: net.sf.jsignpdf.JavaVersion
/opt/jsignpdf-2.2.2/jsignpdf.sh: line 14: [: : integer expression expected
Error: Unable to access jarfile /builds/JSignPdf.jar

This happens because jsignpdf.sh is not posix compliant and busybox has a hard time handling it.

To make it posix compliant the patch bellow should be applied:

--- a/jsignpdf.sh 2023-09-07 15:35:43.992441573 -0300
+++ b/jsignpdf.sh 2023-09-07 16:03:38.602388875 -0300
@@ -1,9 +1,11 @@
-#!/bin/bash
+#!/bin/sh

-DIRNAME=$(dirname "$(readlink -e "$0")")
+DIRNAME=$(dirname "$(readlink -f "$0")")
 DIR=$(cd "$DIRNAME" || exit 112; pwd)

-[ "$OSTYPE" = "cygwin" ] && DIR="$( cygpath -m "$DIR" )"
+if uname -s | grep -i cygwin; then
+  DIR="$( cygpath -m "$DIR" )"
+fi

 JAVA=java
 if [ -n "$JAVA_HOME" ]; then

Then:

$> /opt/jsignpdf-2.2.2/jsignpdf.sh --version
JSignPdf version 2.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant