构建rpm包

使用rpmbuild 构建rpm包

相关资料:

https://fedoraproject.org/wiki/How_to_create_an_RPM_package/zh-cn   How to create an RPM package/zh-cn

https://blog.csdn.net/get_set/article/details/53453320  RPM打包原理、示例、详解及备查   ***** 推荐看

https://my.oschina.net/u/913265/blog/892889   rpm包的制作

示例

目标:构建一个rpm包,安装rpm包后安装可执行hello文件,输出hello信息

安装工具

yum install -y rpm* rpm-build rpmdev*

helle.c

#include <stdio.h>
void main()
{
    printf("helloworldrpmtest 
");
}

Makefile

install:
        mkdir -p $(DIR)/usr/bin/
        gcc helle.c -o $(DIR)/usr/bin/hello

放入目录  hello-1.0 中 ,打包成源文件包hello-1.0.tar.gz  放入rpmbuild的 源码目录  SOURCES中

SPECS  目录中编写  hello.spec 文件

Name:           hello
Version:        1.0
Release:        1%{?dist}
Summary:        hello rpm test

License:  GPLv3+
URL:      http://ftp.gnu.org/gnu/hello
Source0:  http://ftp.gnu.org/gnu/hello/%{name}-%{version}.tar.gz

#BuildRequires:
#Requires:

%description
a hello test

%prep
%setup -q


#%build
#make


%install
make install  DIR=%{buildroot}


%files
%{_bindir}/hello


%changelog

构建rpm包

rpmbuild  -ba hello.spec

构建成功的rpm包 在RPMS 目录中存放

原文地址:https://www.cnblogs.com/jkklearn/p/13458553.html