Skip to content

Commit e793228

Browse files
YuvalItzchakovmuuki88
authored andcommitted
Fixes issue #789 where brpJavaRepack was negated (#932)
* 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.
1 parent fa717bb commit e793228

File tree

14 files changed

+86
-16
lines changed

14 files changed

+86
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
%define __os_install_post \
2-
%{_rpmconfigdir}/brp-compress \
3-
%{!?__debug_package:%{_rpmconfigdir}/brp-strip %{__strip}} \
4-
%{_rpmconfigdir}/brp-strip-static-archive %{__strip} \
5-
%{_rpmconfigdir}/brp-strip-comment-note %{__strip} %{__objdump} \
6-
%{nil}
1+
%define __jar_repack %nil

src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object RpmPlugin extends AutoPlugin {
121121
(rpmProvides, rpmRequirements, rpmPrerequisites, rpmObsoletes, rpmConflicts) apply RpmDependencies,
122122
maintainerScripts in Rpm := {
123123
val scripts = (maintainerScripts in Rpm).value
124-
if (rpmBrpJavaRepackJars.value) {
124+
if (!rpmBrpJavaRepackJars.value) {
125125
val pre = scripts.getOrElse(Names.Pre, Nil)
126126
val scriptBits = IO.readStream(RpmPlugin.osPostInstallMacro.openStream, Charset forName "UTF-8")
127127
scripts + (Names.Pre -> (pre :+ scriptBits))

src/sbt-test/rpm/changelog-test/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ $ exists target/rpm/SPECS/rpm-test.spec
55

66
# Check files for defaults
77
> check-spec-file
8-
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
8+
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
99
> check-spec-file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
enablePlugins(JavaServerAppPackaging)
3+
4+
name := "rpm-test-no-repack"
5+
6+
version := "0.1.0"
7+
8+
maintainer := "Josh Suereth <[email protected]>"
9+
10+
packageSummary := "Test rpm package"
11+
12+
packageDescription :=
13+
"""A fun package description of our software,
14+
with multiple lines."""
15+
16+
rpmRelease := "2"
17+
18+
rpmVendor := "typesafe"
19+
20+
rpmUrl := Some("http://github.com/sbt/sbt-native-packager")
21+
22+
rpmLicense := Some("BSD")
23+
24+
rpmBrpJavaRepackJars := false
25+
26+
TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
27+
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test-no-repack.spec")
28+
assert(spec.contains("""%define __jar_repack %nil"""), "Missing java repack disabling in %pre")
29+
out.log.success("Successfully tested rpm test file")
30+
()
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Run the RPM packaging.
2+
> rpm:package-bin
3+
$ exists target/rpm/RPMS/noarch/rpm-test-no-repack-0.1.0-2.noarch.rpm
4+
$ exists target/rpm/SPECS/rpm-test-no-repack.spec
5+
6+
> check-spec-file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
enablePlugins(JavaServerAppPackaging)
3+
4+
name := "rpm-test-with-repack"
5+
6+
version := "0.1.0"
7+
8+
maintainer := "Josh Suereth <[email protected]>"
9+
10+
packageSummary := "Test rpm package"
11+
12+
packageDescription :=
13+
"""A fun package description of our software,
14+
with multiple lines."""
15+
16+
rpmRelease := "2"
17+
18+
rpmVendor := "typesafe"
19+
20+
rpmUrl := Some("http://github.com/sbt/sbt-native-packager")
21+
22+
rpmLicense := Some("BSD")
23+
24+
rpmBrpJavaRepackJars := true
25+
26+
TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
27+
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test-with-repack.spec")
28+
assert(!spec.contains("""%define __jar_repack %nil"""), "%pre should not contain jar repack when set to true")
29+
out.log.success("Successfully tested rpm test file")
30+
()
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Run the RPM packaging.
2+
> rpm:package-bin
3+
$ exists target/rpm/RPMS/noarch/rpm-test-with-repack-0.1.0-2.noarch.rpm
4+
$ exists target/rpm/SPECS/rpm-test-with-repack.spec
5+
6+
> check-spec-file

src/sbt-test/rpm/scriptlets-override-build-rpm/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ $ exists target/rpm/SPECS/rpm-test.spec
55

66
# Check files for defaults
77
> check-spec-file
8-
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
8+
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
99
> check-spec-file

src/sbt-test/rpm/scriptlets-override-rpm/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $ exists var/run/rpm-test
2020
# TODO symlinks aren't checked
2121

2222
> check-spec-file
23-
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
23+
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
2424
> check-spec-file
2525

2626
> unique-scripts-in-spec-file

src/sbt-test/rpm/scriptlets-rpm/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ $ exists target/rpm/SPECS/rpm-test.spec
66
# Check files for defaults
77
> check-spec-file
88
> check-rpm-version
9-
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
9+
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
1010
> check-spec-file

src/sbt-test/rpm/sysvinit-rpm/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $ exists var/run/rpm-test
2323

2424
# TODO symlinks aren't checked
2525

26-
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
26+
> set NativePackagerKeys.rpmBrpJavaRepackJars := false
2727
> check-spec-file
2828
> check-spec-autostart
2929

src/sphinx/formats/rpm.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ After
339339
Jar Repackaging
340340
~~~~~~~~~~~~~~~
341341

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

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

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

0 commit comments

Comments
 (0)