Skip to content

Commit

Permalink
FIX #405: Script replacements doesn't work with jdeb packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
kardapoltsev committed Nov 11, 2014
1 parent 60c5e90 commit 087840f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package debian
import sbt._
import sbt.Keys.{ target, normalizedName, version, streams, mappings, packageBin }
import linux.{ LinuxSymlink, LinuxPackageMapping, LinuxFileMetaData }
import linux.LinuxPlugin.autoImport.{ linuxPackageMappings, linuxPackageSymlinks, packageArchitecture }
import linux.LinuxPlugin.autoImport.{ linuxPackageMappings, linuxPackageSymlinks, packageArchitecture, linuxScriptReplacements }
import scala.collection.JavaConversions._
import org.vafer.jdeb.{ DebMaker, DataProducer }
import org.vafer.jdeb.mapping._
Expand Down Expand Up @@ -67,9 +67,14 @@ object JDebPackaging extends AutoPlugin with DebianPluginLike {
val controlDir = targetDir / Names.Debian
val control = debianControlFile.value
val conffile = debianConffilesFile.value
val replacements = debianMakeChownReplacements.value +: linuxScriptReplacements.value

val controlScripts = debianMaintainerScripts.value
controlScripts foreach { case (file, script) => IO.copyFile(file, controlDir / script) }
for ((file, name) <- controlScripts) {
val targetFile = controlDir / name
copyAndFixPerms(file, targetFile, LinuxFileMetaData())
filterAndFixPerms(targetFile, replacements, LinuxFileMetaData())
}

log.info("Building debian package with java based implementation 'jdeb'")
val console = new JDebConsole(log)
Expand Down
29 changes: 29 additions & 0 deletions src/sbt-test/debian/jdeb-script-replacements/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
enablePlugins(JavaServerAppPackaging, JDebPackaging)

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"

TaskKey[Unit]("check-control-files") <<= (target, streams) map { (target, out) =>
val header = "#!/bin/sh"
val debian = target / "debian-test-0.1.0" / "DEBIAN"
val postinst = IO.read(debian / "postinst")
val postrm = IO.read(debian / "postrm")
Seq(postinst, postrm) foreach { script =>
assert(script.startsWith(header), "script doesn't start with #!/bin/sh header:\n" + script)
assert(header.r.findAllIn(script).length == 1, "script contains more than one header line:\n" + script)
}
out.log.success("Successfully tested systemV control files")
()
}
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-script-replacements/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-control-files

0 comments on commit 087840f

Please sign in to comment.