如何将源码包转换成rpm包

1)安装rpm-build软件包
[root@localhost~]# yum -y install rpm-build

2)生成rpmbuild目录结构

[root@localhost~]# rpmbuild -ba nginx.spec
 
//制作rpm包,但是没有配置文件会报错,报错也需要敲,会产生所需的目录

 

3)准备工作,将源码软件复制到SOURCES目录

[root@localhost~]# wget http://nginx.org/download/nginx-1.23.1.tar.gz
[root@localhost~]# cp  nginx-1.13.1.tar.gz /root/rpmbuild/SOURCES/

4)创建并修改SPEC配置文件

[root@localhost~]# vim /root/rpmbuild/SPECS/nginx.spec

Name:nginx
Version:1.23.1
Release: 1
Summary: Nginx is a web server software

Group: nginx
License:GPL
URL: www.test.com
Source0:nginx-1.23.1.tar.gz

#BuildRequires: 
#Requires:      

%description
nginx [engine x] is an HTTP and reverse proxy server.

%post
useradd nginx

%prep
%setup -q


%build
./configure
make %{?_smp_mflags}


%install
make install DESTDIR=%{buildroot}


%files
%doc
/usr/local/nginx/*


%changelog

 

使用配置文件创建RPM包:
1)安装依赖软件包

[root@localhost~]# yum -y install gcc make pcre-devel openssl-devel

2)rpmbuild创建RPM软件包

[root@localhost~]# rpmbuild -ba rpmbuild/SPECS/nginx.spec
[root@localhost~]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.13.1-1.x86_64.rpm
 
[root@localhost~]# ls rpmbuild/RPMS/x86_64/         

 

测试安装

rpm -ivh /root/rpmbuild/RPMS/x86_64/nginx-1.13.1-1.x86_64.rpm

 

posted @ 2022-08-19 13:31  fengjian1585  阅读(539)  评论(0编辑  收藏  举报