Difference between revisions of "Package Management"

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
This program is a higher-level interface to <code>rpm</code> and repositories. RedHat systems must be registered with RHN to make full use of yum, because registration is the only way to access the offical RedHat repositories. Other repositories can be added by adding entries in ''/etc/yum.repos.d/'', but this should be avoided unless some non-RedHat-supplied software is really needed.
 
This program is a higher-level interface to <code>rpm</code> and repositories. RedHat systems must be registered with RHN to make full use of yum, because registration is the only way to access the offical RedHat repositories. Other repositories can be added by adding entries in ''/etc/yum.repos.d/'', but this should be avoided unless some non-RedHat-supplied software is really needed.
  
On RHEL 5, yum has replaced "up2date" for getting updates/packages/etc. requested on the RHN website.
+
It's written in Python, so be careful when updating python.
====Useful invocations====
+
 
 +
On RHEL 5, yum has replaced "up2date" for getting updates/packages/etc. that are requested on the RHN website.
 +
===Useful invocations===
 
; <code>yum search string1 [string2] [&hellip;]</code> : Search for packages whose name or description match the given string(s)
 
; <code>yum search string1 [string2] [&hellip;]</code> : Search for packages whose name or description match the given string(s)
 
; <code>yum install package1 [package2] [&hellip;]</code> : Is  used  to install the latest version of a package or group of packages while ensuring that all dependencies are satisfied.  If no  package  matches the given package name(s), they are assumed to be a shell glob and any matches are then installed. Sometimes a specific version of package must be specified (e.g. 32-bit versus 64-bit, or if mutliple versions of the same program are installed for some insane reason), see [[#Package Names|Package Names]].
 
; <code>yum install package1 [package2] [&hellip;]</code> : Is  used  to install the latest version of a package or group of packages while ensuring that all dependencies are satisfied.  If no  package  matches the given package name(s), they are assumed to be a shell glob and any matches are then installed. Sometimes a specific version of package must be specified (e.g. 32-bit versus 64-bit, or if mutliple versions of the same program are installed for some insane reason), see [[#Package Names|Package Names]].
Line 10: Line 12:
 
; <code>yum check-update</code> : Implemented so you could know if your machine  had  any  updates that needed  to  be  applied  without running it interactively. Returns exit value of 100 if there are packages available for an update.  Also  returns  a list of the pkgs to be updated in list format. Returns 0 and no packages are available for update.
 
; <code>yum check-update</code> : Implemented so you could know if your machine  had  any  updates that needed  to  be  applied  without running it interactively. Returns exit value of 100 if there are packages available for an update.  Also  returns  a list of the pkgs to be updated in list format. Returns 0 and no packages are available for update.
 
; <code>yum remove package1 [package2] [&hellip;]</code> : Remove packages ''and all packages that depend on them''.
 
; <code>yum remove package1 [package2] [&hellip;]</code> : Remove packages ''and all packages that depend on them''.
 +
Note that there is no way to simply "reinstall" a package when using yum. Instead, a remove-install combo may be necessary. However, this can be trouble, because could wipe out a lot of innocent packages. So, either use rpm for this (''preferred'') or make sure to copy the list of packages that yum reports will be removed and install the whole list again.
 +
; <code> yum grouplist </code>: List the groups of packages available for specific functionality.
 +
; <code> yum groupinfol "group name" ["group name2"] [&hellip;] </code>: show the items installed for a specific group.
 +
; <code> yum groupinstall "group name" ["group name2"] [&hellip;] </code>: Install groups of packages for specific functionality.
 +
 +
=== Useful information about GROUPS ===
  
Note that there is no way to simply "reinstall" a package when using yum. Instead, a remove-install combo may be necessary. However, this can be trouble, because could wipe out a lot of innocent packages. So, either use rpm for this (''preferred'') or make sure to copy the list of packages that yum reports will be removed and install the whole list again.
+
These are sets of packages that are useful to install together. There is an issue though that the install does not always do what you expect on Centos 7. [https://access.redhat.com/solutions/1310043 See this writeup].
 +
 
 +
In our environment we would want at minimum:
 +
 
 +
  yum -y group install "Development Tools" "Scientific Support" --setopt=group_package_types=mandatory,default,optional
 +
 
 +
Note the optional in the package types!!
 +
 
 +
The result is NOT always what you want. It seems that the optional packages are not installed if the particular package group was installed before, or is part of an "environment", such as "Compute Node" for "Scientific Support". This *also* does not allow you to remove the group. The best work arounds:
 +
# Install the system as "Minimal" to begin with, then add the groups you want.
 +
# If you don't want to re-install. You can use <code>repoquery -g -l --grouppkgs=optional "Scientific Support"</code> to list the packages, and then pipe that into yum.
  
====Package Names====
+
===Package Names===
 
A package can be referred to for install,update,list,remove etc. with any of the following:
 
A package can be referred to for install,update,list,remove etc. with any of the following:
 
* name
 
* name
Line 24: Line 42:
  
 
==rpm==
 
==rpm==
 +
Mostly used by us to install packages that aren't in a repository and to reinstall broken packages without messing with packages that depend on them.
 +
===Useful invocations===
 +
; <code>rpm -i package_file1 [package_file2] [&hellip;]</code> : Installs the listed packages. Note that these are pathnames and not package names as used for yum.
 +
; <code>rpm -e --nodeps package_name1 [package_name2] [&hellip;]</code> : Removes the named packages, without removing packages that depend on them. Note that these are package names and not pathnames like when installing. I'm pretty sure the names don't follow the same rules as for yum, so the whole package name might be necessary.
 +
==up2date==
 +
This is, for pre-RHEL5 systems, the only method of getting updates/packages/etc. that are requested on the RHN website.
 +
 +
===Useful invocations===
 +
 +
; <code>up2date</code> : Runs the interactive, GUI version, so if you SSH'd in, make sure it was with X forwarding. Not the preferred method, just because the interactive aspect isn't usually needed.
 +
; <code>up2date -u</code> : Gets and installs the updates from RHN in "unattended" mode, with no GUI. Generally the best method, although some systems have some updates flagged to be skipped (things like new kernels).
 +
 +
= Useful Tricks =
 +
 +
See also: [https://wiki.centos.org/TipsAndTricks/YumAndRPM Tips and Trick for Yum]
 +
 +
; Download but not install an rpm: <code> yum reinstall --downloadonly --downloaddir=/root  package-name </code>
 +
; Extract a single file from rpm:
 +
<code>
 +
rmp2cpio package.rpm | cpio --list
 +
rmp2cpio package.rpm | cpio -ivd ./path/filename
 +
</code>

Latest revision as of 15:48, 4 January 2018

Every machine has yum and rpm installed, and these are the main methods of adding software to a machine.

yum

This program is a higher-level interface to rpm and repositories. RedHat systems must be registered with RHN to make full use of yum, because registration is the only way to access the offical RedHat repositories. Other repositories can be added by adding entries in /etc/yum.repos.d/, but this should be avoided unless some non-RedHat-supplied software is really needed.

It's written in Python, so be careful when updating python.

On RHEL 5, yum has replaced "up2date" for getting updates/packages/etc. that are requested on the RHN website.

Useful invocations

yum search string1 [string2] […]
Search for packages whose name or description match the given string(s)
yum install package1 [package2] […]
Is used to install the latest version of a package or group of packages while ensuring that all dependencies are satisfied. If no package matches the given package name(s), they are assumed to be a shell glob and any matches are then installed. Sometimes a specific version of package must be specified (e.g. 32-bit versus 64-bit, or if mutliple versions of the same program are installed for some insane reason), see Package Names.
yum update [package1] [package2] […]
Update packages with same name rules as "install". If no packages are named, all installed packages will be updated. Sometimes that's a bad thing; always use "check-update" first.
yum check-update
Implemented so you could know if your machine had any updates that needed to be applied without running it interactively. Returns exit value of 100 if there are packages available for an update. Also returns a list of the pkgs to be updated in list format. Returns 0 and no packages are available for update.
yum remove package1 [package2] […]
Remove packages and all packages that depend on them.

Note that there is no way to simply "reinstall" a package when using yum. Instead, a remove-install combo may be necessary. However, this can be trouble, because could wipe out a lot of innocent packages. So, either use rpm for this (preferred) or make sure to copy the list of packages that yum reports will be removed and install the whole list again.

yum grouplist
List the groups of packages available for specific functionality.
yum groupinfol "group name" ["group name2"] […]
show the items installed for a specific group.
yum groupinstall "group name" ["group name2"] […]
Install groups of packages for specific functionality.

Useful information about GROUPS

These are sets of packages that are useful to install together. There is an issue though that the install does not always do what you expect on Centos 7. See this writeup.

In our environment we would want at minimum:

 yum -y group install "Development Tools" "Scientific Support"  --setopt=group_package_types=mandatory,default,optional

Note the optional in the package types!!

The result is NOT always what you want. It seems that the optional packages are not installed if the particular package group was installed before, or is part of an "environment", such as "Compute Node" for "Scientific Support". This *also* does not allow you to remove the group. The best work arounds:

  1. Install the system as "Minimal" to begin with, then add the groups you want.
  2. If you don't want to re-install. You can use repoquery -g -l --grouppkgs=optional "Scientific Support" to list the packages, and then pipe that into yum.

Package Names

A package can be referred to for install,update,list,remove etc. with any of the following:

  • name
  • name.arch
  • name-ver
  • name-ver-rel
  • name-ver-rel.arch
  • name-epoch:ver-rel.arch
  • epoch:name-ver-rel.arch

rpm

Mostly used by us to install packages that aren't in a repository and to reinstall broken packages without messing with packages that depend on them.

Useful invocations

rpm -i package_file1 [package_file2] […]
Installs the listed packages. Note that these are pathnames and not package names as used for yum.
rpm -e --nodeps package_name1 [package_name2] […]
Removes the named packages, without removing packages that depend on them. Note that these are package names and not pathnames like when installing. I'm pretty sure the names don't follow the same rules as for yum, so the whole package name might be necessary.

up2date

This is, for pre-RHEL5 systems, the only method of getting updates/packages/etc. that are requested on the RHN website.

Useful invocations

up2date
Runs the interactive, GUI version, so if you SSH'd in, make sure it was with X forwarding. Not the preferred method, just because the interactive aspect isn't usually needed.
up2date -u
Gets and installs the updates from RHN in "unattended" mode, with no GUI. Generally the best method, although some systems have some updates flagged to be skipped (things like new kernels).

Useful Tricks

See also: Tips and Trick for Yum

Download but not install an rpm
yum reinstall --downloadonly --downloaddir=/root package-name
Extract a single file from rpm

rmp2cpio package.rpm | cpio --list
rmp2cpio package.rpm | cpio -ivd ./path/filename