0

In my organization we need to deploy custom mysql packages for our Scientific Linux nodes. We need the latest version of mysql and the install directory as

/opt/mysql

I am trying to build from the Generic Linux Source Code archive mysql-5.5.18.tar.gz

This is my first time trying to build a rpm package and I get stuck with this spec file:

Name:       mysql       
Version:    5.5.18
Release:    1
Summary:    よろしく

Group:      incubation
License:    GPL 
Source0:    mysql-5.5.18.tar.gz 
BuildRoot:  %{_tmppath}/%{name}-buildroot

Source1: mysql.sysconfig
Source2: mysql.init
Source3: my.cnf

%description
first shot

%prep
%setup -q


%build
cmake . -DCMAKE_INSTALL_PREFIX="/opt/mysql" \
    -DMYSQL_DATADIR="/var/lib/mysql"

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install


mkdir -p $RPM_BUILD_ROOT/var/log
touch $RPM_BUILD_ROOT/var/log/mysqld.log


mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT/var/run/mysqld
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
install -m 0755 -d $RPM_BUILD_ROOT/var/lib/mysql

%clean
rm -rf $RPM_BUILD_ROOT

With fails like this:

rpmbuild -ba SPECS/mysql-server.spec
[ STRIPPED DATA ]
-- Installing: /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/opt/mysql/man/man8/mysqld.8
+ mkdir -p /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/var/log
+ touch /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/var/log/mysqld.log
+ mkdir -p /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/etc/rc.d/init.d
+ mkdir -p /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/var/run/mysqld
+ mkdir -p /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/etc/sysconfig
+ install -m 0755 -d /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/var/lib/mysql
+ /usr/lib/rpm/find-debuginfo.sh --strict-build-id /home/jean_daniel/rpmbuild/BUILD/mysql-5.5.18
extracting debug info from /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/opt/mysql/bin/mysql_plugin
extracting debug info from /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-
[ STRIPPED DATA ]
extracting debug info from /home/jean_daniel/rpmbuild/BUILDROOT/mysql-5.5.18-1.x86_64/opt/mysql/lib/libmysqlclient.so.18.0.0
symlinked /usr/lib/debug/opt/mysql/lib/libmysqlclient.so.18.0.0.debug to /usr/lib/debug/opt/mysql/lib/libmysqlclient_r.so.18.debug
symlinked /usr/lib/debug/opt/mysql/lib/libmysqlclient.so.18.0.0.debug to /usr/lib/debug/opt/mysql/lib/libmysqlclient_r.so.debug
symlinked /usr/lib/debug/opt/mysql/lib/libmysqlclient.so.18.0.0.debug to /usr/lib/debug/opt/mysql/lib/libmysqlclient.so.debug
symlinked /usr/lib/debug/opt/mysql/lib/libmysqlclient.so.18.0.0.debug to /usr/lib/debug/opt/mysql/lib/libmysqlclient_r.so.18.0.0.debug
symlinked /usr/lib/debug/opt/mysql/lib/libmysqlclient.so.18.0.0.debug to /usr/lib/debug/opt/mysql/lib/libmysqlclient.so.18.debug
cpio: mysql-5.5.18/storage/innobase/lexyy.c: Cannot stat: No such file or directory
cpio: mysql-5.5.18/storage/innobase/pars0grm.c: Cannot stat: No such file or directory
cpio: mysql-5.5.18/storage/innobase/pars0grm.y: Cannot stat: No such file or directory
cpio: mysql-5.5.18/storage/innobase/pars0lex.l: Cannot stat: No such file or directory
74358 blocks
+ /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
error: Bad file: /home/jean_daniel/rpmbuild/SOURCES/my.cnf: No such file or directory
error: Bad file: /home/jean_daniel/rpmbuild/SOURCES/mysql.init: No such file or directory
error: Bad file: /home/jean_daniel/rpmbuild/SOURCES/mysql.sysconfig: No such file or directory


RPM build errors:
    Bad file: /home/jean_daniel/rpmbuild/SOURCES/my.cnf: No such file or directory
    Bad file: /home/jean_daniel/rpmbuild/SOURCES/mysql.init: No such file or directory
    Bad file: /home/jean_daniel/rpmbuild/SOURCES/mysql.sysconfig: No such file or directory

I don't know where to look at.

Any ideas? Thanks in advance

1 Answer 1

1

The files that are missing (that are specified in the spec file as Source[123]) are either RedHat specific or is the basic my.cnf file. These won't be typically included in the basic mysql-5.5.18 source tarball and are generally added by Red Hat in their RPMs.

What I would do is get the SRPM for this version of MySQL. Go to http://dev.mysql.com/downloads/mysql/ and "Select Platform: Source Code". This will give you the list of SRPMs for RHEL. Pick the one corresponding to your version of Scientific and install it.

This will give you a bunch of files in /usr/src/redhat (I think, it's been a while), including a RedHat spec file that you can modify to point at /opt/mysql. It will also give you the supplemental files that you're missing in the /usr/src/redhat/SOURCES directory. You can proceed from there. The RPM build process looks for those files in the SOURCES directory. (The spec file probably breaks everything out into a bunch of separate RPMs when you actually build it, i.e., the client package, the server package, dev libraries, etc.)

Update: Take a look at http://fedoraproject.org/wiki/How_to_create_an_RPM_package#Macros which describes how the spec file arranges the installed files. I believe you'll need to define the macros like "_bindir", "_sbindir" and so on at the top of the spec file.

2
  • Thank you for your indications. I could rebuild successfully from the proper SRPM but I couldn't find where to change the install directory to '/opt/mysql'. I changed different variables with no success. Changing RBR=$RPM_BUILD_ROOT to RBR=$RPM_BUILD_ROOT/opt/bin turned out to break the compilation. The spec file is available at this link I wish I could understand better rpm package building. Again if you could help that would be much appreciated. Thanks a lot Dec 8, 2011 at 6:25
  • Updated to look at the How To Create RPM doc. You don't want to change the RPM_BUILD_ROOT. The process is for rpmbuild to build everything in RPM_BUILD_ROOT, which is a temporary directory. Once everything is built, it will run through the %file section and put the built files into the specified locations. You want to change those specified locations using the macros. You don't want to change where compilation takes place.
    – cjc
    Dec 8, 2011 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .