Bookmark this page

Guided Exercise: Explaining and Investigating RPM Software Packages

In this exercise, you will gather information about a package from a third party, extract files from it for inspection, and then install it on a server.

Outcomes

You should be able to install a package not provided by software repositories on a server.

Log in as the student user on workstation using student as the password.

From workstation run the lab software-rpm start command. The script runs a start script that determines whether the host, servera, is reachable on the network. The script also downloads the rhcsa-script-1.0.0-1.noarch.rpm package in the /home/student directory on servera.

[student@workstation ~]$ lab software-rpm start
  1. Use the ssh command to log in to servera as the student user.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$ 
  2. View package information and list files in the rhcsa-script-1.0.0-1.noarch.rpm package. Also view the script that runs when the package is installed or uninstalled.

    1. View information for the rhcsa-script-1.0.0-1.noarch.rpm package.

      [student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm -i
      Name        : rhcsa-script
      Version     : 1.0.0
      Release     : 1
      Architecture: noarch
      Install Date: (not installed)
      Group       : System
      Size        : 1056
      License     : GPL
      Signature   : (none)
      Source RPM  : rhcsa-script-1.0.0-1.src.rpm
      Build Date  : Wed 06 Mar 2019 03:59:46 PM IST
      Build Host  : foundation0.ilt.example.com
      Relocations : (not relocatable)
      Packager    : Snehangshu Karmakar
      URL         : http://example.com
      Summary     : RHCSA Practice Script
      Description :
      A RHCSA practice script.
      The package changes the motd.
    2. List files in the rhcsa-script-1.0.0-1.noarch.rpm package.

      [student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm -l
      /opt/rhcsa-script/mymotd
    3. View the script that runs when the rhcsa-script-1.0.0-1.noarch.rpm package is installed or uninstalled.

      [student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm --scripts
      preinstall scriptlet (using /bin/sh):
      if [ "$1" == "2" ]; then
         if [ -e /etc/motd.orig ]; then
           mv -f /etc/motd.orig /etc/motd
         fi
      fi
      postinstall scriptlet (using /bin/sh):
      ...output omitted...
  3. Extract the contents of the rhcsa-script-1.0.0-1.noarch.rpm package in the /home/student directory.

    1. Use the rpm2cpio and cpio -tv commands to list the files in the rhcsa-script-1.0.0-1.noarch.rpm package.

      [student@servera ~]$ rpm2cpio rhcsa-script-1.0.0-1.noarch.rpm | cpio -tv
      -rw-r--r--   1 root     root    1056 Mar  6 15:59 ./opt/rhcsa-script/mymotd
      3 blocks
    2. Extract all files from the rhcsa-script-1.0.0-1.noarch.rpm package in the /home/student directory. Use the rpm2cpio and cpio -idv commands to extract the files and create the leading directories where needed in verbose mode.

      [student@servera ~]$ rpm2cpio rhcsa-script-1.0.0-1.noarch.rpm | cpio -idv
      ./opt/rhcsa-script/mymotd
      3 blocks
    3. List to verify the extracted files in the /home/student/opt directory.

      [student@servera ~]$ ls -lR opt
      opt:
      total 0
      drwxrwxr-x. 2 student student 20 Mar  7 14:44 rhcsa-script
      
      opt/rhcsa-script:
      total 4
      -rw-r--r--. 1 student student 1056 Mar  7 14:44 mymotd
  4. Install the rhcsa-script-1.0.0-1.noarch.rpm package. Use the sudo command to gain superuser privileges to install the package.

    1. Use the sudo rpm -ivh command to install the rhcsa-script-1.0.0-1.noarch.rpm RPM package.

      [student@servera ~]$ sudo rpm -ivh rhcsa-script-1.0.0-1.noarch.rpm
      [sudo] password for student: student
      Verifying...                          ################################# [100%]
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:rhcsa-script-1.0.0-1             ################################# [100%]
      [student@servera ~]$ 
    2. Use the rpm command to verify that the package is installed.

      [student@servera ~]$ rpm -q rhcsa-script
      rhcsa-script-1.0.0-1.noarch
  5. Exit from servera.

    [student@servera ~]$ exit
    logout
    Connection to servera closed.
    [student@workstation ~]$ 

Finish

On workstation, run the lab software-rpm finish script to complete this exercise. This script removes all the packages installed on servera during the exercise.

[student@workstation ~]$ lab software-rpm finish

This concludes the guided exercise.

Revision: rh124-8.2-df5a585