Syndicate
Site (RSS, Atom)
Contact
Weblog status
Total entries: 78
Last entry: 2022-10-16 13:52:24
Last updated: 2022-10-16 14:12:58
powered by vim, bash, cat, grep, sed, and nb 3.4.2

Juli 2012 Archives

2012-07-17 23:05:08

Oracle Instant Client RPM failure

Oracle provides its own RPM packages for e.g. Red Hat Enterprise Linux. But some packages are faulty because they don't "provide" libs they contain and therefore cannot fullfill requirements other packages have. Here's an example:

$ yum install php-5.3.13-1m.el6.x86_64.rpm
Error: Package: php-5.3.13-1m.el6.x86_64
           Requires: libclntsh.so.10.1()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
$ ls /usr/lib/oracle/10.2.0.4/client64/lib/*clntsh*
/usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so
/usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so.10.1
$ rpm -qf /usr/lib/oracle/10.*/client64/lib/libclntsh.so.*
oracle-instantclient-basic-10.2.0.4-1.x86_64

Apparently the Oracle RPM package builders switched the "AutoProv" tag in the spec file off. This is easy to fix if you know how a spec file should look like and how packages are built. But let me show you a nice tool: rpmrebuild. With this tool you can rebuild RPM packages from binary packages, reconstruct spec file from binary packages and much more. You can rebuild the oracle packages with i.e.

rpmrebuild --package --notest-install -e \
  oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm

With turning AutoProv and AutoReq on you can build the oracle package without the "requires" error shown above.

But stop! There are some more enhancements which could be done. You can provide an entry in /etc/ld.so.conf.d for the dynamic loader. And then there is a small bug left - at least in some oracle instant client packages version 10: The libs and binaries have the flag for executable stack set which can cause trouble when using SELinux.

I took the spec file extracted with rpmrebuild and made many changes. The libs and binaries of the oracle package did I store in a tgz archive:

# tar tzf oracle-instantclient-basic-10.2.0.4.tgz 
oracle-instantclient-basic-10.2.0.4/
oracle-instantclient-basic-10.2.0.4/bin/
oracle-instantclient-basic-10.2.0.4/bin/genezi
oracle-instantclient-basic-10.2.0.4/lib/
oracle-instantclient-basic-10.2.0.4/lib/libocijdbc10.so
oracle-instantclient-basic-10.2.0.4/lib/libociei.so
oracle-instantclient-basic-10.2.0.4/lib/ojdbc14.jar
oracle-instantclient-basic-10.2.0.4/lib/libocci.so.10.1
oracle-instantclient-basic-10.2.0.4/lib/libclntsh.so.10.1
oracle-instantclient-basic-10.2.0.4/lib/libnnz10.so

The spec file looks like this:

%define __spec_install_post %{nil}
%define __os_install_post %{nil}

BuildArch:     x86_64
Name:          oracle-instantclient-basic
Version:       10.2.0.4
Release:       1m
License:       Oracle 
Group:         Applications/File
Summary:       Instant Client for Oracle Database 10g
Source0:       %{name}-%{version}.tgz
Conflicts:     oracle-instantclient-basiclite  
Provides:      %{name} = %{version}-1
BuildRequires: prelink >= 0.3.3

%description
Instant Client allows you to run your applications without
installing the standard Oracle client or having and
ORACLE_HOME.  OCI, OCCI, ODBC, and JDBC applications work
without modification, while using significantly less disk
space than before.  Even SQL*Plus can be used with Instant
Client.  No recompile, no hassle.
This is the Basic package, supporting OCI, OCCI, and JDBC-OCI
with all
languages.

%prep
%setup -q

%install
install -m 755 -d \
$RPM_BUILD_ROOT/usr/lib/oracle/%{version}/client64/{bin,lib}
install -m 755 -d $RPM_BUILD_ROOT/etc/ld.so.conf.d

cp -af bin/* \
$RPM_BUILD_ROOT/usr/lib/oracle/%{version}/client64/bin/
cp -af lib/* \
$RPM_BUILD_ROOT/usr/lib/oracle/%{version}/client64/lib/
for f in bin/genezi lib/libocijdbc10.so lib/libociei.so \
 lib/libocci.so.10.1 lib/libclntsh.so.10.1 lib/libnnz10.so
do
  execstack -c \
$RPM_BUILD_ROOT/usr/lib/oracle/%{version}/client64/$f
done
echo /usr/lib/oracle/%{version}/client64/lib \
>$RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}.conf

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%attr(0644 root root) "/etc/ld.so.conf.d/%{name}.conf"
%attr(0755 root root) \
"/usr/lib/oracle/%{version}/client64/bin/genezi"
%attr(0644 root root) \
"/usr/lib/oracle/%{version}/client64/lib/libclntsh.so.10.1"
%attr(0644 root root) \
"/usr/lib/oracle/%{version}/client64/lib/libnnz10.so"
%attr(0644 root root) \
"/usr/lib/oracle/%{version}/client64/lib/libocci.so.10.1"
%attr(0644 root root) \
"/usr/lib/oracle/%{version}/client64/lib/libociei.so"
%attr(0644 root root) \
"/usr/lib/oracle/%{version}/client64/lib/libocijdbc10.so"
%attr(0644 root root) \
"/usr/lib/oracle/%{version}/client64/lib/ojdbc14.jar"

Here's the installation of the newly created package:

$ yum install oracle-instantclient-basic-10.2.0.4-1m.*.rpm 
...
Dependency Installed:
  compat-libstdc++-33.x86_64 0:3.2.3-69.el6                                                                                                                                                                                    

Updated:
  oracle-instantclient-basic.x86_64 0:10.2.0.4-1mm1                                                                                                                                                                            

Complete!

As you can see there was libstdc++-33 installed as requirement for the oracle libs - this was also broken in the original oracle package. The custom php package which required libclntsh.so could also be installed without error. As a last test I did compare an original package installation and the new package installation for "SELinux compatibility". Old package install:

$ execstack -q /usr/lib/oracle/10.2.0.4/client64/lib/lib*so*
X /usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so
X /usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so.10.1
X /usr/lib/oracle/10.2.0.4/client64/lib/libnnz10.so
X /usr/lib/oracle/10.2.0.4/client64/lib/libocci.so
X /usr/lib/oracle/10.2.0.4/client64/lib/libocci.so.10.1
X /usr/lib/oracle/10.2.0.4/client64/lib/libociei.so
X /usr/lib/oracle/10.2.0.4/client64/lib/libocijdbc10.so

Install of the new rebuilded package:

$ execstack -q /usr/lib/oracle/10.2.0.4/client64/lib/lib*so*
- /usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so
- /usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so.10.1
- /usr/lib/oracle/10.2.0.4/client64/lib/libnnz10.so
- /usr/lib/oracle/10.2.0.4/client64/lib/libocci.so
- /usr/lib/oracle/10.2.0.4/client64/lib/libocci.so.10.1
- /usr/lib/oracle/10.2.0.4/client64/lib/libociei.so
- /usr/lib/oracle/10.2.0.4/client64/lib/libocijdbc10.so

All problems were solved with this rebuilded oracle rpm package.


Posted by Frank W. Bergmann | Permanent link | File under: rpm, redhat, shell