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

rpmBrpJavaRepackJars issue #964

Closed
mr-git opened this issue Apr 13, 2017 · 10 comments
Closed

rpmBrpJavaRepackJars issue #964

mr-git opened this issue Apr 13, 2017 · 10 comments

Comments

@mr-git
Copy link
Contributor

mr-git commented Apr 13, 2017

Expected behaviour

When I set rpmBrpJavaRepackJars in Rpm := false,, I expect that JAR repacking is not happening.

Actual behaviour

In our project with about 250MB of dependency JARs, this is in log:

16:27:09 [error] + /usr/lib/rpm/check-buildroot
16:27:09 [error] + /usr/lib/rpm/redhat/brp-compress
16:27:09 [error] + /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
16:27:09 [error] + /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
16:27:09 [error] + /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
16:27:09 [error] + /usr/lib/rpm/brp-python-bytecompile /usr/bin/python
16:27:09 [error] + /usr/lib/rpm/redhat/brp-python-hardlink
16:27:09 [error] + /usr/lib/rpm/redhat/brp-java-repack-jars
16:38:21 [error] + umask 022

This took a bit more than 11 minutes to repack all JARs

In 1.1.5 version, I hack-disabled repacking like this (hack works for 1.2.0-M9 too):

    maintainerScripts in Rpm := {
      val defaults = (maintainerScripts in Rpm).value
      val disableBrp = Seq("%global __os_install_post %{nil}") // this disables everything BRP related
      val pre = defaults.get(Pre) map {_ ++ disableBrp} getOrElse disableBrp

      Map(
        Pre -> pre, // disable BRP compression in addition to default user creation
        Post -> Nil, // disable service startup
        Postun -> Nil // disable user removal
      )
    },

With my custom BRP disabling in place, same part of log looks as follows:

16:42:46 [error] + /usr/lib/rpm/check-buildroot
16:43:20 [error] + umask 022

Just under 1 minute, no JARs repacked at all.

Information

  • What sbt-native-packager: 1.2.0-M9
  • What sbt version: 0.13.13
  • What is your build system: CentOS 7
  • What package are you building: RPM
  • What version has your build tool: not sure, but one of latest
  • What is your target system: CentOS 7
@mr-git mr-git changed the title BrpRepackaging issues BrpRepackJars issue Apr 13, 2017
@mr-git mr-git changed the title BrpRepackJars issue rpmBrpJavaRepackJars issue Apr 13, 2017
@muuki88
Copy link
Contributor

muuki88 commented Apr 14, 2017

Thanks for your report. I'll take a look next week when I'm back home from Dublin.

Do you have a guess if the script is not correctly applied or itself incorrect?

@mr-git
Copy link
Contributor Author

mr-git commented Apr 14, 2017

Sorry, I have no clue why it happens like this.
The hack I use I found in some very old RedHat bug report: https://bugzilla.redhat.com/show_bug.cgi?id=219731#c3 - so far the it was the best working workaround.
There is the other page, where problem gets discussed: http://www.makewhatis.com/2011/12/15/remove-unwanted-commpression-in-during-rpmbuild-for-jar-files/

@muuki88
Copy link
Contributor

muuki88 commented Apr 14, 2017

The hack I use I found in some very old RedHat bug report

It's a different one than native​-packager uses, right?

@mr-git
Copy link
Contributor Author

mr-git commented Apr 18, 2017

Yes. In nutshell currently packager adds in RPM's SPEC file:

%pre
%define __jar_repack %nil

My hack adds:

%pre
%global __os_install_post %{nil}

According to http://livecipher.blogspot.com/2012/06/disable-binary-stripping-in-rpmbuild.html, I understood (but didn't test), my hack could be added anywhere in SPEC file and it will disable all BRP related jobs, not only JAR repacking, but also all other repacking tasks, but this option is not exposed in sbt-native-packager.
I am not sure which is better, but in my case, there is no need for any repacking and I like to save those 11 minutes on each build.

In my case, I'd like to have those repacking options as opt-in, not opt-out, but that is just me :)

@muuki88
Copy link
Contributor

muuki88 commented Apr 26, 2017

Sorry for my late reply. Busy days.

I am not sure which is better, but in my case, there is no need for any repacking and I like to save those 11 minutes on each build.

Absolutely. We had the solution mentioned in the blog post. e793228 reverted this. @YuvalItzchakov what was the reason for that?

@YuvalItzchakov
Copy link
Contributor

YuvalItzchakov commented Apr 26, 2017

The previous implementation did not remove all packing, only jar repackaging. My modification was only meant to shorten the code required to do that. I think it would be a good idea to expose "advanced flags" to be able to remove these repackaging processes completely.

@muuki88
Copy link
Contributor

muuki88 commented Apr 26, 2017

@YuvalItzchakov thanks for the fast reply 😮

Hm. @mr-git can you check that the brpRepackJar macro is correctly inserted in your build? And check if add / replace your suggestion if it changes anything?

@YuvalItzchakov
Copy link
Contributor

YuvalItzchakov commented Apr 26, 2017

@mr-git My fix made jar repackaging disabled by default, so there's no need to explicitly set the flag to false (which was released with 1.2.0-M8).

@muuki88 muuki88 closed this as completed Jun 10, 2017
@reid-spencer
Copy link

Not sure why this is closed. I get the same results with 1.2.2 and 0.13.16 sbt.

Maybe I'm "doing it wrong"? The relevant settings my build are:

    rpmBrpJavaRepackJars in Rpm := false,
    maintainerScripts in Rpm := {
      MaintainerScriptHelper
        .maintainerScriptsAppend((maintainerScripts in Rpm).value)(
        // See:
        // http://livecipher.blogspot.com/2012/06/disable-binary-stripping-in-rpmbuild.html
        // http://www.developersite.org/103-214194-rpm
        Pre -> "%global __os_install_post %{nil}",
        Pre -> "%global _binaries_in_noarch_packages_terminate_build 0",
        Post  s"echo 'installing ${(packageName in Rpm).value}'"
      )
    }

Any thoughts?

@reid-spencer
Copy link

Oy, and I figured it out. The double Pre entry in the maintainerScriptsAppend method parameter means only the last line is retained so the __os_install_post %{nil} was not included. Putting both in one string fixes the issue. Not sure why maintainerScriptAppend doesn't take a Seq[(String -> Seq[String])] as was the practice in prior releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants