- August 29, 2015
- Posted by: Surender Kumar
- Category: Linux
Configure Your Own Yum Repository
YUM (Yellowdog Updater, Modified) is the package management tool that helps you to install or update the package through the network or local repository, at the same time it provides easy method to install a package with it’s dependent packages. Configuration files are under /etc directory, /etc/yum.conf is the main configuration file that contains the global options such as cache directory, log directory etc. To add new or update the existing repository, you must go to the /etc/repos.d directory and create or open a file that ends on .repo respectively.
In previous post you’ve seen that yum is the easiest method of installing software on Linux system. You need to run only single command (yum install packagename) and yum will do everything else for you by automatically resolving the dependencies and downloading the required files from repositories residing on Internet. But what if you are using Linux and your system does not have connectivity to Internet? The good news is that you can still create your local repository and you can also take the advantage of yum. Isn’t it interesting? Well, It is.
Let’s get started.
Create Installation Package Source
If your system is not connected to Internet, you can use the installation DVD to create local repository to be used with yum since installation DVD contains approximately all the packages required by an administrator to install various services like samba, dns, dhcp, ftp etc.
You must first create the repository source (whether the packages stored locally or remotely). Mount the DVD to any directory of your choice, I will mount it to /dvdrom directory.
[root@centos ~]# mkdir /dvdrom [root@centos ~]# mount /dev/cdrom /dvdrom/ mount: /dev/sr0 is write-protected, mounting read-only [root@centos ~]#
If you want the other systems on your network to be able to install software from your repository, you must install either FTP or Apache services on your system.
If you are going to use FTP, copy the packages from the DVD to FTP folder as shown below:
[root@centos ~]# cp -v /dvdrom/Packages/* /var/ftp/
If you are going to use Apache, copy the packages from the DVD to apache home directory as shown below:
[root@centos ~]# cp -v /dvdrom/Packages/* /var/www/html/
The above command will take some time depending upon the size of DVD. Wait until it completes. The -v option is used for verbose copying which means you will see every file being copied. If you omit -v option, you will not see any copy operation but the copying will be done in background. You can not run any other command until the process completes.
If you are using Apache, you need to perform some additional steps. Edit the Apache configuration file using vim /etc/httpd/conf/httpd.conf command. Change the Line “Options Indexes FollowSymLinks” to “Options All Indexes FollowSymLinks“. And then remove the welcome page by using rm -rf /etc/httpd/conf.d/welcome.conf command.
Verify if either FTP or HTTP is working (whichever you want to use). Do this by opening web browser and typing either ftp://ip-address or http://ip-address.
Create Repository Configuration File
We need to create the repository of the packages that you have downloaded from internet or copied from the disc. CreateRepo is the tool that help you to create the XML based rpm meta structure repository, It is like an index file that point to the rpm files. This XML files used for resolving the dependency packages which is required by main package. Install CreateRepo package.
[root@centos ~]# cd /dvdrom/Packages/ [root@centos Packages]# rpm -Uvh deltarpm-**.el6.x86_64.rpm python-deltarpm-**.el6.x86_64.rpm createrepo-**.rpm
If you are using FTP, run the following command:
[root@centos ~]# createrepo /var/ftp Spawning worker 0 with 8465 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete
If you are using Apache, run the following command:
[root@centos ~]# createrepo /var/www/html Spawning worker 0 with 8465 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete
Remove the all the repo files using rm -rf command from /etc/yum.repos.d directory. This is to ensure that your system do not look for packages from default CentOS or Redhat repositories. If you are creating a central repository for your network, you should delete all repo files from every system and then copy the newly created repo file which we are going to create below. This file should be copied to /etc/yum.repos.d directory on every network computer. Then every computer will be able to access this centralized repository to install software packages over network.
In my case, I will create repository for local computer only. Create a new repo file called myrepository.repo under /etc/repos.d directory using vim /etc/yum.repos.d/myrepository.repo/ command and add the following lines to file:
[MyRepository] name=My Repository baseurl=file:///dvdrom enabled=1 gpgcheck=0
You have to modify the baseurl line according to your own scenario. If you are using FTP, you should use baseurl=ftp://ip-address. If you are using Apache, you should use baseurl=http://ip-address. Since I am using local repository, I have used baseurl=file:///dvdrom.
Setting the value of enabled to 1 enables the repository.
In the last line, I have disabled GPG signature check for packages by setting the value of gpgcheck to 0. You need to set gpgcheck to 0 if you want to allow the installation of unsigned packages. If set to 1, yum will verify the authenticity of the packages by checking the GPG signatures by using the gpgkey. The gpgkey line specifies the path to gpg key. If you have set gpgcheck value to 0, there is no need to mention gpgkey. Below is the quick list of options which can be used in repo file:
cachedir # directory used to store downloaded packages. debuglevel # logging level, from 0 (none) to 10 (all). exactarch # if set to 1, only update packages for the correct architecture. exclude # a space separated list of packages to exclude from installs or updates, for example: exclude=VirtualBox-*. gpgcheck # if set to 1, verify the authenticity of the packages by checking the GPG signatures. You might need to set gpgcheck to 0 if a package is unsigned. gpgkey # pathname of the GPG public key file. installonly_limit # maximum number of versions that can be installed of any one package. keepcache # if set to 0, remove packages after installation. logfile # pathname of the yum log file. obsoletes # if set to 1, replace obsolete packages during upgrades. plugins # if set to 1, enable plugins that extend the functionality of yum. proxy # url of a proxy server including the port number. proxy_password # password for authentication with a proxy server. proxy_username # user name for authentication with a proxy server. reposdir # directories where yum should look for repository files with a .repo extension. The default directory is /etc/yum.repos.d.
Installation using YUM
Before installing any package, clear the repository cache by issuing the following command.
[root@centos ~]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: LocalRepo Cleaning up everything Cleaning up list of fastest mirrors [root@centos ~]#
Install the package using the yum command, let’s install the libreoffice package from the local repository.
[root@centos ~]# yum install libreoffice Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package libreoffice.x86_64 1:188.8.131.52-3.el7 will be installed --> Processing Dependency: libreoffice-math = 1:184.108.40.206-3.el7 for package: 1:libreoffice-220.127.116.11-3.el7.x86_64 --> Processing Dependency: libreoffice-emailmerge = 1:18.104.22.168-3.el7 for package: 1:libreoffice-22.214.171.124-3.el7.x86_64 --> Processing Dependency: libreoffice-base = 1:126.96.36.199-3.el7 for package: 1:libreoffice-188.8.131.52-3.el7.x86_64 --> Running transaction check ---> Package libreoffice-base.x86_64 1:184.108.40.206-3.el7 will be installed --> Processing Dependency: postgresql-jdbc for package: 1:libreoffice-base-220.127.116.11-3.el7.x86_64 --> Processing Dependency: pentaho-reporting-flow-engine for package: 1:libreoffice-base-18.104.22.168-3.el7.x86_64 ---> Package libreoffice-emailmerge.x86_64 1:22.214.171.124-3.el7 will be installed ---> Package libreoffice-math.x86_64 1:126.96.36.199-3.el7 will be installed --> Running transaction check ---> Package pentaho-reporting-flow-engine.noarch 1:0.9.4-8.el7 will be installed --> Processing Dependency: librepository >= 1.1.3 for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch --> Processing Dependency: liblayout >= 0.2.10 for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch --> Processing Dependency: libformula >= 1.1.3 for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch --> Processing Dependency: libfonts >= 1.1.3 for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch --> Processing Dependency: libbase >= 1.1.3 for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch --> Processing Dependency: pentaho-libxml for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch --> Processing Dependency: libserializer for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch --> Processing Dependency: flute for package: 1:pentaho-reporting-flow-engine-0.9.4-8.el7.noarch ---> Package postgresql-jdbc.noarch 0:9.2.1002-5.el7 will be installed --> Running transaction check ---> Package flute.noarch 0:1.3.0-11.OOo31.el7 will be installed ---> Package libbase.noarch 0:1.1.3-10.el7 will be installed ---> Package libfonts.noarch 0:1.1.3-13.el7 will be installed --> Processing Dependency: libloader >= 1.1.3 for package: libfonts-1.1.3-13.el7.noarch ---> Package libformula.noarch 0:1.1.3-10.el7 will be installed ---> Package liblayout.noarch 0:0.2.10-8.el7 will be installed ---> Package librepository.noarch 0:1.1.3-9.el7 will be installed ---> Package libserializer.noarch 0:1.1.2-10.el7 will be installed ---> Package pentaho-libxml.noarch 0:1.1.3-10.el7 will be installed --> Running transaction check ---> Package libloader.noarch 0:1.1.3-9.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================ Package Arch Version Repository Size ============================================================================================ Installing: libreoffice x86_64 1:188.8.131.52-3.el7 LocalRepo 43 k Installing for dependencies: flute noarch 1.3.0-11.OOo31.el7 LocalRepo 61 k libbase noarch 1.1.3-10.el7 LocalRepo 123 k libfonts noarch 1.1.3-13.el7 LocalRepo 190 k libformula noarch 1.1.3-10.el7 LocalRepo 314 k liblayout noarch 0.2.10-8.el7 LocalRepo 653 k libloader noarch 1.1.3-9.el7 LocalRepo 97 k libreoffice-base x86_64 1:184.108.40.206-3.el7 LocalRepo 2.6 M libreoffice-emailmerge x86_64 1:220.127.116.11-3.el7 LocalRepo 59 k libreoffice-math x86_64 1:18.104.22.168-3.el7 LocalRepo 996 k librepository noarch 1.1.3-9.el7 LocalRepo 63 k libserializer noarch 1.1.2-10.el7 LocalRepo 33 k pentaho-libxml noarch 1.1.3-10.el7 LocalRepo 82 k pentaho-reporting-flow-engine noarch 1:0.9.4-8.el7 LocalRepo 283 k postgresql-jdbc noarch 9.2.1002-5.el7 LocalRepo 447 k Transaction Summary ============================================================================================ Install 1 Package (+14 Dependent packages) Total download size: 6.0 M Installed size: 13 M Is this ok [y/d/N]:y [output cut]
That’s all you have successfully configured your own repository which you can use on your own system as well as on all systems in your local network. In fact the 3rd party repositories are also created in the same manner except they are accessible over Internet via Apache web service which we have already covered above.