rpm provides shared object that is also required by a provided executable - linux

Preface: Auto dependencies (AutoReqProv) is ON
As the title says, we have a shared object that is provided by the RPM package we have built, so it is placed in the %files section of the spec file. However, we have executable files in the %files section as well, that are dependent on this .so. So, with auto dependencies on, it is trying to resolve this issue during install of this package. Obviously, this .so has not been installed yet on the target system because it is apart of the package being installed. So, it throws an install error.
Has anyone experienced this issue before? Auto dependencies being on is a requirement for this, so removing it is a last ditch effort.
**Edit: Here is the %files section of my spec file. The .so in question is located in /usr/local/%{name}
%files
%defattr(-,root,root)
/usr/local/%{name}
/usr/bin/*
/etc/ld.so.conf.d/*
/etc/opt/aubit4gl2
/usr/lib/*
%attr(0755, -, -) /usr/local/bin/c4glpg
%attr(0755, -, -) /usr/local/bin/c4glpg2
The error is this:
error: Failed dependencies:
libaubit4gl.so is needed by aubit4gl2-10.0.4-2.i686
Edit 2: Here is the install section of the rpmbuild command output
make[1]: Leaving directory `/home/bhand/rpmbuild/BUILD/aubit4gl2-10.0.4/aubit4gl2'
+ cp -a aubit4gl2/atomix4pg/sqldist /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/local/aubit4gl2/atomix4pg
+ cp -a aubit4gl2/etc/aubitrc /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/etc/opt/aubit4gl2
+ sed -i 's/^AUBITETC=.*/AUBITETC=\/etc\/opt\/aubit4gl2/g' /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/etc/opt/aubit4gl2/aubitrc
+ sed -i 's/^AUBITDIR=.*/AUBITDIR=\/usr\/local\/aubit4gl2/g' /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/etc/opt/aubit4gl2/aubitrc
+ sed -i 's/^AUBITDIR_SRC=.*/AUBITDIR_SRC=\/usr\/local\/aubit4gl2/g' /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/etc/opt/aubit4gl2/aubitrc
+ echo '# NOBLE: Make aubit utils only create 32-bit output'
+ echo CFLAGS=-m32
+ ln -s /usr/local/aubit4gl2/lib/libaubit4gl.so /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/lib/libaubit4gl.so
+ ln -s /usr/local/aubit4gl2/atomix4pg/bin/c4glpg /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/local/bin/c4glpg
+ ln -s /usr/local/aubit4gl2/atomix4pg/bin/c4glpg2 /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/local/bin/c4glpg2
+ ln -s /usr/local/aubit4gl2/bin/amake /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/bin/amake
+ ln -s /usr/local/aubit4gl2/bin/aubit /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/bin/aubit
+ ln -s /usr/local/aubit4gl2/bin/aubit-config /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/bin/aubit-config
Processing files: aubit4gl2-10.0.4-2.i686
warning: Explicit %attr() mode not applicaple to symlink: /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/local/bin/c4glpg
warning: Explicit %attr() mode not applicaple to symlink: /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386/usr/local/bin/c4glpg2
Provides: libA4GL_HTML.so libA4GL_file.so libA4GL_memcache.so libA4GL_pcre.so libA4GL_pick.so libA4GL_roman.so libA4GL_string.so libDATA_module.so libDATA_module_definition.so libDATA_report.so libDATA_struct_form.so libEXREPORT_NOPDF.so libFORM_GENERIC.so libFORM_NOFORM.so libFORM_XDR.so libHELP_std.so libLEX_C.so libLEX_CS.so libLEX_EC.so libLEX_PERL.so libLEX_WRITE.so libLOGREPPROC_CSV.so libLOGREPPROC_HTML.so libLOGREPPROC_TXT.so libLOGREP_CSV.so libLOGREP_HTML.so libLOGREP_TXT.so libMSG_NATIVE.so libPACKER_FORMXML.so libPACKER_GZPACKED.so libPACKER_MEMPACKED.so libPACKER_PACKED.so libPACKER_PERL.so libPACKER_XDR.so libPACKER_XML.so libRPC_NORPC.so libRPC_XDR.so libSQLPARSE_INFORMIX.so libSQLPARSE_NONE.so libSQL_FILESCHEMA.so libSQL_nosql.so libSQL_unixodbc.so libUI_CONSOLE.so libUI_HL_GTK.so libUI_HL_TUI.so libUI_HL_TUIN.so libUI_TUI.so libUI_TUI_wide.so libUI_XML.so libXDRPACKER_module.so libXDRPACKER_module_definition.so libXDRPACKER_report.so libXDRPACKER_struct_form.so libaubit4gl-1.2_39.so libbarcode.so libchannel.so liberrhook_sample.so aubit4gl2 = 10.0.4-2 aubit4gl2(x86-32) = 10.0.4-2 perl(report) perl(using)
Requires(interp): /bin/sh /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(pre): /bin/sh
Requires(post): /bin/sh
Requires(postun): /bin/sh
Requires: /bin/sh /usr/bin/perl libatk-1.0.so.0 libaubit4gl-1.2_39.so libaubit4gl.so libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1) libc.so.6(GLIBC_2.1.3) libc.so.6(GLIBC_2.12) libc.so.6(GLIBC_2.2) libc.so.6(GLIBC_2.2.3) libc.so.6(GLIBC_2.3) libc.so.6(GLIBC_2.7) libcairo.so.2 libcurl.so.4 libdl.so.2 libdl.so.2(GLIBC_2.0) libdl.so.2(GLIBC_2.1) libfontconfig.so.1 libform.so.5 libformw.so.5 libfreetype.so.6 libgdk-x11-2.0.so.0 libgdk_pixbuf-2.0.so.0 libgio-2.0.so.0 libglib-2.0.so.0 libgobject-2.0.so.0 libgtk-x11-2.0.so.0 libm.so.6 libm.so.6(GLIBC_2.0) libncurses.so.5 libncursesw.so.5 libodbc.so.2 libpanel.so.5 libpanelw.so.5 libpango-1.0.so.0 libpangocairo-1.0.so.0 libpangoft2-1.0.so.0 libpcre.so.1 libpthread.so.0 libpthread.so.0(GLIBC_2.0) libtinfo.so.5 libz.so.1 perl(DBI) perl(Date::Calc) perl(strict) perl(using) rtld(GNU_HASH)
Processing files: libaubit4gl-1.2_39-2.i686
Provides: libaubit4gl = 1.2_39-2 libaubit4gl(x86-32) = 1.2_39-2 libaubit4gl-1.2_39.so
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1) libc.so.6(GLIBC_2.1.3) libc.so.6(GLIBC_2.3) libc.so.6(GLIBC_2.7) libcurl.so.4 libdl.so.2 libdl.so.2(GLIBC_2.0) libdl.so.2(GLIBC_2.1) libm.so.6 libm.so.6(GLIBC_2.0) libz.so.1 rtld(GNU_HASH)
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386
Wrote: /home/bhand/rpmbuild/SRPMS/aubit4gl2-10.0.4-2.src.rpm
Wrote: /home/bhand/rpmbuild/RPMS/i686/aubit4gl2-10.0.4-2.i686.rpm
Wrote: /home/bhand/rpmbuild/RPMS/i686/libaubit4gl-1.2_39-2.i686.rpm
Executing(%clean): /bin/sh -e /home/bhand/rpmbuild/tmp/rpm-tmp.wtiBPg
+ umask 022
+ cd /home/bhand/rpmbuild/BUILD
+ cd aubit4gl2-10.0.4
+ rm -rf /home/bhand/rpmbuild/BUILDROOT/aubit4gl2-10.0.4-2.i386
+ exit 0
cp ~/rpmbuild/RPMS/i686/aubit4gl2-10.0.4-2.i686.rpm aubit4gl2-10.0.4-2.centos.7.postgres.i686.rpm
cp ~/rpmbuild/RPMS/i686/libaubit4gl-1.2_39-2.i686.rpm libaubit4gl-1.2_39-2.i686.rpm
cp RELEASENOTES aubit4gl2-10.0.4-2.centos.7.postgres.i686.RELEASENOTES
Edit 3: The output of rpm -qlvp aubit4gl2-10.0.4-2.centos.7.postgres.i686.rpm
rpm -qlvp nscaubit4gl2-10.0.4-2.centos.7.postgres.i686.rpm | grep libaubit4gl
lrwxrwxrwx 1 root root 42 Oct 11 14:06 /usr/lib/libaubit4gl.so -> /usr/local/nscaubit4gl2/lib/libaubit4gl.so
-rwxr-xr-x 1 root root 2439297 Oct 11 14:06 /usr/local/nscaubit4gl2/lib/libaubit4gl-1.2_39.so
lrwxrwxrwx 1 root root 21 Oct 11 14:06 /usr/local/nscaubit4gl2/lib/libaubit4gl.so -> libaubit4gl-1.2_39.so

Make sure the library has the executable bits on.

I added "Provides: libaubit4gl.so" to my spec file and it works now. For some reason, RPM was saying that the aubit4gl package was not providing this .so.
I'm still not 100% on why that is. But, this is what solved my problem.

If any file in the package's %files list is a shared library, the library's SONAME is automatically added to the list of capabilities the package provides.
In my case SONAME for the shared library is empty. After setting SONAME for shared library(as below using -Wl option in gcc) packging the modified shared library worked fine (automatically resolved capabilities).
To test whether SONAME is set properly you can use command objdump -p libaubit4gl.so | grep SONAME
SONAME is assigned/embedded into shared library during linking as below
gcc -shared -fPIC -Wl,-soname,libaubit4gl.so -o libaubit4gl.so foo.o bar.o baz.o -lc
SONAME can be different from file name libaubit4gl.so.
(Note: This is not as per standard but suggesting this to get rid of your error. However if you want to name shared library as per standards see versioning a shared library

You could have your spec file create two .rpm files: a libaubit4gl one and a aubit4gl one. The first provides this library and the other one requires it.
At least, this seems kind of good practice to me, at least if the library can be used w/o the binary.

I was having a similar problem. I was setting the executable bits on the created library with %file %attr, but it turned out that I wasn't setting the executable bits in my %install phase.
Setting the shared library file to 755 during %install AND %files fixed the problem.
I'm guessing that rpmbuild looks at the files in the BUILD directory for its analysis, so they have to be correct there, not just after the "rpm -i" installation.

Related

Set env variable for HSL so IPOPT can use the solver `ma57`

I am sorry but I am not good at setting environment variables / manual builds. I have downloaded the HSL solvers for IPOPT and I believe that I successfully install the whole package but I cannot set the environment variables so I can use it from IPOPT. I am getting this error message:
Exception message: Selected linear solver MA57 not available.
Tried to obtain MA57 from shared library "libhsl.so", but the following error occured:
libhsl.so: cannot open shared object file: No such file or directory
I went according this advice https://stackoverflow.com/a/67655434/12312879 but I am not sure what to do next. The last command sudo make install printed this:
libtool: install: /usr/bin/install -c .libs/libcoinhsl.so.2.2.1 /usr/local/lib/libcoinhsl.so.2.2.1
libtool: install: (cd /usr/local/lib && { ln -s -f libcoinhsl.so.2.2.1 libcoinhsl.so.2 || { rm -f libcoinhsl.so.2 && ln -s libcoinhsl.so.2.2.1 libcoinhsl.so.2; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libcoinhsl.so.2.2.1 libcoinhsl.so || { rm -f libcoinhsl.so && ln -s libcoinhsl.so.2.2.1 libcoinhsl.so; }; })
libtool: install: /usr/bin/install -c .libs/libcoinhsl.lai /usr/local/lib/libcoinhsl.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
If you have a current (3.14) Ipopt, then try setting Ipopt option hsllib to /usr/local/lib/libcoinhsl.so.
If Ipopt is older, then it doesn't have the hsllib option. You can try copying your libcoinhsl.so.2.2.1 to libhsl.so and ensure that Ipopt finds it (e.g., by having its path in LD_LIBRARY_PATH).
I you build Ipopt from source, then the preferred way would be to provide HSL at buildtime, see also https://coin-or.github.io/Ipopt/INSTALL.html#DOWNLOAD_HSL.

Bash: No such file or directory?

I try to use an executable script (wkhtmltopdf) on a Linux shared webserver (Debian, 64bit). I am pretty sure that I compiled everything correct, but whenever I want to execute the file I get as an response :
> ./wkhtmltopdf -H
-bash: ./wkhtmltopdf: No such file or directory
To be sure that the file is there, here the ls output :
> ls
wkhtmltoimage wkhtmltopdf
Furthermore I tested the file command on it, which outputs the following :
> file wkhtmltopdf
wkhtmltopdf: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
My question is now :
Why does bash tells me that there is no 'file or directory', when there obviously is one?
My first guess would be that the shared server does not allow to execute binary files? But shouldn't it then be a problem of permissions, with a different bash output?
Edit :
> id
uid=2725674(p8907906) gid=600(ftpusers) groups=600(ftpusers)
> ls -l wkhtmltopdf
-rwxrwxrwx 1 p8907906 ftpusers 39745960 Jan 20 09:33 wkhtmltopdf
> ls -ld
drwx---r-x 2 p8907906 ftpusers 44 Jan 28 21:02 .
I bet you miss dynamic linker. Just do a
readelf --all ./wkhtmltopdf | grep interpreter
You should get an output like this:
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
There are high chances that you system lacks the interpreter (/lib64/ld-linux-x86-64.so.2 in the example). In this case bash would yell No such file or directory, just like when the binary itself is missing.
You can try to use a different linker. Sometime you can succeed. Just do a:
/path/to/the/linker /path/to/your/executable
This command:
find /lib* -name ld-linux\*
will help you find the linkers on your system. Or you can do the readelf command on some command that does run. It will show you correct, working linker.
OR, since you are running Debian system, just do a
sudo apt-get install wkhtmltopdf
to install native version of the tool :)
In my case
$ readelf --all ./wkhtmltopdf | grep interpreter # readelf: Displays information about ELF files.
[Requesting program interpreter: /lib/ld-linux.so.2]
On a machine where the executable was working:
$ ls -lah /lib/ld-linux.so.2
lrwxrwxrwx 1 root root 25 Apr 16 2018 /lib/ld-linux.so.2 -> i386-linux-gnu/ld-2.27.so
$ dpkg -S /lib/ld-linux.so.2 # -S, --search filename-search-pattern: Search for a filename from installed packages.
libc6:i386: /lib/ld-linux.so.2
So to fix the problem (reference)
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libc6:i386 # GNU C Library: Shared libraries (from apt show)
Missing the linker was my case as well. I could fix it with the help of nsilent22 answer like this:
readelf --all /usr/local/myprogram | grep interpreter
[Requesting program interpreter: /lib64/ld-lsb-x86-64.so.3]
But that linker did not exist anymore.
The old situation in /lib64 was:
ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.31.so
ld-linux-x86-64.so.3 -> ld-linux-x86-64.so.2
So it turned out this was just a symlink to the systems' linker.
Moving over to /lib64 , which itself is a symlink to usr/lib64 and creating a symlink over there did not work. I assume that there are to many symbolic link levels after Debian moved everything into /usr
However creating a 'direct' symlink
ln -s /usr/lib64/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
did the job; /usr/lib64 now shows:
ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.31.so
ld-lsb-x86-64.so.3 -> /usr/lib64/ld-linux-x86-64.so.2
I ran into this issue on my raspberry pi 4 running aarch64 alpine 3.13. Using the answer provided by #vkersten, I was able to determine that I was missing /lib/ld-linux-aarch64.so.1.
I resolved this by installing gcompat with apk add gcompat.

Ansible 'synchronize' overwrites folder even though delete=no

In my Ansible role "xen", I have this task:
---
- name: Install Xen
synchronize: src=install/
dest=/
archive=yes
delete=no
I want to copy the following structure to the destination without overwriting files in the existing folders like /boot and /lib64:
root#node51 [~]# tree -L 1 /etc/ansible/xenhost/xen/files/install
/etc/ansible/xenhost/xen/files/install
├── boot
├── etc
├── lib64
├── usr
└── var
5 directories, 0 files
The task worked, but it replaced all the files in /lib64. That killed my server:
[root#localhost ~]# ls /lib64/
-bash: /usr/bin/ls: /lib64/ld-linux-x86-64.so.2: bad ELF interpreter: No such file or directory
Here's the verbose task output, truncated for brevity:
TASK: [xen | Install Xen] *****************************************************
<127.0.0.1> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676 && echo $HOME/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676']
<127.0.0.1> PUT /tmp/tmpb7EusD TO /root/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676/synchronize
<127.0.0.1> EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676/synchronize; rm -rf /root/.ansible/tmp/ansible-tmp-1448470134.66-193795609318676/ >/dev/null 2>&1']
changed: [192.168.0.123] => {"changed": true, "cmd": "rsync --delay-updates -FF --compress --archive --rsh 'ssh -o StrictHostKeyChecking=no' --out-format='<<CHANGED>>%i %n%L' \"/etc/ansible/xenhost/xen/files/install/\" \"root#192.168.0.123:/\"", "msg": "…truncated…"}
Curiously, the task didn't erase the existing files in /boot.
I made sure to specify delete=no explicitly, just in case, so it should not "Delete files that don't exist (after transfer, not before) in the src path."
Why did the Ansible 'synchronize' module replace /lib64 but copy to /boot as expected?
The issue is that /lib64 is not a directory. It is a symbolic link:
[root#localhost ~]# file /lib64
/lib64: symbolic link to `usr/lib64'
By having Ansible 'synchronize' rsync your lib64 directory, it removes the symbolic link and puts an actual folder in its place.
As a result, the libraries in /usr/lib64 are no longer reachable from /lib64, which is why everything that depended on finding libraries in /lib64 failed:
[root#localhost ~]# ldd /usr/bin/ls
linux-vdso.so.1 => (0x00007fffa9118000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fe4b9630000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fe4b9428000)
libacl.so.1 => /lib64/libacl.so.1 (0x00007fe4b9218000)
libc.so.6 => /lib64/libc.so.6 (0x00007fe4b8e50000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fe4b8be8000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fe4b89c0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fe4b87b8000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe4b9860000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007fe4b85b0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe4b8390000)
Remedy
Copy to /usr/lib64 instead. Put the libraries to copy in /etc/ansible/xenhost/xen/files/install/usr/lib64 instead of in /etc/ansible/xenhost/xen/files/install/lib64, and make sure the latter path does not exist.

CentOS 5.5 - symbolic link creation into RPM spec file

I need to create the following symbolic links into RPM file
/bin/ln -sf libcrypto.so.0.9.8e /lib/libcrypto.so.0.9.8
/bin/ln -sf libssl.so.0.9.8e /lib/libssl.so.0.9.8
In my RPM spec file:
%files
%defattr(-,root,root)
/lib/libcrypto.so.0.9.8
/lib/libssl.so.0.9.8
<other files...>
%install
/bin/ln -sf libcrypto.so.0.9.8e /lib/libcrypto.so.0.9.8
/bin/ln -sf libssl.so.0.9.8e /lib/libssl.so.0.9.8
The /lib/libcrypto.so.0.9.8e and /lib/libssl.so.0.9.8e are exists on my PC, but when I'm trying to install my RPM, I got an error:
libcrypto.so.0.9.8 is needed by my-test-rpm-1.el5.i686
libssl.so.0.9.8 is needed by my-test-rpm-1.el5.i686
What wrong? What I need to do in order to create symbolic links as part of the RPM installation?
Thanks
As workaround I disabled automatic dependency processing by adding:
AutoReqProv: no
to my spec file.
I'm still looking for the real solution.
You need to run ldconfig in the %post part of the spec file:
%post
umask 007
/sbin/ldconfig > /dev/null 2>&1
%postun
umask 007
/sbin/ldconfig > /dev/null 2>&1
should do it.
1) Just for symlinks you don't need to call ldconfig at post stage.
2) As already mentioned by ldav1s: Be sure that your files are listed in %files section.
3) Once again: Be sure that your files are listed - especially if you use something like
%define _unpackaged_files_terminate_build 0
RHEL rpmbuild terminates with an error if files are found in buildroot which are not listed in %files section. With this define you can switch the behaviour/error off but you should exactly know what you are actually doing. If you use this line you should remove it from your spec file.
4) Don't build the rpm package as user root. If you forget to use rpm_build_root you won't destroy your live system. Your example looks like it was taken from a spec file of Red Hat 4.2 of 1997. Since Red Hat 5 (not RHEL 5!) in 1997 the rpm/rpmbuild command knows the RPM_BUILD_ROOT definition. I guess that this is your problem: You don't use the buildroot but install directly into the root FS and run rpmbuild as user root.
Given your example it should be changed to:
%install
/bin/ln -sf libcrypto.so.0.9.8e $RPM_BUILD_ROOT/lib/libcrypto.so.0.9.8
/bin/ln -sf libssl.so.0.9.8e $RPM_BUILD_ROOT/lib/libssl.so.0.9.8
Using buildroot is described in RPM docs.
The best way to do this is by preventing the symlinks you created from being scanned by the automatic depends & requires generators:
%filter_provides_in libcrypto.so.0.9.8e
%filter_provides_in libssl.so.0.9.8e
%filter_requires_in libcrypto.so.0.9.8e
%filter_requires_in libssl.so.0.9.8e
%filter_setup
More information on depends/requires filtering here.

How to solve No such file or directory error: Bad exit status from (%prep) while building an RPM?

I am building an rpm please let me know where i am going wrong,
My spec file is rpms.spec and the contents are:
Summary: GNU indent
Name: rpms
Version: 1
Release: 1
Source0: %{name}-%{version}.tar.gz
License: GPL
Group: Development/Tools
%description
The GNU indent program reformats C code to any of a variety of
formatting standards, or you can define your own.
%prep
%setup -q
%build
./configure
make
%install
make install
%files
%defattr(-,root,root)
/usr/local/bin/indent
%doc /usr/local/info/indent.info
%doc %attr(0444,root,root) /usr/local/man/man1/indent.1
%doc COPYING AUTHORS README NEWS
I have copied the tar file to /usr/src/redhat/SOURCES/ also
and then when i do rpmbuild -ba rpms.spec I get the following error
rpmbuild -ba rpms.spec Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.87218
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf rpms-1
+ /bin/gzip -dc /usr/src/redhat/SOURCES/rpms-1.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd rpms-1 /var/tmp/rpm-tmp.87218: line 35: cd: rpms-1: No such file or directory error: Bad exit status from /var/tmp/rpm-tmp.87218 (%prep)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.87218 (%prep)
There is no directory as rpms-1.I tried creating the directory in BUILd directory it didnt work.
You have set Name to rpms and version to 1
rpmbuild will therefore assume that unpacking rpms-1.tar.gz results in a directory named rpms-1 in which is should step into to do the build.
if you want to override that, change the %setup to
%setup -n yourdir
where yourdir is whatever directory your sources are packaged in, inside your tar.gz file

Resources