Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First commit on #35 #53

Merged
merged 1 commit into from
Oct 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand All @@ -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)
}
Expand Down
19 changes: 14 additions & 5 deletions src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See how these don't specify "in Debian". That's one of oyur answers.

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second answer is here. We don't use "in Debian" anywhere here.

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,
Expand Down
7 changes: 4 additions & 3 deletions src/main/scala/com/typesafe/sbt/packager/debian/Keys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down