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

Fix #37 Adding meaningful logging, when packageDescription in Debian is #146

Merged
merged 1 commit into from
Feb 1, 2014
Merged
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 @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

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

cool. I wonder if we need to consolidate validation errors in one spot at some point. This is a good place right now, but perhaps the debianPackageMetadata can directly have a 'validate' which returns Seq[validatorError] at some point...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my first thought, too. Then I stopped as the PackageMetadata is really a "stupid" information container and the validation if the container is ok, should be done somewhere else.

This should be adressed somehow ;)

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