Пример #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();
  }
Пример #2
0
  public FileCollector addSymlink(UnixFsObject.Symlink symlink) throws IOException {
    specFile.addSymlink(symlink);
    fileCollector.addSymlink(symlink);

    return this;
  }
Пример #3
0
 public FileCollector addDirectory(UnixFsObject.Directory directory) throws IOException {
   specFile.addDirectory(directory);
   fileCollector.addDirectory(directory);
   return this;
 }
Пример #4
0
 public FileCollector addFile(FileObject fromFile, UnixFsObject.RegularFile file)
     throws IOException {
   specFile.addFile(file);
   fileCollector.addFile(fromFile, file);
   return this;
 }
Пример #5
0
 public FileObject getRoot() {
   return fileCollector.getRoot();
 }