#========================================= ##MySQL参数配置#mysql源码路径#源码包版本
%globalsrc_base mysql%global version 5.7.26
%global src_dir %{src_base}-%{version}%global cmake_bin /home/rpmbuilder/cmake-3.16.2-Linux-x86_64/bin/cmake
Name:%{src_base}
Version:%{version}#安装版本
Release: 1
#安装包介绍
Summary: MySQL Server#遵循协议
License: GPLv2#打包需要#BuildRequires: cmake /sbin/useradd /sbin/groupadd /bin/bash /bin/sh /bin/chown
#安装需要#Requires: ncurses ncurses-devel pcre numactl-libs numactl bison libaio libaio-devel
#安装的虚拟环境,在rpmbuild/BUILDROOT目录下
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-XXXXXX)#Sorce信息
Source0: %{name}-%{version}.tar.gz
Source10: boost_1_59_0.tar.bz2
Source90: filter-provides.sh
Source91: filter-requires.sh%if 0%{?rhel} > 6
#For rpm => 4.9 only: https://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering
%global __requires_exclude ^perl\((GD|hostnames|lib::mtr|lib::v1|mtr_|My::)%global __provides_exclude_from ^(/usr/share/(mysql|mysql-test)/.*|%{_libdir}/mysql/plugin/.*\.so)$%else
#https://fedoraproject.org/wiki/EPEL:Packaging#Generic_Filtering_on_EPEL6
%global __perl_provides %{SOURCE90}%global __perl_requires %{SOURCE91}%endif#mysql安装目录
%define mysql_server_path /data0/software/mysql/server#mysql数据目录
%define mysql_data_path /data0/software/mysql/data%define MYSQL_USER mysql%define MYSQL_GROUP mysql#mysql配置文件目录
%define mysql_conf_path /data0/software/mysql/server/etc/my.cnf#mysql描述
%description
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,androbust SQL (Structured Query Language) database server. MySQL Serveris intended for mission-critical, heavy-load production systems as well
asfor embedding into mass-deployed software.#========================================= ##环境准备
%prep
rm-rf $RPM_BUILD_ROOT/%{name}-%{version}#setup把boost和mysql压缩包解压到下面路径#./rpmbuild/BUILD/mysql-5.7.28/mysql-5.7.28/#./rpmbuild/BUILD/mysql-5.7.28/boost_1_59_0/
%setup -q -T -a 0 -a 10 -c -n %{src_dir}
groupadd%{MYSQL_GROUP} >/dev/null 2>&1 ||:
useradd-g %{MYSQL_GROUP} %{MYSQL_USER} -s /bin/nologin >/dev/null 2>&1 ||:#========================================= ##编译
%build%{cmake_bin} ./%{src_dir}-DCMAKE_INSTALL_PREFIX=%{mysql_server_path}-DMYSQL_DATADIR=%{mysql_data_path}-DSYSCONFDIR=%{mysql_server_path}/etc-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DMYSQL_UNIX_ADDR=%{mysql_data_path}/tmp/mysql.sock-DMYSQL_TCP_PORT=3306-DMYSQL_USER=mysql-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DENABLE_DOWNLOADS=1-DDOWNLOAD_BOOST=1-DWITH_BOOST=.
make-j3 %{?_smp_mflags}#========================================= ##安装
%install
rm-rf %{buildroot}
make DESTDIR=%{buildroot} install#========================================= ##制作RPM包
%files%defattr(-, %{MYSQL_USER}, %{MYSQL_GROUP})%attr(755, %{MYSQL_USER}, %{MYSQL_GROUP}) %{mysql_server_path}/*
%changelog