Announcement

Collapse
No announcement yet.

YUM in Linux

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • YUM in Linux

    Packages Repository

    When an rpm package is installed with the rpm command and the rpm needs the installation of other rpms, these others rpms (called dependencies) must be also installed. In order to install automatically these dependencies we can use the yum command configured to use a Package Repository which is a group of rpms that can be dependent plus xml metadata files that contain the dependencies between these rpms. When yum is executed to install an rpm, yum goes to the package repository and automatically installs that rpm and all its dependencies.
    Creating a repository

    In order to create an rpm repository the createrepo rpm must be installed on your system. First copy all the rpms to a new directory and then run createrepo command on that directory :
    Code:
    $ mkdir -p /repo
    $ cp *.rpm /repo
    $ createrepo /repo
    The xml metadata files that contain the rpms dependencies are created and the repository is ready to be used by yum command.
    Configuring yum to use a repository

    Once the package repository has been created, yum command can be configured to 'point' to that repository. This action can be done using the configuration file /etc/yum.repos.d/reponame.repo where 'reponame' is the repository name. The content of this file is like :

    Code:
    [reponame]
    name=reponame
    baseurl=file:///repo
    enabled=1
    gpgcheck=1
    gpgkey=file:///repo/RPM-GPG-KEY-reponame
    'baseurl' parameter is the place that points to the repository physical location. It can be local ('file:///') if the repository is located in the same system where yum is or remote ('http://server/repo', 'nfs://server/repo', 'ftp://server/repo') if the repository is in another system.

    'enabled' parameter tells to yum if that repository must be used (=1) or ignored (=0). This is because of multiple reponame.repo files can be used at once and in some cases can be helpful ignore some repositories.

    'gpgcheck' parameter tells to yum if the GPG authenticity of each rpm package must be checked against imported keys from 'gpgkey' before the package will be installed.
    Configuring yum

    Code:
    The file /etc/yum.conf controls the way yum is executed. A commented version of this file is the following:
    
    $ cat /etc/yum.conf
    [main]
    
    # The 'cachedir' directive specifies the directory where rpms packages downloads are stored
    cachedir=/var/cache/yum
    
    # The 'keepcache' specifies that rpms must be stored on 'cachedir', if keepcache=0 rpms are removed after installation
    keepcache=1
    
    # Log parameters
    debuglevel=2
    logfile=/var/log/yum.log
    
    # The 'distroverpkg' parameter takes the version from the /etc/redhat-release file
    distroverpkg=redhat-release
    
    # The 'tolerant' parameter allows yum to work even with minor errors
    tolerant=1
    
    # The 'exactarch' parameter makes sure that yum downloads correspond to your CPU architecture
    exactarch=1
    
    # The 'obsoletes' parameter checks for and uninstalls any obsolete packages during a 'yum update' command
    obsoletes=1
    
    # The 'gpgcheck' parameter verifies package GPG authenticity
    gpgcheck=1
    
    # The 'plugins' parameter includes plug-ins as defined in the /etc/yum/pluginconf.d/ and /usr/lib/yum-plugins/ directories
    plugins=1
    
    
    # The 'exclude' parameter specifies the packages that must be ignored by yum
    #exclude=
    
    # The 'metadata_expire' parameter specifies a lifetime for xml info. Once is expired yum download xlms fresh info from repository
    # Note: yum-RHN-plugin doesn't honor this.
    metadata_expire=1h
    # By default all .repo files on /etc/yum.repos.d are active yum repositories
    # PUT YOUR REPOS HERE OR IN separate files named file.repo
    Code:
    # in /etc/yum.repos.d
    Using yum

    Once yum configured and pointing to a package repository is time to use yum. As rpm command yum can be use to install/uninstall and query information about the rpms packages contained on the repository :
    Code:
    $ yum install package
    Installs package.rpm from repository
    Code:
    $ yum update package
    Update package.rpm from repository

    Code:
    $ yum remove package
    Uninstalls package.rpm

    Code:
    $ yum wharprovides command
    List repository information about what package installs 'command'

    Code:
    $ yum list
    List all packages available from repository

    Code:
    $ yum update
    If run without any packages, update will update every currently installed package on the system
    Code:
    $ yum upgrade
    Is the same as the update command with the --obsoletes, so obsoletes packages are removed

    Practical example :

    Code:
    $ yum -y install anaconda
    
    Loading "rhnplugin" plugin
    Loading "security" plugin
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    Parsing package install arguments
    Resolving Dependencies
    --> Running transaction check
    ---> Package anaconda.i386 0:11.1.2.113-1 set to be updated
    --> Processing Dependency: booty for package: anaconda
    --> Processing Dependency: libbdevid-python for package: anaconda
    --> Processing Dependency: pyparted >= 1.7.2 for package: anaconda
    --> Processing Dependency: libdhcp6client-1.0.so.2 for package: anaconda
    --> Processing Dependency: python-pyblock >= 0.26-1 for package: anaconda
    --> Processing Dependency: libdhcp.so.1 for package: anaconda
    --> Processing Dependency: libdhcp4client.so.1 for package: anaconda
    --> Running transaction check
    ---> Package libdhcp4client.i386 12:3.0.5-13.el5 set to be updated
    ---> Package pyparted.i386 0:1.8.1-4.el5 set to be updated
    ---> Package python-pyblock.i386 0:0.26-1.el5 set to be updated
    ---> Package booty.noarch 0:0.80.4-6 set to be updated
    ---> Package libdhcp6client.i386 0:1.0.10-4.el5 set to be updated
    ---> Package libdhcp.i386 0:1.20-5.el5 set to be updated
    ---> Package libbdevid-python.i386 0:5.1.19.6-28 set to be updated
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =============================================================================
    Package Arch Version Repository Size
    =============================================================================
    Installing:
    anaconda i386 11.1.2.113-1 centos-debuginfo 5.5 M
    Installing for dependencies:
    booty noarch 0.80.4-6 centos-debuginfo 89 k
    libbdevid-python i386 5.1.19.6-28 centos-debuginfo 57 k
    libdhcp i386 1.20-5.el5 centos-debuginfo 59 k
    libdhcp4client i386 12:3.0.5-13.el5 centos-debuginfo 244 k
    libdhcp6client i386 1.0.10-4.el5 centos-debuginfo 88 k
    pyparted i386 1.8.1-4.el5 centos-debuginfo 25 k
    python-pyblock i386 0.26-1.el5 centos-debuginfo 55 k
    
    Transaction Summary
    =============================================================================
    Install 8 Package(s)
    Update 0 Package(s)
    Remove 0 Package(s)
    
    Total download size: 6.1 M
    Downloading Packages:
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Installing: libbdevid-python ######################### [1/8]
    Installing: libdhcp6client ######################### [2/8]
    Installing: libdhcp4client ######################### [3/8]
    Installing: libdhcp ######################### [4/8]
    Installing: python-pyblock ######################### [5/8]
    Installing: booty ######################### [6/8]
    Installing: pyparted ######################### [7/8]
    Installing: anaconda ######################### [8/8]
    
    Installed: anaconda.i386 0:11.1.2.113-1
    Dependency Installed: booty.noarch 0:0.80.4-6 libbdevid-python.i386 0:5.1.19.6-28 libdhcp.i386 0:1.20-5.el5 libdhcp4client.i386 12:3.0.5-13.el5 libdhcp6client.i386 0:1.0.10-4.el5 pyparted.i386 0:1.8.1-4.el5 python-pyblock.i386 0:0.26-1.el5
    Complete!
    With the command 'yum -y install anaconda' we are only asking to install the anaconda rpm, but as anaconda has a dependency on other 7 packages, all this packages are also installed. The yum command has connected to the 'centos-debuginfo' repository, downloaded the 8 rpm packages and installed them on the system. with the '-y' option we are telling to yum that the answer to all its interactive questions are 'yes'.
    Last edited by kuldeep; 02-21-2015, 11:56 PM.
Working...
X