예제 #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 RpmUnixPackage parameters(PackageParameters parameters) {
    if (parameters.license.isNone()) {
      throw new MissingSettingException("The project has to specify a license.");
    }

    specFile = new SpecFile();
    specFile.name = parameters.id;
    specFile.summary = parameters.name;
    specFile.description = parameters.description.orSome(""); // TODO: This is not right
    specFile.license = parameters.license.some();
    specFile.buildArch = parameters.architecture.orSome("noarch");

    P2<String, String> rpmVersion = getRpmVersion(parameters.version);
    specFile.version = rpmVersion._1();
    specFile.release = rpmVersion._2();

    return this;
  }
예제 #3
0
 public void beforeAssembly(FileAttributes defaultDirectoryAttributes) throws IOException {
   specFile.beforeAssembly(directory(BASE, new LocalDateTime(), defaultDirectoryAttributes));
   fileCollector = new FsFileCollector(workingDirectory.resolveFile("assembly"));
 }
예제 #4
0
 public UnixPackage group(String group) {
   specFile.group = group;
   return this;
 }
예제 #5
0
 public void apply(F2<UnixFsObject, FileAttributes, FileAttributes> f) {
   specFile.apply(f);
 }
예제 #6
0
  public FileCollector addSymlink(UnixFsObject.Symlink symlink) throws IOException {
    specFile.addSymlink(symlink);
    fileCollector.addSymlink(symlink);

    return this;
  }
예제 #7
0
 public FileCollector addFile(FileObject fromFile, UnixFsObject.RegularFile file)
     throws IOException {
   specFile.addFile(file);
   fileCollector.addFile(fromFile, file);
   return this;
 }
예제 #8
0
 public FileCollector addDirectory(UnixFsObject.Directory directory) throws IOException {
   specFile.addDirectory(directory);
   fileCollector.addDirectory(directory);
   return this;
 }