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 #855 Syntax Error on RPM Uninstall #860

Merged
merged 1 commit into from
Aug 7, 2016
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 @@ -10,11 +10,12 @@ then
echo "Try deleting system user and group [${{daemon_user}}:${{daemon_group}}]"
if getent passwd | grep -q "^${{daemon_user}}:";
then
echo "Deleting system user: ${{daemon_user}}"
deleteUser ${{daemon_user}}
echo "Deleting system user: ${{daemon_user}}"
deleteUser ${{daemon_user}}
fi
if getent group | grep -q "^${{daemon_group}}:" ;
then
echo "Deleting system group: ${{daemon_group}}"
deleteGroup ${{daemon_group}}
echo "Deleting system group: ${{daemon_group}}"
deleteGroup ${{daemon_group}}
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ object SystemloaderPlugin extends AutoPlugin {
maintainerScripts.value,
linuxScriptReplacements.value
)(
DebianConstants.Postinst -> s"""|# ${serverLoading.value} support
DebianConstants.Postinst -> s"""|# ${getOrUnsupported(serverLoading.value)} support
|$${{loader-functions}}
|${addAndStartService(serviceAutostart.value)}
|""".stripMargin,
DebianConstants.Prerm -> s"""|# ${serverLoading.value} support
DebianConstants.Prerm -> s"""|# ${getOrUnsupported(serverLoading.value)} support
|$${{loader-functions}}
|stopService $${{app_name}} || echo "$${{app_name}} wasn't even running!"
|""".stripMargin
Expand All @@ -109,7 +109,7 @@ object SystemloaderPlugin extends AutoPlugin {
maintainerScripts.value,
linuxScriptReplacements.value
)(
RpmConstants.Post -> s"""|# ${serverLoading.value} support
RpmConstants.Post -> s"""|# ${getOrUnsupported(serverLoading.value)} support
|$${{loader-functions}}
|# Scriptlet syntax: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Syntax
|# $$1 == 1 is first installation and $$1 == 2 is upgrade
Expand All @@ -118,12 +118,13 @@ object SystemloaderPlugin extends AutoPlugin {
|${addAndStartService(serviceAutostart.value, " ")}
|fi
|""".stripMargin,
RpmConstants.Postun -> s"""|# ${serverLoading.value} support
|if [ $$1 -ge 1 ]
RpmConstants.Postun -> s"""|# ${getOrUnsupported(serverLoading.value)} support
|if [ $$1 -ge 1 ] ;
|then
| restartService $${{app_name}} || echo "Failed to try-restart $${{app_name}}"
|fi
|""".stripMargin,
RpmConstants.Preun -> s"""|# ${serverLoading.value} support
RpmConstants.Preun -> s"""|# ${getOrUnsupported(serverLoading.value)} support
|$${{loader-functions}}
|if [ $$1 -eq 0 ] ;
|then
Expand Down Expand Up @@ -162,4 +163,6 @@ object SystemloaderPlugin extends AutoPlugin {
)
}

private def getOrUnsupported(serverLoader: Option[ServerLoader]): String = serverLoader.map(_.toString).getOrElse("No system loader")

}
9 changes: 4 additions & 5 deletions src/sbt-test/rpm/sysvinit-rpm/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


enablePlugins(JavaServerAppPackaging, SystemVPlugin)

name := "rpm-test"
Expand Down Expand Up @@ -40,7 +42,6 @@ TaskKey[Unit]("unzipAndCheck") <<= (baseDirectory, packageBin in Rpm, streams) m

TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec")
println(spec)
assert(spec contains "addGroup rpm-test", "addGroup not present in \n" + spec)
assert(spec contains "addUser rpm-test", "Incorrect useradd command in \n" + spec)
assert(spec contains "deleteGroup rpm-test", "deleteGroup not present in \n" + spec)
Expand Down Expand Up @@ -126,7 +127,6 @@ TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>

TaskKey[Unit]("check-spec-autostart") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec")
println(spec)
assert(spec contains
"""
|# Scriptlet syntax: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Syntax
Expand All @@ -141,9 +141,8 @@ TaskKey[Unit]("check-spec-autostart") <<= (target, streams) map { (target, out)
()
}

TaskKey[Unit]("check-spec-no-autostart") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec")
println(spec)
TaskKey[Unit]("check-spec-no-autostart") := {
val spec = IO.read(target.value / "rpm" / "SPECS" / "rpm-test.spec")
assert(spec contains
"""
|# Scriptlet syntax: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Syntax
Expand Down