快速的将基于git管理的源码打包成rpm软件包(以vim为例)

准备工具:

安装打包依赖:

$ sudo yum install rpm-build build-essential

安装vim依赖:

$ sudo yum install -y ruby ruby-devel lua lua-devel luajit \
luajit-devel ctags git python python-devel \
python3 python3-devel tcl-devel \
perl perl-devel perl-ExtUtils-ParseXS \
perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \
perl-ExtUtils-Embed

spec示例代码(VIM):

%define _name_prefix local                                                                                                                                                                                                                                                              
%define _name vim
%define debug_package  %{nil}

Name: %{_name_prefix}-%{_name}
Version: 8.1.0
Release: 1
Vendor: Local build
License: GPL
Group: Applications/Local
URL: http://vim.org
Source: http://vim.orgn/%{_name}.tar.gz
BuildRoot: %{_tmppath}/%{_name}
BuildArch: x86_64
# Obsoletes: old-package

Summary: %{_name_prefix}-%{_name} (RHEL AS%{_osvernum} / CentOS%{_osvernum})

Requires: rpm, ruby, ruby-devel, lua, lua-devel, luajit, luajit-devel, ctags, git, python, python-devel, python34, python34-devel, tcl-devel, perl, perl-devel, perl-ExtUtils-ParseXS, perl-ExtUtils-CBuilder, perl-ExtUtils-Embed
BuildRequires: rpm, ruby, ruby-devel, lua, lua-devel, luajit, luajit-devel, ctags, git, python, python-devel, python34, python34-devel, tcl-devel, perl, perl-devel, perl-ExtUtils-ParseXS, perl-ExtUtils-CBuilder, perl-ExtUtils-Embed

# Autoreq: 0

%description
local version of vim.

%prep
%setup -q -n %{_name}

%build
# make
./configure --with-features=huge \
                            --enable-multibyte \
                            --enable-rubyinterp=yes \
                            --enable-pythoninterp=yes \
                            --with-python-config-dir=/usr/lib/python2.7/config \
                            --enable-python3interp=yes \
                            --with-python3-config-dir=/usr/lib/python3.4/config \
                            --enable-perlinterp=yes \
                            --enable-luainterp=yes \
                            --disable-gtktest \
                            --enable-cscope \
                            --prefix=/usr/local/vim
make                        

%install
make install DESTDIR=%{buildroot}

# %clean
# rm -rf %{buildroot}

%files
# %defattr(-,root,root)
/usr/local/vim

%pre

%post

通用Build 脚本(buildrpm.sh):

#!/bin/bash
git archive HEAD --format=tar --prefix=${1}/ --output=${1}.tar
gzip ${1}.tar
mkdir -p ~/rpmbuild/SOURCES
mv ${1}.tar.gz ~/rpmbuild/SOURCES
rpmbuild -ba ~/Workspace/spec/${1}.spec 

准备VIM源码:

$ git clone https://github.com/vim/vim

进入VIM源码目录,执行打包命令:

$ cd vim
$ buildrpm.sh vim

打包结束后,~/rpmbuild/RPMS/x86_64/目录下会生成rpm包文件:local-vim-8.1.0-1.x86_64.rpm。

References:

https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source

转载于:https://my.oschina.net/chenchacha/blog/2981190

你可能感兴趣的:(快速的将基于git管理的源码打包成rpm软件包(以vim为例))