Linux 软件包工具rpmbuild

 下载工具rpm-build

yum search rpm-build
yum install rpm-build.x86_64

制作属于自己的RPM

1.准备打包目录

ls rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS

2.放入软件包

 cp /root/nginx-1.18.0.tar.gz rpmbuild/SOURCES/

3.编辑spec文件

 vim rpmbuild/SPECS/nginx.spec
文件内容如下
Name: nginx # 软件包名
Version: 1.18.0 # 版本
Release: 1%{?dist} # 发行次数 需要手动修改
Summary: A light-weight WEB server
License: GPL # 开源协议
URL: https://nginx.org/en/ # 项目官网
Source0: nginx-1.18.0.tar.gz # 源码包 从soureces 目录下面找
BuildRequires: gcc gcc-c++ make # 编译环境
Requires: zlib zlib-devel openssl-devel openssl pcre pcre-devel # 软件包依赖关系

%description # 描述信息
Engine x is a light web server and a useful reverse proxy server.

%prep # 安装rpm包前的准备脚本

%setup -q # 解压源码包

%build # 开始编译
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx # 配置编译参数
make %{?_smp_mflags} # 编译

%install # 安装
make install DESTDIR=%{buildroot}

%files # 指定文件释放路径
/usr/local/nginx/*

%post  #安装
useradd -M -s /sbin/nologin nginx
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx

%postun  #卸载
if [ $1 -eq 0 ]; then
    /usr/sbin/userdel nginx
fi

%changelog

4.检查

 tree rpmbuild/
rpmbuild/
├── BUILD // 源码包编译的工作现场
├── BUILDROOT // 另一个源码包编译的工作现场
├── RPMS // 保存打包完成的rpm包
├── SOURCES // 源码包
│ └── nginx-1.18.0.tar.gz
├── SPECS // 制作RPM包要使用的配置文件
│ └── nginx.spec
└── SRPMS // 包含源码未编译的RPM包

5.制作软件包

rpmbuild -ba rpmbuild/SPECS/nginx.spec

6.复制出来并检查

cp rpmbuild/RPMS/x86_64/nginx-1.18.0-1.el8.x86_64.rpm .
>rpm -qpi nginx-1.18.0-1.el8.x86_64.rpm
Name : nginx
Version : 1.18.0
Release : 1.el8
Architecture: x86_64
Install Date: (not installed)
Group : Unspecified
Size : 773910
License : GPL
Signature : (none)
Source RPM : nginx-1.18.0-1.el8.src.rpm
Build Date : Wed 17 Apr 2024 02:03:02 AM PDT
Build Host : bogon
Relocations : (not relocatable)
URL : https://nginx.org/en/
Summary : A light-weight WEB server
Description :
Engine x is a light web server and a useful reverse proxy server.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值