sbt-native-packager RPM 问题

Posted

技术标签:

【中文标题】sbt-native-packager RPM 问题【英文标题】:sbt-native-packager RPM issue 【发布时间】:2017-01-01 12:05:24 【问题描述】:

我们使用 sbt 来构建基于 Play 框架的后端。 目前我们使用 sbt dist 并运行构建二进制文件。

我正在将其构建为 RPM 包,在此过程中会出现一些错误。

我找到了这个 repo - https://github.com/muuki88/sbt-native-packager-examples 跑了一个

sbt clean rpm:package-bin

在与 rpm 相关的两个子目录 - rpm-sigarsimple-rpm 下,出现了相同的错误,就像在我的项目中一样,请参阅回溯:

oreststetsiak@spyro ~/coding/sbt-native-packager-examples/simple-rpm $ sbt clean rpm:package-bin
[info] Loading project definition from /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/project
[info] Set current project to simple-rpm (in build file:/home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/)
[success] Total time: 0 s, completed Aug 23, 2016 6:54:33 PM
[info] Packaging /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/scala-2.10/simple-rpm_2.10-1.0-sources.jar ...
[info] Done packaging.
[info] Updating file:/home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/simple-rpm...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Main Scala API documentation to /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/scala-2.10/api...
[info] Wrote /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/scala-2.10/simple-rpm_2.10-1.0.pom
[info] Compiling 1 Scala source to /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/scala-2.10/classes...
[warn] there were 1 feature warning(s); re-run with -feature for details
model contains 4 documentable templates
[warn] one warning found
[info] Main Scala API documentation successful.
[info] Packaging /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/scala-2.10/simple-rpm_2.10-1.0-javadoc.jar ...
[info] Done packaging.
[warn] there were 1 feature warning(s); re-run with -feature for details
[warn] one warning found
[info] Packaging /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/scala-2.10/simple-rpm_2.10-1.0.jar ...
[info] Done packaging.
[error] + umask 022
[error] + cd /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/BUILD
[error] + [ -e /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/buildroot ]
[error] + mv /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/tmp-buildroot/etc /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/tmp-buildroot/usr /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/tmp-buildroot/var /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/buildroot
[error] + /usr/lib/rpm/brp-compress
[error] + /usr/lib/rpm/brp-strip /usr/bin/strip
[info] Building target platforms: noarch-mukis.de-Linux
[info] Building for target noarch-mukis.de-Linux
[info] Executing(%install): /bin/sh -e /tmp/sbt_53b70991/rpm-tmp.yZCzUZ
[error] + /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
[error] + /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
[info] Processing files: simple-rpm-1.0-1.noarch
[info] Provides: config(simple-rpm) = 1.0-1 simple-rpm = 1.0-1
[info] Requires(interp): /bin/sh /bin/sh /bin/sh /bin/sh
[info] Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
[info] Requires(pre): /bin/sh
[info] Requires(post): /bin/sh
[info] Requires(preun): /bin/sh
[info] Requires(postun): /bin/sh
[info] Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/buildroot
[info] Wrote: /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/RPMS/noarch/simple-rpm-1.0-1.noarch.rpm
[info] Executing(%clean): /bin/sh -e /tmp/sbt_53b70991/rpm-tmp.e0IrHo
[error] + umask 022
[error] + cd /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/BUILD
[error] + /bin/rm -rf /home/oreststetsiak/coding/sbt-native-packager-examples/simple-rpm/target/rpm/buildroot
[error] + exit 0
[success] Total time: 3 s, completed Aug 23, 2016 6:54:36 PM

我的工作站基于 Linux Mint 18,即 DEB。

我还尝试在 AWS EC2 中的 RedHat 7.2 下构建它——同样的错误,

这种错误不会破坏 Jenkins CI 中的构建,但我不想在构建日志中看到它。

有什么建议吗?

【问题讨论】:

【参考方案1】:

您没有遇到错误。正如你在最后一行看到的

[success] Total time: 3 s, completed Aug 23, 2016 6:54:36 PM

结果是成功的。 RPM 不幸地记录到标准错误。

【讨论】:

这很好,thanx,还有一个任务:我们使用了很多环境变量,而且服务效果很好,以防万一,如果我在启动脚本中手动添加所有这些看到的环境变量,是这样吗一个好方法?您建议如何/在哪里保留一堆有意义的环境变量?问候!感谢您的帮助.... 根据我的经验,敏感的环境变量不应该成为您的启动脚本的一部分,也不应该将它们签入您的存储库。一个很好的例子是播放应用程序的秘密。它们应该由您运行服务的系统提供(这就是为什么它们毕竟被称为环境变量;))。与您的运营人员谈谈这个:) “它们应该由您运行服务的系统提供”是否意味着所有环境变量都应该是全局环境变量,可通过命令 env 获得?事实上,我们在 env varialbes 列表中有 play application secret,其他 env 变量(如 S3 用户、DB url、DB 用户名/密码等)是在配置 AWS 云形成模板期间创建的跨度>

以上是关于sbt-native-packager RPM 问题的主要内容,如果未能解决你的问题,请参考以下文章

如何在 sbt-native-packager rpm 构建中包含 libsigar?

sbt-native-packager RPM 问题

在 build.sbt 中使用 Jenkins 内部版本号通过 sbt-native-packager 构建 RPM

在 sbt-native-packager 中过滤映射

在 SBT 中为 sbt-native-packager 的 packageMappings 构建路径

使用 sbt-native-packager 时的配置目录