.\" manual page [] for ara .\" SH section heading .\" SS subsection heading .\" LP paragraph .\" IP indented paragraph .\" TP hanging label .TH ARA 1 "November 1, 2004" .SH NAME ara \- a utility for doing boolean regexp queries on the the Debian package database .SH SYNOPSIS .SS Batch mode: .B ara [options] query .LP In batch mode, \fBara\fP takes one or more queries as arguments, read the database files according to its configuration, and outputs the results to \fBstdout\fP. .SS Interactive mode: .B ara [options] \-i .LP With the \fB\-i\fP or \fB\-interactive\fP options, \fBara\fP reads the database files and then prompts the user for queries or commands. The results are displayed (with the help of a pager such as \fBmore\fP or \fBless\fP if necessary), and \fBara\fP prompts the user again. Interactive mode is strongly recommended, since loading the package databases can be long, but once loaded, queries run quite fast. This is a major advantage of \fBara\fP over tools such as \fBdpkg\-iasearch\fP or \fBdpkg\-dctrl\fP. For key bindings see \fBKEY BINDINGS\fP. .SS Graphical interface (GTK2): A graphical interface, \fBxara(1)\fP, is provided by the Debian package \fBxara-gtk\fP. .SS Query syntax See the \fBEXAMPLES\fP section for a quick introduction ; \fBxara\fP has some built\-in help. The syntax is described in detail below. .SH DESCRIPTION .LP .B ara and .B xara allow the user to search the Debian software package database (which includes installed and uninstalled packages) using powerful queries made of boolean combinations of regular expressions acting on fields given by patterns. For example, the query \fB section=utils & depends:(gtk or tk8 or xlibs or kde or gnome or qt) & debian & package \fP will display packages in the section \fButils\fP that have graphical interfaces (because they depend on graphical toolkits or X11 libraries), and whose description contains the words \fBdebian\fP and \fBpackage\fP. .SH RATIONALE .LP Debian users can easily install software with the commands \fBdselect\fP or \fBapt\-get install\fP. They can choose (on Debian 3.1 unstable) from over 30,000 packages. Finding the right package can be quite difficult. Although packages are categorized in crude sections, there are still too many packages and reading all descriptions is out of the question. The database files are huge and their mail\-like syntax makes them hard to search with line\-oriented tools like grep. There exist commands such as \fBdpkg\-iasearch\fP(1) or \fBdpkg\-dctrl\fP(1) but their capabilities are limited. Graphical package management tools such as \fBaptitude\fP or \fBsynaptic\fP have search capabilities. Although \fBara\fP can call \fBapt\fP to install or remove packages, its orientation is that of a powerful search tool. Indeed, the name \fBara\fP comes from the imperative form of the Turkish verb \fBaramak\fP which means "to search". .SH THE DEBIAN PACKAGE DATABASE .LP The database of Debian packages is a huge text file at \fB/var/lib/dpkg/available\fP (or a collection of text files under \fB/var/lib/apt/lists/\fP). These files are in a mailbox\-like format, and a typical entry looks like this: .nf Priority: required Section: base Installed\-Size: 460 Origin: debian Maintainer: Dpkg Development Bugs: debbugs://bugs.debian.org Architecture: i386 Source: dpkg Version: 1.10.24 Replaces: dpkg (<< 1.10.3) Depends: libc6 (>= 2.3.2.ds1\-4), .... Filename: pool/main/d/dpkg/dselect_1.10.24_i386.deb Size: 119586 MD5sum: c740f7f68dab08badf4f60b51a33500a Description: a user tool to manage Debian packages dselect is the primary user interface for installing, removing and managing Debian packages. It is a front\-end to dpkg. .LP Each package is thus described by a set of fields (like Package, Description, Version...). .SH QUERY SYNTAX AND SEMANTICS .LP Here we describe the query syntax in some detail. As of version 1.0, \fBara\fP introduces new, simplified syntax which is quite traditional and should be familiar to anyone having used search engines. Search terms are simply combined with \fBAND\fP, \fBOR\fP and \fBNOT\fP boolean operators. Having a look at the \fBEXAMPLES\fP section at the end of this manual should provide you a starting point. Consider the set \fBD\fP of Debian package descriptions contained in the file \fB/var/lib/dpkg/available\fP (or in files under \fB/var/lib/apt/lists/\fP). Each description is a set of couples of the form \fB(f,v)\fP where \fBf\fP and \fBv\fP are strings: \fBf\fP is the name of the field (namely, \fBPackage\fP, \fBDescription\fP, \fBFilename\fP, \fBDepends\fP, etc.); \fBv\fP is its value. Thus \fBD\fP is a set of set of couples, forming the universe. Queries select subsets of the universe \fBD\fP. Output options select which fields of the selected part of the universe to display, and how to display them. .SS Queries A \fBquery\fP is a boolean combination of atomic expressions. An \fBatomic expression\fP selects a subset of the set \fBD\fP of descriptions. I call this set the \fBmeaning\fP of the expression; if \fBe\fP denotes an atomic expression, its meaning is denoted by \fB[e]\fP. The meaning of a boolean combination of atomic expressions is just the boolean combination of the meaning of its constituents. In other words, if \fBe1\fP and \fBe2\fP are atomic expressions, then \fBe1 & e2\fP is a query, whose meaning is the intersection of the meanings of \fBe1\fP and \fBe2\fP; and the meaning of \fBe1 | e2\fP is the union of the meanings of \fBe1\fP and \fBe2\fP. .SS Atomic expressions Atomic expressions can be of the forms \fBpattern\fP, \fB/regexp/\fP, \fBquoted_string\fP, \fBfieldspec operator1 string\fP, or \fBfieldspec operator2 regexp\fP. .SS Boolean operators and constants .TP \fBe1 & e2\fP (also \fBe1 AND e2\fP, \fBe1 and e2\fP) This is logical conjunction (set intersection). Returns the intersection of [e1] and [e2], i.e. packages satisfying both e1 and e2. .TP \fBe1 | e2\fP (also \fBe1 OR e2\fP, \fBe1 or e2\fP) This is logical disjunction (set union). Union of [e1] and [e2], i.e. packages satisfying e1, e2 or both. .TP \fB!e1\fP (also \fBNOT e1\fP, \fBnot e1\fP) This is logical negation (set complementation). Complement of [e1], i.e. packages not satisfying e1. Please note that \fB~\fP stands for the current default field specifier and is not an alias for the complementation operator. .TP \fBtrue\fP (also \fBall\fP) The set of all descriptions, i.e. all packages. .TP .B \fBfalse\fP (also \fBnone\fP) The empty set, i.e. no packages. .SS Field specifiers A field specifier \fBfieldspec\fP is a comma\-separated list of field patterns. Field patterns are like simple shell patterns and they may contain star characters (which stand for anything) or question marks (which stand for any single character). They are case\-insensitive. They specify a set of fields. For example \fBdescription\fP and \fBDescription\fP specify the set of fields \fB{ Description }\fP, whereas \fBde*\fP specifies \fB{ Description, Depends }\fP. The special specifier \fB~\fP denotes the current default specifier (see below). .SS Current fields specifiers and simplified atomic expressions The need to repeat the field specifier can make the above syntax cumbersome. That is why there is a \fBcurrent field specifier\fP. The current field specified is, by default, \fBDescription,Package\fP. Simplified atomic expressions are simply words or simplified shell expressions (which do not need to be enclosed in double quotes) and they are searched in fields in the current field specifier. They can be made of letters, digits, underscores, dashes and periods. They may contain stars of question marks which are interpreted as for field patterns (i.e., as simplified shell expressions). If double quotes are used, other characters and spaces can be used. The default field specifier in a query \fBquery\fP can be changed to \fBfieldspec\fP by simply prefixing the query with \fBfieldspec:\fP. This gives \fBfieldspec:query\fP. However if \fBquery\fP is complex (i.e., contains binary boolean operators) you need to enclose \fBquery\fP in parentheses, as in \fBfieldspec:(query1 or query2)\fP. .SS String literals \fBString literals\fP can be given with or without double quotes; without double quotes, the syntax is as for C identifiers, except that you can use dashes, you must start with a latin letter (\fB[a\-zA\-Z]\fP) and you can continue with Latin letters, decimal digits or underscore (\fB[a\-zA\-Z0\-9_]\fP). Inside double quotes, all characters are allowed, except double quotes, which must be preceded by a backslash. .SS Variables Results of queries can be stored in variables, which may be recalled later. This isn't very useful in batch mode but is useful in interactive and graphical modes. Variable names start with a dollar and follow usual conventions for variables, i.e., they can be any mix of alphanumeric characters and symbols such as underscore, dash, etc. Variable names are case\-sensitive so that \fB$Installed\fP and \fB$installed\fP are different. To assign the result of a query (which is a set of packages) a variable named \fB$variable\fP just execute the query \fB$variable := query\fP. You may then recall this particular set by simply writing \fB$variable\fP. Example: \fB$installed := status:(installed & !not\-installed)\fP .SS Operators Hierarchical comparison operators can be negated by changing the direction of the angle brackets and adding or removing an equality sign at end (\fB<=\fP becomes \fB>\fP). Other operators are negated as follows: \fB=\fP becomes \fB!=\fP and \fB=~\fB becomes \fB!~\fP. .TP .B fieldspec=string Atomic expression selecting packages having a field in \fBfieldspec\fP having a value a value exactly equal to \fBstring\fP. .TP .B fieldspecstring, fieldspec>=string) Atomic expression selecting packages having a field in \fBfieldspec\fP whose value is strictly less than \fBstring\fP. The order used is the Debian versioning order. This order is compatible with the natural order on integers and with Debian version numbers. When comparing strings not containing special characters, letters sort before numbers, as opposed to lexicographic ASCII order we are used to. This means that hexadecimal numbers (such as MD5 sums) will not have their usual order. Note that \fBstring\fP must be on the right side of the operator (i.e., you cannot write \fB1000 < Size\fP). .TP \fBfieldspec=~/expression/\fP (also \fBfieldspec:/expression/\fP) Selects descriptions whose field named \fBfieldspec\fP exists and whose value matches, case\-sensitively, the regular expression \fBexpression\fP. .TP .B \fBfieldspec=~/expression/i\fP (also \fBfieldspec:/expression/i\fP) Same as above, but the regular expression is case\-insensitive. .TP .B \fBfieldspec=~/expression/w\fP (also \fBfieldspec:/expression/w\fP) Same as above, but the regular expression is case\-sensitive and matches only at word boundaries. Note that letters\-to\-digit or digit\-to\-letter transitions are considered to be word boundaries. .TP .B \fBfieldspec=~/expression/iw\fP (also \fBfieldspec:/expression/iw\fP) The regular expression here is case\-insensitive and matched at word boundaries. .SS Regular expressions Regular expressions are given between a pair of slashes; the last slash can be followed by a commutative sequence of letters denoting flags. Regular expression syntax is sed\-like: grouping parentheses and alternation must be backslashed. For more details, see the Objective Caml manual chapter on the Str module. In short (\fBx\fP,\fBx1\fP,\fBx2\fP are meta\-symbols denoting regular expressions): .TP .B /./ Any character. .TP .B /toto/ Literal string toto. .TP .B /x1x2/ Concatenation. .TP .B /x1\\|x2/ Alternation. .TP .B \\(x1\\)* Star closure. .TP .B [c\-d] Character range. .TP .B \\b Word boundaries. .TP .B /x/i Case insensitive. .TP .B /x/w At word boundaries. .SS Remark Most queries will contain an appreciable amount of shell metacharacters. For example, logical disjunction is denoted by the pipe character, which is used by all known shells. The problem is aggravated by the fact that names of real commands are likely to appear in the used expressions; successfully setting up a UNIX pipeline by error is therefore plausible. When calling \fBara\fP from the command line in batch mode, You are strongly urged to protect your queries by surrounding them with simple quotes; never write something like \fBara Pack*=~/halt|reboot|shutdown/\fP as this will very likely reboot your system (and is incorrect regular expression syntax, if \fBhalt\fP or \fBreboot\fP or \fBshutdown\fP is meant: pipes must be backslashed). Instead, one should write .B ara 'Pack*=~/halt\\|reboot\\|shutdown /' .SH OPTIONS .SS Operation .TP \fB\-interactive\fP, \fB\-i\fP Interactive mode ; prompt for a query, display it. .TP \fB\-config \fP (also for \fBxara\fP) Set configuration file name (default \fB$HOME/.ara/ara.config\fP). .TP \fB\-noconfig\fP Dont attempt to create a configuration file. .TP \fB\-nohistory\fP Dont save command history .SS Help options .TP \fB\-help\fP (also for \fBxara\fP) Display some help \fB\-about\fP Display copyright, thanks and dedication. .TP \fB\-version\fP, \fB\-about\fP (also for \fBxara\fP) Print author, license, version and dedication (and exit if called from CLI). .TP \fB\-examples\fP Display some documentation including examples exit. .TP \fB\-q \fP Query (e.g., depends:xlibs & !package:xcalc). .TP \fB\-query \fP Ditto. .SS Options pertaining to the terminal .TP \fB\-progress\fP (\fB\-noprogress\fP) Show or dont show progress indicator when loading database. .TP \fB\-lines \fP Set height of terminal for interactive display. By default this is taken from the environment variable \fBLINES\fP or as 25 if it is undefined. .TP \fB\-columns \fP Set width of terminal for interactive display. By default this is taken from the environment variable \fBCOLUMNS\fP or as 25 if it is undefined. .TP \fB\-pager\fP (\fB\-nopager\fP) Use (or dont use) a pager displaying long output in interactive mode. The pager command is defined in the configuration file \fB$HOME/.ara/ara.config\fP. By default this is \fB/etc/alternatives/pager\fP. The pager is only used when the output size exceeds the terminal height. .TP \fB\-debug\fP (also for \fBxara\fP) Enable debugging information .TP \fB\-debug\-level\fP (also for \fBxara\fP) Set debugging level (higher is more verbose, max is 100, default is 10) .SS Display styles \fB\-new\fP Show only newest version of each package. .TP \fB\-old\fP List all versions of packages. .TP \fB\-short \fP Display names of packages satisfying query (and their version if \fB\-old\fP is set), with multiple packages per line. .TP \fB\-list \fP Same, but display one package name per line, and no curly braces (default). .TP \fB\-raw \fP For each package satisfying the query, display all selected fields. .TP \fB\-table \fP Display results as a table. .TP \fB\-noborders\fP Dont draw ASCII borders for tabular output. .TP \fB\-borders\fP Draw ASCII borders for tabular output. .TP \fB\-count \fP Display number of matching packages. .TP \fB\-fields\fP Limit output to specified fields. The optional width specifiers are used with the \fB\-table\fP option and ignored otherwise. Use * to display all fields (but remember to escape the star character from your shell). .TP \fB\-ast\fP Dump the abstract syntax tree of parsed queries to stderr. .SH EXAMPLES .TP .B \fBara 'Section=utils'\fP List the name of every package in section utils. .TP .B \fBara 'Section=utils and !Depends:(gnome|kde|gtk)'\fP ... except those whose dependency field matches the regexp gnome\\|kde\\|gtk .TP .B \fBara \-list 'Section=utils and Status:(installed & !not\-installed)'\fP List all installed packages in section \fButils\fP. .TP .B \fBara \-short 'section=utils and !depends:(gtk|gnome|kde) and priority=optional'\fP ... list multiple names per line, and show only optional packages. .TP .B \fBara \-short 'section=utils & (!depends:(gtk|gnome|kde) | size<100000) & priority=optional'\fP Well, exclude gtk,gnome or kde stuff only if 100000 bytes or greater. .TP .nf \fBara \-noborders \-fields Package,Size,Maintainer:20 \-table \\ \fB \-short 'section=utils & (!depends:(gtk|gnome|kde) | size<100000) & priority=optional'\fP \fP .fi .LP ... show Package, Size and Maintainer fields from the above results as a nice ascii table, limiting the maintainer field to 20 characters, but without crude ASCII borders. .TP .nf \fBara \-old \-fields Package:8,Size,Description:100 \\ \fB \-table 'Section=games and not (Depends:(gtk|sdl|kde|opengl|gnome|qt) \fB or /shoot\\|kill\\|destroy\\|blast\\|race\\|bomb/iw \fB or /multi\\(\-\\|\\)player\\|strategy\\|conquest\\|3\\(\-\\|\\)d/iw) \fB and Depends:(xlibs or vga) \fB and Size <= 1000000'\fP \fP .fi .LP Assuming a 125\-column display, display the first eight characters of the package name, the size in bytes, and the first hundred characters of the (first line) of the description of all packages in the games section whose size does not exceeding one million bytes, and which do not depend on fancy stuff like GTK, SDL, KDE, OpenGL, Qt or Gnome, do not mention some form of violence (to shoot, to kill, etc.) in their description, are not described as multi\-player, strategy, conquest or three\-dimensional, and yet depend on either xlibs or svga to exclude console\-based games. .SH SPEED .B ara reads the whole database into memory and then processes queries. Since the database is usually big, this takes some time. However, queries then run quite fast. So specify multiple queries or use the \fB\-interactive\fP option to amortize the cost of reading the database. .SH LICENSE .B ara is released under the GNU General Public License, version 2, a copy of which is included in the source distribution. .SH THANKS Many thanks to George Danchev, Thomas Schoepf and Sven Luther for doing the Debian packaging of ara and many helpful comments. .SH CONFIGURATION FILES The system-wide configuration file for ara is \fB/etc/ara.config\fP. Its syntax is self-evident and follows the Ocaml lexical conventions. Values in the user-specific configuration file \fB$HOME/.ara/ara.config\fP override those of \fB/etc/ara.config\fP. .SH OTHER FILES Command line history is saved in \fB$HOME/.ara/ara.history\fP. The following databases are loaded by default: \fB/var/lib/dpkg/available\fP .br \fB/var/lib/dpkg/status\fP .br \fB/var/lib/apt/lists/*_Packages\fP .br \fB/var/lib/apt/lists/*_Sources\fP .SH ENVIRONMENT VARIABLES In \fBara\fP the variables \fBLINES\fP and \fBCOLUMNS\fP are used to determine the dimensions of the terminal. Note that these variables are not exported by default in your shell ; add \fBexport LINES COLUMNS\fP in your \fB.zshrc\fP or \fB.bashrc\fP. .SH SEE ALSO \fBxara(1)\fP, \fBapt-cache\fP(8), \fBaptitude\fP(8), \fBdpkg\fP(8), \fBdselect\fP(8), \fBgrep\-aptavail\fP(1), \fBgrep\-available\fP(1), \fBgrep\-dctrl\fP(1), \fBgrep\-status\fP(1), \fBgrep\-dctrl\fP(1), \fBpackagesearch\fP(1), \fBsynaptic\fP(1). .SH AUTHOR Oguz Berke Durak http://abaababa.ouvaton.org/ara/ .SH KNOWN BUGS Due to lack of Unicode support, non\-ASCII characters lead to problems under Unicode terminals. Note that the database files are encoded in Latin1. .br