Subject: Dependency pattern syntax
To: None <>
From: None <>
List: tech-pkg
Date: 05/24/2006 23:47:47
Hi all,
I got a bit bored the last few days and started to write some code for a
better^Wdifferent bulk build framework. During that I stumpled across
the need to implement the pattern matches used by pkg_add and felt a
sudden pain running down my spine.

We currently have:
(a) fnmatch syntax (php-4.4.*, zip-[0-9]*)
(b) csh like patterns (foo-1.2{,nb*} being popular, but also e.g.
(c) Dewey patterns (pkg>=1.4, pkg>=1.4<2)

Frankly, this is a total mess to implement and esp. the former too
provide too much flexibility for this purpose. I propse the follow
grammar instead, which is a slight extension of the current Dewey
		   EXPR '|' PATTERN ;

	EXPR := pkgname |
		pkgname COMPARISION ;

	COMPARISION := op version |
		       op version COMPARISION ;

version having the same form as before.
would be treated as infinite nb version (e.g. larger than all others).
op is one of ">", ">=", "<", "<=", "==", "!=" and "~". The "~" means:
begins with the same version number.
pkgname is ${PKGNAME} stripped before the last "-" (aka without the
version number).
When multiple packages match an alternative pattern, the left EXPR wins.

To illustrate this a translation of the patterns above:
	php-4.4.* => php~4.4
	zip-[0-9]* => zip
	foo-1.2{,nb*} => foo~1.2nb
		(note: missing nb part treated as 0, foo-1.2.1 would *not* match)
	  => ghostscript>=6.01|ghostscript-afpl>=6.01

I think all uses of (a) and (b) in the tree can be converted, but I
haven't checked the list yet. What do you think?