rpm打包示例

21 篇文章 2 订阅
10 篇文章 0 订阅

操作平台: fedora 29
需要的包

dnf install rpmdevtools rpmlint

示例源文件:
hello-2.10.tar.gz

使用 rpmdev-setuptree 创建编译所需要的目录, 会创建在当前用户的主目录下.

~/rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS

将源代码包放入 SOURCES 目录.
使用 rpmdev-newspec hello~/rpmbuild/SPECS 目录创建 .spec 文件.

~/rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
│   └── hello-2.10.tar.gz
├── SPECS
│   └── hello.spec
└── SRPMS

此时 hello.spec 内容为:

ame:           hello
Version:
Release:        1%{?dist}
Summary:

License:
URL:
Source0:

BuildRequires:
Requires:

%description


%prep
%autosetup


%build
%configure
%make_build


%install
rm -rf $RPM_BUILD_ROOT
%make_install


%files
%license add-license-file-here
%doc add-docs-here



%changelog
* Sat May 11 2019 Nick <Nick@fedora>
-

修改该说明文件. 然后在 ~/rpmbuild/SPECS/rpmbuild -ba hello.spec 进行打包

注意事项有:
每一项后面不要为空.
所有需要安装的文件都要在该文件中有指定.
每一个文件要用 utf8 格式
Summary 首字母要大写
每一项中尽量使用变量来指代.
使用 # 进行注释. 注释行中不要有变量.
changelog 的格式也要注意, 前面的日期的格式也是固定的. 第一条 changelog 前面是 * 号, 最后要包含版本号 - 2.10-1
打包过程最好使用独立普通帐户进行操作.

本例中生成的文件如下:

~/rpmbuild/RPMS/x86_64/
hello-2.10-1.fc29.x86_64.rpm
hello-debuginfo-2.10-1.fc29.x86_64.rpm
hello-debugsource-2.10-1.fc29.x86_64.rpm

~/rpmbuild/SRPMS/
hello-2.10-1.fc29.src.rpm

最后使用 rpmlint hello.spec ../SRPMS/hello* ../RPMS/*/hello* 进行规范一致性检查.

更多说明见参考文献.
最终完成的无警告和错误的配置文件如下:

Name:           hello
Version:        2.10
Release:        1%{?dist}
Summary:        The "Hello World" program from GNU

License:        GPLv3+
URL:            https://www.gnu.org/software/%{name}
#Source0:        https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
Source0:        http://files.git.oschina.net/group1/M00/07/A6/PaAvDFzWvNiAZPhOAAsWd2xzuuI7717.gz?token=587733e6cb3c40d6ffcbcf6535b494aa&ts=1557576946&disposition=attachment&attname=%{name}-%{version}.tar.gz

BuildRequires: gettext
Requires(post): info
Requires(preun): info

%description
The "Hello World" program, done with all bells and whistles of a proper FOSS
project, including configuration, build, internationalization, help files, etc.

%prep
%autosetup


%build
%configure
make %{?_smp_mflags}

%install
%make_install
%find_lang %{name}
rm -f %{buildroot}/%{_infodir}/dir

%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :

%preun
if [ $1 = 0 ] ; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi

%files -f %{name}.lang
%{_mandir}/man1/hello.1.*
%{_infodir}/hello.info.*
%{_bindir}/hello

%license COPYING
%doc AUTHORS ChangeLog NEWS README THANKS TODO



%changelog
* Sat May 11 2019 test rpm build Nick <Nick@fedora> - 2.10-1
- Thu Jul 07 2011 The Coon of Ty <Ty@coon.org> - 2.10-1
- Initial version of the package

[1]. https://developer.fedoraproject.org/deployment/rpm/about.html
[2]. https://fedoraproject.org/wiki/How_to_create_a_GNU_Hello_RPM_package
[3]. https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages/
[4]. https://blog.csdn.net/get_set/article/details/53453320

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值