源码包打包让公司其他人更快的安装

拿ngixnx-1.12.2来说

1.安装rpm-build软件包
yum -y install rpm-build
2.生成rpmbuild目录结构
rpmbuild -ba nginx.spec //会报错,没有文件或目录报错也要打上去 避免自己去创建文件夹 它会自己生成目录
3.将源码软件复制到SOURCES目录
cp nginx-1.12.2.tar.gz /root/rpmbuild/SOURCES/
4.创建并修改SPEC配置文件
vim /root/rpmbuild/SPECS/nginx.spec
Name:nginx //必须写正确
Version:1.12.2 //必须写正确
Release:10
Summary:Nginx is a web server software. //说明
Group:tearena
License:GPL
URL:www.test.com
Source0:nginx-1.12.2.tar.gz
#BuildRequires:
#Requires:
%description
nginx [engine x] is an HTTP and reverse proxy server.
%prep
%setup -q //自动解压源码包,并cd进入目录
%build
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-stream --with-http_stub_status_module //自己要加载的模块
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
%files
%doc
/usr/local/nginx/* //对哪些文件进行打包
%changelog
5.安装依赖软件包
yum –y install gcc pcre-devel zlib-devel openssl-devel
6.rpmbuild创建RPM软件包
rpmbuild -ba /root/rpmbuild/SPECS/nginnginx-1.12.2-10.x86_64.rpm x.spec
看一下 RPM包生成
ls /root/rpmbuild/RPMS/x86_64/
nginx-1.12.2-10.x86_64.rpm nginx-debuginfo-1.12.2-10.x86_64.rpm repodata //第一个就是生成的RPM包以后省了很多麻烦

猜你喜欢

转载自blog.51cto.com/13740508/2115457
今日推荐