Please review: Relax NG schema for bitten recipes

22 views
Skip to first unread message

W. Martin Borgert

unread,
Jan 31, 2012, 3:39:20 PM1/31/12
to bit...@googlegroups.com
Hi,

this is a first draft for a bitten recipe schema. Please
try to validate your recipes using the attached Python
script. Write about any problems to the list, just in case
a bus runs over me and I cannot answer in private.

For most attributes I'm not sure whether they are optional
or not. Some are explicitly described as optional in the
bitten documentation(1), but it's obvious, that many others
are meant to be optional, too.

Furthermore, it seems, that some attributes are meant to
be boolean True/False, i.e. svn:checkout verbose and
svn:update no_auth_cache, but it's not really clear from
the documentation.

Cheers

(1) http://bitten.edgewall.org/wiki/Documentation/commands.html

bitten-recipe.rng
bitten-recipe.rnc
bitten-recipe.py

Olaf Meeuwissen

unread,
Jan 31, 2012, 6:28:58 PM1/31/12
to bit...@googlegroups.com
"W. Martin Borgert" <deb...@debian.org> writes:

> this is a first draft for a bitten recipe schema. Please
> try to validate your recipes using the attached Python
> script. Write about any problems to the list, just in case
> a bus runs over me and I cannot answer in private.

Just tried to validate the two recipes we use here most.

$ python bitten-recipe.py step-by-step-make-distcheck.xml
Traceback (most recent call last):
File "bitten-recipe.py", line 10, in <module>
relaxng.assertValid(lxml.etree.parse(recipe))
File "lxml.etree.pyx", line 3017, in lxml.etree._Validator.assertValid (src/lxml/lxml.etree.c:129442)
lxml.etree.DocumentInvalid: Invalid attribute onerror for element step, line 62

The offending line is:

<step id="prep-slave" onerror="fail" description="blah">

Looks like you missed the "onerror"[1] attribute.
[1] http://bitten.edgewall.org/wiki/Documentation/recipes.html

$ python bitten-recipe.py simple-make-distcheck.xml
Traceback (most recent call last):
File "bitten-recipe.py", line 10, in <module>
relaxng.assertValid(lxml.etree.parse(recipe))
File "lxml.etree.pyx", line 3017, in lxml.etree._Validator.assertValid (src/lxml/lxml.etree.c:129442)
lxml.etree.DocumentInvalid: Invalid attribute root for element gcov, line 33

Here the offending bit of XML reads:

<c:gcov include="*.cc" root="_build"/>

Here the "root" attribute is not documented on the wiki but the code has
documentation[2] for it.
[2] http://bitten.edgewall.org/browser/trunk/bitten/build/ctools.py#L286

Hope this helps,
--
Olaf Meeuwissen, LPIC-2 FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962 Help support software freedom
http://www.fsf.org/jf?referrer=1962

W. Martin Borgert

unread,
Jan 31, 2012, 7:27:41 PM1/31/12
to bit...@googlegroups.com
On 2012-02-01 08:28, Olaf Meeuwissen wrote:
> Looks like you missed the "onerror"[1] attribute.
> [1] http://bitten.edgewall.org/wiki/Documentation/recipes.html

Indeed, thanks! I added it with the three possible values.

> Here the "root" attribute is not documented on the wiki but the code has
> documentation[2] for it.
> [2] http://bitten.edgewall.org/browser/trunk/bitten/build/ctools.py#L286

OK, added. I used only the wiki, so any further attributes etc.
that are not documented there, are still missing in the Relax NG.

Cheers

bitten-recipe.rng
bitten-recipe.rnc

Olaf Meeuwissen

unread,
Jan 31, 2012, 9:26:48 PM1/31/12
to bit...@googlegroups.com
"W. Martin Borgert" <deb...@debian.org> writes:

Thanks. I've rerun with the updated Relax NG and my
simple-make-distcheck.xml now passes fine. The other,
step-by-step-make-dist.xml recipe does not. This time this is due to a
local extension (I've written an alternative gcov-like command and I'm
using the ohcount command attached to bitten:#453). How would you deal
with these kind of things? Just a thought.

W. Martin Borgert

unread,
Feb 1, 2012, 5:52:20 AM2/1/12
to bit...@googlegroups.com
Quoting "Olaf Meeuwissen" <olaf.me...@avasys.jp>:
> Thanks. I've rerun with the updated Relax NG and my
> simple-make-distcheck.xml now passes fine. The other,
> step-by-step-make-dist.xml recipe does not. This time this is due to a
> local extension (I've written an alternative gcov-like command and I'm
> using the ohcount command attached to bitten:#453). How would you deal
> with these kind of things? Just a thought.

Relax NG allows for extensions, but I had to re-arrange the
schema a little bit to make use of this. Take a look at the
attachments and change the Python snippet to use olaf.rng
instead of bitten-recipe.rng.

bitten-recipe.rng
olaf.rng

Olaf Meeuwissen

unread,
Feb 1, 2012, 6:18:13 PM2/1/12
to bit...@googlegroups.com
"W. Martin Borgert" <deb...@debian.org> writes:

Cool. That worked, provided I change the xmlns:src value to whatever it
has been set to in the recipe and extend the element definition to cover
any other options that src:ohcount may have grown locally. Of course, I
would also have to add something for that gcov-like addition but simply
commented it out for testing purposes.

So, for any local extensions one may have it would be enough to whip up
your own Relax NG and have it include bitten-recipe.rng.

Thanks,

W. Martin Borgert

unread,
Feb 2, 2012, 4:45:48 AM2/2/12
to bit...@googlegroups.com
Quoting "Olaf Meeuwissen" <olaf.me...@avasys.jp>:
> So, for any local extensions one may have it would be enough to whip up
> your own Relax NG and have it include bitten-recipe.rng.

Yes, that's the idea. I will clean up the files a little bit
and contribute them to the bitten sources, if nobody has
further problems or objections.

Cheers

anatoly techtonik

unread,
Feb 2, 2012, 5:22:47 AM2/2/12
to bit...@googlegroups.com
Well,  Bitten already had capability to check configs when editing them, and it would be more useful if this capability could be exposed to `trac-admin bitten config` commands. With commands I can not see much value in a separate scheme for config validation. It could be handy if syntax documentation could be generated from it automatically.

So, It would be nice to see:

bitten config list
bitten config export <name>
bitten config import <name>
bitten config check <filename>

-- 
anatoly t. 

Simon Cross

unread,
Feb 3, 2012, 2:45:41 AM2/3/12
to bit...@googlegroups.com
On Thu, Feb 2, 2012 at 12:22 PM, anatoly techtonik <tech...@gmail.com> wrote:
> Well,  Bitten already had capability to check configs when editing them, and

This is true, but the checks in bitten.recipes are somewhat different.
From the docstring of Recipe.validdate:

"""
This method checks a number of constraints:
- the name of the root element must be "build"
- the only permitted child elements or the root element with the name
"step"
- the recipe must contain at least one step
- step elements must have a unique "id" attribute
- a step must contain at least one nested command
- commands must not have nested content
"""

> it would be more useful if this capability could be exposed to `trac-admin
> bitten config` commands.

I think that would be a fairly easy patch (the Trac admin command just
needs to load the file into a recipe and run validate). I'm not sure
how useful it is while the primary interaction with recipes is via the
Bitten web interface though.

Schiavo
Simon

Simon Cross

unread,
Feb 3, 2012, 2:47:04 AM2/3/12
to bit...@googlegroups.com
Hi

On Thu, Feb 2, 2012 at 11:45 AM, W. Martin Borgert <deb...@debian.org> wrote:
> Yes, that's the idea. I will clean up the files a little bit
> and contribute them to the bitten sources, if nobody has
> further problems or objections.

Thank you for all your work on the schema. Do you have some idea of
where in the Bitten sources you'd see them going? Would they just be a
documentation thing? Are you envisioning some sort of tool for
checking recipes built on top of them?

Schiavo
Simon

W. Martin Borgert

unread,
Feb 3, 2012, 4:03:33 AM2/3/12
to bit...@googlegroups.com
On 2012-02-03 09:47, Simon Cross wrote:
> Do you have some idea of
> where in the Bitten sources you'd see them going?

No idea.

> Would they just be a
> documentation thing?

Originally the idea was to have a formal documentation, but...

> Are you envisioning some sort of tool for
> checking recipes built on top of them?

It would be very easy to integrate the check into Bitten. One
would have to allow the user to install or upload their own
schemas, if they use private extensions.

import lxml.etree

schema_fn = "bitten-recipe.rng"
recipe_fn = "myrecipe.build"

if __name__ == "__main__":
with open(schema_fn) as rng:
relaxng = lxml.etree.RelaxNG(lxml.etree.parse(rng))
with open(recipe_fn) as recipe:
relaxng.assertValid(lxml.etree.parse(recipe))

Cheers

Simon Cross

unread,
Feb 19, 2012, 6:14:41 PM2/19/12
to bit...@googlegroups.com
I've created http://bitten.edgewall.org/ticket/755 for this.

W. Martin Borgert: There's some feedback I need from you on the ticket
before I can land it (just questions about whether you're happy with
the licensing, attribution and copyright assignment).

Schiavo
Simon

W. Martin Borgert

unread,
Feb 20, 2012, 1:23:47 PM2/20/12
to bit...@googlegroups.com, Simon Cross

OK with me.

Simon Cross

unread,
Feb 20, 2012, 5:31:57 PM2/20/12
to W. Martin Borgert, bit...@googlegroups.com
On Mon, Feb 20, 2012 at 8:23 PM, W. Martin Borgert <deb...@debian.org> wrote:
> OK with me.

Thanks! Patch committed in r1010.

W. Martin Borgert

unread,
Feb 21, 2012, 7:02:50 AM2/21/12
to Simon Cross, bit...@googlegroups.com
Quoting "Simon Cross" <hodg...@gmail.com>:
> Thanks! Patch committed in r1010.

We should also add a description on how to add custom
commands. I sent an example to the list:
http://groups.google.com/group/bitten/msg/02f0d8920b34db9b

Simon Cross

unread,
Feb 21, 2012, 7:19:46 AM2/21/12
to W. Martin Borgert, bit...@googlegroups.com
On Tue, Feb 21, 2012 at 2:02 PM, W. Martin Borgert <deb...@debian.org> wrote:
> We should also add a description on how to add custom
> commands. I sent an example to the list:
> http://groups.google.com/group/bitten/msg/02f0d8920b34db9b

Any idea where that description should live? Docstring of the
checkrecipe.py script? Want to submit a patch? :)

Schiavo
Simon

Reply all
Reply to author
Forward
0 new messages