user1285928
user1285928

Reputation: 1476

RPM extract jar files

I wan to create RPM packages which is used to extract only jar files:

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

It turns out that after RPM install some files are corrupted because there is a spacial way to extract files from jar file. Maybe during build simple exatract command is used I suppose.

Is there any way to solve this? I get now this error:

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!

Looks like the file is not properly extracted.

Upvotes: 1

Views: 4596

Answers (2)

Etan Reisner
Etan Reisner

Reputation: 80931

Run rpm -E '%{__os_install_post}' and find the brp-java-repack-jars script (/usr/lib/rpm/redhat/brp-java-repack-jars on my CentOS 5 system) and take a look at it.

It unpacks and repacks the jars it finds.

Newer versions might let you control it a bit but in the one I have you don't have much say over things.

For the version in CentOS 5 it looks like your choices are:

  • Define your own custom __os_install_post that doesn't call it that script
  • Update the script to be smarter about handling META-INF and MANIFEST.MF files correctly.
  • Delete that script from your system entirely
  • Remove zip and/or unzip from your system entirely

Upvotes: 2

Clauds
Clauds

Reputation: 950

If your tarball contains jar files that should stay as they are, disable repackaging of the jar files. Add the following to the top of your spec file:

%define __jar_repack %{nil}

Upvotes: 5

Related Questions