Tuesday, August 30, 2022

[SOLVED] How to publish a rpm package to YUM

Issue

I have created a rpm package, and I need to publish it to YUM so that users can directly do yum install softwareName to install the application. I searched on google but can't find many resources. I'm new to this thing so I don't really know what I want to do is possible. I've tried to create a local yum repository for the application, but it seems work only for the local machine. Can anyone help please? Thank you.


Solution

Assuming you've YUM installed on a Linux box.

You need to create a YUM repository that contains your RPM. For example,

./mydir/Packages/my.rpm

Use createrepo to create repository for that directory.

createrepo ./mydir

Above would create a repodata directory in ./mydir

Then tell YUM where that repository is by creating a repo file in /etc/yum.repos.d/my.repo. Contents of my.repo can be something like this:

[my_repo]
name=My YUM REPO
baseurl=file:///path/to/mydir
enabled=1

Then do, yum --enablerepo=* clean all. This should regenerate metadata for yum.

Finally,

`yum --enablerepo=* install my`

Above, my refers to my.rpm

In order to access this from other machines on the network, you need a web access,

Install http. Place your repository somewhere in, /var/www/html/repos/mydir/Packages/my.rpm

Then follow other steps and edit my.repo file to include hostname of the machine in the baseurl attribute :

 baseurl=http://myrepository.com/mydir


Answered By - iamauser
Answer Checked By - Terry (WPSolving Volunteer)