使用rpmbuild制作rpm包


使用rpmbuild制作rpm包

這里以制作cmake-3.15.5為例,首先保證環境中安裝有rpmbuild,其次下載cmake-3.15.5.tar.gz源代碼包。

1.  在/root目錄下生成rpmbuild目錄

mkdir -p ~/rpmbuild/BUILD ~/rpmbuild/RPMS ~/rpmbuild/BUILDROOT ~/rpmbuild/SRPMS ~/rpmbuild/SOURCES ~/rpmbuild/SPECS

2.  vi ~/rpmbuild/SPECS/cmake.spec 自動生成spec模板文件,並填寫相關字段,現給出我的spec文件

#
# spec file for package cmake
#
# Copyright (c) 2020 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%define version 3.15.5
%define directory /usr/local

Name: cmake
Version: %{version}
Release: 1%{?dist}
License: GPL
Summary: cmake tools
# Url:
# Group:
Source: cmake-3.15.5.tar.gz
# Patch:
# BuildRequires:
# PreReq:
# Provides:
BuildRoot: %{_tmppath}/%{name}-%{version}-build

%description

%prep
%setup -q

%build
./configure --prefix=%{directory}
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot} %{?_smp_mflags}
%pre

%preun

%post

%postun

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%{directory}/doc
%{directory}/bin
%{directory}/share

%changelog

3.  執行 rpmbuild -ba ~/rpmbuild/SPECS/cmake.spec

接下來是比較長的編譯和安裝過程,執行成功的界面如下:

 以 exit 0 退出表示沒有出錯,然后在~/rpmbuild/RPMS/目錄下可以看到形成了x86_64目錄,該目錄下有cmake-3.15.5-1.x86_64.rpm安裝包:

 在~/rpmbuild/SRPMS/目錄下形成了cmake-3.15.5-1.src.rpm安裝包:

 到此,由源代碼包制作rpm包的流程結束。

4.  rpm -ivh ~/rpmbuild/RPM/x86_64/cmake-3.15.5-1.x86_64.rpm安裝生成的rpm包:

 以上表示安裝成功。

5.  解析rpm包

rpm –qpl *.rpm # 列出rpm包包含的內容 rpm2cpio *.rpm | cpio –div # 解壓rpm包


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM