Sabayon: Using Portage to Build a Binary Package for Installation by Entropy

Published: Oct. 1, 2015, 9 p.m.

Updated: None

My biggest complaint with Sabayon after using the 14.08 release for more than three months was the lack of a way to get software that is not available in the Sabayon repositories for management by the Entropy binary package management system. There didn't appear to be an easy way to build binary packages from source or from a third party tarball as there is for RPM based distributions through the rpmbuild tool. As it turns out, although Entropy can't do this, Sabayon has several alternatives for getting software that is not available in its binary repositories for for installation and management using Entropy by employing some of the functions available in Portage -- the Gentoo source package management system -- to first build the packages. This article describes one such relatively simple and safe method.

Introduction

As we are not actually using Portage to install a package, but merely using it to build a binary package, it is probably not absolutely necessary to prepare the system for hybrid source/binary package management, but it is probably best to do so, and I followed my own advice. That procedure is described here; the relevant part of that procedure for the method described in this article is the section on "System-Wide Procedure".

The procedure described in this article, to briefly summarize:

  • builds a binary package in a Gentoo specific binary package format using the Portage command, emerge, with specific options to specify building only, as opposed to building and installing
  • then converts the Gentoo specific format binary package to a Sabayon specific binary package format using a subcommand of Entropy's equo
  • and finally, installs the Sabayon binary package using Entropy's equo



Procedure

Begin the process of building a package by viewing the information on the Gentoo Packages page to determine what dependencies if any exist for the desired package. Build-time dependencies that are available in Sabayon should be installed first using Entropy. Build-time dependencies that are not available through Entropy should be built recursively using the process described in this article. Run-time dependencies that are available in Entropy will be resolved and installed during the final package installation by Entropy. Run-time dependencies that are not available in Entropy should also be built in advance using the procedure described here. It should be noted that the Sabayon developers warn that core system packages should not be built in this way.

All of the following commands are entered as root.

  1. Install all dependencies not available through Entropy (again, run-time dependencies that are available in Entropy, will be automatically resolved and installed during package installation). Dependency package availability can be determined using:
    equo search dependencypackagename
  2. update Portage Tree with
    emerge --sync
  3. if customization of the package to be built by Portage is desired add the package to be installed to
    /etc/portage/package.use/00-sabayon.package.use.
    with the appropriate flag or -flag. Note that optional dependencies will only be installed by Entropy only if these packages are specified through the USE flags.
  4. build package with
    emerge -av -B packagename
    the Gentoo package will be saved to /usr/portage/packages/package-category/package-x.x.x.tbz2
  5. optionally create a directory for temporarily saving packages converted from Gentoo format to Sabayon format, to be reused each time a package is built. this directory will be the argument to the --savedir below.
  6. convert the Gentoo format binary package to a Sabayon format with
    equo pkg inflate --savedir /converted/package/directory /usr/portage/packages/package-category/package-x.x.x.tbz2
  7. copy the converted package to the default Entropy package download version with
    cp /converted/package/directory/package-category/package-category:package-x.x.x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx~9999.tbz2 /var/lib/entropy/client/packages/packages/amd64/5
  8. finally, install the package with
    equo -i /var/lib/entropy/client/package/amd64/5/package-category/package-category:packagename-x.x.x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx~9999.tbz2
    Note that the option -i in the above is short for the subcomand install.



Example: Installing glances

Having been introduced to the glancess process monitoring tool by Voyager, I have installed it on every other Linux I have used since trying Voyager. Unfortunately, it is not available through Entropy, Sabayon's binary package management system. But the method introduced above of using Portage to build the binary package can be used for installation and management by Entropy.

The first step is to look at the package details on Gentoo's package page for glances which shows the use flags chart, hddtemp, snmp, and web. Clicking on each of these opens another page with the description of the flag and other packages that are related to the flag, giving clues on whatever dependencies exist for the desired package. Clicking on chart, there is an indication that it depends on matplotlib a subsequent search for which in Entropy (equo search matplotlib) shows that it is available through Entropy, meaning its own dependencies are also available through Entropy. CLicking on the hddtemp, snmp, and web indicates that these USE flags are actually referring to the packages app-admin/hddtemp, net-analyzer/net-snmp, and dev-python/bottle. A subsequent search for these shows that they are available in the Entropy system.

It is also necessary to follow the link to the Git repository browser from the Gentoo packages glances page in order to see the ebuild for the version to be installed as that provides more information on dependencies. In the case of glances, the following excerpt from glances-2.4.2.ebuild is relevant.

RDEPEND="${DEPEND}
	>=dev-python/psutil-2.0.0[${PYTHON_USEDEP}]
	hddtemp? ( app-admin/hddtemp )
	snmp? ( dev-python/pysnmp[${PYTHON_USEDEP}] )
	web? ( dev-python/bottle[${PYTHON_USEDEP}] )
	chart? ( dev-python/matplotlib[${PYTHON_USEDEP}] )"

From my heuristic experience, I have found that these lines indicate that dev-python/psutil is an explicit dependency and app-admin/hddtemp, dev-python/pysnmp, dev-python/bottle, and dev-python/matplotlib are optional dependencies that will only be installed if the corresponding USE flags are specified.

Because all of these dependencies are available in Entropy, we can just proceed with the rest of the process without using this process to recursively build the dependency packages. Also, initially we won't worry about specifying the USE flags in /etc/portage/package.use/00-sabayon.package.use.

Next

  1. update the Portage Tree with

    emerge --sync

  2. build the Gentoo binary package with

    emerge -av -B sys-process/glances
    The package will be saved to /usr/portage/packages/sys-process/glances-2.4.2.tbz2. Since the version of the package was not specified in the above command, Portage will take the best version, not necessarily the latest, which in this case happens to be the latest version, 2.4.2 (as of 23 Oct 2015). The following code block shows the initial response to the command and the prompt for confirmation.

    V570-SABAYON packages # emerge -av -B sys-process/glances
    
    These are the packages that would be built, in order:
    
    Calculating dependencies... done!
    [ebuild  N     ] sys-process/glances-2.4.2::gentoo  USE="-chart -doc -hddtemp -snmp -web" PYTHON_TARGETS="python2_7 python3_4 -python3_3" 5,370 KiB
    
    Total: 1 package (1 new), Size of downloads: 5,370 KiB
    
    Would you like to merge these packages? [Yes/No] y
    

    The end of the output of the emerge operation and subsequent steps in the terminal.
    After the emerge operation, running ls at /usr/portage/packages/sys-process/ shows that the Gentoo specific binary package is at /usr/portage/packages/sys-process/glances-2.4.2.tbz2. The command to convert the package to a Sabayon format binary package is shown at the next prompt.

  3. create a directory for saving the converted package, which will be used in the next step, if desired, otherwise it will be saved to some default directory by equo. I created a directory in my home directory called sabpac with my standard user.

  4. convert the package to the Sabayon binary package format and save it to the previously created directory with

    equo pkg inflate --savedir /home/brook/sabpac /usr/portage/packages/glances/glances/glances-2.4.2.tbz2
    This will create /home/brook/sabpac/sys-process/sys-process:glances-2.4.2.acb8874294b3ae2f1207ab1d3c89f1c2e06a381a~9999.tbz2. The string between the version number and the ~ appears to be some sort of hash that is used by the delta download feature during updates by Entropy. I kept the name as is but, alternatively, it can be renamed removing this string.

  5. copy the converted package to the default location for packages downloaded by Entropy with

    cp ~/sabpac/sys-process/sys-process:glances-2.4.2.acb8874294b3ae2f1207ab1d3c89f1c2e06a381a~9999.tbz2 /var/lib/entropy/client/packages/packages/amd64/5

    the package copied to the default package download location
    The newly built glances package copied to the default Entropy package download location.

  6. install glances with

    equo -i /var/lib/entropy/client/packages/packages/amd64/5/sys-process:glances-2.4.2.acb8874294b3ae2f1207ab1d3c89f1c2e06a381a~9999.tbz2

    The last command entered installs the package.

Had I specified the use flags indicated in the Gentoo packages page for sys-process/glances in /etc/portage/package.use/00-sabayon.package.use by inserting the line

sys-process/glances chart hddtemp snmp web doc
when running emerge -av -B sys-process/glances, the response would have been:
EB8540w-SABAYON glances # emerge -av -B sys-process/glances

 * IMPORTANT: 19 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.


These are the packages that would be built, in order:

Calculating dependencies... done!
[ebuild  N     ] sys-process/glances-2.4.2::gentoo  USE="chart doc hddtemp snmp web" PYTHON_TARGETS="python2_7 python3_4 -python3_3" 0 KiB

Total: 1 package (1 new), Size of downloads: 0 KiB

Would you like to merge these packages? [Yes/No] Yes

The message regarding Gentoo news appears in the second output, because it was a different computer on which I hadn't bothered to read the news. In any case, note the difference in the output with the addition of the USE flags from the previously presented response of the emerge command; in the previous output there were - prepended to the USE flags whereas, now there are not. When installing the final package with equo, the dependencies referred to by the use flags are resolved and installed along with glances, as shown in the following screenshot. Without the use flags only required are installed as specified in the ebuild, as previously mentioned.

In this case this is the dev-python/psutil package.

Dependencies required for use flags specified in /etc/portage/package.use/00-sabayon.package.use are resolved by Entropy.
Installing glances with equo when USE flags are specified.
Dependencies required for use flags specified in /etc/portage/package.use/00-sabayon.package.use are resolved by Entropy. If chart, hddtemp, snmp, web, and doc had not been specified, only psutils would have been installed per the .ebuild.

Compare the screenshot with the previous one displaying the output of the equo i command where the initial Gentoo package was built without including the USE flags.



Conclusion

For potential Sabayon users with needs similar to mine, who want software that may not be available in the regular Sabayon binary repositories can use this relatively simple function of Gentoo's portage to obtain software from Gentoo's repositories and build the binary package for installation and management by Entropy. This method, where Portage is only used to build a binary package for subsequent conversion to a Sabayon binary package and installation by Entropy, is safer than converting Sabayon to a hybrid source/binary system. The safety of this method stems from the fact that Portage doesn't actually install the package.

the newly built and installed glances running in GNOME Terminal Sabayon 15.10 Cinnamon
The newly built and installed glances running in GNOME Terminal.
Everything seems fine except for the atypical -- compared -- to glances found in other distributions is the DISK I/O info shows ram0 through ram15 in addition to sda blocks. An improved version or build of glances that shows I/O to RAM?

I find this bit of knowledge of Sabayon's Gentoo foundation greatly improves Sabayon's viability as a useful day to day distribution. It also shows that Sabayon is a uniquely flexible system suited more to those who are willing to learn more about its foundation.

Thanks to albfneto on the Sabyon forums for pointing out the method described in this article.