From 45b71f2e21f177549809c7a9444408875466c828 Mon Sep 17 00:00:00 2001 From: Hermann Schwarting Date: Sun, 2 Feb 2014 19:18:27 +0100 Subject: [PATCH 1/2] Use defaultLinuxLogsLocation for /var/log Log directory 'logs' in the installation directory is soft-linked to /var/log/app-name/. Instead of hard coding /var/log use the already provided variable defaultLinuxLogsLocation. --- .../sbt/packager/archetypes/JavaServerApplication.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala index e6617f38e..a9c8d4619 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala @@ -88,8 +88,8 @@ object JavaServerAppPackaging { d.mkdirs() LinuxPackageMapping(Seq(d -> (logsDir + "/" + name)), LinuxFileMetaData(user, group)) }, - linuxPackageSymlinks in Debian <+= (normalizedName, defaultLinuxInstallLocation) map { - (name, install) => LinuxSymlink(install + "/" + name + "/logs", "/var/log/" + name) + linuxPackageSymlinks in Debian <+= (normalizedName, defaultLinuxInstallLocation, defaultLinuxLogsLocation) map { + (name, install, logsDir) => LinuxSymlink(install + "/" + name + "/logs", logsDir + "/" + name) }, // === Maintainer scripts === From 6628136cbb08448450228d2798535effb25cefce Mon Sep 17 00:00:00 2001 From: Hermann Schwarting Date: Sun, 2 Feb 2014 19:25:27 +0100 Subject: [PATCH 2/2] Add test for defaultLinuxLogsLocation Add a new test 'debian/log-directory' to check that a custom setting for defaultLinuxLogsLocation is correctly applied. --- src/sbt-test/debian/log-directory/build.sbt | 37 +++++++++++++++++++ .../debian/log-directory/project/plugins.sbt | 1 + src/sbt-test/debian/log-directory/test | 15 ++++++++ 3 files changed, 53 insertions(+) create mode 100644 src/sbt-test/debian/log-directory/build.sbt create mode 100644 src/sbt-test/debian/log-directory/project/plugins.sbt create mode 100644 src/sbt-test/debian/log-directory/test 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..30b643a5c --- /dev/null +++ b/src/sbt-test/debian/log-directory/build.sbt @@ -0,0 +1,37 @@ +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 = args(0) + val target = args(args.size - 1) + val absolutePath = ("readlink -m " + link).!!.trim + assert(link != absolutePath, + "Expected symbolic link '" + link + "' does not exist") + assert(target == absolutePath, + "Expected symbolic link '" + link + "' to point to '" + + target + "', but instead it's '" + absolutePath + "'") + } +} 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