Added GStreamer paths to PATH environment variable on Windows so that we can find the correct version even if there is more than one version of Autopsy installed.

This commit is contained in:
esaunders 2019-04-01 13:55:12 -04:00
parent 90ec9f5191
commit 3c1789463c
3 changed files with 78 additions and 48 deletions

View File

@ -40,6 +40,24 @@
<fileset dir="${thirdparty.dir}/Tesseract-OCR"/> <fileset dir="${thirdparty.dir}/Tesseract-OCR"/>
</copy> </copy>
<!--Copy GStreamer to release-->
<copy todir="${basedir}/release/gstreamer" >
<fileset dir="${thirdparty.dir}/gstreamer"/>
</copy>
<!-- The 'libgstlibav.dll' file is too big to store on GitHub, so we
have it stored in a ZIP file. We'll extract it in place and remove
the ZIP file afterward. -->
<var name="gstreamer-base-path" value="${basedir}/release/gstreamer/1.0/" />
<unzip src="${gstreamer-base-path}/x86_64/lib/gstreamer-1.0/libgstlibav.zip"
dest="${gstreamer-base-path}/x86_64/lib/gstreamer-1.0/"/>
<delete file="${gstreamer-base-path}/x86_64/lib/gstreamer-1.0/libgstlibav.zip" />
<unzip src="${gstreamer-base-path}/x86/lib/gstreamer-1.0/libgstlibav.zip"
dest="${gstreamer-base-path}/x86/lib/gstreamer-1.0/"/>
<delete file="${gstreamer-base-path}/x86/lib/gstreamer-1.0/libgstlibav.zip" />
<!--Copy other jars--> <!--Copy other jars-->
<copy file="${thirdparty.dir}/rejistry/Rejistry-1.0-SNAPSHOT.jar" todir="${ext.dir}" /> <copy file="${thirdparty.dir}/rejistry/Rejistry-1.0-SNAPSHOT.jar" todir="${ext.dir}" />
<copy file="${thirdparty.dir}/sevenzip/sevenzipjbinding.jar" todir="${ext.dir}" /> <copy file="${thirdparty.dir}/sevenzip/sevenzipjbinding.jar" todir="${ext.dir}" />

View File

@ -18,9 +18,12 @@
*/ */
package org.sleuthkit.autopsy.core; package org.sleuthkit.autopsy.core;
import com.sun.jna.platform.win32.Kernel32;
import java.awt.Cursor; import java.awt.Cursor;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -74,6 +77,8 @@ public class Installer extends ModuleInstall {
*/ */
if (PlatformUtil.isWindowsOS()) { if (PlatformUtil.isWindowsOS()) {
try { try {
addGstreamerPathsToEnv();
//Note: if shipping with a different CRT version, this will only print a warning //Note: if shipping with a different CRT version, this will only print a warning
//and try to use linker mechanism to find the correct versions of libs. //and try to use linker mechanism to find the correct versions of libs.
//We should update this if we officially switch to a new version of CRT/compiler //We should update this if we officially switch to a new version of CRT/compiler
@ -271,6 +276,43 @@ public class Installer extends ModuleInstall {
} }
} }
/**
* Add the Gstreamer bin and lib paths to the PATH environment variable so
* that the correct plugins and libraries are found when Gstreamer is
* initialized later.
*/
private static void addGstreamerPathsToEnv() {
Path gstreamerPath = InstalledFileLocator.getDefault().locate("gstreamer", Installer.class.getPackage().getName(), false).toPath();
if (gstreamerPath == null) {
logger.log(Level.SEVERE, "Failed to find GStreamer.");
} else {
String arch = "x86_64";
if (!PlatformUtil.is64BitJVM()) {
arch = "x86";
}
Path gstreamerBasePath = Paths.get(gstreamerPath.toString(), "1.0", arch);
Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(), "bin");
Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(), "lib", "gstreamer-1.0");
// Update the PATH environment variable to contain the GStreamer
// lib and bin paths.
Kernel32 k32 = Kernel32.INSTANCE;
String path = System.getenv("PATH");
if (path == null || path.trim().isEmpty()) {
k32.SetEnvironmentVariable("PATH", gstreamerLibPath.toString());
} else {
/*
* Note that we *prepend* the paths so that the Gstreamer
* binaries associated with the current release are found rather
* than binaries associated with an earlier version of Autopsy.
*/
k32.SetEnvironmentVariable("PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
}
}
}
/** /**
* Make a folder in the config directory for object detection classifiers if one does not * Make a folder in the config directory for object detection classifiers if one does not
* exist. * exist.
@ -288,7 +330,7 @@ public class Installer extends ModuleInstall {
File pythonModulesDir = new File(PlatformUtil.getUserPythonModulesPath()); File pythonModulesDir = new File(PlatformUtil.getUserPythonModulesPath());
pythonModulesDir.mkdir(); pythonModulesDir.mkdir();
} }
/** /**
* Make a folder in the config directory for Ocr Language Packs if one does * Make a folder in the config directory for Ocr Language Packs if one does
* not exist. * not exist.
@ -296,10 +338,10 @@ public class Installer extends ModuleInstall {
private static void ensureOcrLanguagePacksFolderExists() { private static void ensureOcrLanguagePacksFolderExists() {
File ocrLanguagePacksDir = new File(PlatformUtil.getOcrLanguagePacksPath()); File ocrLanguagePacksDir = new File(PlatformUtil.getOcrLanguagePacksPath());
boolean createDirectory = ocrLanguagePacksDir.mkdir(); boolean createDirectory = ocrLanguagePacksDir.mkdir();
//If the directory did not exist, copy the tessdata folder over so we //If the directory did not exist, copy the tessdata folder over so we
//support english. //support english.
if(createDirectory) { if (createDirectory) {
File tessdataDir = InstalledFileLocator.getDefault().locate( File tessdataDir = InstalledFileLocator.getDefault().locate(
"Tesseract-OCR/tessdata", Installer.class.getPackage().getName(), false); "Tesseract-OCR/tessdata", Installer.class.getPackage().getName(), false);
try { try {

View File

@ -117,16 +117,15 @@
<exec executable="${ai-exe-path}"> <exec executable="${ai-exe-path}">
<arg line="/edit ${aip-path-base} /SetAppdir -buildname DefaultBuild -path [ProgramFilesFolder][ProductName]-${app.version}"/> <arg line="/edit ${aip-path-base} /SetAppdir -buildname DefaultBuild -path [ProgramFilesFolder][ProductName]-${app.version}"/>
</exec> </exec>
<var name="gstreamer-relative-path" value="gstreamer/1.0/x86"/> <!-- Delete the 64 bit version of gstreamer since its not needed by the 32 bit installer -->
<antcall target="install-gstreamer" inheritAll="true" /> <var name="gstreamer-relative-path" value="gstreamer/1.0/x86_64"/>
<antcall target="ai-build" inheritAll="true" />
<delete includeEmptyDirs="true"> <delete includeEmptyDirs="true">
<fileset dir="${inst-path}/${app.name}/${gstreamer-relative-path}"/> <fileset dir="${inst-path}/autopsy/${gstreamer-relative-path}"/>
</delete> </delete>
<antcall target="ai-build" inheritAll="true" />
<delete dir="${nbdist.dir}/installer_${app.name}_32-cache"/> <delete dir="${nbdist.dir}/installer_${app.name}_32-cache"/>
<move file="${nbdist.dir}/installer_${app.name}_32-SetupFiles/installer_${app.name}_32.msi" tofile="${nbdist.dir}/${app.name}-${app.version}-32bit.msi" /> <move file="${nbdist.dir}/installer_${app.name}_32-SetupFiles/installer_${app.name}_32.msi" tofile="${nbdist.dir}/${app.name}-${app.version}-32bit.msi" />
</target> </target>
@ -153,48 +152,19 @@
<exec executable="${ai-exe-path}"> <exec executable="${ai-exe-path}">
<arg line="/edit ${aip-path} /SetPackageType x64"/> <arg line="/edit ${aip-path} /SetPackageType x64"/>
</exec> </exec>
<var name="gstreamer-relative-path" value="gstreamer/1.0/x86_64"/> <!-- Delete the 32 bit version of gstreamer since its not needed by the 64 bit installer -->
<antcall target="install-gstreamer" inheritAll="true" /> <var name="gstreamer-relative-path" value="gstreamer/1.0/x86"/>
<antcall target="ai-build" inheritAll="true" />
<delete includeEmptyDirs="true"> <delete includeEmptyDirs="true">
<fileset dir="${inst-path}/${app.name}/${gstreamer-relative-path}"/> <fileset dir="${inst-path}/autopsy/${gstreamer-relative-path}"/>
</delete> </delete>
<antcall target="ai-build" inheritAll="true" />
<delete dir="${nbdist.dir}/installer_${app.name}_64-cache"/> <delete dir="${nbdist.dir}/installer_${app.name}_64-cache"/>
<move file="${nbdist.dir}/installer_${app.name}_64-SetupFiles/installer_${app.name}_64.msi" tofile="${nbdist.dir}/${app.name}-${app.version}-64bit.msi" /> <move file="${nbdist.dir}/installer_${app.name}_64-SetupFiles/installer_${app.name}_64.msi" tofile="${nbdist.dir}/${app.name}-${app.version}-64bit.msi" />
</target> </target>
<target name="install-gstreamer" description="Install a copy of GStreamer.">
<!-- Make GStreamer available to the installer -->
<mkdir dir="${inst-path}/${app.name}/${gstreamer-relative-path}"/>
<copy todir="${inst-path}/${app.name}/${gstreamer-relative-path}" >
<fileset dir="${thirdparty.dir}/${gstreamer-relative-path}"/>
</copy>
<!-- The 'libgstlibav.dll' file is too big to store on GitHub, so we
have it stored in a ZIP file. We'll extract it in place and remove
the ZIP file afterward. -->
<unzip src="${inst-path}/${app.name}/${gstreamer-relative-path}/lib/gstreamer-1.0/libgstlibav.zip"
dest="${inst-path}/${app.name}/${gstreamer-relative-path}/lib/gstreamer-1.0/"/>
<delete file="${inst-path}/${app.name}/${gstreamer-relative-path}/lib/gstreamer-1.0/libgstlibav.zip" />
<!-- GStreamer needs special path info to be set -->
<exec executable="${ai-exe-path}">
<arg line="/edit ${aip-path} /NewEnvironment -name GSTREAMER_PATH -value [APPDIR]${app.name}\${gstreamer-relative-path}\bin -install_operation CreateUpdate -behavior Append -system_variable"/>
</exec>
<exec executable="${ai-exe-path}">
<arg line="/edit ${aip-path} /NewEnvironment -name GSTREAMER_PATH -value [APPDIR]${app.name}\${gstreamer-relative-path}\lib\gstreamer-1.0 -install_operation CreateUpdate -behavior Append -system_variable"/>
</exec>
<exec executable="${ai-exe-path}">
<arg line="/edit ${aip-path} /NewEnvironment -name PATH -value %GSTREAMER_PATH% -install_operation CreateUpdate -behavior Append -system_variable"/>
</exec>
</target>
<!-- 32/64 specific since config settings are different --> <!-- 32/64 specific since config settings are different -->
<target name="update-config" description="Updates configuration file with correct JVM args."> <target name="update-config" description="Updates configuration file with correct JVM args.">
<!-- Update configuration file to include jre --> <!-- Update configuration file to include jre -->