2012-02-07 42 views
0

私は新しいチーム/プロジェクトのためにinstall4jを評価しています。計画は、自社のプラットフォームに特化した自社製インストーラーのセットを、単一のinstall4jインストーラーで置き換えることです。私はチームビルドの出力のための簡単なインストーラを作成しました。 Install4jは、ビルドの出力を自己解凍ファイルに入れて、実行時にディレクトリに入れるシンプルなインストーラーでうまくいっています。install4jでビルドされたインストーラに埋め込まれたファイルを解凍して解凍するにはどうすればよいですか?

ただし、ビルド出力に埋め込まれているファイルを解凍しようとすると、以下の例外が発生して失敗します。

install4jはgzipされたtarファイルを「そのまま」扱うことができませんか?このためにカスタムコードを記述する必要はありますか?それとも、他の種類のエラーのように見えますか?私はチェックし、コマンドラインから自分が指定したディレクトリにファイルを解凍して解凍することができます。

これは私がMySQLのための私のインストーラで複数のアーティファクトを行う必要がある何かである、Tomcatのなど

java.util.zip.ZipException: error in opening zip file 
    at java.util.zip.ZipFile.open(Native Method) 
    at java.util.zip.ZipFile.<init>(ZipFile.java:131) 
    at java.util.zip.ZipFile.<init>(ZipFile.java:148) 
    at com.install4j.runtime.beans.actions.files.AbstractExtractZipFileAction.getMaxProgress(Unknown Source) 
    at com.install4j.runtime.beans.actions.files.AbstractExtractZipFileAction.extractZip(Unknown Source) 
    at com.install4j.runtime.beans.actions.files.AbstractExtractZipFileAction.execute(Unknown Source) 
    at com.install4j.runtime.beans.actions.SystemInstallOrUninstallAction.install(Unknown Source) 
    at com.install4j.runtime.installer.InstallerContextImpl.performActionInt(Unknown Source) 
    at com.install4j.runtime.installer.ContextImpl.performAction(Unknown Source) 
    at com.install4j.runtime.installer.controller.Controller.executeActions(Unknown Source) 
    at com.install4j.runtime.installer.controller.Controller.handleCommand(Unknown Source) 
    at com.install4j.runtime.installer.controller.Controller.start(Unknown Source) 
    at com.install4j.runtime.installer.Installer.runInProcess(Unknown Source) 
    at com.install4j.runtime.installer.Installer.main(Unknown Source) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at com.exe4j.runtime.LauncherEngine.launch(Unknown Source) 
    at com.install4j.runtime.launcher.Launcher.main(Unknown Source) 

答えて

0

install4jでZIPアクションは現在、ZIPファイルで、gzip圧縮されたtarファイルでは動作しません。

+0

これで、私は今カスタムコードを書く必要があります。それを行う最も効率的な方法への任意のアドバイス/ヒント/ポインター? 「スクリプトの実行」アクションを簡単に実行できますか?または、拡張機能を書く必要がありますか?拡張機能を書く必要がある場合は、チュートリアルを教えてください。 – Frank

+0

今日私は同じ問題を抱えていますが、それでもバージョン6.0.4では動作しません。たぶん、それは次のバージョンの1つの改善かもしれませんか?それ以外の場合、ビルド時にファイルを解凍して圧縮する必要がありますが、これは推奨される回避策ではありません。 – Hardie82

+0

私は問題トラッカーにこれを追加しました。 –

2

これは私が思ったほど難しくはありませんでした。私はthis postにJAVAコードのスニペットを見つけました。

「スクリプトの実行」アクションを追加したコードは次のとおりです。インストールされているプラ​​ットフォーム用の適切なmysql tarファイルを決定するにはまだスマートではありませんが、それはスタートです。

import java.io.*; 
import java.util.zip.*; 
import org.apache.tools.tar.TarEntry; 
import org.apache.tools.tar.TarInputStream; 

File tgzFile = new File(context.getInstallationDirectory(), "mysql/mysql-5.5.17-linux2.6-i686.tar.gz"); 

// Create the Tar input stream. 
FileInputStream fin = new FileInputStream(tgzFile); 
GZIPInputStream gin = new GZIPInputStream(fin); 
TarInputStream tin = new TarInputStream(gin); 

String outputDirectory = "mysql"; 

// Create the destination directory. 
File outputDir = new File(outputDirectory); 
outputDir.mkdir(); 

// Extract files. 
TarEntry tarEntry = tin.getNextEntry(); 
while (tarEntry != null) { 
    File destPath = new File(context.getInstallationDirectory(), outputDirectory + File.separator + tarEntry.getName()); 

    if (tarEntry.isDirectory()) { 
     destPath.mkdirs(); 
    } else { 
     // If the parent directory of a file doesn't exist, create it. 
     if (!destPath.getParentFile().exists()) 
      destPath.getParentFile().mkdirs(); 

     FileOutputStream fout = new FileOutputStream(destPath); 
     tin.copyEntryContents(fout); 
     fout.close(); 
    // Presserve the last modified date of the tar'd files. 
     destPath.setLastModified(tarEntry.getModTime().getTime()); 
    } 
    tarEntry = tin.getNextEntry(); 
} 
tin.close(); 

return true; 
+0

この実装で私が発見した1つの問題があります。 GNUロングファイル名は扱いません。 99文字を超えるパスを持つtarファイルは正しく処理されません。それでもやっている。 – Frank

関連する問題