2021-05-12 14:32:11
使用rmpbuild製作AliSQL資料庫rpm軟體包
2020-06-16 17:21:16
環境: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: System Environment/Libraries
License: GPL
URL: http://www.abner.com.cn
Source0: %{name}-%{version}.tar.gz
BuildRequires: gcc gcc-c++
Requires: ncurses-devel bison
%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||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/*
%changelog
Version: 5.6.3
Release: 1%{?dist}
Summary: AliSQL
Group: System Environment/Libraries
License: GPL
URL: http://www.abner.com.cn
Source0: %{name}-%{version}.tar.gz
BuildRequires: gcc gcc-c++
Requires: ncurses-devel bison
%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||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/*
%changelog
四、安裝打包編譯需要的軟體
1、安裝編譯所需要的軟體
[root@alisql ~]# yum install gcc gcc-c++ ncurses-devel perl -y
2、安裝cmake軟體
cmake-2.8.8.tar.gz可以到Linux公社資源站下載:
------------------------------------------分割線------------------------------------------
免費下載地址在 http://linux.linuxidc.com/
使用者名稱與密碼都是www.linuxidc.com
具體下載目錄在 /2017年資料/2月/17日/使用rmpbuild製作AliSQL資料庫rpm軟體包/
下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm
------------------------------------------分割線------------------------------------------
將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軟體包。
本文永久更新連結地址:http://www.linuxidc.com/Linux/2017-02/140725.htm
相關文章