CentOS: Create and share your own YUM repository

This blog explains how to create your own yum repository with the createrepo tool and to distribute specialized packages within an organization. In this blog I have given an example of kernel RPMs repository.

Creating your own yum repository is very simple, and very straightforward. In order to do it, you need the createrepo tool, which can be found in the createrepo package, so to install it, execute as root:
# yum install createrepo
Once the package is installed, you can begin creating your repository. You will also need some RPM packages to create the repository with. Decide where you want to store your repository; let's say, /var/ftp/pub will be the base directory . 
Depending on how particular you want to get, you can dump everything to a single repository or keep things organized. 
# mkdir -p /var/ftp/pub/repo/CentOS/7/{SRPMS,aarch64}
Now copy your aarch64 packages to /var/ftp/pub/repo/CentOS/7/aarch64, and the SRPMS you have (if wanted) to /var/ftp/pub/repo/CentOS/7/SRPMS. To easily automate the creation of the repository metadata, create a shell script called create-my-repo and place it somewhere in your PATH:
#!/bin/sh
destdir="/var/ftp/pub/repo/CentOS/7"
for arch in arm64
do
    pushd ${destdir}/${arch} >/dev/null 2>&1
        createrepo .
    popd >/dev/null 2>&1
done
Make the script executable and whenever you run it, it will call the createrepo tool on one directory: /var/ftp/pub/repo/CentOS/7/aarch64 Once this is done, your repository is ready for use.  If /var/ftp is the available FTP root, then ftp://internalhost.com/pub/repo/CentOS/7/aarch64 would be the download URL for the aarch64 packages. To make this available to the other client systems, create a yum repository configuration file called /etc/yum.repos.d/local.repo with the following contents:
$ sudo vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=ftp://<ipaddress/hostname.com>/pub/repo/CentOS/7/
gpgcheck=0
enabled=1
save and exit.  

Comments

Popular posts from this blog

Apache Ambari on ARM64

Benchmarking BigData

usermod/groupmod tools - Rename username and usergroup in Ubuntu