Conary:cvc Recipe Template
From rPath Wiki
As of Conary version 1.0.15, you may now define recipe template files which Conary's cvc tool will use to generate an initial recipe file as part of creating a new package with the cvc newpkg command.
Recipe template files should be located in the following subdirectories, for site-wide and user-specific precedence respectively:
-
/etc/conary/recipeTemplates -
$HOME/.conary/recipeTemplates
You can instruct cvc to use a specific recipe template file by defining the recipeTemplate directive in Conary's configuration file. This directive should be used inside of a configuration context within the Conary configuration file as demonstrated in the example usage section.
Conary is distributed with two templates which you can refer to:
-
/etc/conary/recipeTemplates/default: A default template with some basic content and copyright information -
/etc/conary/recipeTemplates/rpath: A default template for use with rPath recipes and containing rPath copyright information
Here is the content of the default recipe template file:
#
# Copyright (c) %(year)s %(contactName)s (%(contact)s)
#
class %(upperName)s(PackageRecipe):
name = '%(name)s'
version = ''
def setup(r):
pass
Macros for use in recipe templates include the following:
-
%(name)s: Package name (likemypackage) -
%(upperName)s: Upper-case package name (likeMypackage) -
%(contactName)s: Value of thenamedirective in the conary Configuration file -
%(contact)s: Value of thecontactdirective in the Conary configuration file -
%(year)s: Current year
Example Usage
The following information will briefly explain an example usage of Conary's recipe templates:
This example will use the working subdirectory $HOME/recipefoo, so begin by creating the subdirectory:
[you@yourhost ~]$ mkdir recipefoo
Next, create a recipe template file in the correct recipe template subdirectory of your home directory ($HOME/.conary/recipeTemplates). For this example, create the recipe template subdirectory, and use your preferred text editor to create a new recipe template file foo:
[you@yourhost ~]$ mkdir -p .conary/recipeTemplates [you@yourhost ~]$ vim .conary/recipeTemplates/foo
Add the following content to the recipe template file foo:
#
# Copyright (c) %(year)s, WidJets, Inc.
#
# This file is distributed under the terms of the MIT License.
# A copy is available at http://www.rpath.com/permanent/mit-license.html
class %(upperName)s(PackageRecipe):
name = '%(name)s'
version = ''
buildRequires = [ 'ncurses:devel', 'libtermcap:devel' ]
def setup(r):
pass
After saving the file and exiting the editor, you will then use your preferred text editor, executed with your user account privileges to create a Conary configuration context in the .conaryrc file located in your home directory:
[you@yourhost ~]$ vim .conaryrc
Add the following content to the bottom of your .conaryrc file:
[recipefoo] recipeTemplate foo
Now, save the .conaryrc file, exit your editor, and try it out; change into your project working subdirectory, and issue a cvc newpkg command referencing your new configuration content, then observe the results:
[you@yourhost ~]$ cd recipefoo [you@yourhost recipefoo]$ cvc --context recipefoo newpkg bar [you@yourhost recipefoo]$ ls bar/ bar.recipe CONARY
Notice that the bar.recipe file was created automatically? Of course its content should reflect the recipe template we created:
[you@yourhost recipefoo]$ cat bar/bar.recipe
#
# Copyright (c) 2007, Wid Jets, Inc.
#
# This file is distributed under the terms of the MIT License.
# A copy is available at http://www.rpath.com/permanent/mit-license.html
class Bar(Package Recipe):
name = 'bar'
version = ''
buildRequires = [ 'ncurses:devel', 'libtermcap:devel' ]
def setup(r):
pass
Your template is now the basis of a new recipe file, and is ready for additional instructions.
Categories: Conary | Packaging | Recipe
