CentOS 5.5 - symbolic link creation into RPM spec file - linux

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.

Related

rpminstall - run shell script inside rpm during install

I am working on an RPM which unpackages a tar file into an RPM whenever I run rpmbuild. I have two questions around the process:
Is my process of unpackaging the tar file into the RPM correct?
When I install the actual rpm onto a server, I'd like it to run a script inside the RPM which I have copied in called install.sh. How do I do that?
%build
# let's skip this for now
%install
mkdir -p %{buildroot}
chmod 755 ~/rpmbuild/SOURCES/bin/*
cp -frv ~/rpmbuild/SOURCES/bin/* %{buildroot}
%files
/*
%changelog
# let's skip this for now
Generally RPM support pre and post installation/uninstall scripts. And they are defined with %pre, %post, %preun and %postun. So if you are sure this file (install.sh) already exist you can run it on this way:
%pre
/path/to/install.sh
or
%post
/path/to/install.sh

Error while creating rpm package using rpmbuild from spec file

I want to build a rpm package from a spec file(hello-world.spec).The command and error output are given below
Command1:
rpmbuild -ba hello-world.spec
ErrorOutput1:
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.z4GoQn
+ umask 022
+ cd /root/rpmbuild/BUILD
+
: not foundm-tmp.z4GoQn: 28: /var/tmp/rpm-tmp.z4GoQn:
error: Bad exit status from /var/tmp/rpm-tmp.z4GoQn (%prep)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.z4GoQn (%prep)
Content of my spec file is
Name: hello-world
Version: 1
Release: 1
Summary: Most simple RPM package
License: FIXME
%description
This is my first RPM package, which does nothing.
%prep
# we have no source, so nothing here
%build
cat > hello-world.sh <<EOF
#!/usr/bin/bash
echo Hello world
EOF
%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh
%files
/usr/bin/hello-world.sh
%changelog
# let's skip this for now
My System/software details are
OS: Ubuntu 16.04
RPM version:4.12.0.1
The list of contents in rpmbuild folder is
Command2:
:~/rpmbuild# ls
Output2:
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
Can anybody help on this issue?
Check how your files is being generated. If you are passing files from windows to Linux, usually, there are different EOL for the files. We had a similar issue, I recommend you to change all the files to Unix format. I'm sharing with you how to reproduce your issue, if you edit that file in a Linux environment, like "nano", the problem disappears.

%prep problems when building RPMs on CentOS 7

Following all the random guides on the net and even on here:
What is the minimum I have to do to create an RPM file?
Nothing seems to work with Centos 7 (surprise!)
It seems if you leave %prep in your spec file, rpmbuild will try its hardest to ./configure and make something. what I'm not sure.
here is a super basic .spec file I'm trying to make an rpm to just copy in a file.
$more newpackage.spec
Name: hello
Version: 1.2
Release: 1%{?dist}
Summary: Testing testing 1 2 3
License: Beer
URL: No
#so apparently now you have to have version numbers everywhere, even the tar files, uhg
Source0: hello-1.2.tar.gz
#and the breaking begins :-( why everything broke with you centos 7?
# BuildRoot: %{_tmppath}/%{name}-%{version}-root
# BuildRequires:
# Requires:
%description
nothing to see here folks
#well here is some of the confusion
#%prep
%setup -q
# ./configure missing? um yeahhhh
# %build
# %configure
# make %{?_smp_mflags}
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
%files
#/usr/bin/hello.sh
%{_bindir}/hello.sh
# %doc
# %changelog
in side the tar file is /usr/bin/hello.sh
which is shell script that just runs echo "hello world"
if i comment %prep rpmbuild complains about ./configure not being found.
rpmbuild -v -bb newpackage.spec
Looks like commenting out %build dosen't actully stop rpmbuild from trying to build the sources...
so if i DELETE out %build and %configure and that make line. things work

Why am I getting "Unable to find the checksum in the image" error?

I'm using the CentOS_6.5_Final minimum install ISO. I would like to add kernel-devel to the Packages directory and rebuild the ISO for install.
First I loop mounted the source ISO and copied the data to a directory, added kernel-devel from the full DVD ISO using the same loop mount method.
Then I created the repodata from the /mnt/CentOS-6.5-x86_64-minimal directory.
createrepo -p /mnt/CentOS-6.5-x86_64-minimal/Packages/
The repodata is then place in /mnt/CentOS-6.5-x86_64-minimal/Packages/repodata, so I moved it to /mnt/CentOS-6.5-x86_64-minimal/repodata and replaced the original /mnt/CentOS-6.5-x86_64-minimal/repodata with the new.
I then rebuilt the ISO.
genisoimage -o /tmp/CentOS-6.5-x86_64-minimal.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -V OSSA_01 -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /mnt/CentOS-6.5-x86_64-minimal/
Have I missed a step?
I'm not really looking to use the ks file right now. How do I make sure the image checksum is still valid? Is this what the GPG files in the ISO root are for?
Got it, I was missing two hidden files..
.discinfo and .treeinfo

rpmbuild spec file %install section error

I have a spec file which is similar to:
BuildRoot: /tmp/build_%{name}-%{version}-%{release}
%prep
...
...
%install
# Directories
install -m 755 -d %{buildroot}/usr/app/mypackage/config
install -m 755 -d %{buildroot}/usr/app/mypackage/src
....
# Bash script
install -m 755 script/script1.sh %{buildroot}/usr/app/mypackage/config/script1.sh
install -m 755 script/script2.sh %{buildroot}/usr/app/mypackage/config/script2.sh
install -m 755 script/myapp-log %{buildroot}/etc/logrotate.d/myapp-log
When I run the rpmbuild I get the error:
install: cannot create regular file `/tmp/build_my_app-1.0-2/etc/logrotate.d/myapp-log'
I can get around this by manually creating the /etc/ and then /etc/logrotate.d directories in the /tmp/build_my_app-1.0-2/ directory.
When I re-reun the rpmbuild it will work.
I guess this is because I am not creating this directory in my install section but as its not directly related to my application I don't want to put that in.
My guess is that there is some clever tag I can use to fix this so that the build will work without any manual intervention.
My Question:
Could someone please suggest a way for me to achieve this (assuming its possible) or whether I need to write a script around the rpmbuild to set this up first.
You are missing the step to create the installation directories in your %install section. Remember that since you can build in "different" roots, you cannot expect certain directories (like ${buildroot}/etc) to be present.
Try adding
mkdir -p ${buildroot}/etc/logrotate.d
just before the install command that copies the file into ${buildroot}/etc/logrotate.d.

Resources