Top-posting, have mercy...
I have *a sketch* to a python plugin which can handle the two examples
below. I have tried to do it in a way where adding new features should
be easy. While keeping the overall ideas, I have messed with some
details. My variant of check-large docs should demonstrate some subtle
changes:
#!/bin/bash
# @deprecates: CheckLargeDocs
# @group: Generic
# @url:
http://fedoraproject.org/wiki/Packaging/Guidelines#PackageDocumentation
# @text: Large documentation files must go in a -doc subpackage.
unpack_rpms
min=10000
max=1000000
docsize=$(for rpm in rpms-unpacked/*; do
(cd $rpm; test -d ./usr/share/doc && tar c ./usr/share/doc)
done | wc -c)
echo Documentation size is $docsize bytes.
test $docsize -lt $min && exit $FR_PASS
test $docsize -gt $max && exit $FR_FAIL
exit $FR_PENDING
Changes and possible discussions:
- Instead of defining environment variables when calling the script,
I write a bash file which is sourced before calling. This means that not
only plain, scalar variables are available. The script contains e. g.
the function unpack_rpms used here. I have just been involved in a 1 Gb
package, and I wouldn't want that unpacked without purpose...
- Instead of splitting the spec into separate files I use bash
associative arrays (i. e., hashes) to publish spec data
- I'm not really happy with using return codes like 1, 2 and three for
regular returns. It makes it impossible to detect the errors which will
occur. So, some symbolic constants like here might be good (defined in
the span 80-90) Using 0 for 'pass' is certainly possible anyway.
- Declaring the "Group" tag means that this test wilil only be invoked
if it's applicable for this package. So, there must already be existing
python tests for this group. You cannot define a new group using this API.
I attach the generated file sourced before running scripts; it's somehow
the framework of the interface.
On 08/09/2012 03:13 PM, Mikolaj Izdebski wrote:
I just want to make sure that simple things are simple, like:
#!/bin/sh
# @Group: Java
# @Deprecates: CheckNoArch
# @Description: Package has BuildArch: noarch (if possible)
egrep -q -i '^ *BuildArch: *noarch *$' srpm-unpacked/$name.spec
(Note the use of $name
Or:
#!/bin/sh
# @Deprecates: CheckLargeDocs
# @Strict
# @URL:
http://fedoraproject.org/wiki/Packaging/Guidelines#PackageDocumentation
# @Description: Large documentation files must go in a -doc subpackage.
min=10000
max=1000000
docsize=$(for rpm in ./rpms/*; do (cd ./$rpm; test -d ./usr/share/doc && tar c
./usr/share/doc); done | wc -c)
echo Documentation size is $docsize bytes.
test $docsize -lt $min && exit 0
test $docsize -gt $max && exit 2
exit 1
That tests are very simple and yet make my life easier. Using JSON for this
is definitely an overkill and contradicts the "should be easy to learn" goal.
_______________________________________________
fedorareview mailing list
fedorareview(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/fedorareview