RPM解压jar文件

RPM extract jar files

我想创建仅用于提取 jar 文件的 RPM 包:

Name:           pack-agent
Version:        1.0
Release:        1%{?dist}
Summary:        Linux Agent installation script
Group:          Utilities
License:        license
Source0:        pack-agent-1.0.tar.gz
BuildArch:      x86_64
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description

%prep
%setup -q -n opt

%build

%install
#install -m 0755 -d $RPM_BUILD_ROOT/agent
#cp -ap agent/* $RPM_BUILD_ROOT/agent/

install -m 0755 -d %{buildroot}/opt
#cp -a * %{buildroot}/agent
cp -a * %{buildroot}/opt

%clean
rm -rf $RPM_BUILD_ROOT

%files
/opt
%defattr(-,root,root,-)

%doc
%changelog

事实证明,在安装 RPM 后,一些文件已损坏,因为有一种特殊的方法可以从 jar 文件中提取文件。我想也许在构建过程中使用了简单的 exatract 命令。

有什么办法可以解决吗?我现在收到这个错误:

org.osgi.framework.BundleException: The bundle file:/opt/agent/deploy/System_Install-1.0.jar does not have a META-INF/MANIFEST.MF! Make sure, META-INF and MANIFEST.MF are the first 2 entries in your JAR!

看起来文件没有正确提取。

运行 rpm -E '%{__os_install_post}' 并找到 brp-java-repack-jars 脚本(/usr/lib/rpm/redhat/brp-java-repack-jars 在我的 CentOS 5 系统上)并查看它。

它解压并重新打包它找到的罐子。

较新的版本可能会让您稍微控制它,但在我拥有的版本中,您对事情没有太多发言权。

对于 CentOS 5 中的版本,您的选择似乎是:

  • 定义您自己的自定义 __os_install_post 不调用它的脚本
  • 更新脚本以更智能地正确处理 META-INFMANIFEST.MF 文件。
  • 从您的系统中完全删除该脚本
  • 从您的系统中完全删除 zip and/or unzip

如果您的 tarball 包含应保持原样的 jar 文件,请禁用对 jar 文件的重新打包。将以下内容添加到规范文件的顶部:

%define __jar_repack %{nil}