Ejemplo n.º 1
0
  public void packageToFile(File packageFile, ScriptUtil.Strategy strategy) throws Exception {
    File workingDirectoryF = VfsUtil.asFile(workingDirectory);
    File rpms = new File(workingDirectoryF, "RPMS");
    File specsDir = new File(workingDirectoryF, "SPECS");
    File tmp = new File(workingDirectoryF, "tmp");

    File specFilePath = new File(specsDir, specFile.name + ".spec");

    FileUtils.forceMkdir(new File(workingDirectoryF, "BUILD"));
    FileUtils.forceMkdir(rpms);
    FileUtils.forceMkdir(new File(workingDirectoryF, "SOURCES"));
    FileUtils.forceMkdir(specsDir);
    FileUtils.forceMkdir(new File(workingDirectoryF, "SRPMS"));
    FileUtils.forceMkdir(tmp);

    fileCollector.collect();

    ScriptUtil.Result result =
        scriptUtil
            .createExecution(specFile.name, "rpm", getScripts(), workingDirectoryF, strategy)
            .execute();

    specFile.includePre = result.preInstall;
    specFile.includePost = result.postInstall;
    specFile.includePreun = result.preRemove;
    specFile.includePostun = result.postRemove;
    specFile.buildRoot = VfsUtil.asFile(fileCollector.getFsRoot());

    LineStreamUtil.toFile(specFile, specFilePath);

    new Rpmbuild()
        .setDebug(debug)
        .setBuildroot(VfsUtil.asFile(fileCollector.getFsRoot()))
        .define("_tmppath " + tmp.getAbsolutePath())
        .define("_topdir " + workingDirectoryF.getAbsolutePath())
        .define("_rpmdir " + packageFile.getParentFile().getAbsolutePath())
        .define("_rpmfilename " + packageFile.getName())
        .setSpecFile(specFilePath)
        .setRpmbuildPath(rpmbuildPath)
        .buildBinary();
  }