在我的组织中,我们需要为 Scientific Linux 节点部署自定义 mysql 包。我们需要最新版本的 mysql 和安装目录
/选择/mysql
我正在尝试从通用 Linux 源代码档案 mysql-5.5.18.tar.gz 构建
这是我第一次尝试构建 rpm 包,但我被这个 spec 文件难住了:
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
失败如下:
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
我不知道该看哪儿。
有什么想法吗?提前致谢
答案1
缺失的文件(在 spec 文件中指定为 Source[123])要么是 RedHat 特有的,要么是基本的 my.cnf 文件。这些文件通常不会包含在基本的 mysql-5.5.18 源 tarball 中,通常由 Red Hat 在其 RPM 中添加。
我要做的是获取此版本 MySQL 的 SRPM。转到http://dev.mysql.com/downloads/mysql/和“选择平台:源代码”。这将为您提供 RHEL 的 SRPM 列表。选择与您的 Scientific 版本相对应的 SRPM 并安装它。
这将为您提供 /usr/src/redhat 中的一堆文件(我想,已经有一段时间了),包括一个 RedHat spec 文件,您可以修改它以指向 /opt/mysql。它还将为您提供 /usr/src/redhat/SOURCES 目录中缺少的补充文件。您可以从那里继续。RPM 构建过程会在 SOURCES 目录中查找这些文件。(当您实际构建 spec 文件时,它可能会将所有内容分解为一堆单独的 RPM,即客户端包、服务器包、开发库等。)
更新:查看http://fedoraproject.org/wiki/How_to_create_an_RPM_package#Macros它描述了 spec 文件如何排列已安装的文件。我相信您需要在 spec 文件的顶部定义“_bindir”、“_sbindir”等宏。