话说在《automake:从C到make》中,我从一个C语言源代码文件开始,制作了一个标准的tar包。
有了bar包怎么制作rpm包呢。
参考了linuxfans.org的文章《rpm 建包原理(2010.11.22 更新)》,我学会了如何制作rpm包。下面将把过程展现出来。
建立开发环境
首先需要编译器等软件
yum groupinstall "Development tools"
然后对rpm进行一点配置
echo '%_topdir /home/lophyxp/rpm' >> ~/.rpmmacros
echo '%debug_package %{nil}' >> ~/.rpmmacros
建立目录树
mkdir -vp ~/rpm/{SOURCES,SPECS,BUILD,RPMS/x86_64,SRPMS}
准备源代码
进入《automake:从C到make》做好的目录,生成tar包,并复制到SOURCES目录
cd hello
./configure
make
make dist-xz
mv hello/hello-0.01.tar.xz rpm/SOURCES/
准备spec文件
vi rpm/SPECS/hello.spec
====hello.spec============
#hello.spec
Summary: Hello world rpm package.
Name: hello
Version: 0.0.1
Release: 1
Source: %{name}-%{version}.tar.xz
License: GPL
Packager:lophyxp
Group: Applications/System
BuildRoot: %{_tmppath}/%{name}-%{version}-%{relase}-buildroot-%(%{__id_u} -n)
%description
This is a software say hello world to you.
%prep
%setup -n %{name}-%{version}
%configure
%build
make %{?_smp_mflags} OPTIMIZE="%{optflags}"
%install
%makeinstall
%clean
%{__rm} -rf %{buildroot}
%{__rm} -rf %{_builddir}/%{name}-%{version}
%files
%defattr(-,root,root)
%{_bindir}/hello
%changelog
* Sat Oct 08 2016 Lophyxp
- 0.0.1 - 1 First spec release
==========================================
制作rpm包
rpmbuild -ba rpm/SPECS/hello.spec
ls rpm/RPMS/x86_64
ls rpm/SRPMS
得到rpm包和src.rpm包。