rpm包制作过程

一、打包rpm包所需安装工具

1.yum install rpm-build
2.yum install rpmdevtools

二、制作过程

1.创建rpmbuild文件夹

rpmdev-setuptree

实际操作截图
在这里插入图片描述

2.打包源码程序到/rpmbuild/SOURCS下

1> 编写一个hello.c的源码

#include<stdio.h>

int main()
{
	printf("hello woeld! My first rpm!\n");
	return 0;
}

3.关于.spec文件的分析

Name:		
Version:	
Release:	1%{?dist}
Summary:	

Group:		
License:	
URL:		
Source0:	

BuildRequires:	
Requires:	

%description


%prep
%setup -q


%build
%configure
make %{?_smp_mflags}


%install
make install DESTDIR=%{buildroot}


%files
%doc



%changelog

1>引言部分(the introduction section)

Name:		
Version:	//版本号
Release:	1%{?dist} //发行号
Summary:	

Group:	//软件包属于哪个组	
License:	//版本权
URL:	//制作者	
Source0:	//rpm包使用的源文件

BuildRequires:	//定义依赖关系
Requires:	

%description  //描述信息

2>准备部分(The prep section)

%prep
%setup -q  //自动执行解压缩

3>构建部分(The build section)

%build
%configure
make %{?_smp_mflags} //_spm_mflags宏存在使用

4>安装部分(The install section)

%install
make install DESTDIR=%{buildroot}

5>清理部分

%clean
%{__rm} -rf %{buidroot}

6>文件部分(The files section)

%files
%defattr(-,root,root,0755//定义文件权限
%doc //做文档使用

7>改变日志部分

%changelog

4.rpmbuild命令

-ba //既制作二进制又制作rpm格式
-bb //制作二进格式rpm包
-bc //执行到build部分
-bp //只执行到prep部分
-bi //只执行install部分
-bl //检查报错
-bs //制作成源码格式的二进制包

三、rpm包制作示例

1.将编写好的hello.c文件放入hello-1.0文件中,然后压缩成hello-1.0.tar.gz,然后cp到rpmbuild/SOURCE下

2.编写hello.spec文件

Name:	hello	
Version: 1.0	
Release:	1
Summary: hello
License:	GPL
Source0:	hello-1.0.tar.gz


%description


%prep
%setup -q


%build
gcc -o hello hello.c


%install
install -m 777 hello /home/bxn/


%files
%doc

%changelog

3.编译生成rpm包

rpmbuild -ba ./rpmbuild/SPECS/hello.spec 

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值