BuycPanel Blog

BuycPanel Blog

Latest news and updates

The Seven Steps to Create and Set Up Your Custom RPMs

Posted by Jamison on 29 11 2016.

Much thanks to how cPanel continuously strives hard to make the lives of its users easier and more convenient, many of the RPMs now come as cPanel & WHM’s third-party dependencies pre-installed into the platforms.

 

Best of all, you can even customize these RPMs depending on your needs. However, you need to follow a chain of commands, but all it takes is this 7-step program.

 

Step 1

 

After logging in as the root user through SSH, the first thing you should do is to create the .rpmmacros file. You can use any text editor you like to create this file and store it in the /root/ directory.

 

Make sure you include these in the file:

 

 	%_topdir /root/rpmbuild
 	# enable debug RPM package by commenting this out.
 	%debug_package %{nil}

 

Step 2

 

Some RPMs need rebuilding when you want to customize them. This involves creating directories that may still not exist on your server, including the following:

 

 	/root/rpmbuild/BUILD
…

Much thanks to how cPanel continuously strives hard to make the lives of its users easier and more convenient, many of the RPMs now come as cPanel & WHM’s third-party dependencies pre-installed into the platforms.

 

Best of all, you can even customize these RPMs depending on your needs. However, you need to follow a chain of commands, but all it takes is this 7-step program.

 

Step 1

 

After logging in as the root user through SSH, the first thing you should do is to create the .rpmmacros file. You can use any text editor you like to create this file and store it in the /root/ directory.

 

Make sure you include these in the file:

 

  • %_topdir /root/rpmbuild
  • # enable debug RPM package by commenting this out.
  • %debug_package %{nil}

 

Step 2

 

Some RPMs need rebuilding when you want to customize them. This involves creating directories that may still not exist on your server, including the following:

 

  • /root/rpmbuild/BUILD
  • /root/rpmbuild/SPECS
  • /root/rpmbuild/SOURCES
  • /root/rpmbuild/BUILDROOT
  • /root/rpmbuild/RPMS
  • /root/rpmbuild/SRPMS

 

To create these directories, just execute this command:

 

  • mkdir -p /root/rpmbuild/BUILD /root/rpmbuild/SPECS /root/rpmbuild/SOURCES /root/rpmbuild/BUILDROOT /root/rpmbuild/RPMS /root/rpmbuild/SRPMS

 

It is extremely important you name everything exactly the way listed above, including the capitalization of the directory names.

 

Step 3

 

Now, you can install your source RPM. To do this, just execute the rpm command. In the event you do not know the right cPanel and WHM version for the SRPM you need, you can find it on the cPanel’s httpupdate server.

 

When running the rpm command, it should look something like this:

 

  • rpm -Uvh http://httpupdate.cpanel.net/RPM/11.42/src/cpanel-php54-5.4.23-4.cp1142.src.rpm

Once successfully done with the installation a message similar to this will come up:

 

  • “Retrieving http://httpupdate.cpanel.net/RPM/11.42/src/cpanel-php54-5.4.23-4.cp1142.src.rpm 1:cpanel-php54 ########################################### [100%]”

 

Step 4

 

Using a text editor, revise the .spec file found in your system’s directory called: /root/rpmbuild/SPECS/. From here, you can make any additions you want for your RPM’s configuration settings.

 

Step 5

 

Now, you have to rebuild the RPM. Do this by executing the rpmbuild command while staying on the modified .spec file. This will create a new local RPM.

 

To give you an idea, the command should look something like this:

 

  • rpmbuild -bb /root/rpmbuild/SPECS/php.spec

 

Properly done, the re-written RPM and all its subpackages will make its way to the /root/rpmbuild/RPMS/ directory.

 

Step 6

 

Go to your /root/rpmbuild/RPMS/ directory. From here, execute the rpm command once more, and it will install the newly made, custom-built RPM.

 

Step 7

 

For many cPanel and WHM users, preventing unintentional updates make it to their list of priorities when building and installing custom RPMs. They do so, in order to avoid any potential problem from arising in the future, especially when cPanel rolls out updates or upgrades.

 

Know though, that this method is only optional, as it only prohibits automatic upgrades to the cPanel & WHM platforms (you can still upgrade, but would have to perform it manually.). The down side to not performing this step, on the other hand, is that future cPanel and WHM updates or upgrades may overwrite the custom-built RPMs.

 

To perform this last step, just add the custom RPM in the update_local_rpm_versions script, which contains all the local RPMs.