如何制作一个自有EPEL源的RPM包实现自动源部署

Linux系统 0 765 团子精英 收藏

在EDA环境中,我们经常要手动配置EPEL源来实现某些第三方的工具安装。但是每次都需要手动查找并配置,这就让人很恼火。

能不能将repo文件做成一个rpm包,下次直接rpm安装呢?下面来描述一个简单的repo文件安装的rpm包制作方法

一、创建一个rpmtest文件夹

mkdir rpmtest

进入到文件夹

cd rpmtest

二、编写配置文件

创建一个spec文件。这里以XX大学epel地址为例

touch fasteda.spec

填入内容


Name: fasteda-epel
Version: 1.0
Release: 1
Summary: Installs EPEL YUM repository
License: GPL
%description
This package installs the EPEL YUM repository by copying the repo file to /etc/yum.repos.d/.
%prep
%build
%install
mkdir -p %{buildroot}/etc/yum.repos.d
cp /root/rpmtest/fasteda-epel.repo %{buildroot}/etc/yum.repos.d/
%clean
rm -rf %{buildroot}
%files
/etc/yum.repos.d/fasteda-epel.repo
%post
%postun
rm -f /etc/yum.repos.d/fasteda-epel.repo
%changelog

三、编写repo文件,在rpmtest目录

touch fasteda-epel.repo

内容如下


# fasteda-epel.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - fasteda.cn
#mirrorlist=http://mirrorlist.fasteda.cn/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.fasteda.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.fasteda.cn/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - fasteda.cn
#mirrorlist=http://mirrorlist.fasteda.cn/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.fasteda.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.fasteda.cn/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - fasteda.cn
#mirrorlist=http://mirrorlist.fasteda.cn/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.fasteda.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.fasteda.cn/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - fasteda.cn
baseurl=http://mirrors.fasteda.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.fasteda.cn/centos/RPM-GPG-KEY-CentOS-7


四、安装rpmbuild

yum install  rpm-build rpmrebuild rpmdevtools -y

五、编译rpm包

rpmbuild -bb fasteda-epel.spec

六、测试

在/root/rpmbuild/RPMS/x86_64找到你的安装包,注意这个路径。不是rpmtest

fasteda-epel-1.0-1.x86_64.rpm

安装 

rpm -ivh fasteda-epel-1.0-1.x86_64.rpm

查看是否已经配置好

ls /etc/yum.repos.d/

卸载

rpm -e fasteda-epel

再次查看

ls /etc/yum.repos.d/


完成!

相关推荐:

网友留言:

您需要 登录账户 后才能发表评论

我要评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
验证码