Creating a yum repository (repo) and Creating a yum group to install + kickstart

Creating a yum repository is fairly easy, the only command you need is createrepo and some rpms. This is a quick guide to making a repo, I have a more complete example in my howto make an install server .

Make a directory to contain your rpms, it’s nice to name the directory the same as the repo name. Even better, segregate the rpms by architecture, i386, i686, noarch, SRPMS, etc. Copy the rpms into the appropriate directories and run create repo on that directory.  Ensure you sign your rpms with your gpg key
Example: 
[user@machine] mkdir -p MyRepo/i386 MyRepo/noarch MyRepo/i686 MyRepo/SRPMS
[user@machine] mv myrpm.noarch.rpm MyRepo/noarch
[user@machine] mv myrpm.src.rpm MyRepo/SRPMS
[user@machine] mv mybinrpm.i386.rpm MyRepo/i386
[user@machine] createrepo MyRepo

Groups File (comps.xml)

Now, if you want to install all the rpms in your repo, or a specific subset, you’ll need to create a groups file otherwise known as comps.xml. For our example, if we wanted myrpm.noarch.rpm to be installed by default and mybinrpm.i386.rpm to be an optional install, we would create a comps.xml file like this: 
<comps>
<!--  <meta> -->
<!-- Meta information will go here eventually -->
<!--  </meta> -->
  <group>
    <id>mygroup</id>
    <name>MyGroup</name>
    <default>true</default>
    <description>Default RPMS from MyRepo</description>
    <uservisible>true</uservisible>
    <packagelist>
      <packagereq type="default">myrpm</packagereq>
      <packagereq type="optional">mybinrpm</packagereq>
    </packagelist>
  </group>
</comps>
Now we need to rerun createrepo so that clients will know our group assignments. 
[user@machine] createrepo -g comps.xml MyRepo

/etc/yum.repos.d

Now, if we want to install this group on a machine, we create a .repo file in /etc/yum.repos.d like this: 
[MyRepo]
name=My Repository
baseurl=http://path/to/MyRepo
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MyRepo
If you didn’t sign your rpms and do not wish to verify signatures, set gpgcheck=0 in your .repo file. If you did sign your rpms, then you’ll need to export your gpg key into a file so yum can import the file into the rpm database.

Exporting your GPG-Key for RPM/YUM

First, find the name of your key if you don’t already know it.

[thomas@host ~] gpg --list-keys
/home/thomas/.gnupg/pubring.gpg
-------------------------------------------
pub   1024D/79E7E0DB 2007-10-08
uid                  Repository Owner <repository@example.org>
sub   2048g/04F5FDBA 2007-10-08
Then export the key into a file:

[thomas@host ~]$ gpg --export -a "Repository Owner <repository@example.org>" >RPM-GPG-KEY-example.org
[thomas@host ~]$ cat RPM-GPG-KEY-example.org 
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.5 (GNU/Linux)
 
mQGiBEcKQlgRBACLKP/FOWmTf75UjfShH84YkbLFnQqOlfdYKQ7ss57cRYn1v8lj
UoQjmPDhVLH+SpREAkDAoPjxiTln32nHoMWdIEJ/cdfBvhAg+PyHW4MCdyJu1hSO
UpqNQTUnnZ6dvTE5n/7fGepI/W24rOKzqrHqaolIx8sopMbF1UUck7lySwCg12Me
HOqFXWB6iiAmYYBwxJbE90ED/0b02K4xNJ5EFrZ8YcJmFlLnMfmICZiYveU4yqHY
CqtzNyCDFq6ZapNdzhAZC1VtUQGvTfXDvvjXv6rs8Z3SrJDjiwboJePTQS/sfT+p
iNlhBOd/yejf4w7XgXaEbw+BVy8EzDdvzEXjcBRLFoK7Dill+7Leba7G6kLcsPbr
B013A/0a+fgXYXFM8WYPsHZpG1SnPGQriwQppSVKVdeQomd7nppIa0f+UJyvQboQ
Hooivc75kAWmIIVCu4IK1LugH0ke5XbbvDBw3wiSGHcS6NPlSLzKXwOb53uGC47I
k1BK7aDnUnIKcEOneQSJkgfGmmzUr9jf2i8eX+LYZxgMU1eFY7QpUmVwb3NpdG9y
eSBPd25lciA8cmVwb3NpdG9yeUBleGFtcGxlLm9yZz6IYAQTEQIAIAUCRwpCWAIb
AwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEOC722t55+DbUnoAoLNhzDmVORR9
xh+rsz812yV78wfUAKCLhHgzM/EuIsyE8UHCl0bHAKI6CLkCDQRHCkJeEAgAmrgk
pBazmB6Mcm6mWds7dLXPVCRNknYz0J0NcIQEA43nUveWCtJpay8gs9QAfC8RLaT3
CMsCRPDGrm3tjd1KpCK/ENUHA9OtctVXqPdTOJN0lEWLkPAxtA5aEzEKUXLrzn8g
EHU6Ik9gyFjs74r4/e60OZWAeNMn7e1XK39BO+qWVgg717pkbh4EsMJcSO6mppTc
Z92QF/Kkl0qPpLsekWnIIC666+FcDr2O/e1TUGK/dsl3UvEknBZMsHY3IEmRWVEC
68dUbz7oY1AsU2Ck5lX+UuXnlnIp7jkW/eqWq1HHtfDQJ/Leb6f4tjlRJfyyWaqQ
F50bupAdVhgsjBA7awADBQgAjRZ11CODlZTboW/r1mdxnW9oMJvqq6xGBQ9/3PPf
WnGY6pxGNR5uuhgwl1gb2882u4ynL7DTkwuK1rg0febulpbNgqqx7sdKDSy7Xiwz
TAYE+8Q2Z1A7jlblU0I5srFz20LMCW4xCYg5DmPqPY8BVxYGyGowBtTcO2skkyjX
BW5UWGLRxM6b5kt53jUQlTC2z88BK+E2RLeZE9/Ln9fVFG1aRf9McXaQcj8jRiuR
8D30E927RosyUJ9t/IBOlkfIyYqP6sYOsnrZhyWAh4iDVrB5nSdruDYHawme72We
b6UggUonKXWmra6XuGKLV8Q5pCharQzJ7nBKWK4NrbvFIIhJBBgRAgAJBQJHCkJe
AhsMAAoJEOC722t55+DbTHkAn3Hjp5XTfcdEPVMnbPrmdQVwRjhJAJ400WMsJD1E
BJSAdiyou23Z2seraQ==
=+H8a
-----END PGP PUBLIC KEY BLOCK-----
Then move this file to the location specified in the .repo file. Yum will install the key into the rpm database for you. To install the key manually, you can do the following:

[root@host thomas]# rpm --import RPM-GPG-KEY-example.org
[root@host thomas]# rpm -q gpg-pubkey
gpg-pubkey-b2980b13-3c1d0597
gpg-pubkey-f51839ac-46362566
gpg-pubkey-79e7e0db-470a4258
We can see that our key (gpg-pubkey-79e7e0db-470a4258) was installed into the rpm database).
Now, to install this group. 
[user@machine] yum groupinstall mygroup
This will install any default or mandatory rpms as listed in comps.xml, any optional rpms will not be installed.

Kickstart

To install our packages via kickstart, we’ll need to add the repo to our kickstart file 
repo --name=MyRepo --baseurl=http://path/to/MyRepo

 

转自:http://scanty.blog.51cto.com/242145/217782

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值