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

Fixes issue #789 where brpJavaRepack was negated #932

Merged
merged 7 commits into from
Jan 25, 2017
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
@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. This is the actual bug fix. Thanks :)

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