{"id":670,"date":"2021-07-23T12:35:16","date_gmt":"2021-07-23T12:35:16","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/how-to-build-and-install-custom-rpms\/"},"modified":"2021-07-23T12:35:16","modified_gmt":"2021-07-23T12:35:16","slug":"how-to-build-and-install-custom-rpms","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/how-to-build-and-install-custom-rpms\/","title":{"rendered":"How to Build and Install Custom RPMs"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>cPanel, L.L.C. ships many of cPanel &#038; WHM\u2019s third-party dependencies as RPMs. In order to customize these dependencies on your server, you <strong>must<\/strong> custom-build the RPM and then reinstall it. For example, use this method to build and install Roundcube customizations in cPanel &#038; WHM version 58 and later.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        You <strong>must<\/strong> log in through SSH as the root user to install an RPM.\n    <\/div>\n<\/div>\n<h2 id=\"before-you-begin\">Before you begin<\/h2>\n<p>Perform the following steps to ensure your system\u2019s readiness to build and install an RPM:<\/p>\n<ol>\n<li>\n<p>Install the rpm-build package.<\/p>\n<p>Use the following command to install the rpm-build package on your system:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">yum install rpm-build<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Enable the <code>devel<\/code> target for cPanel &#038; WHM.<\/p>\n<p>Run the <code>update_local_rpm_versions<\/code> and <code>check_cpanel_rpms<\/code> scripts before you install a custom RPM. These scripts ensure that the <code>devel<\/code> target is enabled and up-to-date. The <code>devel<\/code> target installs the <code>devel<\/code> versions of RPMs, which cPanel &#038; WHM uses to compile SRPMs locally.<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/scripts\/update_local_rpm_versions --edit target_settings.cpanel-devel installed\n\/scripts\/check_cpanel_rpms --targets cpanel-devel --fix<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        To rebuild some cPanel-provided RPMs, you may need to install additional RPMs that cPanel &#038; WHM does <strong>not<\/strong> include in default installations. These additional RPMs contain files that the system only needs to rebuild, but not run, the cPanel-provided RPMs.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>Install additional prerequisites.<\/p>\n<p>Before you can build and install a custom-built RPM, you <strong>must<\/strong> install all of the RPM\u2019s prerequisites. You can find all of an RPM\u2019s prerequisites, and the required version numbers, in its <code>.spec<\/code> file.<\/p>\n<ul>\n<li>Lines in the <code>.spec<\/code> file that begin with <code>BuildRequires:<\/code> indicate a prerequisite that the RPM requires for the build process.<\/li>\n<li>Lines in the <code>.spec<\/code> file that begin with <code>Requires:<\/code> indicate a prerequisite that the RPM requires for installation.<\/li>\n<\/ul>\n<p>For example, <code>BuildRequires: cpanel-mysql &gt;= 5.0.95<\/code> indicates that the RPM requires the <code>cpanel-mysql<\/code> RPM of MySQL\u00ae version 5.0.95 or higher.<\/p>\n<\/li>\n<li>\n<p>Ensure that you have installed all necessary RPMs.<\/p>\n<p>Run the <code>\/scripts\/sysup<\/code> script to ensure that you have installed all of the prerequisite RPMs.<\/p>\n<ul>\n<li>If all of these RPMs exist on your server, you will receive the following message: <code>All Needed RPMS are installed.<\/code><\/li>\n<li>If you receive an error message, correct those installation problems first to avoid additional errors when you build and install your custom RPM.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2 id=\"build-and-install-custom-rpms\">Build and install custom RPMs<\/h2>\n<p>Perform the following steps to build and install Roundcube customizations in cPanel &#038; WHM version 58 and later:<\/p>\n<ol>\n<li>\n<p>Create the <code>.rpmmacros<\/code> file.<\/p>\n<p>Use your preferred text editor to create the <code>.rpmmacros<\/code> file in the <code>\/root\/<\/code> directory.<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">%_topdir \/root\/rpmbuild\n<span style=\"color:#75715e\"># enable debug RPM package by commenting this out.<\/span>\n%debug_package %<span style=\"color:#f92672\">{<\/span>nil<span style=\"color:#f92672\">}<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<\/li>\n<li>\n<p>Create the directories to rebuild the RPM.<\/p>\n<p>If not present on your server, create the following directories:\n<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">5\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">6\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/root\/rpmbuild\/BUILD\n\/root\/rpmbuild\/SPECS\n\/root\/rpmbuild\/SOURCES\n\/root\/rpmbuild\/BUILDROOT\n\/root\/rpmbuild\/RPMS\n\/root\/rpmbuild\/SRPMS<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>Run the following command to create these directories:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">mkdir -p \/root\/rpmbuild\/BUILD \/root\/rpmbuild\/SPECS \/root\/rpmbuild\/SOURCES \/root\/rpmbuild\/BUILDROOT \/root\/rpmbuild\/RPMS \/root\/rpmbuild\/SRPMS<\/code><\/pre>\n<\/div>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n        You <strong>must<\/strong> use these names for the BUILD, SPECS, SOURCES, BUILDROOT, RPMS, and SRPMS directories. You must capitalize the entire name for each of these directories.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>Install the source RPM.<\/p>\n<p>Use the <code>rpm<\/code> command to install the source RPM (SRPM).<\/p>\n<ul>\n<li>The <code>.spec<\/code> file will install to the <code>\/root\/rpmbuild\/SPECS\/<\/code> directory.<\/li>\n<li>The source tarball, patches, and any additional files for the RPM will install to the <code>\/root\/rpmbuild\/SOURCES\/<\/code> directory.<\/li>\n<\/ul>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        You can find the correct SRPM for your version of cPanel &#038; WHM on our httpupdate server. Click on your server\u2019s version of cPanel &#038; WHM, and then click on the <code>src\/<\/code> directory to view a list of all available SRPMs for that version.\n    <\/div>\n<\/div>\n<p>Your command will resemble the following example:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">rpm -Uvh http:\/\/httpupdate.cpanel.net\/RPM\/11.42\/src\/cpanel-php54-5.4.23-4.cp1142.src.rpm <\/code><\/pre>\n<\/div>\n<p>When the installation finishes, you will see a message that resembles the following example:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">Retrieving http:\/\/httpupdate.cpanel.net\/RPM\/11.42\/src\/cpanel-php54-5.4.23-4.cp1142.src.rpm <span style=\"color:#ae81ff\">1<\/span>:cpanel-php54 <span style=\"color:#75715e\">########################################### [100%]<\/span><\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Edit the <code>.spec<\/code> file.<\/p>\n<p>Use your preferred text editor to modify the <code>.spec<\/code> file in the <code>\/root\/rpmbuild\/SPECS\/<\/code> directory. Add the desired configuration settings for your RPM.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        To change any of the sources that ship with the SRPM, modify the files in the \/root\/rpmbuild\/SOURCES\/ directory.\n    <\/div>\n<\/div>\n<p>The following example section of a <code>.spec<\/code> file includes the SOAP protocol:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">%configure --prefix<span style=\"color:#f92672\">=<\/span>%<span style=\"color:#f92672\">{<\/span>_prefix<span style=\"color:#f92672\">}<\/span> <span style=\"color:#ae81ff\"> <\/span>--with-libdir<span style=\"color:#f92672\">=<\/span>%<span style=\"color:#f92672\">{<\/span>_lib<span style=\"color:#f92672\">}<\/span> <span style=\"color:#ae81ff\"> <\/span>--verbose <span style=\"color:#ae81ff\"> <\/span>--enable-static <span style=\"color:#ae81ff\"> <\/span>--with-mcrypt<span style=\"color:#f92672\">=<\/span>%<span style=\"color:#f92672\">{<\/span>_3rdparty_prefix<span style=\"color:#f92672\">}<\/span> <span style=\"color:#ae81ff\"> <\/span>--with-iconv --enable-mbstring <span style=\"color:#ae81ff\"> <\/span>--with-gd <span style=\"color:#ae81ff\"> <\/span>--enable-soap <span style=\"color:#ae81ff\"> <\/span>--enable-mbregex <span style=\"color:#ae81ff\"> <\/span>--with-imap-ssl --with-imap<span style=\"color:#f92672\">=<\/span>%<span style=\"color:#f92672\">{<\/span>_3rdparty_libdir<span style=\"color:#f92672\">}<\/span>\/imap\/ <span style=\"color:#ae81ff\"> <\/span><\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Rebuild the RPM.<\/p>\n<p>Run the <code>rpmbuild<\/code> command on the modified <code>.spec<\/code> file to build the new RPM locally. Your command should resemble the following example:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">rpmbuild -bb \/root\/rpmbuild\/SPECS\/php.spec<\/code><\/pre>\n<\/div>\n<p>The <code>rpmbuild<\/code> tool writes the RPM and any subpackages to the <code>\/root\/rpmbuild\/RPMS\/<\/code> directory.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        The system may report dependencies issues when you run this command. If so, install these dependencies with yum before you continue.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>Run the command to update your RPM with force.<\/p>\n<p>Navigate to the <code>\/root\/rpmbuild\/RPMS\/<\/code> directory and run the <code>rpm<\/code> command to install your new custom-built RPM.<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">rpm -Uvh cpanel-php54-5.4.23-4.cp1142.x86_64.rpm --force<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Prevent unintentional updates.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n        This step is <strong>optional<\/strong> and may freeze updates to this RPM and prevent future cPanel &#038; WHM upgrades. However, if you do not perform this step, cPanel &#038; WHM may overwrite your custom RPM on its next update or upgrade.\n    <\/div>\n<\/div>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/scripts\/update_local_rpm_versions --add srpm_versions.cpanel-php54 <span style=\"color:#ae81ff\">5<\/span>.4.23-4.cp1142<\/code><\/pre>\n<\/div>\n<p>To verify your custom RPM\u2019s configuration, view the <code>\/var\/cpanel\/rpm.versions.d\/local.versions<\/code> file.<\/p>\n<p>The contents of the <code>local.versions<\/code> file should resemble the following example:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">--- file_format:   version: <span style=\"color:#ae81ff\">2<\/span> srpm_versions:   cpanel-php54: <span style=\"color:#ae81ff\">5<\/span>.4.23-4.cp1142<\/code><\/pre>\n<\/div>\n<\/li>\n<\/ol>\n<h2 id=\"return-to-the-cpanel-whm-version-of-an-rpm\">Return to the cPanel &#038; WHM version of an RPM<\/h2>\n<p>Perform the following steps if you wish to return to the cPanel &#038; WHM version of an RPM:<\/p>\n<ol>\n<li>\n<p>Run the following command to remove the custom RPM from the local.versions file:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/scripts\/update_local_rpm_versions --del srpm_versions.cpanel-php54<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Run the following script to reinstall the cPanel &#038; WHM version of the RPM:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/scripts\/check_cpanel_rpms<\/code><\/pre>\n<\/div>\n<\/li>\n<\/ol><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview cPanel, L.L.C. ships many of cPanel &#038; WHM\u2019s third-party dependencies as RPMs. In order to customize these dependencies on your server, you must custom-build the RPM and then reinstall it. For example, use this method to build and install Roundcube customizations in cPanel &#038; WHM version 58 and later. Note: You must log in &hellip;<\/p>\n","protected":false},"author":1,"featured_media":671,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/670"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/671"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}