rpm spec
详细介绍 rpm spec 制作步骤。
开始
Name: leafpad
Version:
Release: 1
Summary:
Group:
License:
URL:
Source0:
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:
Requires:
%description
%prep
%setup -q
%build
%configure
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc
%changelog
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Name:
Version:
Release: 1%{?dist} # 根据此项可进行rpm升级操作,?代表有dist值就使用没有则不使用dist变量
Summary:
Group: # /usr/share/doc/rpm-4.11.3/GROUPS中可以查看或者去 https://fedoraproject.org/wiki/RPMGroups
License:
URL:
pagkager: echoxu xjh@xujianhui.cn
Vendor: https://www.echoxu.cn
Source0: https://nginx.org/download/%{Name}-%{Version}.tar.gz # 并不会从互联网下载,只是去查找%{Name}-%{Version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX # 虚拟安装根目录,由于将rpm包安装在此处,目录结构和rpm真实安装后的目录结构相同,如:/var/tmp/nginx-1.16.0-root/usr/local/nginx
BuildRequires: # 构建rpm时所依赖的包
Requires: # 安装rpm时所依赖的包
%description # "rpm -qi" 查询时所显示的内容
%prep # 准备阶段,如解压缩源码文件,复制文件等操作
%setup -q # 不显示输出内容,进入并解压源码包
%build # 执行configure”和“make”操作
%configure
make -j 4 %{?_smp_mflags} #利用多核进行编译,类似于make -j 4
%install # 临时安装软件到 $RPM_BUILD_ROOT中,也是前面指定的BuildRoot值 ,man install查看install帮助手册
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%clean # 清理临时安装目录
rm -rf $RPM_BUILD_ROOT
rm -rf $BUILD
%pre # 制作完成后的rpm在其安装之前要执行的脚本
%post # 安装完成后执行的脚本
%preun # 卸载开始之前执行的脚本
%postun # 卸载完成后要执行的脚本
%files # 收集BuildRoot里的文件并打包进rpm包,除了debug文件
%defattr(-,root,root,-)
%doc # 作为文档使用,/usr/share下
%changelog # 更新日志
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
- 查看宏:https://docs.fedoraproject.org/en-US/packaging-guidelines/RPMMacros/
- 查看软件包应该属于哪个组:https://fedoraproject.org/wiki/RPMGroups
mysql.sepc
需要针对 mysql 服务器进行内核参数调整
- spec 文件
- 开机启动文件:mysql.service
- mysql.tar.gz
- my.cnf
- mysql.logrotate
- tcmalloc
修改my.cnf,添加如下参数并重启
[mysqld_safe]
malloc-lib=tcmalloc
安装tcmalloc
- 安装libunwind 0.99
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
- 安装tcmalloc
./configure
make&&make install
- 添加到LD_LIBRARY_PATH
#cd /etc/ld.so.conf.d/
#echo "/usr/local/lib">local_lib.conf
#ldconfig
5.5 之前的mysql调整/etc/init.d/mysql 或者mysqld_safe
添加 export LD_PRELOAD=/usr/lib/libtcmalloc.so /* 或者编译后的位置 */
5.5 还可以在my.cnf添加参数
[mysqld_safe]
malloc-lib=tcmalloc
启动mysql #lsof -n | grep -i tcmalloc 查看是否已加载
编译安装 libunwind
git clone https://github.com/libunwind/libunwind
cd libunwind
./autogen.sh
./configure --prefix=/usr --enable-shared #编译成.so,否则默认静态.la
make
make install
2
3
4
5
6
https://blog.51cto.com/luweiv998/2354385
%setup
参数介绍:http://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html
https://rpm-packaging-guide.github.io/#rpm-macros
https://www.cnblogs.com/wshsdlau/p/3529045.html
https://blog.51cto.com/purplegrape/1382076
https://blog.51cto.com/changfei/1703824
https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html#cmake-compiler-flags
https://blog.csdn.net/taget/article/details/8493596
https://cloud.tencent.com/developer/article/1444873
https://www.cnblogs.com/gaogao67/p/12148214.html
编译器参数:
[echoxu@fedora ~]$ rpm --eval %{optflags}
-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
[echoxu@fedora ~]$ rpm --eval %{?_smp_mflags}
-j8
2
3
4