sierpień 3, 2008

New, better FEver

FEver is a project which aims to make it easy to track upstream in Fedora. All that has to be specified are name of the package to be checked, regular expression and URL. FEver’s task is just to download that URL, look for regular expression and return the newest one. Then, the another script just notifies about it in Bugzilla. It provides enough means to check a lot of packages but it’s not enough. Some of packages have version strings in Release tag etc. The old FEver could not check them.

That’s why it needed to be rewritten. New fever (no longer capitalizing) thanks to its S-Expressions-like syntax will be able to check almost every package. In order to show how it will look like, I’m going to show two examples.

The first one is openarena, nice FPS game based on Quake III engine. We can use yum list openarena to find out that its newest version in repo is 0.7.7. We can also check that its newest available version is 0.7.7 as well. In its download site there are full versions with dots in it however filenames are without it (I always prefer checking filenames most). So what can be done to compare 0.7.7 to 077? Of course dots need to be removed from the first string. Let’s see how the comparison can be done in new fever:

(cmp
(shell "echo $version | tr -d ." (koji_get_dict "openarena"))
(re "/oa(\d+?)(?:\D+).zip" (get "http://openarena.ws/files.html")))

I know it may look a bit complicated but in fact it isn’t; furthermore fever will have some convenient methods for the most frequent cases later. Ok, so let’s analyze how the sexpression works. First, there’s cmp method which just compares two given strings using rpmvercmp algorithm. Next, we have shell (its alias - $ - can also be used) which returns the output of first parameter executed in shell; the second parameter can be either string or dict. If it’s a string, its value is stored as $var variable; if it’s a dict then variables $key = value are created. koji_get_dict is a method which returns (for the time being) four variables: release, version, nvr and relnotag (release without disttag). re function just returns the newest match in second argument in this case; get, as you can guess, just downloads url.

So that’s how openarena can be checked. Let’s check ekg2. Ekg2 is a multi-protocol instant messaging app. Its newest version is 0.2-0.4.rc1. In its official site 0.2-rc1 can be found. So ekg2 has important “rc1″ in release tag but useless “0.4″ before it. This code (which will probably be more elegant in the future) makes it possible to check ekg2:

(cmp
(re ".*-(.*?)-.*\.(.*?)\.fc\d+$" (getitem (koji_get_dict "ekg2") "nvr"))
(re "ekg2-(0.*?).tar.gz" (get "http://ekg2.org/download.php")))

The most important part is the first re. It uses a regular expression to get rid of disttag and every useless part in NVR. So it returns version and last part of release: that are two groups. What does re do with several groups? By default returns them joined by “-” character. It can be changed by adding third parameter and set to e.g. “\1*\2″, where \1 are \2 are group numbers. getitem is an equivalent of python’s operator.getitem.

I hope you like the new fever and will use it when it’s done ;) if you have any questions or proposal, feel free to express them :)

Posted by ecik under fedora, fever |

Liczba komentarzy: 2 »

  1. I’d love to see this integrated with the packagedb and bodhi

    Komentarz autor Luke — 03/08/2008 @ 18:35

  2. @Luke: I agree it’d be nice but I have no real idea how it would be supposed to look like…

    Komentarz autor ecik — 03/08/2008 @ 19:25

Wątek RSS dla komentarzy do tego wpisu. | Trackback: http://ecik.nonlogic.org/blog/wpisy/57-new-better-fever/trackback

Dodaj komentarz

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .