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

Adding additional features for rpm #187

Merged
merged 1 commit into from
Mar 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# ${{app_name}} <${{app_name}}>
#
# chkconfig: - 20 80
# chkconfig: 2345 20 80
# description: ${{descr}}
#

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service ${{app_name}} start
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ if ! getent passwd | grep -q "^${{daemon_user}}:";
then
echo "Creating system user: ${{daemon_user}}"
useradd --gid ${{daemon_group}} --no-create-home --system -c '${{descr}}' ${{daemon_user}}
fi
fi
3 changes: 3 additions & 0 deletions src/main/resources/com/typesafe/sbt/packager/rpm/preuninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Halting ${{app_name}}
echo "Shutdown ${{app_name}}"
service ${{app_name}} stop
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ object JavaServerAppPackaging {
def linuxSettings: Seq[Setting[_]] = Seq(
// This one is begging for sbt 0.13 syntax...
linuxScriptReplacements <<= (
// TODO do we need to separated rpm and debian maintainers?
Copy link
Member

Choose a reason for hiding this comment

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

We may, I think the strings have different 'canonical' formats, although we sort of ignore that now...

maintainer in Linux, packageSummary in Linux, daemonUser in Linux, daemonGroup in Linux, normalizedName,
sbt.Keys.version, defaultLinuxInstallLocation, linuxJavaAppStartScriptBuilder in Debian)
apply { (author, descr, daemonUser, daemonGroup, name, version, installLocation, builder) =>
Expand Down Expand Up @@ -117,12 +118,20 @@ object JavaServerAppPackaging {
// == Maintainer scripts ===
// TODO this is very basic - align debian and rpm plugin
rpmPre <<= (rpmPre, linuxScriptReplacements) apply { (pre, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.preinstTemplateSource, replacements)
Some(pre.map(_ + "\n").getOrElse("") + scriptBits)
Copy link
Member

Choose a reason for hiding this comment

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

What's this about?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, got it. You have to embed the script into the RPMSPEC, right.

},
rpmPost <<= (rpmPost, linuxScriptReplacements) apply { (pre, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.postinstTemplateSource, replacements)
Some(pre.map(_ + "\n").getOrElse("") + scriptBits)
},
rpmPostun <<= (rpmPostun, linuxScriptReplacements) apply { (post, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.postuninstallTemplateSource, replacements)
Some(post.map(_ + "\n").getOrElse("") + scriptBits)
},
rpmPreun <<= (rpmPostun, linuxScriptReplacements) apply { (post, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.preuninstallTemplateSource, replacements)
Some(post.map(_ + "\n").getOrElse("") + scriptBits)
}
)

Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ trait RpmPlugin extends Plugin with LinuxPlugin {

object RpmPlugin {

def preinstTemplateSource: java.net.URL = getClass.getResource("preinstall")
def postinstTemplateSource: java.net.URL = getClass.getResource("postinstall")
def preuninstallTemplateSource: java.net.URL = getClass.getResource("preuninstall")
def postuninstallTemplateSource: java.net.URL = getClass.getResource("postuninstall")
def postinstTemplateSource: java.net.URL = getClass.getResource("preinstall")
}