使用rmpbuild制作AliSQL数据库rpm软件包
2018-06-17 23:24:22来源:未知 阅读 ()
环境:REHL6.5
软件:rpmbuild
使用到的文件:ALiSQL-Master
一、安装所需要的软件
[root@alisql ~]# yum install rpm* rpm-build rpmdev* –y
[root@alisql ~]# rpmdev-setuptree
[root@alisql ~]# tree rpmbuild/
rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
5 directories, 0 files
二、将软件源码包上传到SOURCE目录
三、编写配置文件
在rpmbuild/SPECS目录下执行rpmdev-newspec -o alisql.spec,会在当前目录下生成名为alisql.spec的模板文件
[root@alisql SPECS]# rpmdev-newspec -o alisql.spec
根据修改alisql.spec文件,修改后的内容如下
Name: alisql
Version: 5.6.3
Release: 1%{?dist}
Summary: AliSQL
Group: Applications/Databases
License: GPL
URL: https://github.com/alibaba/AliSQL
Source0: %{name}-%{version}.tar.gz
BuildRequires: gcc gcc-c++
Requires: ncurses-devel bison perl
%define MYSQL_USER mysql
%define MYSQL_GROUP mysql
%description
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%prep
%setup -q
useradd mysql
mkdir -p /usr/local/mysql
mkdir -p /data/mysqldb
%build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%pre
id mysql &>/dev/null||useradd -m -s /bin/bash mysql &>/dev/null
mkdir -p /data/mysqldb
chown -R mysql: /data/mysqldb
%clean
rm -rf $RPM_BUILD_ROOT
%post
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysqldb &>/dev/null
cp -f /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
sed -i 's/^# basedir.*/basedir=\/usr\/local\/mysql/g' /etc/my.cnf
sed -i 's/^# datadir.*/datadir=\/data\/mysqldb/g' /etc/my.cnf
sed -i 's/^# socket.*/socket= \/tmp\/mysql.sock/g' /etc/my.cnf
cp -f /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
echo export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH >> /etc/profile
source /etc/profile
chkconfig --add mysqld &>/dev/null
chkconfig mysqld on &>/dev/null
%preun
chkconfig --del mysqld &>/dev/null
rm -rf /etc/init.d/mysqld &>/dev/null
%postun
userdel -r mysql &>/dev/null
rm -fr /data/mysqldb &>/dev/null
rm -fr /usr/local/mysql &>/dev/null
%files
%defattr(-,mysql,mysql,-)
/usr/local/mysql/bin
/usr/local/mysql/data
/usr/local/mysql/include
/usr/local/mysql/lib
/usr/local/mysql/scripts
/usr/local/mysql/share
/usr/local/mysql/support-files
/usr/local/mysql/README
/usr/local/mysql/docs
/usr/local/mysql/man
%exclude /usr/local/mysql/COPYING
%exclude /usr/local/mysql/mysql-test
%exclude /usr/local/mysql/sql-bench
%changelog
四、安装打包编译需要的软件
Name: alisql Version: 5.6.3 Release: 1%{?dist} Summary: AliSQL Group: Applications/Databases License: GPL URL: https://github.com/alibaba/AliSQL Source0: %{name}-%{version}.tar.gz BuildRequires: gcc gcc-c++ Requires: ncurses-devel bison perl %define MYSQL_USER mysql %define MYSQL_GROUP mysql %description The %{name}-devel package contains libraries and header files for developing applications that use %{name}. %prep %setup -q useradd mysql mkdir -p /usr/local/mysql mkdir -p /data/mysqldb %build cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1 make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' %pre id mysql &>/dev/null||useradd -m -s /bin/bash mysql &>/dev/null mkdir -p /data/mysqldb chown -R mysql: /data/mysqldb %clean rm -rf $RPM_BUILD_ROOT %post /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysqldb &>/dev/null cp -f /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf sed -i 's/^# basedir.*/basedir=\/usr\/local\/mysql/g' /etc/my.cnf sed -i 's/^# datadir.*/datadir=\/data\/mysqldb/g' /etc/my.cnf sed -i 's/^# socket.*/socket= \/tmp\/mysql.sock/g' /etc/my.cnf cp -f /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld echo export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH >> /etc/profile source /etc/profile chkconfig --add mysqld &>/dev/null chkconfig mysqld on &>/dev/null %preun chkconfig --del mysqld &>/dev/null rm -rf /etc/init.d/mysqld &>/dev/null %postun userdel -r mysql &>/dev/null rm -fr /data/mysqldb &>/dev/null rm -fr /usr/local/mysql &>/dev/null %files %defattr(-,mysql,mysql,-) /usr/local/mysql/bin /usr/local/mysql/data /usr/local/mysql/include /usr/local/mysql/lib /usr/local/mysql/scripts /usr/local/mysql/share /usr/local/mysql/support-files /usr/local/mysql/README /usr/local/mysql/docs /usr/local/mysql/man %exclude /usr/local/mysql/COPYING %exclude /usr/local/mysql/mysql-test %exclude /usr/local/mysql/sql-bench %changelog
1、安装编译所需要的软件
[root@alisql ~]# yum install gcc gcc-c++ ncurses-devel perl -y
2、安装cmake软件(点此下载)
将cmake源码包上传到家目录进行解压
[root@alisql ~]# tar -xf cmake-2.8.8.tar.gz [root@alisql ~]# cd cmake-2.8.8 [root@alisql cmake-2.8.8]# ./configure [root@alisql cmake-2.8.8]# make && make install
3、安装bison
[root@alisql ~]# yum install bison -y
五、在rpmbuild/SPECS目录下执行打包编译
[root@alisql SPECS]# rpmbuild -bb alisql.spec
等待软件打包成功,此时会在rpmbuild/RPMS/x86_64文件夹下生成rpm软件包。
参考文章
1、http://blog.chinaunix.net/uid-23069658-id-3944462.html
2、http://laoguang.blog.51cto.com/6013350/1103628
3、http://blog.csdn.net/kouyanqiu/article/details/53103249
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:Mysql 安装与卸载
下一篇:开启mysql远程登录
- PHP访问MySQL查询超时怎么办 2020-03-09
- MySQL中使用WHERE子句的方法 2019-10-25
- 关于laravel后台模板laravel-admin select框的使用详解 2019-10-08
- PHP 使用 Swoole - TaskWorker 实现异步操作 Mysql 2019-09-23
- 使用 Shell 在多服务器上批量操作 2019-09-23
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash