From e88a018b84c809995177d7aed8bcc29d0b994a16 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Fri, 25 Oct 2013 00:43:13 +0200 Subject: [PATCH] First commit on #35 This doesn't work: debianMakePrermScript in Debian := Some(baseDirectory.value / "debian" / "prerm") (Changed some typos) --- .../archetypes/JavaAppUpstartScript.scala | 3 +-- .../archetypes/JavaServerApplication.scala | 12 ++++++------ .../sbt/packager/debian/DebianPlugin.scala | 19 ++++++++++++++----- .../typesafe/sbt/packager/debian/Keys.scala | 7 ++++--- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala index 03119ffd1..071405dbc 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala @@ -39,8 +39,7 @@ object JavaAppUpstartScript { def generateScript(replacements: Seq[(String, String)]): String = TemplateWriter.generateScript(upstartTemplateSource, replacements) - - def generatePrerem(appName: String): String = + def generatePrerm(appName: String): String = TemplateWriter.generateScript(preremTemplateSource, Seq("app_name" -> appName)) def generatePostinst(appName: String): String = TemplateWriter.generateScript(postinstTemplateSource, Seq("app_name" -> appName)) 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 4b22d7f62..6196ad38e 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala @@ -23,9 +23,9 @@ object JavaServerAppPackaging { def settings: Seq[Setting[_]] = JavaAppPackaging.settings ++ - debianUpstartSetttings + debianUpstartSettings - def debianUpstartSetttings: Seq[Setting[_]] = + def debianUpstartSettings: Seq[Setting[_]] = Seq( debianUpstartScriptReplacements <<= (maintainer in Debian, packageSummary in Debian, normalizedName, sbt.Keys.version) map { (author, descr, name, version) => // TODO name-version is copied from UniversalPlugin. This should be consolidated into a setting (install location...) @@ -39,12 +39,12 @@ object JavaServerAppPackaging { } yield LinuxPackageMapping(Seq(s -> ("/etc/init/" + name + ".conf"))).withPerms("0644") }, // TODO - only make these if the upstart config exists... - debianMakePreremScript <<= (normalizedName, target in Universal) map makeDebianPreremScript, + debianMakePrermScript <<= (normalizedName, target in Universal) map makeDebianPrermScript, debianMakePostinstScript <<= (normalizedName, target in Universal) map makeDebianPostinstScript) - private[this] final def makeDebianPreremScript(name: String, tmpDir: File): Option[File] = { - val scriptBits = JavaAppUpstartScript.generatePrerem(name) - val script = tmpDir / "tmp" / "bin" / "debian-prerem" + private[this] final def makeDebianPrermScript(name: String, tmpDir: File): Option[File] = { + val scriptBits = JavaAppUpstartScript.generatePrerm(name) + val script = tmpDir / "tmp" / "bin" / "debian-prerm" IO.write(script, scriptBits) Some(script) } diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala index a1f5caeab..6de92cbba 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala @@ -44,18 +44,27 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin { packageSummary in Debian <<= packageSummary in Linux, maintainer in Debian <<= maintainer in Linux, debianMaintainerScripts := Seq.empty, - debianMakePreremScript := None, + debianMakePreinstScript := None, + debianMakePrermScript := None, debianMakePostinstScript := None, + debianMakePostrmScript := None, // TODO - We should make sure there isn't one already specified... - debianMaintainerScripts <++= debianMakePreremScript map { - case Some(script) => Seq(script -> "prerem") + debianMaintainerScripts <++= debianMakePreinstScript map { + case Some(script) => Seq(script -> "preinst") + case None => Seq.empty + }, + debianMaintainerScripts <++= debianMakePrermScript map { + case Some(script) => Seq(script -> "prerm") case None => Seq.empty }, debianMaintainerScripts <++= debianMakePostinstScript map { case Some(script) => Seq(script -> "postinst") case None => Seq.empty - } - ) ++ inConfig(Debian)(Seq( + }, + debianMaintainerScripts <++= debianMakePostrmScript map { + case Some(script) => Seq(script -> "postrm") + case None => Seq.empty + }) ++ inConfig(Debian)(Seq( packageArchitecture := "all", debianPackageInfo <<= (name, version, maintainer, packageSummary, packageDescription) apply PackageInfo, diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/Keys.scala b/src/main/scala/com/typesafe/sbt/packager/debian/Keys.scala index 9535a9c9a..ad9d44c92 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/Keys.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/Keys.scala @@ -28,9 +28,10 @@ trait DebianKeys { val debianSign = TaskKey[File]("debian-sign", "runs the dpkg-sig command to sign the generated deb file.") val debianSignRole = SettingKey[String]("debian-sign-role", "The role to use when signing a debian file (defaults to 'builder').") - - val debianMakePreremScript = TaskKey[Option[File]]("makePreremScript", "Creates or discovers the upstart script used by this project") - val debianMakePostinstScript = TaskKey[Option[File]]("makePostInstScript", "Creates or discovers the upstart script used by this project") + val debianMakePreinstScript = TaskKey[Option[File]]("makePreinstScript", "Creates or discovers the preinst script used by this project") + val debianMakePrermScript = TaskKey[Option[File]]("makePrermScript", "Creates or discovers the prerm script used by this project") + val debianMakePostinstScript = TaskKey[Option[File]]("makePostInstScript", "Creates or discovers the postinst script used by this project") + val debianMakePostrmScript = TaskKey[Option[File]]("makePostrmScript", "Creates or discovers the postrm script used by this project") val debianMakeUpstartScript = TaskKey[Option[File]]("makeUpstartScript", "Creates or discovers the upstart script used by this project") val debianUpstartScriptReplacements = TaskKey[Seq[(String, String)]]("upstartScriptReplacements", """|Replacements of template parameters used in the upstart script.