Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #324 adding empty dirs to deb package #325

Merged
merged 3 commits into from
Aug 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ package debian

import Keys._
import sbt._
import sbt.Keys.{ target, name, normalizedName, TaskStreams }
import linux.{ LinuxFileMetaData, LinuxPackageMapping, LinuxSymlink }
import linux.Keys.{ linuxScriptReplacements, daemonShell }
import sbt.Keys.{ target, normalizedName }
import linux.{ LinuxSymlink }
import com.typesafe.sbt.packager.linux.LinuxPackageMapping
import scala.collection.JavaConversions._

Expand Down Expand Up @@ -63,12 +62,11 @@ trait JDebPackaging { this: DebianPlugin with linux.LinuxPlugin =>
*/
private[debian] def fileAndDirectoryProducers(mappings: Seq[LinuxPackageMapping], target: File): Seq[DataProducer] = mappings.map {
case LinuxPackageMapping(paths, perms, zipped) =>
// TODO implement mappers here or use the maintainerscripts logic?
val (dirs, files) = paths.partition(_._1.isDirectory)
paths map {
case (path, name) if path.isDirectory =>
val permMapper = new PermMapper(-1, -1, perms.user, perms.group, null, perms.permissions, -1, null)
new DataProducerDirectory(target / name, null, Array("**"), Array(permMapper))
val dirName = if (name.startsWith("/")) name.drop(1) else name
new DataProducerDirectory(target, Array(dirName), null, Array(permMapper))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look wrong, but doesn't look correct either :/ So we have

pDir = target
pIncludes = Array(dirName)
pExclues = null // nothing to exclude
pMapper = Array(permMapper)

This means that if you add a directory producer with an empty directory and exclude all it's contents (the way before), the empty directory doesn't get created? Sounds for me more like a bug in jdeb. @tcurdt @ebourg may know more about this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've dug into jdeb sources before I could get it works)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought so :( Well, as this is a bit mysterious after all, we should really add tests for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already done)

case (path, name) =>
val permMapper = new PermMapper(-1, -1, perms.user, perms.group, perms.permissions, null, -1, null)
new DataProducerFile(target / name, name, null, null, Array(permMapper))
Expand Down
40 changes: 40 additions & 0 deletions src/sbt-test/debian/jdeb-dir-mappings/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import NativePackagerKeys._

packagerSettings

mapGenericFilesToLinux

name := "debian-test"

version := "0.1.0"

maintainer := "Josh Suereth <joshua.suereth@typesafe.com>"

packageSummary := "Test debian package"

packageDescription := """A fun package description of our software,
with multiple lines."""

debianPackageDependencies in Debian ++= Seq("java2-runtime", "bash (>= 2.05a-11)")

debianPackageRecommends in Debian += "git"

linuxPackageMappings in Debian += packageDirectoryAndContentsMapping(
(baseDirectory.value / "src" / "resources" / "conf") -> "/usr/share/conf")

linuxPackageMappings in Debian += packageDirectoryAndContentsMapping(
(baseDirectory.value / "src" / "resources" / "empty") -> "/var/empty")

packageBin in Debian <<= debianJDebPackaging in Debian

TaskKey[Unit]("check-dir-mappings") <<= (target, streams) map { (target, out) =>
// val tmpDir = java.nio.file.Files.createTempDirectory("jdeb")
val extracted = file("/tmp/jdeb" + System.currentTimeMillis().toString)
Seq("dpkg-deb", "-R", (target / "debian-test_0.1.0_all.deb").absolutePath, extracted.absolutePath).!
assert((extracted / "usr/share/conf/application.conf").exists(), "File application.conf not exists")
assert((extracted / "usr/share/conf/log4j.properties").exists(), "File log4j.properties not exists")
assert((extracted / "var/empty").exists(), "Empty dir not exists")
extracted.delete()
out.log.success("Successfully tested control script")
()
}
1 change: 1 addition & 0 deletions src/sbt-test/debian/jdeb-dir-mappings/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
5 changes: 5 additions & 0 deletions src/sbt-test/debian/jdeb-dir-mappings/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Run the debian packaging.
$ mkdir src/resources/empty
> debian:package-bin
$ exists target/debian-test_0.1.0_all.deb
> check-dir-mappings