Difference between revisions of "Createrepo"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Package_management_tools|Package management tools</yambe:breadcrumb> =createrepo= A local yum repository server can be setup to allow caching of packages lo...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<yambe:breadcrumb>Package_management_tools|Package management tools</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[System administration tools]] > [[Package management tools]] > [[Createrepo|createrepo]]
=createrepo=


A local yum repository server can be setup to allow caching of packages locally for various clients.  To configure local repository server following steps can be used:
A local yum repository server can be setup to allow caching of packages locally for various clients.  To configure local repository server following steps can be used:
*Install rpmfusion, rpmforge and epel repositories
*Install rpmfusion, rpmforge and epel repositories
*Install createrepo package using '<tt>yum -y install createrepo</tt>'
*Install createrepo package using '<tt>yum -y install createrepo</tt>'
*Configure yum to keepcache for current server by making '<tt>keepcache="1"</tt>' in /etc/yum.conf
*Edit '<tt>/etc/yum.conf</tt>' as follows:
*Rsync /var/cache/yum to /var/www/html (or appropriate document root folder for web server)
** Configure yum to keepcache for current server by making '<tt>keepcache="1"</tt>'
*For each folder in /var/cache/yum/x86_64/6 such as base, epel, etc. do following:
** Configure yum to store cache in /var/www/html by making '<tt>cachedir=/var/www/html/$basearch/$releasever</tt>'
**Go to /var/cache/yum/x86_64/6/&lt;folder_name&gt;/packages
*For each folder in /var/www/html/x86_64/6 such as base, epel, etc. do following:
**Go to /var/www/html/x86_64/6/&lt;folder_name&gt;/packages
**Run '<tt>createrepo -c cache_dir --update .</tt>'
**Run '<tt>createrepo -c cache_dir --update .</tt>'
*Create repository configuration file '&lt;organization&gt;.repo' with following contents:
*Create repository configuration file 'local.repo' with following contents:
<pre>
<pre>
[&lt;organization&gt;-base]
[local-base]
name=RHEL  - repo.&lt;organization&gt;.com - base
name=RHEL  - repo.&lt;organization&gt;.com - base
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/base/packages/
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/base/packages/
enabled = 1
enabled = 1
protect = 0
gpgcheck = 0
gpgcheck = 0
keepcache = 0
keepcache = 0
metadata_expire = 0


[&lt;organization&gt;-epel]
[local-epel]
name=RHEL  - repo.&lt;organization&gt;.com - epel
name=RHEL  - repo.&lt;organization&gt;.com - epel
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/epel/packages/
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/epel/packages/
enabled = 1
enabled = 1
protect = 0
gpgcheck = 0
gpgcheck = 0
keepcache = 0
keepcache = 0
metadata_expire = 0


[&lt;organization&gt;-extras]
[local-extras]
name=RHEL  - repo.&lt;organization&gt;.com - extras
name=RHEL  - repo.&lt;organization&gt;.com - extras
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/extras/packages/
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/extras/packages/
enabled = 0
enabled = 0
protect = 0
gpgcheck = 0
gpgcheck = 0
keepcache = 0
keepcache = 0
metadata_expire = 0


[&lt;organization&gt;-rpmforge]
[local-rpmforge]
name=RHEL  - repo.&lt;organization&gt;.com - rpmforge
name=RHEL  - repo.&lt;organization&gt;.com - rpmforge
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/rpmforge/packages/
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/rpmforge/packages/
enabled = 1
enabled = 1
protect = 0
gpgcheck = 0
gpgcheck = 0
keepcache = 0
keepcache = 0
metadata_expire = 0


[&lt;organization&gt;-rpmfusion-free-updates]
[local-rpmfusion-free-updates]
name=RHEL  - repo.&lt;organization&gt;.com - rpmfusion-free-updates
name=RHEL  - repo.&lt;organization&gt;.com - rpmfusion-free-updates
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/rpmfusion-free-updates/packages/
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/rpmfusion-free-updates/packages/
enabled = 1
enabled = 1
protect = 0
gpgcheck = 0
gpgcheck = 0
keepcache = 0
keepcache = 0
metadata_expire = 0


[&lt;organization&gt;-rpmfusion-nonfree-updates]
[local-rpmfusion-nonfree-updates]
name=RHEL  - repo.&lt;organization&gt;.com - rpmfusion-nonfree-updates
name=RHEL  - repo.&lt;organization&gt;.com - rpmfusion-nonfree-updates
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/rpmfusion-nonfree-updates/packages/
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/rpmfusion-nonfree-updates/packages/
enabled = 1
enabled = 1
protect = 0
gpgcheck = 0
gpgcheck = 0
keepcache = 0
keepcache = 0
metadata_expire = 0


[&lt;organization&gt;-updates]
[local-updates]
name=RHEL  - repo.&lt;organization&gt;.com - updates
name=RHEL  - repo.&lt;organization&gt;.com - updates
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/updates/packages/
baseurl = http://repo.&lt;organization&gt;.com/x86_64/6/updates/packages/
enabled = 1
enabled = 1
protect = 0
gpgcheck = 0
gpgcheck = 0
keepcache = 0
keepcache = 0
metadata_expire = 0
</pre>
</pre>
*Replace &lt;organization&gt; with organization name everywhere.  Ensure that repo.&lt;organization&gt;.com points to repository server being configured using /etc/hosts or DNS
*Replace &lt;organization&gt; with organization name everywhere.  Ensure that repo.&lt;organization&gt;.com points to repository server being configured using /etc/hosts or DNS
*Copy this &lt;organization&gt;.repo file to some other machine at /etc/yum.repos.d/  Do not use the repository on same machine else /var/cache/yum of this machine would have additional folders for the same machines repository.   
*Copy local.repo file to some other machine at /etc/yum.repos.d/  Do not use the repository on same machine else /var/cache/yum of this machine would have additional folders for the same machines repository.   
*Try to use yum and verify that local repository is visible
*Try to use yum and verify that local repository is visible
The purpose of various options in repository configuration file is:
;name:This is used to give a description name to repository
;baseurl:Location where repository is located
;enabled:Use this repository for yum updates.  Hence enabled=1.
;gpgcheck:Check signature on packages.  Since all packages have been signed using different keys and already been verified when they are downloaded on repository machine using yum, we do not need to check signatures again. Hence gpgcheck=0
;metadata_expire:How long to wait before reconnecting to repository server to get fresh list of packages.  For local repository it can be set to 0 so that for every yum update fresh metadata is used.
To install package only using local repository use:
<pre>
yum -y install &lt;package&gt; --disablerepo='*'  --enablerepo='local*'
</pre>




Line 76: Line 88:
For all new packages following steps can be used:
For all new packages following steps can be used:
*yum -y install &lt;package&gt; on repository server
*yum -y install &lt;package&gt; on repository server
*rsync /var/cache/yum/ to /var/www/html/
*For each folder in /var/www/html/x86_64/6 such as base, epel, etc. do following:
*For each folder in /var/cache/yum/x86_64/6 such as base, epel, etc. do following:
**Go to /var/www/html/x86_64/6/&lt;folder_name&gt;/packages
**Go to /var/cache/yum/x86_64/6/&lt;folder_name&gt;/packages
**Run '<tt>createrepo -c cache_dir --update .</tt>'
**Run '<tt>createrepo -c cache_dir --update .</tt>'


Line 86: Line 97:




<yambe:breadcrumb>Package_management_tools|Package management tools</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[System administration tools]] > [[Package management tools]] > [[Createrepo|createrepo]]

Latest revision as of 12:18, 28 July 2022

Home > CentOS > CentOS 6.x > System administration tools > Package management tools > createrepo

A local yum repository server can be setup to allow caching of packages locally for various clients. To configure local repository server following steps can be used:

  • Install rpmfusion, rpmforge and epel repositories
  • Install createrepo package using 'yum -y install createrepo'
  • Edit '/etc/yum.conf' as follows:
    • Configure yum to keepcache for current server by making 'keepcache="1"'
    • Configure yum to store cache in /var/www/html by making 'cachedir=/var/www/html/$basearch/$releasever'
  • For each folder in /var/www/html/x86_64/6 such as base, epel, etc. do following:
    • Go to /var/www/html/x86_64/6/<folder_name>/packages
    • Run 'createrepo -c cache_dir --update .'
  • Create repository configuration file 'local.repo' with following contents:
[local-base]
name=RHEL  - repo.<organization>.com - base
baseurl = http://repo.<organization>.com/x86_64/6/base/packages/
enabled = 1
gpgcheck = 0
keepcache = 0
metadata_expire = 0

[local-epel]
name=RHEL  - repo.<organization>.com - epel
baseurl = http://repo.<organization>.com/x86_64/6/epel/packages/
enabled = 1
gpgcheck = 0
keepcache = 0
metadata_expire = 0

[local-extras]
name=RHEL  - repo.<organization>.com - extras
baseurl = http://repo.<organization>.com/x86_64/6/extras/packages/
enabled = 0
gpgcheck = 0
keepcache = 0
metadata_expire = 0

[local-rpmforge]
name=RHEL  - repo.<organization>.com - rpmforge
baseurl = http://repo.<organization>.com/x86_64/6/rpmforge/packages/
enabled = 1
gpgcheck = 0
keepcache = 0
metadata_expire = 0

[local-rpmfusion-free-updates]
name=RHEL  - repo.<organization>.com - rpmfusion-free-updates
baseurl = http://repo.<organization>.com/x86_64/6/rpmfusion-free-updates/packages/
enabled = 1
gpgcheck = 0
keepcache = 0
metadata_expire = 0

[local-rpmfusion-nonfree-updates]
name=RHEL  - repo.<organization>.com - rpmfusion-nonfree-updates
baseurl = http://repo.<organization>.com/x86_64/6/rpmfusion-nonfree-updates/packages/
enabled = 1
gpgcheck = 0
keepcache = 0
metadata_expire = 0

[local-updates]
name=RHEL  - repo.<organization>.com - updates
baseurl = http://repo.<organization>.com/x86_64/6/updates/packages/
enabled = 1
gpgcheck = 0
keepcache = 0
metadata_expire = 0
  • Replace <organization> with organization name everywhere. Ensure that repo.<organization>.com points to repository server being configured using /etc/hosts or DNS
  • Copy local.repo file to some other machine at /etc/yum.repos.d/ Do not use the repository on same machine else /var/cache/yum of this machine would have additional folders for the same machines repository.
  • Try to use yum and verify that local repository is visible

The purpose of various options in repository configuration file is:

name
This is used to give a description name to repository
baseurl
Location where repository is located
enabled
Use this repository for yum updates. Hence enabled=1.
gpgcheck
Check signature on packages. Since all packages have been signed using different keys and already been verified when they are downloaded on repository machine using yum, we do not need to check signatures again. Hence gpgcheck=0
metadata_expire
How long to wait before reconnecting to repository server to get fresh list of packages. For local repository it can be set to 0 so that for every yum update fresh metadata is used.

To install package only using local repository use:

yum -y install <package> --disablerepo='*'  --enablerepo='local*'


Updating repository with new packages

For all new packages following steps can be used:

  • yum -y install <package> on repository server
  • For each folder in /var/www/html/x86_64/6 such as base, epel, etc. do following:
    • Go to /var/www/html/x86_64/6/<folder_name>/packages
    • Run 'createrepo -c cache_dir --update .'

Securing setup using HTTPS

The setup can be secured by using HTTPS certificates and by change baseurl to https://. For self-signed certificates refer to easy-rsa to learn how to create certificates and also to learn how to add certificate to host so that yum can use it.


Home > CentOS > CentOS 6.x > System administration tools > Package management tools > createrepo