How do I use RPM to install GCC from my CentOS distribution media?

21,551

Solution 1

I'd recommend using yum localinstall rather than using the rpm command directly; that way you'll have the gcc package in your yum database so that it can keep track of updates. The command would just be:

yum localinstall /mnt/cdrom/CentOS/gcc-(whatever).rpm

Solution 2

You want to use something like rpm -ivh /mnt/cdrom/CentOS/gcc-(whatever).rpm. The command line options there are:

  • -i -- install (you can use -U to install or upgrade, many just always use that)
  • -v -- verbose output
  • -h -- show hashmarks, a simplistic progress bar

Yum will figure out which package you mean if you type yum install gcc. That'll use your chosen repository, or the CD if you've got the correct repository installed (which you probably do). In general, yum is easier to use if you're not doing anything strange.

Solution 3

There is probably already a repo defined in yum for the centos media that you can use that just needs to be enabled. The documentation included in the file shows you how you could disable all your remote repos, enable just the local media repo and install your software package from cd.

$ cat /etc/yum.repos.d/CentOS-Media.repo 
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
#  CentOS-5.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c5-media [command]
#  
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c5-media [command]

[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

Solution 4

1 step rpm -ivh vsftpd.x86_64 0:2.2.2-7.rpm

2 step rpm -ivh createrepo-0.9.8-4.rpm

3 step copy every thing from DVD or .iso to /var/ftp/pub (cp -av /var/ftp/pub)

4 step createrepo -v /var/ftp/pub/

5 step vi /etc/yum.repos.d/base.repo

6 step

[base] name=Server Software baseurl=ftp://192.168.0.254/pub/ enabled=1 gpgcheck=0

7 step yum install gcc -y

Share:
21,551

Related videos on Youtube

Kev
Author by

Kev

###Actively looking for freelance work ###About Me: I'm a professional software developer and have spent my time building provisioning and web based self-service systems for IIS, Apache and Citrix XenServer, amongst other things. My Curriculum Vitae can be viewed on Stack Overflow Careers (might be a bit out of date). Stuff I like to listen to at last.fm You can get in touch here: kevin.e.kenny #@# gmail.com (you know what to do with the # and spaces). No Survey Emails Please. Also not ashamed to admit I like trains, mostly diesels, late Era 8 (BR Sectorisation) and Era 9 onwards :) I'm also interested in signalling if anyone from Network Rail is looking this far down ;)

Updated on September 17, 2022

Comments

  • Kev
    Kev over 1 year

    I have a few package installation related questions concerning RPM, YUM and CentOS and getting GCC installed:

    1. I've mounted my distribution media on my CentOS 5.2 machine but I can't seem to work out how to point RPM at the media and use that instead of looking to the internet. All the examples I've googled for appear to assume downloading the RPM's from the internet.

    2. What does the -ivh switch combo do (I'm guessing -i is for install)? I did man rpm but the switch count and combinations blew my mind.

    3. Should I be using YUM instead of RPM?

  • Bill Weiss
    Bill Weiss almost 14 years
    Good answer, I didn't know about that.
  • Bill Weiss
    Bill Weiss almost 14 years
    "Set up a local package repository" seems like overkill for "hey, how do I install a package?", doesn't it?
  • Kev
    Kev almost 14 years
    These were all great answers and they all got a +1 from me earlier, but this was the one got me going.
  • Allen
    Allen almost 14 years
    If you are going to go with a yum localinstall keep in mind that it usually works best when the package being installed has no dependencies. That's why setting up the local DVD repo as mtinberg/Rajat explained is not overkill, because it won't be the last time you install something from the DVD. I can't believe that yum did not go out on the internet to resolve the dependencies on binutils, cpp, and glibc-devel. Am I missing something?