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

Fixing scriptlets and adding tests #177

Merged
merged 1 commit into from
Mar 2, 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
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