Wednesday, August 29, 2012

Create your own local yum repositories



Points of interest
Q: Where are my yum files downladed while the install is in progress
Temporary cache directory on CentOS - /var/cache/yum/
In my case it was /var/cache/yum/x86_64/6




Create your own local yum repositories

I'd like to share my notes with all on how I create local yum repositories. By local I mean that the rpm files are on a computer here at home, not somewhere out in cyberspace. I've done this since Fedora 9 with both the "Fedora" repository and the install DVD.

This how to was written with Fedora 14 in mind but should work equally as well with any earlier release.

The installation DVD files

Note: For all terminal commands I'll be using the su -c command. To use this command you will need to know the root password and use it when prompted.

I'll also be using the vi text editor. Of course, feel free to substitute with the editor of choice.

I'll be using the Fedora 14 x86_64 installation DVD. This method will work equally as well with the 32 Bit installation DVD.


I've seen a few threads here where members have asked about creating a yum repository of all the files contained on the installation DVD. Here's what to do.

Step 1. Create a folder to hold the files.

Start by opening a terminal and deciding where to keep the rpm files. You can put them almost anywhere you want. For this example I've created a folder under / called fedora64.

Code:
su -c 'mkdir /fedora64'
Step 2. Get the files.

Now that you have a place to keep your rpm files let's actually put some files in there. Insert your installation DVD and wait for it to mount. This should happen automatically and Nautilus will probably open up showing you the disk's contents. Close it.

Now type
Code:
mount
The output should include information on the mounted DVD disk. Here's that output on my computer.
Code:
/dev/sr0 on /media/Fedora 14 x86_64 DVD type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=500,gid=500,iocharset=utf8,mode=0400,dmode=0500)
We'll use this information to copy the files, using tab completion to complete a path that contains spaces. The rpm files are kept in a folder on the installation DVD called Packages. Let's copy the files. In the terminal type

Code:
su
<password>
cp /media/Fed<tab>P<tab> /fedora64/
By using the tab key the path will be filled in for you automatically. The end result is the following command.
Code:
cp /media/Fedora\ 14\ x86_64\ DVD/Packages/ /fedora64/
Keep in mind that this copy operation will likely take several minutes as there are some 2500+ files in the Packages folder.

When the copy operation is complete you need to run createrepo on this new folder. For an explanation of what createrepo does hit this link or simple type man createrepo.

If you don't have createrepo installed then install it now with the command

Code:
su -c 'yum install createrepo'
Step 3. Create the metadata.

Run the following command to create the metadata.
Code:
su -c 'createrepo fedora64'
This will be another fairly lengthy operation. When it has finished there will be 4 files in /fedora64/repodata, as described in the preceding link. The command completes without error, displaying the following output.

Code:
2766/2766 - hunspell-te-0.20050929-5.fc14.noarch.rpm                            
Saving Primary metadata
Saving file lists metadata
Saving other metadata
That should be all we need to do to set up the repository folder. It is now time to move on to creating the actual .repo file.

Step 4. Create a repository file.

Create an empty file in the folder /etc/yum.repos.d. I'm going to call my file fedora64.repo so I type
Code:
su -c 'vi /etc/yum.repos.d/fedora64.repo'
In this file we need to add a minimum of 4 lines.
Code:
[fedora64]
Name=Fedora $releasever $basearch local repository
baseurl=file:///fedora64
enabled=1
Save the file and exit the editor.

Step 5. Test the repository.

Now it's time to test the new repository. Type
Code:
yum repolist
The output on my computer.
Code:
repo id                                    repo name                                                     status
adobe-linux-i386                           Adobe Systems Incorporated                                            18
f14-dvd                                    Fedora 14 x86_64 networked DVD repository                       2,679+87
fedora                                     Fedora 14 - x86_64                                            22,031+130
fedora64                                   Fedora64                                                        2,679+87
flash                                      flash                                                                1+3
google-chrome                              google-chrome                                                          3
google64                                   Google - x86_64                                                        4
rpmfusion-free                             RPM Fusion for Fedora 14 - Free                                      411
rpmfusion-free-updates                     RPM Fusion for Fedora 14 - Free - Updates                            131
rpmfusion-nonfree                          RPM Fusion for Fedora 14 - Nonfree                                   181
rpmfusion-nonfree-updates                  RPM Fusion for Fedora 14 - Nonfree - Updates                          45
updates                                    Fedora 14 - x86_64 - Updates                                   4,180+122
Hopefully, if we did everything right, there will be no errors and you will see your new repository listed amongst the normal Fedora repositories. Your new repository is now ready for use.

This completes this section on how to create a local yum repository for the installation DVD rpm files.
__________________
Glenn
The Bassinator © ®
Powered by Fedora 17 x86_64

No comments:

Post a Comment

I would be glad to know if this post helped you.