Changes from Version 1 of RepoCreate

skvidal (IP:
11/04/08 17:22:52 (10 years ago)



  • RepoCreate

    v0 v1  
     1= How to setup your own package repository =  
     3Sometimes you'll find you need to be able to collect a bunch of rpm packages you  
     4have together in one place and you want to make them available to your systems 
     5running yum. It is pretty easy to do. 
     7== Overview == 
     8A package repository used by yum is simply a directory with one or more RPMs 
     9plus some "meta information" used by yum to be able to easily access 
     10information (dependencies, file lists, etc.) for the RPMs.  yum can then 
     11to access this directory over ftp/http or a file URI (including over NFS). 
     13== Steps == 
     141. Collect the packages together in one directory. You can make as many 
     15   subdirs as you want, but there needs to be a top level dir where they all 
     16   live. That's where we're going to form our repository. 
     181. Yum uses a digest of the information stored in each rpm to do its work.  
     19   This information is created using the 'createrepo' program. If 
     20   you don't have createrepo installed you can install it with: 
     22   {{{ yum install createrepo }}} 
     24   If you are generating your repository on a machine that doesn't use RPMs, 
     25   you can download createrepo from and build/install it manually. 
     27   Once you have createrepo installed you need to run it. It only requires one 
     28   argument which is the directory in which you would like to generate the 
     29   repository data. So if the packages dir we made in step 1 is in /srv/my/repo 
     30   then you would run: 
     32   {{{ createrepo /srv/my/repo }}} 
     34   You should see a lot of things fly by but it should finish without an error. 
     35   In the end you should have a directory named /srv/my/repo/repodata with at 
     36   least 4 files in it. Maybe more. 
     383. To make this repository known to yum you need to add a .repo file to your 
     39   yum configuration. On the systems where you want to use this repo you need 
     40   to make a new file in '''/etc/yum.repos.d/'''. The file can be named anything but 
     41   the extension on the file has to be .repo. Let's call this one 'myrepo.repo'. 
     43   In the file you just need to include the following: 
     44   {{{ 
     45   [myrepo] 
     46   name = This is my repo 
     47   baseurl = url://to/get/to/srv/my/repo/ 
     48   }}} 
     50   That's all you need in that file. The 'baseurl' line is the path that machine 
     51   uses to get to the repository. If the machine has direct access to it or  
     52   mounts it as a filesystem you can use a baseurl line like: 
     53    {{{     baseurl = file:///srv/my/repo/  }}} 
     55      '''NB: there are 3 slashes (/) following the file:, not 2. That is correct.''' 
     57   If you access the file via an http or https server you would use something 
     58   like:  
     59    {{{ 
     60     baseurl = http://servername/my/repo 
     61    }}} 
     62   More details about client-side repo configuration can be found in 
     63   the yum.conf man page. 
     654. Now, everytime you modify, remove or add a new rpm package to /srv/my/repo 
     66   you need to recreate the repository metadata. You do that by running 
     67   createrepo the same way you did in step 2. 
     70== More Advanced options == 
     72 1. createrepo --update: Sometimes you have a lot of packages in it and  
     73    regenerating all that data for each package when only a few have been 
     74    added or changed is just time consuming. This is where --update comes in 
     75    handy. You run createrepo just like you did before but you pass  
     76    --update to it. Like this: 
     78     {{{ 
     79      createrepo --update /srv/my/repo 
     80     }}} 
     82    Now, createrepo will only update the items which have been changed,  
     83    been added or been removed. 
     86 2. createrepo -x package_file_name: Suppose you have a few packages in your 
     87    repository directory but you really don't want the unsuspecting world to  
     88    see them. You can exclude packages easily with createrepo: 
     89     {{{ 
     90      createrepo -x filename -x filename2 -x filename* /srv/my/repo 
     91     }}} 
     94If you want to learn more about using createrepo to create and maintain your 
     95own package repository please see the createrepo man page or the other 
     96documents in this collection.