Thursday, April 16, 2009

How to create a local Repository for Linux!

Creating a Local Repository of Yum and apt:-

You should have a FTP server or HTTP server to make yum actually working. However since we haven't really gone through setting up FTP or HTTP server, please read-on and understand the process. If you have got vsftpd installed, use that. Otherwise, don't forget to actually set it up yourself later.

Here we will create a local repository for Fedora and CentOS in the easy way.

0. You should have the yum as well as the createrepo package installed first.

1. Create the directory to hold the repository.

mkdir -p /var/ftp/pub/yum-repo/centos/
mkdir -p /var/ftp/pub/yum-repo/fedora/

2. createrepo /var/ftp/pub/yum-repo/centos/ ; createrepo /var/ftp/pub/yum-repo/fedora/ will create the local yum repository by creating a folder named "repodata with four xml files named, filelists.xml.gz, other.xml.gz, primary.xml.gz and repomd.xml

You will have to run the createrepo command each time a rpm is added there.

3. Now in the client's yum.conf, add the repo directly. However in recent versions, the repositories are put in a separate directory called /etc/yum.repos.d/ . If so, put the contents in a filename, with the extension .repo

[humanlinux repo]
name=Fedora Core $releasever - humanlinux Local Repo
baseurl=file:///var/ftp/pub/yum-repo/fedora/
enabled=1
gpgcheck=0
#gpgkey=file:///path/to/your/RPM-GPG-KEY

Fedora Specific Local Repository:- 

NB : You can create directories inside /var/ftp/pub/yum-repo/fedora/ to look like /var/ftp/pub/yum-repo/fedora/base/8/i386 , /var/ftp/pub/yum-repo/fedora/updates/8/i386 , /var/ftp/pub/yum-repo/fedora/base/9/i386, /var/ftp/pub/yum-repo/fedora/updates/9/i386 and so on.

1) Filling the repos with RPMs:- 

Copy the rpm packages to /var/ftp/pub/yum-repo/fedora/ or /var/ftp/pub/yum-repo/fedora/base/8/i386 from the DVD's Packages directory.

OR

rsync from a rsync supported mirror from the list, http://mirrors.fedoraproject.org//mirrorlists/publiclist/Fedora/8/ like rsync://ftp.sh.cvut.cz/fedora/linux and

rsync -avrt rsync://ftp.sh.cvut.cz/fedora/linux/releases/8/Everything/i386/os/ /var/ftp/pub/yum-repo/fedora/base/8/i386 (remember to have a slash after os/ :-))

2) Updates and regular downloading:- 

/var/ftp/pub/yum-repo/fedora/updates/8/i386

rsync the updates from rsync://ftp.sh.cvut.cz/fedora/linux/updates/8/i386/ to /var/ftp/pub/yum-repo/fedora/updates/8/i386

And then enter the command in a cron job too, to download the updates frequently.

Creating Apt repository:- 

This is done using the apt-mirror tool. Download and install apt-mirror first and then edit the /etc/apt/mirror.list ( to list which packages tree should be mirrored ) which is similar to /etc/apt/sources.list.

apt-mirror will do the rest of the job. Once it is finished, clean up the repositories by running /var/spool/apt-mirror/var/clean.sh.

tell2humanlinux@gmail.com

4 comments:

  1. I think is nice post,cause not many blogger can write this trick for linux
    thanks
    im from http://egadged.blogspot.com

    ReplyDelete
  2. Thank you very much. Just the right one that i am looking for.

    ReplyDelete
  3. Its very briefly described set of information, which I have ever seen in any blog.I am really thankful to publisher.

    ReplyDelete
  4. Seriously..

    Reading the man page was like man pages always are:

    Yes,it had buttons and knobs and blinky lights and swirly things and arcane symbols and and and and... but provide actual real world examples? Ha! Whatever would we want to do that for?!?

    Thank your your clarity and brevity. It helped a lot.

    ReplyDelete