Skip to content

Commit

Permalink
Fix #37 Adding meaningful logging, when packageDescription in Debian is
Browse files Browse the repository at this point in the history
empty
  • Loading branch information
muuki88 committed Feb 1, 2014
1 parent 20e5aed commit acfd080
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,19 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
script
}


private[this] def prependAndFixPerms(script: File, lines: Seq[String], perms: LinuxFileMetaData): File = {
val old = IO.readLines(script)
IO.writeLines(script, lines ++ old, append = false)
chmod(script, perms.permissions)
script
}


private[this] def appendAndFixPerms(script: File, lines: Seq[String], perms: LinuxFileMetaData): File = {
IO.writeLines(script, lines, append = true)
chmod(script, perms.permissions)
script
}


private[this] def createFileIfRequired(script: File, perms: LinuxFileMetaData): File = {
if (!script.exists()) {
script.createNewFile()
Expand All @@ -65,7 +62,6 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
script
}


private[this] def scriptMapping(scriptName: String)(script: Option[File], controlDir: File): Seq[(File, String)] = {
(script, controlDir) match {
// check if user defined script exists
Expand All @@ -85,7 +81,6 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
}
}


def debianSettings: Seq[Setting[_]] = Seq(
debianPriority := "optional",
debianSection := "java",
Expand Down Expand Up @@ -131,6 +126,11 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
},
debianControlFile <<= (debianPackageMetadata, debianPackageInstallSize, target) map {
(data, size, dir) =>
if (data.info.description == null || data.info.description.isEmpty) {
sys.error(
"""packageDescription in Debian cannot be empty. Use
packageDescription in Debian := "My package Description"""")
}
val cfile = dir / Names.Debian / Names.Control
IO.write(cfile, data.makeContent(size), java.nio.charset.Charset.defaultCharset)
chmod(cfile, "0644")
Expand Down Expand Up @@ -208,8 +208,7 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {

val userGroupAdd = Seq(
TemplateWriter.generateScript(DebianPlugin.postinstGroupaddTemplateSource, replacements),
TemplateWriter.generateScript(DebianPlugin.postinstUseraddTemplateSource, replacements)
)
TemplateWriter.generateScript(DebianPlugin.postinstUseraddTemplateSource, replacements))

prependAndFixPerms(postinst, userGroupAdd, LinuxFileMetaData())

Expand Down Expand Up @@ -269,7 +268,6 @@ object DebianPlugin {
val Conffiles = "conffiles"
}


private def postinstGroupaddTemplateSource: java.net.URL = getClass.getResource("postinst-groupadd")
private def postinstUseraddTemplateSource: java.net.URL = getClass.getResource("postinst-useradd")
private def postinstChownTemplateSource: java.net.URL = getClass.getResource("postinst-chown")
Expand Down

0 comments on commit acfd080

Please sign in to comment.