diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala b/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala index c037fde3b..b5a109150 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala @@ -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._ @@ -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)) 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)) diff --git a/src/sbt-test/debian/jdeb-dir-mappings/build.sbt b/src/sbt-test/debian/jdeb-dir-mappings/build.sbt new file mode 100644 index 000000000..a59e4f1d3 --- /dev/null +++ b/src/sbt-test/debian/jdeb-dir-mappings/build.sbt @@ -0,0 +1,40 @@ +import NativePackagerKeys._ + +packagerSettings + +mapGenericFilesToLinux + +name := "debian-test" + +version := "0.1.0" + +maintainer := "Josh Suereth " + +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") + () +} diff --git a/src/sbt-test/debian/jdeb-dir-mappings/project/plugins.sbt b/src/sbt-test/debian/jdeb-dir-mappings/project/plugins.sbt new file mode 100644 index 000000000..b53de154c --- /dev/null +++ b/src/sbt-test/debian/jdeb-dir-mappings/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) diff --git a/src/sbt-test/debian/jdeb-dir-mappings/src/resources/conf/application.conf b/src/sbt-test/debian/jdeb-dir-mappings/src/resources/conf/application.conf new file mode 100644 index 000000000..e69de29bb diff --git a/src/sbt-test/debian/jdeb-dir-mappings/src/resources/conf/log4j.properties b/src/sbt-test/debian/jdeb-dir-mappings/src/resources/conf/log4j.properties new file mode 100644 index 000000000..e69de29bb diff --git a/src/sbt-test/debian/jdeb-dir-mappings/test b/src/sbt-test/debian/jdeb-dir-mappings/test new file mode 100644 index 000000000..eaac4b35b --- /dev/null +++ b/src/sbt-test/debian/jdeb-dir-mappings/test @@ -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