Skip to content

Commit

Permalink
Omit Depends: from control file if not set. Fixes tcurdt#208
Browse files Browse the repository at this point in the history
  • Loading branch information
rspieldenner committed May 7, 2015
1 parent bf9f330 commit 5152ce9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/java/org/vafer/jdeb/DebMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public class DebMaker {
/** The section of the package. Default value if not specified in the control file */
private String section = "java";

/** The dependencies of the package. Default value if not specified in the control file */
private String depends = "default-jre | java6-runtime";
/** The dependencies of the package. */
private String depends;

/** The description of the package. Default value if not specified in the control file */
private String description;
Expand Down Expand Up @@ -444,9 +444,6 @@ public BinaryPackageControlFile createSignedDeb(Compression compression, final P
if (packageControlFile.get("Package") == null) {
packageControlFile.set("Package", packageName);
}
if (packageControlFile.get("Depends") == null) {
packageControlFile.set("Depends", depends);
}
if (packageControlFile.get("Section") == null) {
packageControlFile.set("Section", section);
}
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/org/vafer/jdeb/DebMakerTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,40 @@ public void visit(TarArchiveEntry entry, byte[] content) throws IOException {
assertFalse("Variables not replaced in the control file " + entry.getName(), body.contains("[[name]] [[version]]"));
assertTrue("Expected variables not found in the control file " + entry.getName(), body.contains("jdeb 1.0"));
}
if (entry.getName().contains("control")) {
String control = new String(content, "ISO-8859-1");
assertTrue("Depends missing" + entry.getName(), control.contains("Depends: some-package"));
}
}
});

assertTrue("Control files not found in the package", found);
}

public void testDependsIsOmittedWhenEmpty() throws Exception {
File deb = new File("target/test-classes/test-control.deb");
if (deb.exists() && !deb.delete()) {
fail("Couldn't delete " + deb);
}

Collection<DataProducer> producers = Arrays.asList(new DataProducer[] {new EmptyDataProducer()});
Collection<DataProducer> conffileProducers = Arrays.asList(new DataProducer[] {new EmptyDataProducer()});
DebMaker maker = new DebMaker(new NullConsole(), producers, conffileProducers);
maker.setDeb(deb);
maker.setControl(new File("target/test-classes/org/vafer/jdeb/deb/controlwithoutdepends"));

maker.createDeb(Compression.NONE);

// now reopen the package and check the control files
assertTrue("package not build", deb.exists());

boolean found = ArchiveWalker.walkControl(deb, new ArchiveVisitor<TarArchiveEntry>() {
public void visit(TarArchiveEntry entry, byte[] content) throws IOException {
if (entry.getName().contains("control")) {
String control = new String(content, "ISO-8859-1");
assertFalse("Depends should be omitted" + entry.getName(), control.contains("Depends:"));
}
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Package: controlwithoutdepends
Version: 1.0.1
Section: misc
Priority: optional
Architecture: i386
Maintainer: John Doe <[email protected]>
Distribution: development
Description: revision @REVISION@, test package
This is a sample package control file.
.
Use for testing purposes only.
XB-UserDefinedField: This is a user defined field.

0 comments on commit 5152ce9

Please sign in to comment.