Personal tools
     DOCUMENTATION

FAQ:Replace Dashes in Upstream Software Version

From rPath Wiki

Jump to: navigation, search
FAQ
Question: Conary says I have a version string with an illegal '-' character. How can I write a recipe to package a software appliance that uses dashes (-) in its version?


Answer: Use a macro in the Python code in the recipe to replace dashes with a legal character, such as an underscore.

First, rename the version string in your recipe; for example, if the version string is 1.4.2-0.9, rename it to 1.4.2_0.9. Then, use a macro to rename the version string back for retrieval of the archive file. This recipe fragment demonstrates this concept:

 
class MyApp(AutoPackageRecipe):
    name = 'myapp'
    version = '1.0.0_5.2'
 
    def unpack(r):
        r.macros.upver = r.version.replace('_', '-')
        r.addArchive('http://www.example.com/foo/'
                     '%(name)s-%(upver)s.tar.bz2'

In using the macro %(upver)s for the version string in the r.addArchive argument, the correct filename may be specified, while still maintaining a legal version string for the %(version)s macro.