RPM打包笔记

     2016年03月03日       江南兔子哥       运维笔记->系统管理       rpm spec 

搭建独立的rpm打包环境
在home目录下建立配置文件,并建立好相应的目录

cat >${HOME}/.rpmmacros<<EOF
%_topdir %(echo $HOME)/rpmbuild
EOF
mkdir ${HOME}/rpmbuild/
cd ${HOME}/rpmbuild/;mkdir BUILD  RPMS  SOURCES  SPECS  SRPMS

一个用于打包tar包的spec文件

Name:         xx
Version:      0.19.1
Release:      20130814
Buildarch:    noarch
Vendor:      leileisyh
Group:        SOME_GROUP
Summary:      Hadoop Client
License:      Commercial
BuildRoot:    %{_tmppath}/%{name}-%{version}-%{release}-build
Prefix:       /home/xx
AutoReqProv:  no
Requires:     yyy = 版本-发布号
 
%description
Something
 
%prep
%define  __os_install_post %{nil}
%define  _prefix           %prefix
 
%build
[ -d ${RPM_BUILD_ROOT} ] && rm -rf ${RPM_BUILD_ROOT} && mkdir -p ${RPM_BUILD_ROOT}
 
%install
mkdir -p ${RPM_BUILD_ROOT}%{_prefix} && tar -xzf /tmp/xx.tgz -C ${RPM_BUILD_ROOT}%{_prefix} || exit 1
 
%files
%defattr (-,root,root,-)
%{_prefix}