Guide to Establishing and Hosting a Remote Yum Repository on GitHub
Introduction
Unlock the secrets behind the seamless installation of packages on your system from remote machines. Dive into the world of RPM packages and discover the mysteries of their deployment. π΅οΈββοΈ
In this guide, not only will we demystify the process for you, but weβll empower you to host your very own RPM packages, ready to be installed on any YUM-based distribution. π
Our chosen platform for this adventure? GitHub. Join us as we unravel the intricacies of creating and hosting a YUM repository on GitHub, opening up a world of possibilities for streamlined package management on your systems. π Letβs embark on this journey together and turn the seemingly complex into a manageable and rewarding experience. π
Prerequisite
Before delving into the process of hosting your YUM repository, ensure the following prerequisites are in place:
- GitHub Pages Deployment:
A GitHub repository deployed/can be deployed on GitHub Pages is essential for hosting your YUM repository. - RPM-Based Machine:
Make sure you have access to an RPM-based machine. This will serve as the foundation for your YUM repository, providing the necessary environment for building RPM package and setting up YUM repository. - RPM File for Hosting:
Identify and have the RPM file ready that you intend to host in the remote repository. This file will be a key component in populating your YUM repository with the desired packages. Ensure it is prepared and available for the upcoming
Setting up GitHub Repository
- Create a dedicated repository on GitHub for hosting your YUM repository.
- Deploy the GitHub repository on GitHub Pages for seamless accessibility.
- Clone this repository onto your RPM-based machine to facilitate further setup steps.
Preparing YUM repository content
- Copy RPM Package:
Place your RPM package in the root directory of the GitHub repository.
cp <package_name>.rpm <PATH_TO_REPO>
- Install createrepo Tool:
Utilize the following command to install thecreaterepo
tool.
yum install createrepo
- Run createrepo:
Execute thecreaterepo
tool at the root of the Git repository to structure your YUM repository.
createrepo .
This will generate the following file structure:
βββ <package_name>.rpm
βββ repodata
βββ <random_hash_1>-filelists.xml.gz
βββ <random_hash_2>-other.sqlite.bz2
βββ <random_hash_3>-primary.sqlite.bz2
βββ <random_hash_4>-other.xml.gz
βββ <random_hash_5>-primary.xml.gz
βββ <random_hash_6>-filelists.sqlite.bz2
βββ repomd.xml
- Commit and Push Changes:
Save your changes, commit them, and push the updated repository to GitHub.
git add .
git commit -m "Add RPM package and create YUM repository structure"
git push origin main
- Deployment on GitHub Pages:
Once deployed on GitHub Pages, your YUM repository is ready for use in installing packages.
Connecting YUM client to remote repository
- Create YUM Configuration File:
Generate a YUM configuration file for your package at/etc/yum.repos.d/<package_name>.repo
- Configure Repository Settings:
Specify the following key settings in the configuration file:
Repository ID β One word unique repository ID (example:
[myrepo]
)
Name β Human-readable name of the repository (example:name=My GitHub Repository
)
Baseurl β URL to the repodata directory. (In our case link to GitHub Page)
Enabled β Enable repository when performing updates and installs (example:enabled=1
)
GPG Check: Optionally configure GPG check (e.g.,gpgcheck=0
for simplicity).
- Sample Configuration File:
Your configuration file should resemble the following example:
[myrepo]
name=My GitHub Repository
baseurl=<URL>
enabled=1
gpgcheck=0
- Save Changes:
Save the changes made to the configuration file. - Install Package:
With the YUM repository configured, you can now install your package using the following command:
yum install <package_name>
By following these steps, your YUM-based machine is now set up to seamlessly connect to and install packages from the remote repository.
Adding newer version of package
- Clone Remote Repository:
If not already present locally, clone the remote repository to your machine. - Copy Newer Package Version:
Place the newer version of the package in the root directory of the cloned repository. - Update YUM Repository Metadata:
Run the following command to update the YUM repository metadata.
createrepo --update .
- Commit Changes and Redeploy:
Commit the new changes to the repository.
git add .
git commit -m "Add newer version of <package_name>"
git push origin main
- Redeploy GitHub Page:
Ensure that your GitHub Page is redeployed to reflect the changes. - Verify in YUM Client:
Your YUM client will now detect the new version of the package, making it available for installation.
By following these steps, you can seamlessly add a newer version of the package to your existing YUM repository without the need to create an entirely new repository.
Naming Convention for package
As your repository grows, adopting a standardized naming convention becomes crucial. The βrpm.orgβ suggests the following format, which proves highly effective:
name-version-release.architecture.rpm
name β name describing the packaged software
version β version of the packaged software
release β number of times this version of the software has been packaged
architecture β shorthand name describing the type of computer hardware the packaged software is meant to run on
Example:
For instance, a package named βexampleβ with version β1.0β and release β1β intended for the x86 architecture would be named:
example-1.0-1.x86_64.rpm
Conclusion
I hope this article has helped you in learning to create and manage your YUM repository on GitHub efficiently. π
From setting up the repository to connecting clients and adding newer versions, I tried to cover everything I know about this topic.
Remember to adhere to best practices like naming conventions and consider automation for long-term efficiency. Happy package management on YUM-based distributions! π