diff --git a/src/sbt-test/debian/log-directory/build.sbt b/src/sbt-test/debian/log-directory/build.sbt new file mode 100644 index 000000000..b747c60ec --- /dev/null +++ b/src/sbt-test/debian/log-directory/build.sbt @@ -0,0 +1,40 @@ +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.LinkOption.NOFOLLOW_LINKS + +import NativePackagerKeys._ +import com.typesafe.sbt.packager.archetypes.ServerLoader + +packageArchetype.java_server + +serverLoading in Debian := ServerLoader.Upstart + +daemonUser in Debian := "root" + +mainClass in Compile := Some("empty") + +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.""" + +defaultLinuxLogsLocation := "/non-standard/log" + +InputKey[Unit]("check-softlink") <<= inputTask { (argTask: TaskKey[Seq[String]]) => + (argTask) map { (args: Seq[String]) => + assert(args.size >= 2, "Usage: check-softlink link to target") + val link = Paths.get(args(0)) + val target = Paths.get(args(args.size - 1)) + assert(Files.exists(link, NOFOLLOW_LINKS), + "Expected symbolic link '" + link + "' does not exist") + assert(Files.isSymbolicLink(link), "'" + link + "' should be a symbolic link") + assert(Files.readSymbolicLink(link) equals target, + "Symbolic link '" + link + "' should point to '" + target + "'") + } +} diff --git a/src/sbt-test/debian/log-directory/project/plugins.sbt b/src/sbt-test/debian/log-directory/project/plugins.sbt new file mode 100644 index 000000000..b53de154c --- /dev/null +++ b/src/sbt-test/debian/log-directory/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) diff --git a/src/sbt-test/debian/log-directory/test b/src/sbt-test/debian/log-directory/test new file mode 100644 index 000000000..d237b92bd --- /dev/null +++ b/src/sbt-test/debian/log-directory/test @@ -0,0 +1,15 @@ +# Run the debian packaging. +> debian:package-bin +$ exists target/debian-test-0.1.0.deb + +$ exists target/debian-test-0.1.0/etc +$ exists target/debian-test-0.1.0/etc/default/debian-test +$ exists target/debian-test-0.1.0/etc/init/debian-test.conf + +# Check defaults +$ exists target/debian-test-0.1.0/DEBIAN/prerm +$ exists target/debian-test-0.1.0/DEBIAN/postinst + +# Check that the non-standard log directory was used +$ exists target/debian-test-0.1.0/non-standard/log/debian-test +> check-softlink target/debian-test-0.1.0/usr/share/debian-test/logs points to /non-standard/log/debian-test