Skip to content

Commit

Permalink
Fixing scriptlets and adding tests
Browse files Browse the repository at this point in the history
- Ordering for userdel/groupdel is crucial
- fixed copy n paste errors
  • Loading branch information
muuki88 committed Mar 2, 2014
1 parent e26728e commit a33fcbf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/main/resources/com/typesafe/sbt/packager/rpm/postuninstall
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Adding system user/group : ${{daemon_user}} and ${{daemon_group}}
if ! getent group | grep -q "^${{daemon_group}}:" ;
# Removing system user/group : ${{daemon_user}} and ${{daemon_group}}
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}}"
userdel ${{daemon_user}}
fi
if getent group | grep -q "^${{daemon_group}}:" ;
then
echo "Deleting system group: ${{daemon_group}}"
groupdel ${{daemon_group}}
fi
if ! getent passwd | grep -q "^${{daemon_user}}:";
then
echo "Deleting system user: ${{daemon_user}}"
userdel ${{daemon_user}}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object JavaServerAppPackaging {
Some(pre.map(_ + "\n").getOrElse("") + scriptBits)
},
rpmPostun <<= (rpmPostun, linuxScriptReplacements) apply { (post, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.postinstTemplateSource, replacements)
val scriptBits = TemplateWriter.generateScript(RpmPlugin.postuninstallTemplateSource, replacements)
Some(post.map(_ + "\n").getOrElse("") + scriptBits)
}
)
Expand Down
10 changes: 7 additions & 3 deletions src/sbt-test/rpm/sysvinit-rpm/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ maintainer := "Josh Suereth <joshua.suereth@typesafe.com>"

packageSummary := "Test rpm package"

packageDescription := """A fun package description of our software,
with multiple lines."""
packageDescription := "Description"

rpmRelease := "1"

Expand All @@ -25,7 +24,12 @@ mainClass in (Compile, run) := Some("com.example.MainApp")

TaskKey[Unit]("unzipAndCheck") <<= (packageBin in Rpm, streams) map { (rpmFile, streams) =>
val rpmPath = Seq(rpmFile.getAbsolutePath)
Process("rpm2cpio" , rpmPath) #| Process("cpio -i --make-directories") ! streams.log
Process("rpm2cpio" , rpmPath) #| Process("cpio -i --make-directories") ! streams.log
val scriptlets = Process("rpm -qp --scripts " + rpmFile.getAbsolutePath) !! streams.log
assert(scriptlets contains "groupadd --system rpm-test", "groupadd not present in \n" + scriptlets)
assert(scriptlets contains "useradd --gid rpm-test --no-create-home --system -c 'Test rpm package' rpm-test", "Incorrect useradd command in \n" + scriptlets)
assert(scriptlets contains "groupdel rpm-test", "groupdel not present in \n" + scriptlets)
assert(scriptlets contains "userdel rpm-test", "userdel rpm not present in \n" + scriptlets)
// TODO check symlinks
()
}
Expand Down

0 comments on commit a33fcbf

Please sign in to comment.