Exemplo 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();
  }
Exemplo n.º 2
0
  public FileCollector addSymlink(UnixFsObject.Symlink symlink) throws IOException {
    specFile.addSymlink(symlink);
    fileCollector.addSymlink(symlink);

    return this;
  }
Exemplo n.º 3
0
 public FileCollector addDirectory(UnixFsObject.Directory directory) throws IOException {
   specFile.addDirectory(directory);
   fileCollector.addDirectory(directory);
   return this;
 }
Exemplo n.º 4
0
 public FileCollector addFile(FileObject fromFile, UnixFsObject.RegularFile file)
     throws IOException {
   specFile.addFile(file);
   fileCollector.addFile(fromFile, file);
   return this;
 }
Exemplo n.º 5
0
 public FileObject getRoot() {
   return fileCollector.getRoot();
 }