rpmbuild 改变压缩格式

发布于 2025-01-05 07:33:40 字数 1845 浏览 1 评论 0原文

我尝试将我们的 geoserver 的一些地图文件打包到内部 rpm 包中。对于构建部分,这只是复制文件。我认为这符合预期。但打包这 20GB 的图像需要非常长的时间。

我读到过 rpm 在内部压缩数据,并且这可以通过几种不同的压缩算法来完成。但是,我不知道我的转速选择哪种压缩以及我如何影响它。我找不到 rpmbuild 命令的任何选项,也找不到 specfile 的任何选项,也找不到我可以用 rpmbuild --showrc 列出的一般 rpm 选项的任何选项,

我对 rpmbuild 和 specfiles 不是很有经验,但阅读后rpm.org 上有很多手册页和教程,我没有进一步的想法。

我使用的规范文件如下所示:

%define debug_package %{nil}

%global mapsversion 0.9
# If this is a snapshot, put the date here and uncomment
#global snapshot_version 20100519

# This is the version in a form acceptable
# an an RPM version string (i.e. no '-')
# Hier werden die Makros definiert.
%global rpmversion %(echo %{mapsversion} | tr '-' '_')
%global pkgversion %{mapsversion}%{?snapshot_version:-SNAPSHOT}
%global pkgname %{name}

Name:           geoserver-maps-part2
Version:        %{rpmversion}
Release:        1%{?dist}
Summary:        Swiss Maps for GeoServer
Group:          Application/ourApp
License:        Copyright (c) 2011
URL:            http://doc.polyalert.local
#Source0:        %{name}-%{version}.tgz
BuildArch:  noarch
BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires:   geoserver

%define mapshome /opt/geoserver/swisstopo
%define mapssource /home/user/polyalert_env/geoserver/swisstopo

%description
Swiss Maps for GeoServer

%prep

%build
/bin/true

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{mapshome}
cp -a %{mapssource}/pk100 $RPM_BUILD_ROOT%{mapshome}

%clean
rm -rf $RPM_BUILD_ROOT

%pre

%post

%preun


%files
%{mapshome}/pk100

%changelog
* Tue Feb 14 2012 user - 1.0
- First version of specfile

我这样调用 rpmbuild:

rpmbuild -bb --define "_topdir $TOP_DIR" --define "_gpg_name ourkey" --define "_signature gpg" --sign $TOP_DIR/SPECS/$SPEC_FILE_NAME $RPM_BUILD_PARAMETER

有什么建议吗?

I try to pack some map files for our geoserver in an internal rpm package. For the build part, this is just to copy the files. I think this works as expected. But it takes terribly long to pack those 20GB of images.

I've read that rpm internally compresses the data and that this can be done with several different compression algorithms. But, I don't have a clue which compression my rpm chooses and how I can influence this. I could not find any options for the rpmbuild command, nor for the specfile nor for the general rpm options I can list with rpmbuild --showrc

I´m not very experienced with rpmbuild and specfiles, but after reading lots of man pages and tutorials on rpm.org I have no further ideas.

The specfile I use looks like:

%define debug_package %{nil}

%global mapsversion 0.9
# If this is a snapshot, put the date here and uncomment
#global snapshot_version 20100519

# This is the version in a form acceptable
# an an RPM version string (i.e. no '-')
# Hier werden die Makros definiert.
%global rpmversion %(echo %{mapsversion} | tr '-' '_')
%global pkgversion %{mapsversion}%{?snapshot_version:-SNAPSHOT}
%global pkgname %{name}

Name:           geoserver-maps-part2
Version:        %{rpmversion}
Release:        1%{?dist}
Summary:        Swiss Maps for GeoServer
Group:          Application/ourApp
License:        Copyright (c) 2011
URL:            http://doc.polyalert.local
#Source0:        %{name}-%{version}.tgz
BuildArch:  noarch
BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires:   geoserver

%define mapshome /opt/geoserver/swisstopo
%define mapssource /home/user/polyalert_env/geoserver/swisstopo

%description
Swiss Maps for GeoServer

%prep

%build
/bin/true

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{mapshome}
cp -a %{mapssource}/pk100 $RPM_BUILD_ROOT%{mapshome}

%clean
rm -rf $RPM_BUILD_ROOT

%pre

%post

%preun


%files
%{mapshome}/pk100

%changelog
* Tue Feb 14 2012 user - 1.0
- First version of specfile

I call rpmbuild like this:

rpmbuild -bb --define "_topdir $TOP_DIR" --define "_gpg_name ourkey" --define "_signature gpg" --sign $TOP_DIR/SPECS/$SPEC_FILE_NAME $RPM_BUILD_PARAMETER

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

紫﹏色ふ单纯 2025-01-12 07:33:40

十一年后...

在评论中指出,您现在可以选择:

%define _source_payload w0.ufdio
%define _binary_payload w0.ufdio

完全绕过压缩。我在 RPM 4.11.3 / CentOS 7.9 上进行了验证(fdio 选项不起作用)。

使用 rpm -qp --qf "%{PAYLOADCOMPRESSOR}\n",与之前版本的 (none) 相比,我能够确认它是(none)代码>xz。

互联网搜索没有找到关于这些标志的任何有用信息,而最受欢迎的结果似乎就回到了这里...


原始答案:

我今天正在处理一些 RPM 内容,无意中发现了你的答案!

将这些内容放入您的 spec 文件中:

%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio

仍将使用 gzip,但将其传递给 -0 级别,该级别应该仅存储。在我的 RPM 上,它从 21MB 增长到 76MB,所以我很确定这就是您的答案!

顺便说一句,我发现在一个 macro 文件中 - 您还可以执行 bzdio 以及从 09 的任何数字code> 使用 bzip2。这是在 RHEL4 上;更高版本的 RPM 似乎支持更多压缩选项;但同样,对于你想要的,以上应该就是你所需要的。

Eleven years later...

In the comments it was noted that you can now put the option:

%define _source_payload w0.ufdio
%define _binary_payload w0.ufdio

To totally bypass the compression. I verified on RPM 4.11.3 / CentOS 7.9 (the fdio option didn't work).

With rpm -qp --qf "%{PAYLOADCOMPRESSOR}\n" <filename>, I was able to confirm it said (none) compared to the previous build's xz.

An internet search finds nothing useful concerning these flags and the most popular result seems to come right back here...


The original answer:

I was working with some RPM stuff today and accidentally stumbled upon the answer for ya!

Put these in your spec file:

%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio

That will still use gzip but pass it -0 for a level, which should just store. On my RPM, it made it grow from 21MB to 76MB, so I'm pretty sure this is your answer!

BTW, I found that in one of the macro files - you can also do bzdio and any number from 0 to 9 to use bzip2. This was on RHEL4; later versions of RPM seem to support more compression options; but again, for what you want, the above should be what you need.

鲜肉鲜肉永远不皱 2025-01-12 07:33:40

请检查您的构建机器中的文件 /usr/lib/rpm/macros(该文件可能在路径中存在差异),它那里有压缩方法的总支持列表:例如:

329 #       Compression type and level for source/binary package payloads.
330 #               "w9.gzdio"      gzip level 9 (default).
331 #               "w9.bzdio"      bzip2 level 9.
332 #               "w7.xzdio"      xz level 7, xz's default.
333 #               "w7.lzdio"      lzma-alone level 7, lzma's default
334 #
335 #%_source_payload       w9.gzdio
336 #%_binary_payload       w9.gzdio

所以这里就像 Aaron 所说的那样,您可以设置它这里是通用的,或者专门为您的项目设置。规格

Please check the file /usr/lib/rpm/macros in your build machine, (the file maybe diff in path), it has a total support list of compression methods there: e.g.:

329 #       Compression type and level for source/binary package payloads.
330 #               "w9.gzdio"      gzip level 9 (default).
331 #               "w9.bzdio"      bzip2 level 9.
332 #               "w7.xzdio"      xz level 7, xz's default.
333 #               "w7.lzdio"      lzma-alone level 7, lzma's default
334 #
335 #%_source_payload       w9.gzdio
336 #%_binary_payload       w9.gzdio

so here just as Aaron said, you can set it here for universal, or set specifically for your proj. spec.

橘虞初梦 2025-01-12 07:33:40

我遇到了同样的问题,Ant 使用 Spring Boot Loader 构建可运行的 Jar RPM,抱怨这一点:

Caused by: java.lang.IllegalStateException: Unable to open Nested Entry 'BOOT-INF/lib/accessors-smart-1.2 。罐'。它已被压缩,嵌套的 jar 文件必须在不压缩的情况下存储。请检查用于创建可执行 jar 文件的机制

我的 ant 构建任务是这样的:

<exec executable="rpmbuild"  failonerror="true"> 
  <env key="version" value="${fullversion}" /> 
  <arg value="-ba" /> 
  <arg value="--clean" />
  <arg value="${specfile}" />
</exec>

我使用可运行 JAR 构建 RPM 的解决方案是禁用重新打包,在规范文件上设置宏定义并没有这样做对我来说。

将其添加到规范文件中对我有用:

#Disable jar unpacking
%define __jar_repack 0

参考:
https://bugzilla.redhat.com/show_bug.cgi?id=219731

感谢之前的发帖者也帮助我们关注这个问题。

埃里安

I ran into the same issue with Ant building a runnable Jar RPM with Spring Boot Loader complaining of this:

Caused by: java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/accessors-smart-1.2.jar'. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file

My ant build task was like this:

<exec executable="rpmbuild"  failonerror="true"> 
  <env key="version" value="${fullversion}" /> 
  <arg value="-ba" /> 
  <arg value="--clean" />
  <arg value="${specfile}" />
</exec>

My solution to build an RPM with a runnable JAR was to disable the repacking, setting the macro definitions on the spec file did not do it for me.

Adding this to the spec file was what worked for me:

#Disable jar unpacking
%define __jar_repack 0

Reference:
https://bugzilla.redhat.com/show_bug.cgi?id=219731

Thanks to the previous posters for helping to focus in on the issue too.

Erion

绝影如岚 2025-01-12 07:33:40

我在 RHEL 6.6 上使用了“%define _binary_payload w9.xzdio”。据我了解,RHEL 6 中使用的默认压缩工具是 xz,但默认压缩级别似乎是 2,尽管 7 应该是 xz 的默认值。我将其提高到 9,一些巨大的 RPM 从 653MB 增加到 439MB。与默认压缩相比,我总共节省了 1 GB 的空间。

I have used "%define _binary_payload w9.xzdio" on RHEL 6.6. As I understand, the default compression tool used in RHEL 6 is xz, but the default compression level appears to be 2, even though 7 is supposed to be xz's default. I kicked it up to 9 and some giant RPMs went from 653MB to 439MB. I was able to save a total of 1 gigabyte over the default compression.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文