public void testBasic() throws Exception {
    if (!Dpkg.available()) {
      return;
    }

    DebPackagingFormat packagingFormat = (DebPackagingFormat) lookup(PackagingFormat.ROLE, "deb");

    FileObject dpkgTest = VFS.getManager().resolveFile(getTestPath("target/deb-test"));
    FileObject packageRoot = dpkgTest.resolveFile("root");
    File packageFile = VfsUtil.asFile(dpkgTest.resolveFile("file.deb"));

    PackageVersion version = packageVersion("1.0", "123", false, some("1"));
    PackageParameters parameters =
        packageParameters(
                "mygroup",
                "myartifact",
                version,
                "id",
                "default-name",
                Option.<java.lang.String>none(),
                EMPTY,
                EMPTY)
            .contact("Kurt Cobain")
            .architecture("all");

    List<String> nil = List.nil();
    packagingFormat
        .start()
        .parameters(parameters)
        .debParameters(Option.<String>none(), some("devel"), false, nil, nil, nil, nil, nil, nil)
        .debug(true)
        .workingDirectory(packageRoot)
        .packageToFile(packageFile, ScriptUtil.Strategy.SINGLE);

    assertTrue(packageFile.canRead());
  }
예제 #2
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();
  }