APT 2.0 search patterns
Hi,
so this below is roughly a first draft at understanding
the syntax of search patterns of aptitude and integrating
it into apt. It's very incomplete and needs more work.
I hope to get a complete parser with a documented syntax
description so everyone can easily understand what's going
on later this cycle.
# What we are missing:
1) aptitude has a bug where I cannot match versions with
~ in it, as ~ begins a short pattern.
$ aptitude search '?version(1.0~1)'
E: Expected ')', got '~'.
$ aptitude search '~v1.0~1'
E: Unknown pattern type: 1
I am considering restricting the syntax so that if we are
in a function style pattern (starting with ?) that they may
only contain other functional style pattern, that would fix
it.
Alternatively, it might be useful to accept ~ inside of where
we expect a regex, such as version above.
2) fnmatch handling.
3) regex/fnmatch on architecture specification
4) weird corner cases like task^:architecture
aptitude supports :arch only in the form of an exact name before
it, e.g. apt:i386; whereas apt allows any pattern before it right
now. I believe the apt approach makes more sense, and we should
continue doing that, e.g.
<stuff>:<arch> is equivalent to ?and(<stuff>,?architecture(<arch>))
it's a bit unclear how to do that though. Probably every branch
of atom should have an (':' arch)? at the end, or well we redefine
atom as atom_archless and then atom = atom_archless (':' arch)?
How it works in my mind is that we'll change the cacheset code
that we currently have to take each argument and build a pattern
for it, and then execute the pattern against the cache. The patterns
being implemented as CacheFilters.
I expect there'll be some syntax that will behave different than
in 1.x, but I hope we can behave as similar as possible.
# Divergence from aptitude
* No explicit search targets, probably
# Search pattern syntax
## apt arguments (parsing modifier from right, then rest)
argument = pattern ('-' | '+' ) # pattern with modifier
| task_name '^' (':' arch)? # task - roughly equivalent to ~ttask_name or ?task(task_name)
## aptitude search patterns (left to right, longest match)
pattern = condition_list
condition_list = and_group ( '|' and_group )*
and_group = atom atom*
atom = '!' atom
| '(' condition_list ')'
| '?' function_style_tail
| '~' short_tail
| regex # architecture specified
| exact_name:architecture # architecture specified
function_style_tail = '=' variable
| name '(' term_args ')'
| name ':' atom # XXX?
term_args = XXX # basically atom ( ',' atom )*
short_tail = 'v' # virtual
| 'b' # broken
| 'g' # garbage
| 'c' # config-files
| 'i' # installed
| 'E' # essential
| 'F' # false
| 'M' # automatic
| 'N' # new
| 'T' # true
| 'U' # upgradable
| 'o' # obsolete
| 'P' atom # provides
| 'C' atom # conflicts
| 'W' atom # widen
| 'S' atom atom # narrow
| 'D' deptype atom # depends
| 'D' 'B'? deptype atom # depends
| 'R' 'B'? deptype atom # reverse-depends
| 'a' action # action
| XXXX substr # XXX
--
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer i speak de, en
Reply to: