Skip to content

Instantly share code, notes, and snippets.

@aszlig
Last active July 29, 2018 11:16
Show Gist options
  • Save aszlig/929f47b608913888a740a0604174d93f to your computer and use it in GitHub Desktop.
Save aszlig/929f47b608913888a740a0604174d93f to your computer and use it in GitHub Desktop.
diff --git a/pkgs/development/compilers/javacard-devkit/default.nix b/pkgs/development/compilers/javacard-devkit/default.nix
index 19cfd637941..5447165c20c 100644
--- a/pkgs/development/compilers/javacard-devkit/default.nix
+++ b/pkgs/development/compilers/javacard-devkit/default.nix
@@ -1,83 +1,64 @@
-{ stdenv, requireFile, unzip, makeWrapper, oraclejdk8 }:
-
-let
- pkg = "javacard-devkit";
- version = "2.2.2";
-
- underscoreVersion = builtins.replaceStrings ["."] ["_"] version;
-
- downloadUrl = "http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javame-419430.html#java_card_kit-2.2.2-oth-JPR";
-in
+{ stdenv, requireFile, unzip, makeWrapper, oraclejdk8, autoPatchelfHook
+, pcsclite
+}:
stdenv.mkDerivation rec {
- name = "${pkg}-${version}";
+ name = "${pname}-${version}";
+ pname = "javacard-devkit";
+ version = "2.2.2";
+ uscoreVersion = builtins.replaceStrings ["."] ["_"] version;
src = requireFile {
- name = "java_card_kit-${underscoreVersion}-linux.zip";
- url = downloadUrl;
+ name = "java_card_kit-${uscoreVersion}-linux.zip";
+ url = "http://www.oracle.com/technetwork/java/javasebusiness/downloads/"
+ + "java-archive-downloads-javame-419430.html#java_card_kit-2.2.2-oth-JPR";
sha256 = "1rzkw8izqq73ifvyp937wnjjc40a40drc4zsm0l1s6jyv3d7agb2";
};
- nativeBuildInputs = [ unzip makeWrapper ];
-
- unpackPhase = "true";
-
- buildPhase = ''
- unzip $src
+ nativeBuildInputs = [ unzip oraclejdk8 makeWrapper autoPatchelfHook ];
+ buildInputs = [ pcsclite ];
- cd "java_card_kit-${underscoreVersion}"
- unzip "java_card_kit-${underscoreVersion}-rr-bin-linux-do.zip"
+ zipPrefix = "java_card_kit-${uscoreVersion}";
- chmod +x bin/{apdutool,capdump,capgen,converter,cref,exp2text,jcwde,scriptgen,verifycap,verifyexp,verifyrev}
- chmod u+w bin/cref
- patchelf --set-interpreter "$(cat "$NIX_CC/nix-support/dynamic-linker")" bin/cref
-
- mkdir "$out"
- cp -R bin "$out"
- cp -R lib "$out"
- cp -R api_export_files "$out"
+ sourceRoot = ".";
+ unpackCmd = ''
+ unzip -p "$curSrc" "$zipPrefix/$zipPrefix-rr-bin-linux-do.zip" | jar x
+ '';
- for p in "$out/bin/"{apdutool,capdump,capgen,converter,cref,exp2text,jcwde,scriptgen,verifycap,verifyexp,verifyrev}; do
- wrapProgram "$p" --set JAVA_HOME "${oraclejdk8}" --prefix CLASSPATH : "$out/api_export_files"
+ installPhase = ''
+ mkdir -p "$out/share/$pname" "$out/lib"
+ cp -rt "$out/share/$pname" api_export_files
+ cp -r lib "$out/lib/java"
+
+ for i in bin/*; do
+ case "$i" in
+ *.so) install -vD "$i" "$out/libexec/$pname/$(basename "$i")";;
+ *) target="$out/bin/$(basename "$i")"
+ install -vD "$i" "$target"
+ wrapProgram "$target" \
+ --set JAVA_HOME "$JAVA_HOME" \
+ --prefix CLASSPATH : "$out/libexec/$pname/api_export_files"
+ ;;
+ esac
done
- makeWrapper "${oraclejdk8}/bin/javac" $out/bin/javac --prefix CLASSPATH : "$out/lib/api.jar"
- # TODO (question for the reviewer): The resulting javac can then be used with:
- # javac -source 1.2 -target 1.2 myPackage/myApplet.java
- # Should I include the -source/-target arguments in this wrapper?
- # I'm thinking this may break unaware users just adding javacard-devkit to their env
-
-
- # TODO (question for the reviewer): I'm not sure this belongs here, but given
- # the very few information on the net assume a hand-downloaded sdk…? Maybe in the
- # manual instead… but noone I know thinks of reading the manual upon installing
- # a package? Anyway, just pick a place (including /dev/null) and I'll try to
- # move these instructions to there :)
- echo
- echo
- echo
- echo
- echo
- echo "=========================="
- echo "| INSTRUCTIONS FOR USAGE |"
- echo "=========================="
- echo
- echo "First, compile your ‘.java’:"
- echo " javac -source 1.5 -target 1.5 [MyJavaFile].java"
- echo "Then, convert the ‘.class’ file into a ‘.cap’:"
- echo " converter -applet [AppletAID] [MyApplet] [myPackage] [PackageAID] [Version]"
- echo "For more details, please refer to the documentation by Oracle"
- echo
- echo
- echo
- echo
- echo
+ makeWrapper "$JAVA_HOME/bin/javac" "$out/bin/javac" \
+ --prefix CLASSPATH : "$out/lib/java/api.jar"
'';
- installPhase = "true";
-
meta = {
description = "Official development kit by Oracle for programming for the JavaCard platform";
+ longDescription = ''
+ ... some generic long description ...
+
+ Instructions for usage:
+
+ First, compile your '.java':
+ javac -source 1.5 -target 1.5 [MyJavaFile].java
+ Then, convert the '.class' file into a '.cap':
+ converter -applet [AppletAID] [MyApplet] [myPackage] [PackageAID] [Version]
+ For more details, please refer to the documentation by Oracle
+ '';
homepage = http://www.oracle.com/technetwork/java/embedded/javacard/overview/index.html;
license = stdenv.lib.licenses.unfree;
maintainers = [ stdenv.lib.maintainers.ekleog ];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment