Пример #1
0
  private void createOutputJar() {
    // Me make the .uninstaller directory
    String dest =
        IoHelper.translatePath(installdata.getInfo().getUninstallerPath(), variableSubstitutor);
    String jar = dest + File.separator + installdata.getInfo().getUninstallerName();
    File pathMaker = new File(dest);
    pathMaker.mkdirs();

    // We log the uninstaller deletion information
    udata.setUninstallerJarFilename(jar);
    udata.setUninstallerPath(dest);

    // We open our final jar file
    try {
      out = new FileOutputStream(jar);
    } catch (FileNotFoundException e) {
      throw new IzPackException("Problem writing uninstaller jar", e);
    }

    try {
      // Intersect a buffer else byte for byte will be written to the file.
      bos = new BufferedOutputStream(out);
      outJar = new JarOutputStream(bos);
    } catch (IOException e) {
      throw new IzPackException("Problem writing uninstaller jar", e);
    }

    outJar.setLevel(9);
    udata.addFile(jar, true);
  }
Пример #2
0
  private BufferedWriter getExternLogFile(AutomatedInstallData installdata) {
    String logfile = installdata.getVariable(LOGFILE_PATH);
    BufferedWriter extLogWriter = null;
    if (logfile != null) {
      if (logfile.toLowerCase().startsWith("default")) {
        logfile = installdata.getInfo().getUninstallerPath() + "/install.log";
      }
      logfile = IoHelper.translatePath(logfile, variableSubstitutor);
      File outFile = new File(logfile);
      if (!outFile.getParentFile().exists()) {
        outFile.getParentFile().mkdirs();
      }
      FileOutputStream out = null;
      try {
        out = new FileOutputStream(outFile);
      } catch (FileNotFoundException e) {
        Debug.trace("Cannot create logfile!");
        Debug.error(e);
      }
      if (out != null) {
        extLogWriter = new BufferedWriter(new OutputStreamWriter(out));
      }
    }

    return extLogWriter;
  }
Пример #3
0
 public boolean isUninstallShouldBeWriten() {
   String uninstallerCondition = installdata.getInfo().getUninstallerCondition();
   if (uninstallerCondition == null) {
     return true;
   }
   if (uninstallerCondition.length() > 0) {
     return true;
   }
   return this.rules.isConditionTrue(uninstallerCondition);
 }
Пример #4
0
  /**
   * Puts the uninstaller skeleton.
   *
   * @param installdata
   * @param pathResolver
   * @param outJar
   * @throws Exception Description of the Exception
   */
  public void writeJarSkeleton(
      AutomatedInstallData installdata, PathResolver pathResolver, JarOutputStream outJar)
      throws Exception {
    // get the uninstaller base, returning if not found so that
    // installData.uninstallOutJar remains null

    List<Mergeable> uninstallerMerge =
        pathResolver.getMergeableFromPath("com/izforge/izpack/uninstaller/");
    uninstallerMerge.addAll(
        pathResolver.getMergeableFromPath("uninstaller-META-INF/", "META-INF/"));
    uninstallerMerge.addAll(pathResolver.getMergeableFromPath("com/izforge/izpack/api/"));
    uninstallerMerge.addAll(pathResolver.getMergeableFromPath("com/izforge/izpack/util/"));
    uninstallerMerge.addAll(pathResolver.getMergeableFromPath("com/izforge/izpack/gui/"));
    uninstallerMerge.addAll(pathResolver.getMergeableFromPath("com/izforge/izpack/img/"));

    // The uninstaller extension is facultative; it will be exist only
    // if a native library was marked for uninstallation.
    // REFACTOR Change uninstaller methods of merge and get

    // Me make the .uninstaller directory
    // We copy the uninstallers
    for (Mergeable mergeable : uninstallerMerge) {
      mergeable.merge(outJar);
    }

    // Should we relaunch the uninstaller with privileges?
    if (PrivilegedRunner.isPrivilegedMode()
        && installdata.getInfo().isPrivilegedExecutionRequiredUninstaller()) {
      outJar.putNextEntry(new JarEntry("exec-admin"));
      outJar.closeEntry();
    }

    // We put the langpack
    List<Mergeable> langPack =
        pathResolver.getMergeableFromPath(
            "resources/langpacks/" + installdata.getLocaleISO3() + ".xml", "langpack.xml");
    for (Mergeable mergeable : langPack) {
      mergeable.merge(outJar);
    }
  }
 /**
  * Construct new compilation job.
  *
  * @param listener The listener to report progress to.
  * @param idata The installation data.
  * @param name The name of the job.
  * @param files The files to compile.
  * @param classpath The class path to use.
  */
 public CompilationJob(
     CompileHandler listener,
     AutomatedInstallData idata,
     String name,
     ArrayList<File> files,
     List<String> classpath) {
   this.listener = listener;
   this.idata = idata;
   this.langpack = idata.getLangpack();
   this.name = name;
   this.files = files;
   this.classpath = classpath;
 }
Пример #6
0
  private void writeFilesLog(
      AutomatedInstallData installdata,
      BufferedWriter extLogWriter,
      List<String> files,
      JarOutputStream outJar)
      throws IOException {
    outJar.putNextEntry(new JarEntry("install.log"));
    BufferedWriter logWriter = new BufferedWriter(new OutputStreamWriter(outJar));
    logWriter.write(installdata.getInstallPath());
    logWriter.newLine();
    Iterator<String> iter = files.iterator();
    if (extLogWriter != null) { // Write intern (in uninstaller.jar) and extern log file.

      while (iter.hasNext()) {
        String txt = iter.next();
        logWriter.write(txt);
        extLogWriter.write(txt);
        if (iter.hasNext()) {
          logWriter.newLine();
          extLogWriter.newLine();
        }
      }
      logWriter.flush();
      extLogWriter.flush();
      extLogWriter.close();
    } else {
      while (iter.hasNext()) {
        String txt = iter.next();
        logWriter.write(txt);
        if (iter.hasNext()) {
          logWriter.newLine();
        }
      }
      logWriter.flush();
    }
    outJar.closeEntry();
  }