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

Add Debian script header #231

Merged
merged 1 commit into from
Apr 21, 2014
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
1 change: 1 addition & 0 deletions src/main/resources/com/typesafe/sbt/packager/debian/header
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
(data, size, dir) =>
if (data.info.description == null || data.info.description.isEmpty) {
sys.error(
"""packageDescription in Debian cannot be empty. Use
"""packageDescription in Debian cannot be empty. Use
packageDescription in Debian := "My package Description"""")
}
val cfile = dir / Names.Debian / Names.Control
Expand Down Expand Up @@ -188,9 +188,13 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
streams.log info ("Altering postrm/postinst files to add user " + user + " and group " + group)
val postinst = createFileIfRequired(t / Names.Debian / Names.Postinst, LinuxFileMetaData())
val postrm = createFileIfRequired(t / Names.Debian / Names.Postrm, LinuxFileMetaData())
val prerm = createFileIfRequired(t / Names.Debian / Names.Prerm, LinuxFileMetaData())
val headerScript = IO.readLinesURL(DebianPlugin.headerSource)

val replacements = Seq("group" -> group, "user" -> user)

prependAndFixPerms(prerm, headerScript, LinuxFileMetaData())

// remove key, flatten it and then go through each file
pathList.map(_._2).flatten foreach {
case (_, target) =>
Expand All @@ -207,9 +211,11 @@ trait DebianPlugin extends Plugin with linux.LinuxPlugin {
TemplateWriter.generateScript(DebianPlugin.postinstUseraddTemplateSource, replacements))

prependAndFixPerms(postinst, userGroupAdd, LinuxFileMetaData())
prependAndFixPerms(postinst, headerScript, LinuxFileMetaData())

val purgeAdd = Seq(TemplateWriter.generateScript(DebianPlugin.postrmPurgeTemplateSource, replacements))
appendAndFixPerms(postrm, purgeAdd, LinuxFileMetaData())
prependAndFixPerms(postrm, headerScript, LinuxFileMetaData())
}
t
},
Expand Down Expand Up @@ -268,4 +274,5 @@ object DebianPlugin {
private def postinstUseraddTemplateSource: java.net.URL = getClass.getResource("postinst-useradd")
private def postinstChownTemplateSource: java.net.URL = getClass.getResource("postinst-chown")
private def postrmPurgeTemplateSource: java.net.URL = getClass.getResource("postrm-purge")
private def headerSource: java.net.URL = getClass.getResource("header")
}