Managing Software – Part I

Understanding RPM:

·  Managing software is no longer the challenge it was in the past. Now everything is efficiently organized.

·  In this section of the program, you’ll learn about RPMs, the basic package format that’s used for software installation, how software is organized in repositories and how yum is used to manage software from these repositories

A little history:

·  In the early days of Linux, the “tar ball” was the default method for installing software.

·  A tar ball is an archive that contains files that need to be installed. . .there were no rules for exactly what needed to be in the tar ball

o  Neither were there any specifications of how the software in the tar ball was to be installed

·  Working with tar balls was inconvenient for several reasons:

o  There was no standardization

o  When using the tar balls, there was no way to track what was installed

o  Updating and de-installing tar balls was difficult to do

·  In some cases, the tar ball contained source files that still needed to be compiled.

o  In other cases, the tar ball had a nice installation script

o  In other situations still, the tar ball would just include a bunch of files including a README file explaining what to do with the software

·  The ability to trace software was needed to overcome the disadvantages of tar balls.

o  The Red Hat Package Manager (RPM) is one of the standards designed to fulfill this need

o  An RPM is basically an archive file. . .it’s created with the “cpio” command. . .however, its no ordinary archive

o  With RPM, there is also metadata describing what is in the package and where those different files should be installed

o  Because RPM is so well organized, it is easy for an administrator to query exactly what is happening in it

o  Another benefit of RPM is that its database is created in the “/var/lib/rpm” directory

o  This database keeps track of the exact version of files that are installed on the computer

§  Thus, for an administrator, it is possible to query individual RPM files to see their contents

§  You can also query the database to see where a specific file comes from or what exactly is in the RPM

·  The query options make it really easy to find the exact package or files you need to manage

Understanding Meta Package Handlers

·  RPM is a great step forward in managing software, but there is still one inconvenience that must be dealt with---software dependency

What is a dependency:

§  it's a file that something you are trying to install requires

·  To standardize software, many programs used on Linux use libraries and other common components provided by other software packages

o  That means to install packages A, package B is required to be present

o  This way of dealing with software is known as a software dependency

·  Sometimes the software dependency situation can get so bad that a real dependency problem can occur where, after downloading all of the missing dependencies, each of the downloaded packages would have its own set of dependencies

·  The solution to dependency problem is the Meta Package Handler.

o  Meta Package Handler, which in Red Hat/CenTOS is known as yum (Yellowdog Update Manager), works with repositories, which are the installation sources that are consulted whenever a user wants to install a software package

o  In the repositories, all software packages of your distribution are typically available

o  While installing a software package using “yum install somepackage”, yum first checks to see whether there are any dependencies.

o  If there are, yum checks the repositories to see whether the required software is available in the repositories…… and if it is, the administrator will see a list of software that yum wants to install as the required dependencies

o  So, using a yum is really the solution for dependency problem

Creating Your Own Repositories

·  1st, a storage repository is a storage location from which software packages may be retrieved and installed on a computer

2 ways to create a Custom YUM Repository:

1st Way:

Creating a Yum Repository Server for Red Hat and CentOS

Overview

There are many reasons why you may want to have a local repository for your Red Hat or CentOS servers. You may be in an isolated network that has no connection to the outside world, yet you still want to keep your servers up-to-date or have all of the default packages available. Another may be that you develop and maintain your own software and need a central location to store it, where other servers can easily access it.

This tutorial will show you how to configure a Yum repository server

Install Createrepo

To create and intialize your Yum repository, you must first download and install the createrepo package – available from the default CentOS repos. If you do not have access to the Internet, you can install byusing the Red Hat or CentOS installation disc as a repository.

  1. Install Createrepo

yum install createrepo

Create the Repository

Prepare Repository Directory

Your repository needs a directory where the package are stored. Ideally, you will want the repository to be in its own volume, and preferably on its own disk. For the purpose of showing how to create a repo, I’ll just be adding it to the root volume. My repository will created in/repos/CentOS/6/5/. When dealing with multiple Red Hat/CenTOS based distributions and versions, it’s best to create a directory structure that’s easy to understand and manage.

  1. Create a new directory for the repository.

mkdir -p /repos/CentOS/6/5/Packages

2. Add your RPM packages to the directory we just created.

Initialize The Repository

Repositories use a simple database to keep track of all the packages and their dependancies. This is how it can provide you with all the packages required to be installed so quickly. The initialization step creates the database and prepares the directory to host the repository, allowing clients to connect to it.

  1. Initialize the repository.

createrepo /repos/CentOS/6/5

Publish Your Local Repository

The repository is ready, but unless you publish the repository using HTTP or FTP you’re clients won’t be able to use it.

Over HTTP using Apache

  1. Install Apache.

yum install httpd

  1. Create a symbolic link in the default Apache root directory to our new repository. We’re going to create the link so it points to the root of our CentOS repo directory. This lessens the effort required when adding new releases to the repo.

ln -s /var/www/html/CentOS /repos/CentOS

3.  Start the Apache daemon to start hosting the repo files.

Command to start Apache: #service httpd start

Configure Repository on Client

Our repository is now ready for your clients. Before they can access it, we need to create a Yum repository configuration file.

  1. Log onto the client computer.
  2. Navigate to the directory hosting the Yum repository configuration files.

cd /etc/yum.repos.d

  1. Create a configuration file for your local repository.

nano local.repo

  1. Add the following lines to the file. Replace the baseurl value to point to either your HTTP host or your FTP host.

[mylocalrepo]

name=Local CentOS Repo

baseurl=http://my-repo-server/CentOS/6/5

gpgcheck=0

  1. Save your changes and exit the text editor.

2nd Way:

Custom YUM Repository

Sometimes we need to create a Custom YUM Repository (handy when the VPS has no internet connection). We can create a Custom YUM Repository from a desired number of selected RPM package files. Custom YUM Repository only holds the RPM package files we want to include in.

Step 1: Install "createrepo"

To create Custom YUM Repository we need to install additional software called "createrepo" on our cloud server. We can install "createrepo" by running the following command from console:

yum install createrepo

Step 2: Create Repository directory

We need to create a new directory that will be the location of our Custom YUM Repository and will hold the desired RPM package files. We can do this with the following command from console (choose a different /repository1 directory name if you like):

mkdir /repository1

Step 3: Put RPM files to Repository directory

If RPM package files are not yet present on our VPS we need to transfer them to our cloud server via FTP or SSH - use software like WinSCP (free SFTP client and FTP) or similar. We can also download RPM package files directly to our VPS (internet connection needed) with "wget" command from console (please change HTTP link accordingly):

IMPORTANT INFO BELOW: Update Notice

CORRECTION TO THIS: The WGET Used in Video is No Longer in Use... Old One below

wget ftp://rpmfind.net/linux/fedora-secondary/development/rawhide/aarch64/os/Packages/n/NetworkManager-1.2.0-0.6.beta1.fc24.aarch64.rpm

NEW ONE Below:

RPM Pagkage Name: NetworkManager-0.8.1-99.el6.x86_64.rpm

If you have a 64 Bit OS use link below:

x86_64:

# wget ftp://fr2.rpmfind.net/linux/centos/6.9/os/x86_64/Packages/NetworkManager-0.8.1-113.el6.x86_64.rpm

If you have a 32 Bit OS, use link below:

i386:

# wget ftp://fr2.rpmfind.net/linux/centos/6.9/os/i386/Packages/NetworkManager-0.8.1-113.el6.i686.rpm

If RPM files are already present on our VPS, we need to Copy or Move these files to the newly created directory from "Step 2". We can move RPM files with the following command from console (please change /path/to/rpm and /repository1 accordingly):

mv /path/to/rpm /repository1

We can copy RPM files with the following command from console (please change /path/to/rpm and /repository1 accordingly):

cp /path/to/rpm /repository1

Step 4: Run "createrepo"

Createrepo command reads through Custom YUM Repository directory from "Step 2" and creates a new directory called "repodata" in it. Repodata directory holds the metadata information for the newly created repository. Every time we add additional RPM package files to our Custom YUM Repository, we need to re-create Repository metadata with "createrepo" command. We can create new repository metadata by running the following command from console (please change /repository1 accordingly):

createrepo /repository1

Step 5: Create YUM Repository Configuration file

To start using the newly created Custom YUM Repository, we must create the corresponding YUM Repository Configuration file with .repo extension, which must be placed to /etc/yum.repos.d/ directory. Instructions to create YUM Repository Configuration file are covered in the first topic of this article called "YUM Repository Configuration File".

Example Custom YUM Repository Configuration file:

/etc/yum.repos.d/custom.repo

[customrepo]

name=Custom Repository

baseurl=file:///repository1/

enabled=1

gpgcheck=0

Steps to Removing, Disabling, or Enabling YUM Repository:

Remove YUM Repo (Repository) Permanently

Before moving repository permanently is a good idea to check that is the repository installed using rpm package. As many repos usually are, like RPM-Fusion, Livna, etc.

Search Repository RPM-package with following command:

rpm -qa | grep -i repo-name

Example:

rpm -qa |grep -i rpmfusion

rpmfusion-nonfree-release-13-2.noarch

rpmfusion-free-release-13-2.noarch

## OR ##

rpm -qa |grep -i livna

livna-release-1-1.noarch

If RPM-package found then simply remove whole RPM-package with following command:

rpm -e some-repository-rpm-package

Example:

rpm -e livna-release-1-1.noarch

If RPM-package not found then simply remove repo file with following command:

rm /etc/yum.repos.d/repo-file.repo

## OR just rename it (without repo file extension) ##

mv /etc/yum.repos.d/repo-file.repo /etc/yum.repos.d/repo-file.repo.bak

Example:

rm /etc/yum.repos.d/kde.repo

## OR just rename it (without repo file extension) ##

mv /etc/yum.repos.d/kde.repo /etc/yum.repos.d/kde.repo.bak

Disable YUM Repo (Repository)

Disable YUM Repo

Edit repo file on /etc/yum.repos.d/ as root and change enabled to 0

## Change

enabled=1

## To

enabled=0

Example:

# Change

[kde]

name=kde

mirrorlist=http://apt.kde-redhat.org/apt/kde-redhat/fedora/mirrors-stable

gpgkey=http://apt.kde-redhat.org/apt/kde-redhat/kde-redhat.RPM-GPG-KEY

enabled=1

# To

[kde]

name=kde

mirrorlist=http://apt.kde-redhat.org/apt/kde-redhat/fedora/mirrors-stable

gpgkey=http://apt.kde-redhat.org/apt/kde-redhat/kde-redhat.RPM-GPG-KEY

enabled=0

Enable disabled repo quickly with YUM:

yum --enablerepo=some-disabled-repository install some-package

Disable YUM Repo (Repository) using YUM

yum --disablerepo=some-repository install some-package

Example:

yum --disablerepo=kde install some-package