public void registerUninstallKey() throws NativeLibException {
    String uninstallName = getUninstallName();
    if (uninstallName == null) {
      return;
    }
    String keyName = UNINSTALL_ROOT + uninstallName;
    String cmd =
        "\""
            + installdata.getVariable("JAVA_HOME")
            + "\\bin\\javaw.exe\" -jar \""
            + installdata.getVariable("INSTALL_PATH")
            + "\\uninstaller\\uninstaller.jar\"";
    String appVersion = installdata.getVariable("APP_VER");
    String appUrl = installdata.getVariable("APP_URL");

    int oldVal = getRoot();
    try {
      setRoot(HKEY_LOCAL_MACHINE);
      setValue(keyName, "DisplayName", uninstallName);
    } catch (
        NativeLibException
            exception) { // Users without administrative rights should be able to install the app
                         // for themselves
      Debug.trace(
          "Failed to register uninstaller in HKEY_LOCAL_MACHINE hive, trying HKEY_CURRENT_USER: "******"DisplayName", uninstallName);
    }
    setValue(keyName, "UninstallString", cmd);
    setValue(keyName, "DisplayVersion", appVersion);
    if (appUrl != null && appUrl.length() > 0) {
      setValue(keyName, "HelpLink", appUrl);
    }
    // Try to write the uninstaller icon out.
    try {
      InputStream input = ResourceManager.getInstance().getInputStream(UNINSTALLER_ICON);
      String iconPath =
          installdata.getVariable("INSTALL_PATH")
              + File.separator
              + "Uninstaller"
              + File.separator
              + "UninstallerIcon.ico";
      FileOutputStream out = new FileOutputStream(iconPath);
      byte[] buffer = new byte[5120];
      long bytesCopied = 0;
      int bytesInBuffer;
      while ((bytesInBuffer = input.read(buffer)) != -1) {
        out.write(buffer, 0, bytesInBuffer);
        bytesCopied += bytesInBuffer;
      }
      input.close();
      out.close();
      setValue(keyName, "DisplayIcon", iconPath);
    } catch (Exception exception) { // May be no icon resource defined; ignore it
      Debug.trace(exception);
    }
    setRoot(oldVal);
  }
 /**
  * Add the contents of a custom langpack (if exist) to the previos loaded comman langpack. If not
  * exist, trace an info and do nothing more.
  *
  * @param idata install data to be used
  */
 protected void addCustomLangpack(AutomatedInstallData idata) {
   // We try to load and add a custom langpack.
   try {
     idata.langpack.add(ResourceManager.getInstance().getInputStream(LANG_FILE_NAME));
   } catch (Throwable exception) {
     Debug.trace("No custom langpack available.");
     return;
   }
   Debug.trace("Custom langpack for " + idata.localeISO3 + " available.");
 }
Ejemplo n.º 3
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;
  }
Ejemplo n.º 4
0
  /**
   * helper: recursively scan given directory.
   *
   * @return list of files found (might be empty)
   */
  private ArrayList<File> scanDirectory(File path) {
    Debug.trace("scanning directory " + path.getAbsolutePath());

    ArrayList<File> scan_result = new ArrayList<File>();

    if (!path.isDirectory()) {
      return scan_result;
    }

    File[] entries = path.listFiles();

    for (File file : entries) {
      if (file == null) {
        continue;
      }

      if (file.isDirectory()) {
        scan_result.addAll(scanDirectory(file));
      } else if ((file.isFile()) && (file.getName().toLowerCase().endsWith(".java"))) {
        scan_result.add(file);
      }
    }

    return scan_result;
  }
  /** @param args */
  public static void main(String[] args) {
    // default is to look in the current directory
    MultiVolumeInstaller.setMediadirectory(new File(".").getParent());
    if ((args.length > 0) && ("-direct".equals(args[0]))) {
      String[] newargs;
      if (args.length > 1) {
        // cut out the direct parameter
        newargs = new String[args.length - 1];
        System.arraycopy(args, 1, newargs, 0, args.length - 1);
      } else {
        // set arguments to empty string array
        newargs = new String[0];
      }
      MultiVolumeInstaller.install(newargs);
    } else {
      try {
        Class clazz = MultiVolumeInstaller.class;
        Method target = clazz.getMethod("install", new Class[] {String[].class});
        String[] newargs = new String[args.length + 2];

        System.arraycopy(args, 0, newargs, 2, args.length);
        // try to find the directory, where the jar file is located, this class was loaded
        // from
        newargs[0] = "-mediadir";
        newargs[1] = SelfModifier.findJarFile(clazz).getParent();
        System.out.println("Setting mediadir: " + newargs[1]);
        MultiVolumeInstaller.setMediadirectory(SelfModifier.findJarFile(clazz).getParent());
        new SelfModifier(target).invoke(newargs);
      } catch (Exception e) {
        Debug.trace(e);
      }
    }
  }
Ejemplo n.º 6
0
  /** perform the actual compilation */
  private CompileResult compileJobs() {
    ArrayList<String> args = new ArrayList<String>();
    StringTokenizer tokenizer = new StringTokenizer(this.compilerArgumentsToUse);

    while (tokenizer.hasMoreTokens()) {
      args.add(tokenizer.nextToken());
    }

    Iterator<CompilationJob> job_it = this.jobs.iterator();

    this.handler.startAction("Compilation", this.jobs.size());

    // check whether compiler is valid (but only if there are jobs)
    if (job_it.hasNext()) {
      CompilationJob first_job = this.jobs.get(0);

      CompileResult check_result = first_job.checkCompiler(this.compilerToUse, args);
      if (!check_result.isContinue()) {
        return check_result;
      }
    }

    int job_no = 0;

    while (job_it.hasNext()) {
      CompilationJob job = job_it.next();

      this.handler.nextStep(job.getName(), job.getSize(), job_no++);

      CompileResult job_result = job.perform(this.compilerToUse, args);

      if (!job_result.isContinue()) {
        return job_result;
      }
    }

    Debug.trace("compilation finished.");
    return new CompileResult();
  }
Ejemplo n.º 7
0
  /**
   * helper: recursively scan given directory.
   *
   * @return list of files found (might be empty)
   */
  private ArrayList scanDirectory(File path) {
    Debug.trace("scanning directory " + path.getAbsolutePath());

    ArrayList result = new ArrayList();

    if (!path.isDirectory()) return result;

    File[] entries = path.listFiles();

    for (int i = 0; i < entries.length; i++) {
      File f = entries[i];

      if (f == null) continue;

      if (f.isDirectory()) {
        result.addAll(scanDirectory(f));
      } else if ((f.isFile()) && (f.getName().toLowerCase().endsWith(".java"))) {
        result.add(f);
      }
    }

    return result;
  }
Ejemplo n.º 8
0
  private void writeAdditionalUninstallData(UninstallData udata, JarOutputStream outJar)
      throws IOException {
    Map<String, Object> additionalData = udata.getAdditionalData();
    if (additionalData != null && !additionalData.isEmpty()) {
      Set<String> exist = new HashSet<String>();
      for (String key : additionalData.keySet()) {
        Object contents = additionalData.get(key);
        if ("__uninstallLibs__".equals(key)) {
          for (Object o : ((List) contents)) {
            String nativeLibName = (String) ((List) o).get(0);
            byte[] buffer = new byte[5120];
            long bytesCopied = 0;
            int bytesInBuffer;
            outJar.putNextEntry(new JarEntry("/com/izforge/izpack/bin/native/" + nativeLibName));
            InputStream in =
                getClass().getResourceAsStream("/com/izforge/izpack/bin/native/" + nativeLibName);
            while ((bytesInBuffer = in.read(buffer)) != -1) {
              outJar.write(buffer, 0, bytesInBuffer);
              bytesCopied += bytesInBuffer;
            }
            outJar.closeEntry();
          }
        } else if ("uninstallerListeners".equals(key) || "uninstallerJars".equals(key)) {
          // It is a ArrayList of ArrayLists which contains the full
          // package paths of all needed class files.
          // First we create a new ArrayList which contains only
          // the full paths for the uninstall listener self; thats
          // the first entry of each sub ArrayList.
          ArrayList<String> subContents = new ArrayList<String>();

          // Secound put the class into uninstaller.jar
          for (Object o : ((List) contents)) {
            byte[] buffer = new byte[5120];
            long bytesCopied = 0;
            int bytesInBuffer;
            CustomData customData = (CustomData) o;
            // First element of the list contains the listener
            // class path;
            // remind it for later.
            if (customData.listenerName != null) {
              subContents.add(customData.listenerName);
            }
            for (String content : customData.contents) {
              if (exist.contains(content)) {
                continue;
              }
              exist.add(content);
              try {
                outJar.putNextEntry(new JarEntry(content));
              } catch (JarException je) { // Ignore, or ignore not ?? May be it is a
                // exception because
                // a doubled entry was tried, then we should
                // ignore ...
                Debug.trace("JarException in writing custom data: " + je.getMessage());
                continue;
              }
              InputStream in = getClass().getResourceAsStream("/" + content);
              if (in != null) {
                while ((bytesInBuffer = in.read(buffer)) != -1) {
                  outJar.write(buffer, 0, bytesInBuffer);
                  bytesCopied += bytesInBuffer;
                }
              } else {
                Debug.trace("custom data not found: " + content);
              }
              outJar.closeEntry();
            }
          }
          // Third we write the list into the
          // uninstaller.jar
          outJar.putNextEntry(new JarEntry(key));
          ObjectOutputStream objOut = new ObjectOutputStream(outJar);
          objOut.writeObject(subContents);
          objOut.flush();
          outJar.closeEntry();

        } else {
          outJar.putNextEntry(new JarEntry(key));
          if (contents instanceof ByteArrayOutputStream) {
            ((ByteArrayOutputStream) contents).writeTo(outJar);
          } else {
            ObjectOutputStream objOut = new ObjectOutputStream(outJar);
            objOut.writeObject(contents);
            objOut.flush();
          }
          outJar.closeEntry();
        }
      }
    }
  }
Ejemplo n.º 9
0
 /**
  * Traces the given object and additional write their status in the LOGFILE.
  *
  * @param s
  */
 public static void error(Object s) {
   trace(s);
   System.err.println(s);
   System.err.flush();
   log(s);
 }
Ejemplo n.º 10
0
    /**
     * Check whether the given compiler works.
     *
     * <p>This performs two steps:
     *
     * <ol>
     *   <li>check whether we can successfully call "compiler -help"
     *   <li>check whether we can successfully call "compiler -help arguments" (not all compilers
     *       return an error here)
     * </ol>
     *
     * <p>On failure, the method CompileHandler#errorCompile is called with a descriptive error
     * message.
     *
     * @param compiler the compiler to use
     * @param arguments additional arguments to pass to the compiler
     * @return false on error
     */
    public CompileResult checkCompiler(String compiler, ArrayList<String> arguments) {
      // don't do further checks for eclipse compiler - it would exit
      if (compiler.equalsIgnoreCase(ECLIPSE_COMPILER_NAME)) {
        return new CompileResult();
      }

      int retval = 0;
      FileExecutor executor = new FileExecutor();
      String[] output = new String[2];

      Debug.trace("checking whether \"" + compiler + " -help\" works");

      {
        List<String> args = new ArrayList<String>();
        args.add(compiler);
        args.add("-help");

        retval = runCompiler(executor, output, args);

        if (retval != 0) {
          CompileResult result =
              new CompileResult(
                  this.langpack.getString("CompilePanel.error.compilernotfound"),
                  args,
                  output[0],
                  output[1]);
          this.listener.handleCompileError(result);
          if (!result.isContinue()) {
            return result;
          }
        }
      }

      Debug.trace("checking whether \"" + compiler + " -help +arguments\" works");

      // used to collect the arguments for executing the compiler
      LinkedList<String> args = new LinkedList<String>(arguments);

      // add -help argument to prevent the compiler from doing anything
      args.add(0, "-help");

      // add compiler in front of arguments
      args.add(0, compiler);

      // construct classpath argument for compiler
      // - collect all classpaths
      StringBuffer classpath_sb = new StringBuffer();
      for (String cp : this.classpath) {
        if (classpath_sb.length() > 0) {
          classpath_sb.append(File.pathSeparatorChar);
        }
        classpath_sb.append(new File(cp).getAbsolutePath());
      }

      String classpath_str = classpath_sb.toString();

      // - add classpath argument to command line
      if (classpath_str.length() > 0) {
        args.add("-classpath");
        args.add(classpath_str);
      }

      retval = runCompiler(executor, output, args);

      if (retval != 0) {
        CompileResult result =
            new CompileResult(
                this.langpack.getString("CompilePanel.error.invalidarguments"),
                args,
                output[0],
                output[1]);
        this.listener.handleCompileError(result);
        if (!result.isContinue()) {
          return result;
        }
      }

      return new CompileResult();
    }
Ejemplo n.º 11
0
    /**
     * Perform this job - start compilation.
     *
     * @param compiler The compiler to use.
     * @param arguments The compiler arguments to use.
     * @return The result.
     */
    public CompileResult perform(String compiler, ArrayList<String> arguments) {
      Debug.trace("starting job " + this.name);
      // we have some maximum command line length - need to count
      int cmdline_len = 0;

      // used to collect the arguments for executing the compiler
      LinkedList<String> args = new LinkedList<String>(arguments);

      {
        for (String arg : args) {
          cmdline_len += (arg).length() + 1;
        }
      }

      boolean isEclipseCompiler = compiler.equalsIgnoreCase(ECLIPSE_COMPILER_NAME);

      // add compiler in front of arguments
      args.add(0, compiler);
      cmdline_len += compiler.length() + 1;

      // construct classpath argument for compiler
      // - collect all classpaths
      StringBuffer classpath_sb = new StringBuffer();
      for (String cp : this.classpath) {
        if (classpath_sb.length() > 0) {
          classpath_sb.append(File.pathSeparatorChar);
        }
        classpath_sb.append(new File(cp).getAbsolutePath());
      }

      String classpath_str = classpath_sb.toString();

      // - add classpath argument to command line
      if (classpath_str.length() > 0) {
        args.add("-classpath");
        cmdline_len += 11;
        args.add(classpath_str);
        cmdline_len += classpath_str.length() + 1;
      }

      // remember how many arguments we have which don't change for the
      // job
      int common_args_no = args.size();
      // remember how long the common command line is
      int common_args_len = cmdline_len;

      // used for execution
      FileExecutor executor = new FileExecutor();
      String output[] = new String[2];

      // used for displaying the progress bar
      String jobfiles = "";
      int fileno = 0;
      int last_fileno = 0;

      // now iterate over all files of this job

      for (File file : this.files) {
        String fpath = file.getAbsolutePath();

        Debug.trace("processing " + fpath);

        // we add the file _first_ to the arguments to have a better
        // chance to get something done if the command line is almost
        // MAX_CMDLINE_SIZE or even above
        fileno++;
        jobfiles += file.getName() + " ";
        args.add(fpath);
        cmdline_len += fpath.length();

        // start compilation if maximum command line length reached
        if (!isEclipseCompiler && cmdline_len >= MAX_CMDLINE_SIZE) {
          Debug.trace("compiling " + jobfiles);

          // display useful progress bar (avoid showing 100% while
          // still compiling a lot)
          this.listener.progress(last_fileno, jobfiles);
          last_fileno = fileno;

          int retval = runCompiler(executor, output, args);

          // update progress bar: compilation of fileno files done
          this.listener.progress(fileno, jobfiles);

          if (retval != 0) {
            CompileResult result =
                new CompileResult(
                    this.langpack.getString("CompilePanel.error"), args, output[0], output[1]);
            this.listener.handleCompileError(result);
            if (!result.isContinue()) {
              return result;
            }
          } else {
            // verify that all files have been compiled successfully
            // I found that sometimes, no error code is returned
            // although compilation failed.
            Iterator<String> arg_it = args.listIterator(common_args_no);
            while (arg_it.hasNext()) {
              File java_file = new File(arg_it.next());

              String basename = java_file.getName();
              int dotpos = basename.lastIndexOf('.');
              basename = basename.substring(0, dotpos) + ".class";
              File class_file = new File(java_file.getParentFile(), basename);

              if (!class_file.exists()) {
                CompileResult result =
                    new CompileResult(
                        this.langpack.getString("CompilePanel.error.noclassfile")
                            + java_file.getAbsolutePath(),
                        args,
                        output[0],
                        output[1]);
                this.listener.handleCompileError(result);
                if (!result.isContinue()) {
                  return result;
                }
                // don't continue any further
                break;
              }
            }
          }

          // clean command line: remove files we just compiled
          for (int i = args.size() - 1; i >= common_args_no; i--) {
            args.removeLast();
          }

          cmdline_len = common_args_len;
          jobfiles = "";
        }
      }

      if (cmdline_len > common_args_len) {
        this.listener.progress(last_fileno, jobfiles);

        int retval = runCompiler(executor, output, args);

        if (!isEclipseCompiler) {
          this.listener.progress(fileno, jobfiles);
        }

        if (retval != 0) {
          CompileResult result =
              new CompileResult(
                  this.langpack.getString("CompilePanel.error"), args, output[0], output[1]);
          this.listener.handleCompileError(result);
          if (!result.isContinue()) {
            return result;
          }
        } else {
          // verify that all files have been compiled successfully
          // I found that sometimes, no error code is returned
          // although compilation failed.
          Iterator<String> arg_it = args.listIterator(common_args_no);
          while (arg_it.hasNext()) {
            File java_file = new File(arg_it.next());

            String basename = java_file.getName();
            int dotpos = basename.lastIndexOf('.');
            basename = basename.substring(0, dotpos) + ".class";
            File class_file = new File(java_file.getParentFile(), basename);

            if (!class_file.exists()) {
              CompileResult result =
                  new CompileResult(
                      this.langpack.getString("CompilePanel.error.noclassfile")
                          + java_file.getAbsolutePath(),
                      args,
                      output[0],
                      output[1]);
              this.listener.handleCompileError(result);
              if (!result.isContinue()) {
                return result;
              }
              // don't continue any further
              break;
            }
          }
        }
      }

      Debug.trace("job " + this.name + " done (" + fileno + " files compiled)");

      return new CompileResult();
    }
Ejemplo n.º 12
0
  private CompilationJob collectJobsRecursive(IXMLElement node, List<String> classpath)
      throws Exception {
    List<IXMLElement> toplevel_tags = node.getChildren();
    List<String> ourclasspath = new ArrayList<String>(classpath);
    ArrayList<File> files = new ArrayList<File>();

    for (IXMLElement child : toplevel_tags) {
      if ("classpath".equals(child.getName())) {
        changeClassPath(ourclasspath, child);
      } else if ("job".equals(child.getName())) {
        CompilationJob subjob = collectJobsRecursive(child, ourclasspath);
        if (subjob != null) {
          this.jobs.add(subjob);
        }
      } else if ("directory".equals(child.getName())) {
        String name = child.getAttribute("name");

        if (name != null) {
          // substitute variables
          String finalname = this.vs.substitute(name);

          files.addAll(scanDirectory(new File(finalname)));
        }

      } else if ("file".equals(child.getName())) {
        String name = child.getAttribute("name");

        if (name != null) {
          // substitute variables
          String finalname = this.vs.substitute(name);

          files.add(new File(finalname));
        }

      } else if ("packdepency".equals(child.getName())) {
        String name = child.getAttribute("name");

        if (name == null) {
          System.out.println("invalid compilation spec: <packdepency> without name attribute");
          return null;
        }

        // check whether the wanted pack was selected for installation
        boolean found = false;

        for (Pack pack : this.idata.getSelectedPacks()) {
          if (pack.name.equals(name)) {
            found = true;
            break;
          }
        }

        if (!found) {
          Debug.trace("skipping job because pack " + name + " was not selected.");
          return null;
        }
      }
    }

    if (files.size() > 0) {
      return new CompilationJob(
          this.handler, this.idata, node.getAttribute("name"), files, ourclasspath);
    }

    return null;
  }
Ejemplo n.º 13
0
    /**
     * Check whether the given compiler works.
     *
     * <p>This performs two steps:
     *
     * <ol>
     *   <li>check whether we can successfully call "compiler -help"
     *   <li>check whether we can successfully call "compiler -help arguments" (not all compilers
     *       return an error here)
     * </ol>
     *
     * On failure, the method CompileHandler#errorCompile is called with a descriptive error
     * message.
     *
     * @param compiler the compiler to use
     * @param arguments additional arguments to pass to the compiler
     * @return false on error
     */
    public CompileResult checkCompiler(String compiler, ArrayList arguments) {
      int retval = 0;
      FileExecutor executor = new FileExecutor();
      String[] output = new String[2];

      Debug.trace("checking whether \"" + compiler + " -help\" works");

      {
        String[] args = {compiler, "-help"};

        retval = executor.executeCommand(args, output);

        if (retval != 0) {
          CompileResult result =
              new CompileResult(
                  this.langpack.getString("CompilePanel.error.compilernotfound"),
                  args,
                  output[0],
                  output[1]);
          this.listener.handleCompileError(result);
          if (!result.isContinue()) return result;
        }
      }

      Debug.trace("checking whether \"" + compiler + " -help +arguments\" works");

      // used to collect the arguments for executing the compiler
      LinkedList args = new LinkedList(arguments);

      // add -help argument to prevent the compiler from doing anything
      args.add(0, "-help");

      // add compiler in front of arguments
      args.add(0, compiler);

      // construct classpath argument for compiler
      // - collect all classpaths
      StringBuffer classpath_sb = new StringBuffer();
      Iterator cp_it = this.classpath.iterator();
      while (cp_it.hasNext()) {
        String cp = (String) cp_it.next();
        if (classpath_sb.length() > 0) classpath_sb.append(File.pathSeparatorChar);
        classpath_sb.append(new File(cp).getAbsolutePath());
      }

      String classpath_str = classpath_sb.toString();

      // - add classpath argument to command line
      if (classpath_str.length() > 0) {
        args.add("-classpath");
        args.add(classpath_str);
      }

      String[] args_arr = (String[]) args.toArray(output);

      retval = executor.executeCommand(args_arr, output);

      if (retval != 0) {
        CompileResult result =
            new CompileResult(
                this.langpack.getString("CompilePanel.error.invalidarguments"),
                args_arr,
                output[0],
                output[1]);
        this.listener.handleCompileError(result);
        if (!result.isContinue()) return result;
      }

      return new CompileResult();
    }
Ejemplo n.º 14
0
  private CompilationJob collectJobsRecursive(XMLElement node, ArrayList classpath)
      throws Exception {
    Enumeration toplevel_tags = node.enumerateChildren();
    ArrayList ourclasspath = (ArrayList) classpath.clone();
    ArrayList files = new ArrayList();

    while (toplevel_tags.hasMoreElements()) {
      XMLElement child = (XMLElement) toplevel_tags.nextElement();

      if (child.getName().equals("classpath")) {
        changeClassPath(ourclasspath, child);
      } else if (child.getName().equals("job")) {
        CompilationJob subjob = collectJobsRecursive(child, ourclasspath);
        if (subjob != null) this.jobs.add(subjob);
      } else if (child.getName().equals("directory")) {
        String name = child.getAttribute("name");

        if (name != null) {
          // substitute variables
          String finalname = this.vs.substitute(name, "plain");

          files.addAll(scanDirectory(new File(finalname)));
        }

      } else if (child.getName().equals("file")) {
        String name = child.getAttribute("name");

        if (name != null) {
          // substitute variables
          String finalname = this.vs.substitute(name, "plain");

          files.add(new File(finalname));
        }

      } else if (child.getName().equals("packdepency")) {
        String name = child.getAttribute("name");

        if (name == null) {
          System.out.println("invalid compilation spec: <packdepency> without name attribute");
          return null;
        }

        // check whether the wanted pack was selected for installation
        Iterator pack_it = this.idata.selectedPacks.iterator();
        boolean found = false;

        while (pack_it.hasNext()) {
          com.izforge.izpack.Pack pack = (com.izforge.izpack.Pack) pack_it.next();

          if (pack.name.equals(name)) {
            found = true;
            break;
          }
        }

        if (!found) {
          Debug.trace("skipping job because pack " + name + " was not selected.");
          return null;
        }
      }
    }

    if (files.size() > 0)
      return new CompilationJob(
          this.handler,
          this.idata.langpack,
          (String) node.getAttribute("name"),
          files,
          ourclasspath);

    return null;
  }
  /*--------------------------------------------------------------------------*/
  public synchronized void loadLibrary(String name, NativeLibraryClient client) throws Exception {
    String libraryName = strip(name);
    String tempFileName = "";

    // ----------------------------------------------------
    // Return if the library is already loaded
    // ----------------------------------------------------
    if (loaded(libraryName)) {
      return;
    }

    if (System.getProperty("DLL_PATH") != null) {
      String path = System.getProperty("DLL_PATH") + "/" + name + extension;
      path = path.replace('/', File.separatorChar);
      Debug.trace("Try to load library " + path);
      System.load(path);
      return;
    }
    // ----------------------------------------------------
    // First try a straight load
    // ----------------------------------------------------
    try {
      System.loadLibrary(libraryName);
      return;
    } catch (UnsatisfiedLinkError exception) {
    } catch (SecurityException exception) {
    }

    // ----------------------------------------------------
    // Next, try to get the protocol for loading the resource.
    // ----------------------------------------------------
    Class clientClass = client.getClass();
    String resourceName = clientClass.getName();
    int nameStart = resourceName.lastIndexOf('.') + 1;
    resourceName = resourceName.substring(nameStart, resourceName.length()) + CLIENT_EXTENSION;
    URL url = clientClass.getResource(resourceName);
    if (url == null) {
      throw (new Exception("can't identify load protocol for " + libraryName + extension));
    }
    String protocol = url.getProtocol();

    // ----------------------------------------------------
    // If it's a local file, load it from the current location
    // ----------------------------------------------------
    if (protocol.equalsIgnoreCase(FILE_PROTOCOL)) {
      try {
        System.load(getClientPath(name, url));
      } catch (Throwable exception) {
        try {
          System.load(getNativePath(name, client));
        } catch (Throwable exception2) {
          throw (new Exception("error loading library"));
        }
      }
    }

    // ----------------------------------------------------
    // If it is in a *.jar file, extract it to 'java.io.tmpdir'
    // ----------------------------------------------------

    else if (protocol.equalsIgnoreCase(JAR_PROTOCOL)) {
      tempFileName = getTempFileName(libraryName);
      try {
        extractFromJar(libraryName, tempFileName, client);

        clients.add(client);
        temporaryFileNames.add(tempFileName);
        libraryNames.add(
            tempFileName.substring(
                (tempFileName.lastIndexOf(File.separatorChar) + 1), tempFileName.length()));

        // --------------------------------------------------
        // Try loading the temporary file from 'java.io.tmpdir'.
        // --------------------------------------------------
        System.load(tempFileName);
      } catch (Throwable exception) {
        throw (new Exception("error loading library\n" + exception.toString()));
      }
    }
  }