19 September 2011

Configuring Yum in RHEL5 for DVD source


In my last article I explained the problem I faced with the installation of software in RHEL5 Beta2. I tried system-config-packages and the old "rpm" command but nothing worked as it used to in earlier days. So I thought to dig into this thing and tried to find the possible cause and solution to this problem.

So I went on to GNU/Linx community and put up this question. Okay I got some inputs some directions and finally I got what I wanted. First of all let me tell you the scenario once more so that you can better get what I want to say.

Suppose you have installed a RHEL5 system and now after the installation is complete you want to install a package (which is not installed). You put in the DVD and mount it. Go to the said directory and try to install the package via the well old "rpm" command. But to your surprise you found that it failed due to dependency problems. Okay no problem. We all know how to deal with it. We use the "--aid" switch with our "rpm" command that will automatically install the dependency rpm first then the said rpm. Well we try that but it again failed with the same error message. That means it's not finding the dependency rpm. But wait. The dependency rpm and the rpm we want to install both are in the same directory then why is the "rpm" command failing.

Well that's because in RHEL5 (as in Fedora Core 6) all the things are controlled by "yum". I read somethings about "yum" and quickly found that it had problem with dvd sources. But I didn't found any thing on how to disable "yum" completely and go through the well old command line way of installing packages. But I found a way out by which "yum" can access DVD sources and if that happens we can install/un-install packages easily either via graphical tool(system-config-packages) or the command line via "yum" command.

Okay so let's start this.I inserted the RHEL5 Client DVD and mounted it on /media/dvd/


mkdir -p /media/dvd
mount /dev/dvd /media/dvd


Then I created a ISO file for this DVD using the "mkisofs" command.

mkisofs -o /opt/RHEL5.iso -r /media/dvd/

The above command took sometime as I was creating a image file for my DVD (approx 3.6GB). Well after sometime it finished. Now was the time to do the real job. There was no use of the DVD so i unmounted and ejected it.


umount /media/dvd/
eject


Now I created a directory which will act as mount point for the ISO file I created earlier.


mkdir -p /dvd/actual


Now I mounted the ISO file onto the above mount point. Note that to mount the ISO file we need to use special options. So let's see what is the command.


mount -r -o loop -t iso9660 /opt/RHEL5.iso /dvd/actual


The above command mounted the RHEL5 ISO on /dvd/actual. Now I went to the mount point directory and installed a rpm called "createrepo".


cd /dvd
rpm -Uvh actual/Client/creatrepo*


The need for this RPM arises because the DVD of RHEL5 (also of FC6) has "media:" written in it's metadata that creates problem with "yum". Now by using this createrepo I will create a copy of my own for the repodata that will not be having the "media:" thing and that will help me use the repodata with "yum" and hence the software using "yum" too like "system-config-packages" or "pirut".

Now it's time to create the repodata. This is how I did that (note: I didn't changed my current directory. Was where I was previously).


createrepo .


Above command indexed around 2239 Packages and created a repodata/ directory in the current directory of around 8.1 MB. This directory had the repomod.xml and other metadata files. Actually what it did was it indexed all the RPM's present in the current directory, that was "/dvd". So I had rpm's in

/dvd/actual/Client, /dvd/actual/VT, /dvd/actual/Workstation

All got indexed and the metadata was created.

I also copied the GPG key files to my hard disk (to tell yum to use them later).


cp /dvd/actual/*GPG* /opt


There were around 4-5 GPG files they got copied to /opt. Later we will see that we can make "yum" to read these GPG key files and verify a package before installing.

Now finally came the time to tell yum to use this repo to for my installations. That was done by creating a repo file in /etc/yum.repos.d/. This is how it was done:


cd /etc/yum.repos.d/
vi dvd.repo


Inside this file I wrote the following:


[dvd]
name=RHEL5DVD
baseurl=file:///dvd
enabled=1
gpgcheck=1
gpgkey=file:///opt/RPM-GPG-KEY file:///opt/RPM-GPG-KEY-beta file:///opt/RPM-GPG-KEY-fedora file:///opt/RPM-GPG-KEY-fedora-test


Saved the /etc/yum.repos.d/dvd.repo file. Now I thought of disabling the plugins for RHN and "InstallOnly Packages". So I went to /etc/yum/pluginconf.d/ and opened the configuration file for each plugin and made "enabled=1" to "enabled=0".

Now finally I updated my "yum" so that it reads the new repo and other settings once again. For that I did:


yum clean all
yum update


Voila.It's finally done. But hey wait.When I install a package from where will it select the package rpm.It will do that from the mounted ISO.That means I need to mount the ISO everytime.

Well I can use fstab for that.So I created a entry in /etc/fstab so that my ISO gets mounted automatically on boot.

Here was the entry I made in /etc/fstab:


/opt/RHEL5.iso /dvd/actual iso9660 defaults,ro,loop 0 0


Now I ran system-config-packages and search, browse, install and un-install RPM's easily. Now the GUI Package manager can search for installed as well as not installed rpm's. That's great. But the most important thing is that it if install a RPM which needs a dependency RPM (which is not installed) the Package manager will tell us that there is a dependency and will install it automatically.Great !. Same goes for un-installation of packages.If some package is acting as a dependency for some other package and we try to remove it then it will show a message and will ask us what to do.

For command line lovers "yum" command will work. Now they can search package via yum search or if they don't remember the name they can see the large list using yum list command.For installing yum install.This will handle the dependencies too.

Okay so I finally managed to find a way out. But it was a real pain.
But as they say "No Pain No Gain".

Meanwhile I have not formatted my RHEL5 but instead of that in my Vista partition I have installed Ubuntu 7.04 Herd 4. So now I have two Linux RHEL5 Beta2 (Client) and Ubuntu 7.04 Herd 4. Well I kept RHEL5 so that I can learn some more new things.

All in all Package management in RHEL/Fedora needs a great improvement.Today I call upon the developers to come together and help the Redhat guys to improve the "yum","pirut" and "system-config-packages".

source : http://openbysource.blogspot.com/2007/02/configuring-yum-in-rhel5-for-dvd-source.html

Tidak ada komentar:

Posting Komentar

^_^

Jika ada pertanyaan atau order tiket dengan senang hati kami melayani. Silakan Chat dengan Customer Service kami

Customer Support