Skip to content

Commit

Permalink
Fixes issue #789 where brpJavaRepack was negated (#932)
Browse files Browse the repository at this point in the history
* Fixed issue #789 where brpJavaRepack was negated (set to 'false' instead of 'true')

* 1. Changed brpJavaRepack command to a supported flag on RPM
2. Changed the default of repack from true to false, which means repack will not run by default.

* 1. Removed debug logs
2. Added a test to make sure java repack is ran when set to `true`.

* Triggering rebuild.

* Modified RPM names to avoid race conditions and failing tests.

* Fixed broken tests (missing renaming in places, comments).

* Updated RPM repacking description in the docs.
  • Loading branch information
YuvalItzchakov authored and muuki88 committed Jan 25, 2017
1 parent fa717bb commit e793228
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
%define __os_install_post \
%{_rpmconfigdir}/brp-compress \
%{!?__debug_package:%{_rpmconfigdir}/brp-strip %{__strip}} \
%{_rpmconfigdir}/brp-strip-static-archive %{__strip} \
%{_rpmconfigdir}/brp-strip-comment-note %{__strip} %{__objdump} \
%{nil}
%define __jar_repack %nil
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object RpmPlugin extends AutoPlugin {
(rpmProvides, rpmRequirements, rpmPrerequisites, rpmObsoletes, rpmConflicts) apply RpmDependencies,
maintainerScripts in Rpm := {
val scripts = (maintainerScripts in Rpm).value
if (rpmBrpJavaRepackJars.value) {
if (!rpmBrpJavaRepackJars.value) {
val pre = scripts.getOrElse(Names.Pre, Nil)
val scriptBits = IO.readStream(RpmPlugin.osPostInstallMacro.openStream, Charset forName "UTF-8")
scripts + (Names.Pre -> (pre :+ scriptBits))
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/rpm/changelog-test/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ $ exists target/rpm/SPECS/rpm-test.spec

# Check files for defaults
> check-spec-file
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
> check-spec-file
31 changes: 31 additions & 0 deletions src/sbt-test/rpm/scriplets-no-javarepack-rpm/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

enablePlugins(JavaServerAppPackaging)

name := "rpm-test-no-repack"

version := "0.1.0"

maintainer := "Josh Suereth <joshua.suereth@typesafe.com>"

packageSummary := "Test rpm package"

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

rpmRelease := "2"

rpmVendor := "typesafe"

rpmUrl := Some("http://github.com/sbt/sbt-native-packager")

rpmLicense := Some("BSD")

rpmBrpJavaRepackJars := false

TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test-no-repack.spec")
assert(spec.contains("""%define __jar_repack %nil"""), "Missing java repack disabling in %pre")
out.log.success("Successfully tested rpm test file")
()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
6 changes: 6 additions & 0 deletions src/sbt-test/rpm/scriplets-no-javarepack-rpm/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Run the RPM packaging.
> rpm:package-bin
$ exists target/rpm/RPMS/noarch/rpm-test-no-repack-0.1.0-2.noarch.rpm
$ exists target/rpm/SPECS/rpm-test-no-repack.spec

> check-spec-file
31 changes: 31 additions & 0 deletions src/sbt-test/rpm/scriplets-use-javarepack-rpm/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

enablePlugins(JavaServerAppPackaging)

name := "rpm-test-with-repack"

version := "0.1.0"

maintainer := "Josh Suereth <joshua.suereth@typesafe.com>"

packageSummary := "Test rpm package"

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

rpmRelease := "2"

rpmVendor := "typesafe"

rpmUrl := Some("http://github.com/sbt/sbt-native-packager")

rpmLicense := Some("BSD")

rpmBrpJavaRepackJars := true

TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test-with-repack.spec")
assert(!spec.contains("""%define __jar_repack %nil"""), "%pre should not contain jar repack when set to true")
out.log.success("Successfully tested rpm test file")
()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
6 changes: 6 additions & 0 deletions src/sbt-test/rpm/scriplets-use-javarepack-rpm/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Run the RPM packaging.
> rpm:package-bin
$ exists target/rpm/RPMS/noarch/rpm-test-with-repack-0.1.0-2.noarch.rpm
$ exists target/rpm/SPECS/rpm-test-with-repack.spec

> check-spec-file
2 changes: 1 addition & 1 deletion src/sbt-test/rpm/scriptlets-override-build-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ $ exists target/rpm/SPECS/rpm-test.spec

# Check files for defaults
> check-spec-file
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
> check-spec-file
2 changes: 1 addition & 1 deletion src/sbt-test/rpm/scriptlets-override-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ exists var/run/rpm-test
# TODO symlinks aren't checked

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

> unique-scripts-in-spec-file
2 changes: 1 addition & 1 deletion src/sbt-test/rpm/scriptlets-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ $ exists target/rpm/SPECS/rpm-test.spec
# Check files for defaults
> check-spec-file
> check-rpm-version
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
> check-spec-file
2 changes: 1 addition & 1 deletion src/sbt-test/rpm/sysvinit-rpm/test
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $ exists var/run/rpm-test

# TODO symlinks aren't checked

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

Expand Down
7 changes: 3 additions & 4 deletions src/sphinx/formats/rpm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ After
Jar Repackaging
~~~~~~~~~~~~~~~

rpm repackages jars by default (described in this `blog post`_) in order to optimize jars.
This behaviour is turned off by default with this setting:
RPM repackages jars by default in order to optimize jars.
Repacking is turned off by default. In order to enable it, set:

.. code-block:: scala
rpmBrpJavaRepackJars := false
rpmBrpJavaRepackJars := true
Note that this *appends* content to your ``Pre`` definition, so make sure not to override it.
For more information on this topic follow these links:
Expand All @@ -353,7 +353,6 @@ For more information on this topic follow these links:
* `pullrequest #199`_
* `OpenSuse issue`_

.. _blog post: http://swaeku.github.io/blog/2013/08/05/how-to-disable-brp-java-repack-jars-during-rpm-build
.. _issue #195: https://github.com/sbt/sbt-native-packager/issues/195
.. _pullrequest #199: https://github.com/sbt/sbt-native-packager/pull/199
.. _OpenSuse issue: https://github.com/sbt/sbt-native-packager/issues/215
Expand Down

0 comments on commit e793228

Please sign in to comment.