Simple SPK extraction tool for Linux users

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

jinkstjb
Posts: 7
Joined: Sun, 22. Jun 08, 22:43
x3ap

Simple SPK extraction tool for Linux users

Post by jinkstjb »

Until now I completely failed to get Cycrow's spktools working under Linux, so I did the only sensible thing and wrote my own parser for .spk files. :D

The tool is written in Clojure and thus runs on every Java capable system.
This is as much a Clojure learning exercise as it is an attempt at actually getting something useful. Expect this program to be very rough around the edges.
It supports most script or mod plugins by now but has no support for ships, cockpis or maps yet.
(That doesn't mean it's not gonna blow up on you from time to time. Error checks are boring so I skipped them for the most part. :twisted: :P )

Usage is quite simple:

Code: Select all

% java -jar spktool-0.4.2.jar -h /path/to/spk1.spk /path/to/more/stuff/*.spk
Usage:

 Switches                 Default  Desc                             
 --------                 -------  ----                             
 -h, --no-help, --help    false    Show help                        
 -d, --no-dump, --dump    false    Dump SPK headers                 
 -i, --no-info, --info    false    Show basic SPK info              
 -x, --no-xattr, --xattr  true     Use extended attributes (Java 7) 
Most options (except -x/--no-xattr) are mutually exclusive. No options means extract the file.

Code: Select all

% java -jar spktool-0.4.2.jar Shipkillednotifications-V1.0.3-16.11.2008.spk

Processing :extract on Shipkillednotifications-V1.0.3-16.11.2008.spk...
------------------------------------------------------------------------
Name: Ship killed notifications  --  Author: ThisIsHarsh  --  Version: 1.0.3
Description: Adds some extra audio and visual notifications for when a player-owned ship is destroyed.
Web: http://thisisharsh.maeyanie.com  --  Forum: N/A
Dependencies: N/A
------------------------------------------------------------------------
Saving Ship_killed_notifications/t/7105.xml
Saving Ship_killed_notifications/scripts/plugin.killnotify.cfg.mnu.xml
Saving Ship_killed_notifications/scripts/plugin.killnotify.notify.xml
Saving Ship_killed_notifications/scripts/setup.plugin.killnotify.xml
Saving Ship_killed_notifications/scripts/plugin.killnotify.sig.xml
It creates a directory for every plugin it extracts (based on the name provided by the SPK), you have to copy the relevant files from there to where you need them.
If your system has xattr support, it tags every file with user.SPKName and user.SPKVersion to help you track where it came from. (You need to use "mv" or "cp -a" to carry those attributes over.)

[ external image ] here.

If^H^H When you encounter any bugs or errors, please post here, preferably with the stacktrace in [ code ] tags and with a link to the offending SPK so that I can investigate.
Godlike_PL
Posts: 4
Joined: Mon, 26. Dec 11, 18:14
x3ap

Post by Godlike_PL »

Hello,

Im using Linux Mint 15 and I've tried to use old spktools to extract one plugin but it didn't worked. I was already making wine X plugin manager installation when i found your script and IT WORKED!

Thank you very much for this script. I really don't understand why cycrow couldn't use some portable language like C#

Regards
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22433
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

c# isn't a portable language

c++ however is, and thats what i used
pbasford
Posts: 12
Joined: Fri, 29. Apr 05, 19:20
x3tc

Post by pbasford »

hi I’m a bit of a noob with Linux, so please excuse my questions, but how do you install your program in ubuntu.

thanks
phil
Legionos
Posts: 414
Joined: Wed, 13. Jul 11, 17:38
x3tc

Post by Legionos »

Exception in thread "main" java.lang.ExceptionInInitializerError
at spktool.spkfile__init.load(Unknown Source)
at spktool.spkfile__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at clojure.lang.RT.loadClassForName(RT.java:2098)
at clojure.lang.RT.load(RT.java:430)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:621)
at clojure.core$use.doInvoke(core.clj:5507)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at spktool.core$loading__4910__auto__.invoke(core.clj:1)
at spktool.core__init.load(Unknown Source)
at spktool.core__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at clojure.lang.RT.loadClassForName(RT.java:2098)
at clojure.lang.RT.load(RT.java:430)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:415)
at spktool.core.<clinit>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: java.nio.file.LinkOption
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at spktool.spkfile$save.<clinit>(spkfile.clj:108)
... 33 more
Could not find the main class: spktool.core. Program will exit.


Attempting to extract the Logain Industries Freight Distribution Network Lite (FDNL) v1 spk: http://forum.egosoft.com/viewtopic.php?t=281671
lpapp
Posts: 1
Joined: Mon, 23. Jun 14, 22:06

Post by lpapp »

Processing :extract on ./all.spk...
Exception in thread "main" java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:277)
at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:798)
at gloss.data.string.codecs$string_codec$reify__1195.read_bytes(codecs.clj:57)
at gloss.data.bytes.delimited$delimited_codec$fn__604$fn__606.invoke(delimited.clj:188)
at gloss.data.bytes.delimited$delimited_codec$fn__604.invoke(delimited.clj:187)
at gloss.core.protocols$compose_callback$reify__533.read_bytes(protocols.clj:59)
at gloss.data.bytes.delimited$delimited_codec$reify__609.read_bytes(delimited.clj:195)
at gloss.core.protocols$compose_callback$reify__533.read_bytes(protocols.clj:57)
at gloss.core.structure$compile_frame$reify__1252.read_bytes(structure.clj:120)
at gloss.core.structure$sequence_reader$reify__1208.read_bytes(structure.clj:33)
at gloss.core.structure$convert_sequence$reify__1215.read_bytes(structure.clj:56)
at gloss.core.protocols$compose_callback$reify__533.read_bytes(protocols.clj:57)
at gloss.core.codecs$ordered_map$reify__1317.read_bytes(codecs.clj:226)
at gloss.core.structure$sequence_reader$reify__1208.read_bytes(structure.clj:33)
at gloss.core.structure$convert_sequence$reify__1215.read_bytes(structure.clj:56)
at gloss.io$decode.invoke(io.clj:83)
at gloss.io$decode.invoke(io.clj:78)
at spktool.spkfile$parse_spkdata.doInvoke(spkfile.clj:90)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at spktool.spkfile$process_spk.invoke(spkfile.clj:177)
at spktool.core$_main.doInvoke(core.clj:24)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at spktool.core.main(Unknown Source)
hi117
Posts: 9
Joined: Fri, 5. Dec 08, 02:13
x3tc

Post by hi117 »

Had an error extracting SalvageClaimSoftware-V1.21-20.01.2010.spk

Here is the stack trace:
Processing :extract on ../SalvageClaimSoftware-V1.21-20.01.2010.spk...
Exception in thread "main" java.lang.NegativeArraySizeException
at clojure.lang.Numbers.byte_array(Numbers.java:1216)
at spktool.spkfile$inflate.invoke(spkfile.clj:20)
at spktool.spkfile$unpack_all.invoke(spkfile.clj:66)
at spktool.spkfile$parse_spkdata.doInvoke(spkfile.clj:98)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at spktool.spkfile$process_spk.invoke(spkfile.clj:177)
at spktool.core$_main.doInvoke(core.clj:24)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at spktool.core.main(Unknown Source)

Here is error with debugger attached:
Exception occurred: java.lang.NegativeArraySizeException (uncaught)"thread=main", spktool.core$_main.doInvoke(), line=18 bci=1,379
18 (binding [*xattr?* (:xattr options)]

Here is the line when run through a decompiler:
_L18:
JVM INSTR dup ;
JVM INSTR ifnull 632;
goto _L19 _L20
(this is java bytecode)

Let me know if you need more information about this bug.

Edit: This is using java7 via icedtea 7.2.4.7 BTW

Edit2: Found the issue I think, the .spk i was using is version 4.10 (the other one I used this on was 4.00). The program will have to be updated to support the 4.10 .spk format.

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”