rpmbuild on CentOS: no such file or directory - centos

I have created a simple RPM on Fedora27 and it worked fine. It just copied files from tar.gz to /usr/bin/.
When I tried to install this RPM on CentOS I got:
# rpm -i RPMS/x86_64/my_rpm-0.0-5.x86_64.rpm --force
error: Failed dependencies:
libc.so.6(GLIBC_2.26)(64bit) is needed by my_rpm-0.0-5.x86_64
So I assumed I will need to create the RPM on CentOS.
But when I do so I get a weird: 'No such file or directory' that I don't get on Fedora27. Here is a sketch of my spec file:
%define _topdir %(pwd)
%define name my_rpm
%define release 5
%define version 0.0
%define buildroot %{_topdir}/%{name}-%{release}-root
BuildRoot: %{buildroot}
Summary: my_rpm
License: -
Name: %{name}
Release: %{release}
Version: %{version}
Source: %{name}-%{version}-%{release}.tar.gz
Prefix: /usr
Group: Tools
%description
This is my_rpm spec file
%prep
%setup -q -n %(arch)/%{name}-%{version}
%install
install -D my_app -t %{buildroot}/usr/bin/my_rpm/
%files
/usr/bin/my_rpm/*
When I try to build the RPM for it I get:
# rpmbuild -v -bb --clean SPECS/bpf.spec
+ install -D app -t /root/rpmbuild/BUILDROOT/my_rpm-0.0-5.x86_64/usr/bin/my_rpm/
install: failed to access '/root/rpmbuild/BUILDROOT/my_rpm-0.0-5.x86_64/usr/bin/my_rpm/': No such file or directory
The same SPEC exactly runs smoothly on Fedora27.
What should I change in it my spec file so that it would work both on Fedora27 and CentOS7? or maybe I can fix my initial problem with Glibc?
EDIT 1
I added the "mkdir -p ..." command under install and the build was successful but it still gives me the same error, that I need Glibc 2.6.
What I don't understand is why during the build it says:
Requires: libc.so.6()(64bit) libc.so.6(GLIBC_2.14)(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.26)(64bit) libc.so.6(GLIBC_2.3)(64bit) libc.so.6(GLIBC_2.3.4)(64bit) libc.so.6(GLIBC_2.7)(64bit) libc.so.6(GLIBC_2.9)(64bit) libelf.so.1()(64bit) libelf.so.1(ELFUTILS_1.0)(64bit) rtld(GNU_HASH)
Edit 2(solution)
I got it to work. My executables are compiled C code. So I had to re-compile everything on CentOS and then build the rpm. Now it works on both Fedora and CentOS.

Related

rpmbuild no such file or directory

I'm just learning making rpm packages for some custom builds of software that gets compiled from source (some legacy stuff needs this, so I'm trying to learn, as some packages can't use the latest versions), but hitting an error (I'm doing this in Vagrant, and also as root, but typically I'm trying not to use root as I'm aware it has potential for damage, its just this example seems to need some root changes).
sudo rpmbuild -ba testspec.spec --define "_topdir /tmp/"
So far it looks to be using the directory I expected, /tmp/rpmbuild
make[2]: Entering directory `/tmp/rpmbuild/BUILD/exim-4.80.1/build-Linux-x86_64/pdkim'
make[2]: `pdkim.a' is up to date.
make[2]: Leaving directory `/tmp/rpmbu
But then I see these errors...
/usr/lib/rpm/brp-compress: line 8: cd: /tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64: No such file or directory
+ /usr/lib/rpm/brp-strip
find: `/tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-static-archive
find: `/tmp/BUILDROOT/custom-exim-4.80.1-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-comment-note
So it now seems to be looking in /tmp/BUILDROOT
I'm new to rpmbuild, and don't quite understand some of the process.
My test spec file is at...
%define myversion exim-4.80.1
##%define mybase %{getenv:HOME}
%define mybase /tmp
%define _topdir %{mybase}/rpmbuild
%define _tmppath %{mybase}/rpmbuild/tmp
%define name custom-exim
%define release 1
%define version 4.80.1
%define buildroot %{_topdir}/%{name}-%{version}-root
BuildRoot: %{buildroot}
Summary: %{name}
Name: %{name}
Version: %{version}
Release: %{release}
Source0: ftp://exim.noris.de/exim/exim4/old/exim-4.80.1.tar.gz
License: GPLv1+
Group: Language
AutoReq: no
AutoProv: no
Requires: db4-devel pcre-devel libdb-devel libXt-devel libXaw-devel
%description
Custom Exim Build
%prep
#Do the following manually before building rpm
#mkdir -p /tmp/rpmbuild/BUILD /tmp/rpmbuild/SPECS /tmp/rpmbuild/SOURCES /tmp/rpmbuild/BUILDROOT /tmp/rpmbuild/RPMS /tmp/rpmbuild/SRPMS
#wget ftp://exim.noris.de/exim/exim4/old/exim-4.80.1.tar.gz -O /tmp/rpmbuild/SOURCES/exim-4.80.1.tar.gz
%setup -q -n %{myversion}
grep exim /etc/passwd || useradd -c "Exim" -d /var/spool/exim -m -s /bin/bash exim
%build
# exim needs to config changes before compiling, may do these first and repackage
cp %{mybase}/rpmbuild/BUILD/%{myversion}/src/EDITME %{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile
cp %{mybase}/rpmbuild/BUILD/%{myversion}/exim_monitor/EDITME %{mybase}/rpmbuild/BUILD/%{myversion}/Local/eximon.conf
sed -i -e 's/EXIM_USER=$/EXIM_USER=exim/g' "%{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile"
sed -i -e 's/LOOKUP_DNSDB=yes/#LOOKUP_DNSDB=yes/g' "%{mybase}/rpmbuild/BUILD/%{myversion}/Local/Makefile"
make
%install
rm -rf $RPM_BUILD_ROOT
#%{__mkdir_p} '%{buildroot}%{_sbindir}'
make install
%clean
rm -rf $RPM_BUILD_ROOT
%post
%postun
%files
Why is it using /tmp/BUILDROOT literally, instead of /tmp/rpmbuild, and are there other obvious things I'm doing wrong ? I've looked at a lot of other tutorials on rpmbuild, but aren't very clear on best practices or what happens during each phase.
Since the buildroot parm is not passed to rpmbuild, the default path is being used by your spec file:
BuildRoot: %{buildroot}
Try adding the buildroot parm... Add buildroot /tmp/rpmbuild to --define
Or if using a makefile:
BUILD_TMP=/tmp/rpmbuild
TOP_DIR=/tmp
rpmbuild -bb
--buildroot $(BUILD_TMP)
--topdir $(TOP_DIR)
$(SPEC_DIR)/testspec.spec
In my case rpm-build was missing.
So sudo yum install rpm-build solved the problem. Or if you use puppet:
package { 'rpm-build':
ensure => latest,
}

rpm build fails to make build root dir

I am working on making an rpm for a small program used within our enterprise. The %build section of the rpm process works. I'm having trouble with the install section. I've referenced this article response and I believe I am properly referring to the target location with respect to %{_buildroot}.
The program I'm making is to be installed as a system service. So, after the rpm actually is generated for this step, I've got to add the next step in my installation process which is to include the script that is installed to the init.d location and run that install. One step at a time though.
The build errors are as follows (omitting everything but %install):
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.eUDaCK
+ umask 022
+ cd /home/packager/rpmbuild/BUILD
+ '[' /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 '!=' / ']'
+ rm -rf /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
++ dirname /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ mkdir -p /home/packager/rpmbuild/BUILDROOT
+ mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64
+ cd o2arbitord-1.0
+ LANG=C
+ export LANG
+ unset DISPLAY
+ install -m 555 /home/packager/rpmbuild/BUILD/o2arbitord-1.0/o2arbitord /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin
install: cannot create regular file `/home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.eUDaCK (%install)
Now, my rpmbuild directory does not have the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin. While I know that's part of the problem, the rpmbuild process isn't making the directory /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 either. What I don't understand about that one is: why? Looking at the script output above you can clearly see the line: mkdir /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64. So, why isn't the directory made?
How does the line BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) from whatever the definition of %{_buildroot} is? I thought that was the definition, but it appears to be something different.
For reference, my spec file
Name: o2arbitord
Version: 1.0
Release: 1%{?dist}
Summary: a daemon
Group: Applications/System
License: GPL
URL: http://My.site
Source0: %{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: x86_64
BuildRequires: libusb1-devel
#Requires:
%description
%prep
%setup -q
%build
make -f o2arbitord.mk
%install
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/usr/sbin/o2arbitord
%changelog
You are attempting to install a file into a directory that doesn't exist (yet).
RPM only creates the %{buildroot} for you automatically. Anything under that you need to create yourself.
So when you run
install -m 555 %{_builddir}/%{name}-%{version}/%{name} %{buildroot}%{_sbindir}
where %{buildroot}%{_sbindir} expands to /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64/usr/sbin RPM has only created /home/packager/rpmbuild/BUILDROOT/o2arbitord-1.0-1.el6.x86_64 for you already.
You need to create the /usr/sbin part of that path and then copy the file into it.
You can do that with either
%{__mkdir_p} '%{buildroot}%{_sbindir}'
or
%{__install} -d '%{buildroot}%{_sbindir}'
Where
$ rpm -E '__mkdir_p = %{__mkdir_p}'
__mkdir_p = /bin/mkdir -p
$ rpm -E '__install = %{__install}'
__install = /usr/bin/install

unable to install haproxy 1.5 on centos 6.5

I am trying to install haproxy on my centos 6.5 server. I am using the command
yum install haproxy
This command installs a version 1.4.x. I have also looked at the following links, but could not get it to work
http://virtuallyhyper.com/2013/05/configure-haproxy-to-load-balance-sites-with-ssl/
http://blog.haproxy.com/2012/09/10/how-to-get-ssl-with-haproxy-getting-rid-of-stunnel-stud-nginx-or-pound/
https://github.com/bluerail/haproxy-centos
how do i install it?
You can build the RPM as follows:
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
sudo yum -y install pcre-devel openssl-devel
cd rpmbuild/SOURCES
curl -L -O http://www.haproxy.org/download/1.5/src/haproxy-1.5.3.tar.gz
tar zxf haproxy-1.5.3.tar.gz
cd ..
cp -p SOURCES/haproxy-1.5.3/examples/haproxy.spec SPECS/haproxy153.spec
sed -i 's/Release: .*/Release: %{?_release:%{_release}}%{!?_release:1}/' SPECS/haproxy153.spec
sed -i 's/USE_PCRE=1 /USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 /' SPECS/haproxy153.spec
rpmbuild --define "_topdir `pwd`" --define "_release 2" -bb SPECS/haproxy153.spec
(I use a local directory and set the release number otherwise it is the same as http://qiita.com/uemura/items/e822c1ed505b9fe0208f)
Install
scp RPMS/x86_64/haproxy-1.5.3-2.x86_64.rpm root#somewhere:~/
somewhere# yum localinstall ~/haproxy-1.5.3-2.x86_64.rpm
You could install from source using one of these tar bundles:
http://www.haproxy.org/download/1.5/src/
You will probably need to install the following bundles to compile from source:
yum openssl-devel pcre-devel make gcc
Here's also a script which I presume would work on your environment

snort installation error on centos 6.5

[root#localhost ~]# service snortd start
Starting snort: /usr/sbin/snort: error while loading shared libraries: libdnet.1: cannot open shared object file: No such file or directory
[FAILED]
But libdnet is installed:
root#localhost ~]# rpm -qa libdnet
libdnet-1.11-1.2.el6.rf.x86_64
I had a similar problem using snort-2.9.6.2-1.centos6.x86_64.rpm downloaded from snort.org.
yum install snort-2.9.6.2-1.centos6.x86_64.rpm would not work because it needed version 1.11-1.2.el6 and the current version is 1.12-6.el6 so I had to download the rpm and from http://pkgs.repoforge.org/libdnet. After installing that my snort would install.
That aside I see you are already using the right version but it still doesn't work. So try this
# find / -name 'libdnet*'
/usr/lib64/libdnet.so.1.0.1
/usr/lib64/libdnet.so.1
# cd /usr/lib64
# ln -s libdnet.so.1.0.1 libdnet.1
Snort should now start assuming everything else such as the conf files are set up ok

RPM %files absolute path issue

I am relatively new to creating RPM packages. I am using Fedora 19 OS , I am not able to make RPM pick %files from absolute path. Please advice on the same
Name: SampleRpm
Version: 1
License: none
Release: 5.6
buildroot: /root/rpmbuild
prefix: /root/rpmbuild
Summary: Sample
Group: Applications/Sample
%prep
rm -r /home/siva/rpmbuild/SOURCES/
%build
cd /home/siva/repos/centina/sa
ant clean make-private dist
cp /home/siva/repos/centina/sa/dist/Sample.zip /root/rpmbuild/SOURCES
%install
cp /home/siva/repos/centina/sa/dist/Sample.zip /root/setup
cd /root/setup
unzip Sample.zip
chmod +x setup.sh
./setup.sh -o
%description
empty
%files
/root/rpmbuild/SOURCES
i get the following error
error: File not found: /root/rpmbuild/BUILDROOT/SampleRpm-1-5.6.x86_64/root/rpmbuild/SOURCES
Thanks in advance
%files is where the final files will be. I would recommend finding an RPM primer online - there are many that walk you right thru step by step.