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

Build failed on OS X #327

Closed
awasilyev opened this issue Aug 20, 2014 · 14 comments
Closed

Build failed on OS X #327

awasilyev opened this issue Aug 20, 2014 · 14 comments

Comments

@awasilyev
Copy link

latest sbt-native-packager. rpmbuild version 5.4.4

....
[info] Executing(%install): /bin/sh -e /var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_49d26b67/rpm-tmp.2944
[error] + umask 022
[error] + cd /Users/alw/xxx/xxx/core/distribution/target/rpm/BUILD
[error] + /bin/rm -rf /Users/alw/xxx/xxx/core/distribution/target/rpm/buildroot
[error] + /bin/mkdir -p /Users/alw/xxx/xxx/core/distribution/target/rpm/buildroot
[error] + '[' -e /Users/alw/xxx/xxx/core/distribution/target/rpm/buildroot ']'
[error] + mv /Users/alw/xxx/xxx/core/distribution/target/rpm/tmp-buildroot/etc /Users/alw/xxx/xxx/core/distribution/target/rpm/tmp-buildroot/opt /Users/alw/xxx/xxx/core/distribution/target/rpm/tmp-buildroot/var /Users/alw/xxx/xxx/core/distribution/target/rpm/buildroot
[error] + '%{_rpmconfigdir}/brp-compress'
[error] /var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_49d26b67/rpm-tmp.2944: line 32: fg: no job control
[error] error: Bad exit status from /var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_49d26b67/rpm-tmp.2944 (%install)
[error]     Bad exit status from /var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_49d26b67/rpm-tmp.2944 (%install)
[info]
[info]
[info] RPM build errors:
java.lang.RuntimeException: Unable to run rpmbuild, check output for details.
        at scala.sys.package$.error(package.scala:27)
        at com.typesafe.sbt.packager.rpm.RpmHelper$$anonfun$buildPackage$1.apply(RpmHelper.scala:89)
        at com.typesafe.sbt.packager.rpm.RpmHelper$$anonfun$buildPackage$1.apply(RpmHelper.scala:74)
        at sbt.IO$.withTemporaryDirectory(IO.scala:285)
[error] /var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_49d26b67/rpm-tmp.2944: line 32: fg: no job control
[error] error: Bad exit status from /var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_49d26b67/rpm-tmp.2944 (%install)
[error]     Bad exit status from /var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_49d26b67/rpm-tmp.2944 (%install)
[info]
[info]
[info] RPM build errors:
java.lang.RuntimeException: Unable to run rpmbuild, check output for details.
    at scala.sys.package$.error(package.scala:27)
    at com.typesafe.sbt.packager.rpm.RpmHelper$$anonfun$buildPackage$1.apply(RpmHelper.scala:89)
    at com.typesafe.sbt.packager.rpm.RpmHelper$$anonfun$buildPackage$1.apply(RpmHelper.scala:74)
    at sbt.IO$.withTemporaryDirectory(IO.scala:285)
......
@muuki88
Copy link
Contributor

muuki88 commented Aug 20, 2014

You maybe run in an issue with the jarRepackaging. See the docs for how to disable.

If this doesn work, can you post a small build.sbt to reproduce the problem?

@awasilyev
Copy link
Author

disabling jarRepackaging did not help.
I try to build project (guarantee working) from other developer. This is my first experience with sbt/scala, so I can do a newby stupid errors. Whole project is very large, build.sbt depends on many other files. Here is full file described rpm building:

import sbt._
import Keys._
import sbtassembly.Plugin._
import AssemblyKeys._
import com.typesafe.sbt.packager.Keys._
import com.typesafe.sbt.SbtNativePackager._

object CorePackage {

  import Utils._

  val sysUser = "yyyy"
  val sysGroup = "yyyy"
  val userComment = "My service user"
  val homeDir = "/opt/" + sysUser
  val rootDir = homeDir + "/core/"
  val pkgName = "xxx-core"

  val preScript = """|getent group %2$s >/dev/null || groupadd -r %2$s
                     |getent passwd %1$s >/dev/null || \
                     |useradd -r -g %2$s -d %3$s -s /sbin/nologin \
                     |   -c "%4$s" %1$s
                     |if [ $1 -eq 2 ] ; then
                     |  # Upgrading package
                     |  /sbin/service xxx-core stop -force >/dev/null 2>&1 || :
                     |fi
                     |exit 0
                     |
                     |""".stripMargin.format(
                       sysUser,
                       sysGroup,
                       homeDir,
                       userComment
                     )

  val postScript = """|if [ $1 -eq 1 ] ; then
                      |  # Initial installation
                      |  /sbin/chkconfig xxx-core on >/dev/null 2>&1 || :
                      |fi
                      |
                      |""".stripMargin

  val preunScript = """|if [ $1 -eq 0 ] ; then
                       |  # Package removal
                       |  /sbin/service xxx-core stop 15 -force >/dev/null 2>&1 || :
                       |  /sbin/chkconfig --del xxx-core >/dev/null 2>&1 || :
                       |fi
                       |
                       |""".stripMargin

  val postunScript = ""

  def distributionSettings = linuxSettings ++ debianSettings ++ rpmSettings ++ universalSettings ++
      Seq(
        // Universal package
        //packageBin in Universal <<= (packageBin in Universal).dependsOn(assembly),
        name in Universal := pkgName + "-" + Versions.build,
        mappings in Universal <+= assembly map { p => p -> "lib/xxx-core.jar" },
        mappings in Universal += file("/dev/null") -> "logs/.keep",
        mappings in Universal <+= baseDirectory map { d => d / "../conf/package/application.conf" -> "conf/application.conf" },
        mappings in Universal <+= baseDirectory map { d => d / "../conf/package/logger.xml" -> "conf/logger.xml" },
        mappings in Universal <++= baseDirectory map { d =>
          listAll("*")(d / "scripts") flatMap {
            script =>
              script.relativeTo(d / "scripts").map(s => script -> ("bin/" + s.getPath))
      } toSeq
    },
        // Linux package
        maintainer := "Dmitry Zamaruev <[email protected]>",
        packageSummary := "Xxxx core daemon",
        packageDescription := "Xxxx core daemon",
        packageArchitecture := "noarch",
        linuxPackageMappings <+= assembly map { p =>
          (packageMapping( p -> (rootDir + "lib/xxx-core.jar") )
            withUser sysUser withGroup sysGroup withPerms "0644")
        },
        linuxPackageMappings <++= baseDirectory map { d => Seq(
          packageMapping( d / "scripts/service.sh" -> (rootDir + "bin/service.sh") )
            withUser sysUser withGroup sysGroup withPerms "0755",
          packageMapping( d / "scripts/defaults.sh" -> (rootDir + "bin/defaults.sh") )
            withUser sysUser withGroup sysGroup withPerms "0644" withConfig("noreplace"),
          packageMapping( d / "../conf/package/application.conf" -> (rootDir + "conf/application.conf") )
            withUser sysUser withGroup sysGroup withPerms "0644" withConfig("noreplace"),
          packageMapping( d / "../conf/package/logger.xml" -> (rootDir + "conf/logger.xml") )
            withUser sysUser withGroup sysGroup withPerms "0644" withConfig("noreplace"),
          packageMapping( d / "scripts/init.d/xxx-core.rhel.sh" -> "/etc/init.d/xxx-core" )
            withUser "root" withGroup "root" withPerms "0755",
          // HACK to create dirs
          packageMapping( file("/dev/null") -> ("/var/run/" + sysUser + "/.keep-xxx-core") )
            withUser "root" withGroup "root" withPerms "0644",
          packageMapping( file("/dev/null") -> (rootDir + "logs/.keep-xxx-core") )
            withUser "root" withGroup "root" withPerms "0644",
          // HACK to set dir permissions
          packageMapping( d -> (rootDir + "logs") ) withUser sysUser withGroup sysGroup withPerms "0755",
          packageMapping( d -> (rootDir + "conf") ) withUser sysUser withGroup sysGroup withPerms "0755",
          packageMapping( d -> (rootDir + "bin") ) withUser sysUser withGroup sysGroup withPerms "0755",
          packageMapping( d -> ("/var/run/" + sysUser) ) withUser sysUser withGroup sysGroup withPerms "0755"
        )},
        // RPM specific
        name in Rpm := pkgName,
        version in Rpm := Versions.build,
        //packageBin in Rpm <<= (packageBin in Rpm).dependsOn(assembly),
        rpmRelease := Versions.release,
        rpmVendor := "My Inc.",
    rpmGroup := Some("MyGroup"),
    rpmBrpJavaRepackJars := false,
        rpmLicense := Some("Proprietary"),
        rpmRequirements += "jre >= 1.6.0",
        rpmRequirements += "mongo-10gen-server >= 2.0.2",
        rpmRequirements += "rabbitmq-server >= 2.8.0",
        rpmPre := Some(preScript),
        rpmPost := Some(postScript),
        rpmPreun := Some(preunScript),
        rpmPostun := Some(postunScript)
      )
}

@muuki88
Copy link
Contributor

muuki88 commented Aug 21, 2014

Did you turn the repackaging on? So it looks like this

rpmBrpJavaRepackJars := false,

The error is a bit spurious fg: no job control, but if you google for it with rpm then the first answer is this: http://www.redhat.com/archives/rpm-list/2002-October/msg00271.html

Look for an unexpanded (because not defined in configuration) macro
in the spec file. The % is then passed to the shell which (correctly
but non-helpfully) whines about job control.

So, the rpmBrpJavaRepackJars macro seems undefined on your mac and
that's why it can't be turned on.

@awasilyev
Copy link
Author

I try with rpmBrpJavaRepackJars := false - same thing (
How I can debug which macros unavailable ?

On Thu, Aug 21, 2014 at 9:53 PM, Nepomuk Seiler [email protected]
wrote:

Did you turn the repackaging on? So it looks like this

rpmBrpJavaRepackJars := false,

The error is a bit spurious fg: no job control, but if you google for it
with rpm then the first answer is this:
http://www.redhat.com/archives/rpm-list/2002-October/msg00271.html

Look for an unexpanded (because not defined in configuration) macro
in the spec file. The % is then passed to the shell which (correctly
but non-helpfully) whines about job control.

So, the rpmBrpJavaRepackJars macro seems undefined on your mac and
that's why it can't be turned on.


Reply to this email directly or view it on GitHub
#327 (comment)
.

@muuki88
Copy link
Contributor

muuki88 commented Aug 22, 2014

You have to set rpmBrpJavaRepackJars := true, then there isn't a special macro added.

For debugging first take a look at the .spec file created in, AFAIK, target/rpm/RPMS . Everything is defined in there. You can change something and run the rpm build from CLI yourself. Take a look at the RpmHelper class to find the commands.

@awasilyev
Copy link
Author

Aliluia​, rpmBrpJavaRepackJars := true helps.
But there is new issue:

[info] Executing(%install): /bin/sh -e
/var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_acde8e14/rpm-tmp.60977
[error] + umask 022
[error] + cd /Users/alw/xxxx/yyyy/distribution/target/rpm/BUILD
[error] + /bin/rm -rf /Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot
[error] + /bin/mkdir -p
/Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot
[error] + '[' -e /Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot ']'
[error] + mv /Users/alw/xxxx/yyyy/distribution/target/rpm/tmp-buildroot/etc
/Users/alw/xxxx/yyyy/distribution/target/rpm/tmp-buildroot/opt
/Users/alw/xxxx/yyyy/distribution/target/rpm/tmp-buildroot/var
/Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot
[error] + exit 0
[info] Processing files: yyyy-1.0-SNAPSHOT.noarch
[error] /bin/bash: --rpm-requires: invalid option
[error] Usage: /bin/bash [GNU long option] [option] ...
[error] /bin/bash [GNU long option] [option] script-file ...

bash executed with --rpm-requires option instead of some rpm* binary

@muuki88
Copy link
Contributor

muuki88 commented Aug 22, 2014

Aliluia​, rpmBrpJavaRepackJars := true helps.
But there is new issue:

[info] Executing(%install): /bin/sh -e
/var/folders/vx/1pvt1gbs0dgdx_h23ltpsrym0000gn/T/sbt_acde8e14/rpm-tmp.60977
[error] + umask 022
[error] + cd /Users/alw/xxxx/yyyy/distribution/target/rpm/BUILD
[error] + /bin/rm -rf /Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot
[error] + /bin/mkdir -p
/Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot
[error] + '[' -e /Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot ']'
[error] + mv /Users/alw/xxxx/yyyy/distribution/target/rpm/tmp-buildroot/etc
/Users/alw/xxxx/yyyy/distribution/target/rpm/tmp-buildroot/opt
/Users/alw/xxxx/yyyy/distribution/target/rpm/tmp-buildroot/var
/Users/alw/xxxx/yyyy/distribution/target/rpm/buildroot
[error] + exit 0
[info] Processing files: yyyy-1.0-SNAPSHOT.noarch
[error] /bin/bash: --rpm-requires: invalid option
[error] Usage:  /bin/bash [GNU long option] [option] ...
[error]         /bin/bash [GNU long option] [option] script-file ...

bash executed with --rpm-requires option instead of some rpm* binary

@muuki88
Copy link
Contributor

muuki88 commented Aug 22, 2014

I think you have to dig for rpm on your own. These issues are all rpm related, why
should seek help from google and/or the rpm community.

--rpm-requires: invalid option is the error. First hit on google reveals this is a problem on
Mac and homebrew

@muuki88 muuki88 closed this as completed Sep 23, 2014
@nefilim
Copy link
Contributor

nefilim commented Dec 12, 2014

@awasilyev did you fix this issue? i'm running into the same thing, not sure yet why lib magic is involved here but it appears to related to the fact that bash on OSX doesn't support the --rpm-requires option like it does on a RHEL variant.

@IrfanAnsari
Copy link

@awasilyev @nefilim
Has anyone come across any solution for the above issue? I am having the same issue as well.

Regards,
Irfan

@nefilim
Copy link
Contributor

nefilim commented Jan 6, 2015

@IrfanAnsari nope not really, i've opened an issue here: Homebrew/legacy-homebrew#35062

there's a patch in there that works apparently, i briefly tried it yesterday but for some reason homebrew didn't pick it up. i haven't looked deeper into it, i've resorted to a linux build server when i encountered this originally so just going with that for now.

@muuki88
Copy link
Contributor

muuki88 commented Jan 6, 2015

Thanks @nefilim for updating :)

@IrfanAnsari
Copy link

Thanks Guys, much appreciated your reply. I will try the patch at some point and will post about how it goes.

Regards,
Irfan

@kayvank
Copy link

kayvank commented Feb 1, 2016

Thank you, this page solve my problem with native packager. Here is what I did on my os x el capitan:
brew install rpm
& I added the rpmBrpJavaRepackJars := true

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

No branches or pull requests

5 participants