Skip to content

Commit

Permalink
Fixing error with brpJavaRepack setting and add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 committed Apr 10, 2014
1 parent 3b7c243 commit d76f6f3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin {
rpmDependencies <<=
(rpmProvides, rpmRequirements, rpmPrerequisites, rpmObsoletes, rpmConflicts) apply RpmDependencies,
rpmPre <<= (rpmPre, rpmBrpJavaRepackJars) apply {
case (_, true) => None
case (pre, true) => pre
case (pre, false) =>
val scriptBits = IO.readStream(RpmPlugin.osPostInstallMacro.openStream, Charset forName "UTF-8")
Some(pre.map(_ + "\n").getOrElse("") + scriptBits)
Expand Down
2 changes: 2 additions & 0 deletions src/sbt-test/rpm/scriptlets-override-build-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ $ exists target/rpm/SPECS/rpm-test.spec

# Check files for defaults
> check-spec-file
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> check-spec-file
9 changes: 9 additions & 0 deletions src/sbt-test/rpm/scriptlets-override-rpm/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ TaskKey[Unit]("unzipAndCheck") <<= (packageBin in Rpm, streams) map { (rpmFile,
()
}

TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec")
assert(spec contains "echo postinst", "'echo 'postinst' not present in \n" + spec)
assert(spec contains "echo preinst", "'echo 'preinst' not present in \n" + spec)
assert(spec contains "echo postun", "'echo 'postun' not present in \n" + spec)
assert(spec contains "echo preun", "'echo 'preun' not present in \n" + spec)
()
}

5 changes: 5 additions & 0 deletions src/sbt-test/rpm/scriptlets-override-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ $ exists var/log/rpm-test
$ exists var/run/rpm-test

# TODO symlinks aren't checked

> check-spec-file
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> check-spec-file

2 changes: 2 additions & 0 deletions src/sbt-test/rpm/scriptlets-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ $ exists target/rpm/SPECS/rpm-test.spec
# Check files for defaults
> check-spec-file
> check-rpm-version
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> check-spec-file
8 changes: 8 additions & 0 deletions src/sbt-test/rpm/sysvinit-rpm/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ TaskKey[Unit]("unzipAndCheck") <<= (packageBin in Rpm, streams) map { (rpmFile,
()
}

TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec")
assert(spec contains "groupadd --system rpm-test", "groupadd not present in \n" + spec)
assert(spec contains "useradd --gid rpm-test --no-create-home --system -c 'Test rpm package' rpm-test", "Incorrect useradd command in \n" + spec)
assert(spec contains "groupdel rpm-test", "groupdel not present in \n" + spec)
assert(spec contains "userdel rpm-test", "userdel rpm not present in \n" + spec)
()
}
5 changes: 5 additions & 0 deletions src/sbt-test/rpm/sysvinit-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
> rpm:package-bin
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm

> check-spec-file

# Check rpm contents
> unzipAndCheck
$ exists etc/default/rpm-test
Expand All @@ -19,3 +21,6 @@ $ exists var/log/rpm-test
$ exists var/run/rpm-test

# TODO symlinks aren't checked

> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> check-spec-file

0 comments on commit d76f6f3

Please sign in to comment.