FAQ:Package a Binary for Conary
From rPath Wiki
| FAQ | ||
| Question: How can I package software for Conary that is only available in binary form? | ||
Answer: This page explains how to package software for Conary if it is available only in binary form. Included in an example recipe using the BinaryPackageRecipe superclass used in a Recipe Template for Binary Files.
Example Binary Only Recipe
| Before you can package a binary application with Conary, you'll need a working Conary build environment. If you have not yet defined such an environment, see the Conary New Package Tutorial for detailed information on this process. |
For this HOWTO guide, the example package is part of the widget project on a private repository at widget.example.com, and will consist of the tmpwatch application obtained from a binary RPM file.
Create a new package for the binary application within your Conary build environment using the cvc tool. See the cvc(1) manual page for more usage details.
[you@yourhost ~]$ mkdir conary/widget [you@yourhost ~]$ cd conary/widget [you@yourhost widget]$ cvc context widget [you@yourhost widget]$ cvc newpkg tmpwatch
After creating the new tmpwatch package, use your preferred editor to create a new binary package recipe, and add initial content:
[you@yourhost widget]$ cd tmpwatch [you@yourhost tmpwatch]$ vim tmpwatch.recipe
Here is the initial tmpwatch.recipe content:
loadSuperClass('binarypackage=conary.rpath.com@rpl:devel') class Tmpwatch(BinaryPackageRecipe): name = 'tmpwatch' version = '2.9.3' archive = 'http://download.example.com/widget/RPMS/%(name)s-%(version)s-1.i386.rpm'
Save the file, exit your editor, and cook the new recipe:
[you@yourhost tmpwatch]$ cvc cook tmpwatch.recipe
After successfully cooking the recipe, add the recipe to the widget project, and commit to the project repository:
[you@yourhost tmpwatch]$ cvc add tmpwatch.recipe [you@yourhost tmpwatch]$ cvc commit
After a successful commit, cook the changeset into the widget repository, making it available for installation on other Conary-based systems:
[you@yourhost tmpwatch]$ cvc cook tmpwatch
Finally, you can install and verify the binary application with Conary:
[root@yourhost tmpwatch]# conary update tmpwatch [root@yourhost tmpwatch]# conary q --ls tmpwatch /usr/share/man/man8/tmpwatch.8.gz /etc/cron.daily/tmpwatch /usr/sbin/tmpwatch [root@yourhost tmpwatch]#
From the output of the above command, one can see that the tmpwatch binary, manual page, and related daily crontab file are all correctly installed. The package can now also be installed on other Conary systems by specifying the package name along with its installation label. For example:
[root@conaryhost ~]# conary update tmpwatch=widget.example.com@widget:1
Advanced Binary Only Recipe Notes
The example recipe described above represents a simple case of packaging a binary RPM file. More complex binary applications may require additional options in the recipe. Some examples of more advanced packaging options are described here for reference.
Using the unpack() Method
If necessary, you can use the unpack() method instead of defining an archive string in the binary only recipe to realize more flexibility in retrieving and installing the binary file. Furthermore, you can define multiple unpack() methods to allow for retrieving and installing multiple binary files as part of the same package. Here is a recipe example using the unpack() method:
loadSuperClass('binarypackage=conary.rpath.com@rpl:devel') class WidgetMixer(BinaryPackageRecipe): name = 'widgetmixer' version = '1.0' def unpack(r): r.addArchive('http://www.example.com/', dir='/opt/%(name)s/')
As shown in the example above, the widgetmixer binary will be retrieved from www.example.com and installed to the /opt/widgetmixer directory. Note that Conary's source filename guessing is used in this example to determine the tarball filename.
Passing Exceptions to Conary Policy
You can also make other minor changes to the package, or pass exceptions to Conary policy with the BinaryPackageRecipe class. To do so, define the policy() method as such:
def policy(r):
r.ComponentSpec('devel',
'%(bindir)s/widget-config',
'%(mandir)s/man1/widget-config.*')
User Account Management
If the binary software you are packaging requires particular users or groups to function, and those users or groups do not currently exist in the rPath Linux UID registry, you need to define the appropriate info-* recipes for the required user or group, and package them. See the Conary user and group specification and the info-* recipe pages for more details. If the package is publicly visible, you should consider adding the details of of the user and group identifiers to the UID registry.
Categories: FAQ | Conary | Packaging | Recipe
