Copy tsk_logical_imager.exe at build time

disable the configuration feature if the .exe is not in the release folder.
This commit is contained in:
Joe Ho 2019-06-25 09:49:33 -04:00
parent 62413d9dd0
commit 9a4d4fbc66
3 changed files with 47 additions and 28 deletions

View File

@ -23,7 +23,6 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
@ -36,6 +35,7 @@ import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.coreutils.Logger;
import static org.sleuthkit.autopsy.logicalimager.configuration.ConfigureLogicalImager.getTskLogicalImagerExe;
/**
* Configuration Wizard Panel 2
@ -130,10 +130,7 @@ final class ConfigWizardPanel2 implements WizardDescriptor.Panel<WizardDescripto
}
private void writeTskLogicalImagerExe(Path destDir) throws IOException {
try (InputStream in = getClass().getResourceAsStream("tsk_logical_imager.exe")) { // NON-NLS
File destFile = Paths.get(destDir.toString(), "tsk_logical_imager.exe").toFile(); // NON-NLS
FileUtils.copyInputStreamToFile(in, destFile);
}
FileUtils.copyFileToDirectory(getTskLogicalImagerExe(), destDir.toFile());
}
@Override

View File

@ -19,8 +19,7 @@
package org.sleuthkit.autopsy.logicalimager.configuration;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
@ -30,8 +29,11 @@ import org.openide.WizardDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.CallableSystemAction;
import static org.sleuthkit.autopsy.coreutils.PlatformUtil.getInstallModulesPath;
/**
* Configuration Logical Imager
@ -41,18 +43,20 @@ import org.openide.util.NbBundle.Messages;
category = "Tools",
id = "org.sleuthkit.autopsy.configurelogicalimager.ConfigureLogicalImager"
)
@ActionRegistration(
displayName = "#CTL_ConfigureLogicalImager"
)
@ActionRegistration(displayName = "#CTL_ConfigureLogicalImager", lazy = false)
@ActionReference(path = "Menu/Tools", position = 2000, separatorBefore = 1999)
@Messages("CTL_ConfigureLogicalImager=Configure Logical Imager")
public final class ConfigureLogicalImager implements ActionListener {
public final class ConfigureLogicalImager extends CallableSystemAction {
private static final String DISPLAY_NAME = Bundle.CTL_ConfigureLogicalImager();
private static final String TSK_LOGICAL_IMAGER_DIR = "tsk_logical_imager"; // NON-NLS
private static final String TSK_LOGICAL_IMAGER_EXE = "tsk_logical_imager.exe"; // NON-NLS
@NbBundle.Messages({
"ConfigureLogicalImager.title=Configure Logical Imager"
})
@Override
public void actionPerformed(ActionEvent e) {
public void performAction() {
List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<>();
panels.add(new ConfigWizardPanel1());
panels.add(new ConfigWizardPanel2());
@ -80,4 +84,26 @@ public final class ConfigureLogicalImager implements ActionListener {
panel.saveConfigFile();
}
}
@Override
public String getName() {
return DISPLAY_NAME;
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@Override
public boolean isEnabled() {
File tskLogicalImagerExe = getTskLogicalImagerExe();
return tskLogicalImagerExe.exists();
}
static public File getTskLogicalImagerExe() {
String installModulesPath = getInstallModulesPath();
File tskLogicalImagerExe = new File(installModulesPath + File.separator + TSK_LOGICAL_IMAGER_DIR + File.separator + TSK_LOGICAL_IMAGER_EXE);
return tskLogicalImagerExe;
}
}

View File

@ -8,6 +8,7 @@
<property name="i586" location="${basedir}/Core/release/modules/lib/i586" />
<property name="i686" location="${basedir}/Core/release/modules/lib/i686"/>
<property name="crt" location="${basedir}/thirdparty/crt" />
<property name="tsk_logical_imager_dir" location="${basedir}/Core/release/modules/tsk_logical_imager"/>
<import file="build-windows-installer.xml" />
@ -27,14 +28,12 @@
</condition>
<fail unless="ewfFound" message="LIBEWF_HOME must be set as an environment variable."/>
<property name="win64.TskLogicalImager.path" value="${env.TSK_HOME}/win32/x64/Release_NoLibs/tsk_logical_imager.exe"/>
<property name="win32.TskLogicalImager.path" value="${env.TSK_HOME}/win32/Release_NoLibs/tsk_logical_imager.exe" />
<property name="tskLogicalImager.path" value="${env.TSK_HOME}/win32/Release_NoLibs/tsk_logical_imager.exe" />
<property name="win64.TskLib.path" value="${env.TSK_HOME}/win32/x64/Release_PostgreSQL"/>
<property name="win32.TskLib.path" value="${env.TSK_HOME}/win32/Release_PostgreSQL" />
<property name="win64.TskLib.postgres_path" value="${env.TSK_HOME}/win32/x64/Release_PostgreSQL"/>
<property name="win32.TskLib.postgres_path" value="${env.TSK_HOME}/win32/Release_PostgreSQL"/>
<available property="win64.TskLogicalImager.exists" type="file" file="${win64.TskLogicalImager.path}" />
<available property="win32.TskLogicalImager.exists" type="file" file="${win32.TskLogicalImager.path}" />
<available property="tskLogicalImager.exists" type="file" file="${tskLogicalImager.path}" />
<available property="win64.TskLib.exists" type="dir" file="${win64.TskLib.path}" />
<available property="win32.TskLib.exists" type="dir" file="${win32.TskLib.path}" />
<available property="win64.TskLib_postgres.exists" type="dir" file="{win64.TskLib.postgres_path}" />
@ -51,17 +50,12 @@
<exclude name="libtsk_jni.dll"/>
</fileset>
<fileset file="${win64.TskLogicalImager.path}" id="win64logicalImager">
</fileset>
<copy todir="${amd64}" overwrite="true">
<fileset refid="win64dlls" />
<fileset refid="win64logicalImager" />
</copy>
<copy todir="${x86_64}" overwrite="true">
<fileset refid="win64dlls" />
<fileset refid="win64logicalImager" />
</copy>
</target>
@ -72,35 +66,37 @@
<exclude name="libtsk_jni.dll"/>
</fileset>
<fileset file="${win32.TskLogicalImager.path}" id="win32logicalImager">
</fileset>
<copy todir="${i386}" overwrite="true">
<fileset refid="win32dlls" />
<fileset refid="win32logicalImager" />
</copy>
<copy todir="${x86}" overwrite="true">
<fileset refid="win32dlls" />
<fileset refid="win32logicalImager" />
</copy>
<copy todir="${i586}" overwrite="true">
<fileset refid="win32dlls" />
<fileset refid="win32logicalImager" />
</copy>
<copy todir="${i686}" overwrite="true">
<fileset refid="win32dlls" />
<fileset refid="win32logicalImager" />
</copy>
</target>
<target name="copyTskLogicalImager" if="tskLogicalImager.exists">
<fileset file="${tskLogicalImager.path}" id="tskLogicalImager" />
<mkdir dir="${tsk_logical_imager_dir}"/>
<copy todir="${tsk_logical_imager_dir}" overwrite="true">
<fileset refid="tskLogicalImager" />
</copy>
</target>
<!-- This gets called from the main build.xml -->
<target name="copyLibsToBaseDir" depends="checkTskLibDirs" description="Copy windows dlls to the correct location." >
<antcall target="makeBaseLibDirs" inheritRefs="true" />
<antcall target="copyWinTskLibs32ToBaseDir" inheritRefs="true" />
<antcall target="copyWinTskLibs64ToBaseDir" inheritRefs="true" />
<antcall target="copyTskLogicalImager" inheritRefs="true" />
</target>
</project>