return installDir;
}
public void installPackage(PackageDescription packageData) {
InstallData data = InstallData.getInstance();
String log = "<br><b>Package: " + packageData.getName() + "</b>";
LogManager.addCommandsLogfileComment(log);
String rootDir = data.getInstallDir();
String packagePath = data.getPackagePath();
if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) {
File completePackageFile = new File(packagePath, packageData.getPkgSubdir());
packagePath = completePackageFile.getPath();
}
String packageName = packageData.getPackageName();
if (( packageName.equals("")) || ( packageName == null )) {
log = "<b>No package name specified. Nothing to do</b>";
LogManager.addCommandsLogfileComment(log);
} else {
log = "<b>Package Name: " + packageName + "</b>";
LogManager.addCommandsLogfileComment(log);
File completePackage = new File(packagePath, packageName);
if ( completePackage.exists() ) {
String pkgCommand = "";
String[] pkgCommandArray;
String adminFileName = "";
Vector returnVector = new Vector();
Vector returnErrorVector = new Vector();
int returnValue;
// is package relocatable or not?
if ( packageData.isRelocatable() ) {
adminFileName = data.getAdminFileNameReloc();
} else {
adminFileName = data.getAdminFileNameNoReloc();
}
if ( data.isUserInstallation() ) {
HashMap env = data.getShellEnvironment();
String[] envStringArray = Converter.convertHashmapToStringArray(env);
pkgCommand = "/usr/sbin/pkgadd -n -d " + packagePath + " -R " +
rootDir + " -a " + adminFileName + " " + packageName;
pkgCommandArray = new String[9];
pkgCommandArray[0] = "/usr/sbin/pkgadd";
pkgCommandArray[1] = "-n";
pkgCommandArray[2] = "-d";
pkgCommandArray[3] = packagePath;
pkgCommandArray[4] = "-R";
pkgCommandArray[5] = rootDir;
pkgCommandArray[6] = "-a";
pkgCommandArray[7] = adminFileName;
pkgCommandArray[8] = packageName;
returnValue = ExecuteProcess.executeProcessReturnVectorEnv(pkgCommandArray, envStringArray, returnVector, returnErrorVector);
} else {
// shifting of the installation root (-R) is only wanted for user installation
pkgCommand = "/usr/sbin/pkgadd -n -d " + packagePath +
" -a " + adminFileName + " " + packageName;
pkgCommandArray = new String[7];
pkgCommandArray[0] = "/usr/sbin/pkgadd";
pkgCommandArray[1] = "-n";
pkgCommandArray[2] = "-d";
pkgCommandArray[3] = packagePath;
pkgCommandArray[4] = "-a";
pkgCommandArray[5] = adminFileName;
pkgCommandArray[6] = packageName;
returnValue = ExecuteProcess.executeProcessReturnVector(pkgCommandArray, returnVector, returnErrorVector);
}
if ( returnValue == 0 ) {
log = pkgCommand + "<br><b>Returns: " + returnValue + " Successful installation</b><br>";
LogManager.addCommandsLogfileComment(log);
} else { // an error occured during installation
if ( packageData.installCanFail() ) {
log = pkgCommand + "<br><b>Returns: " + returnValue + " Problem during installation. Can be ignored.</b><br>";
LogManager.addCommandsLogfileComment(log);
} else {
log = pkgCommand + "<br><b>Returns: " + returnValue + " Error during installation</b><br>";
LogManager.addCommandsLogfileComment(log);
System.err.println("Error during installation:");
for (int i = 0; i < returnErrorVector.size(); i++) {
LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i));
System.err.println(returnErrorVector.get(i));
}
data.setIsErrorInstallation(true);
}
}
}
else {
log = "<b>Error: Did not find package " + packageName + "</b><br>";
System.err.println(log);
String message = ResourceManager.getString("String_File_Not_Found") + ": " + packageName;
String title = ResourceManager.getString("String_Error");
Informer.showErrorMessage(message, title);
LogManager.addCommandsLogfileComment(log);
data.setIsErrorInstallation(true);
}
}
}