zoukankan      html  css  js  c++  java
  • 使用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包
  • 相关阅读:
    容器与线程--更新
    js生成元素的事件不执行问题
    Webpack 笔记
    思考题——爬楼梯
    正则表达式笔记
    github + travis 自动构建 vue 项目到 gitpage
    css3 动画 vs js 动画
    深度哲学对工作的启发
    yml 文件操作方法
    布尔变量在项目中的应用
  • 原文地址:https://www.cnblogs.com/tongyishu/p/12294523.html
Copyright © 2011-2022 走看看