+2004-09-30 Karl Trygve Kalleberg <karltk@gentoo.org>
+ * Added unit tests for --help
+
2004-09-27 Karl Trygve Kalleberg <karltk@gentoo.org>
* Added short commands
* Fixed copyright dates
-- clean up colours for output!
- - error, warning, info
- - package, searchterm, useflag, number, ...
- - structured output, to allow for XML, piping and tty?
-- list all global useflags
-- list all local useflags
+- pkgquery language:
+ Query ::= NewStyle | OldStyle | with OldStyle NewStyle
+ NewStyle ::= NameVar in /RegExp/
+ | VerVar in [ VerExpr ]
+ | SetVar in [ SetExpr ]
+ NameVar ::= PC | PN | DESCRIPTION | SRC_URI | HOMEPAGE
+
+ SetVar ::= LICENSE | KEYWORDS | IUSE
+ VerVar ::= SLOT | PV | DEPEND | RDEPEND
+
+ BinaryOp ::= and | or
+ UnaryOp ::= not
+
+ VerExpr ::= SingleVer
+ | VerExpr BinOp VerExpr
+ | UnaryOp UnaryOp
+
+ SetExpr ::= Element
+ | Element BinOp Element
+ | UnaryOp Element
+
+ SingleVer ::= PrefixOp VersionBody ( VersionSuffix )? ( - Revision )?
+ PrefixOp ::= ! | < | > | <= | >= | = | ~
+ VersionBody ::= Number ( . Number )+ ( . * )?
+ VersionSuffix ::= _ ( pre | beta | alpha | rc ) Number?
+ | [a-z]
+ Revision ::= r Number
+
+------
+
+ PC in /dev-java/ and
+ PN in /ant/ and
+ PV in [ >=1.0 or <=2.3 and =2.0.* ] and
+ IUSE in [ java or junit ]
+
+
+--
+ with >=dev-java/ant-1.0*
+ IUSE in [ java or junit ] and
+ SLOT in [ >=1.0 ]
+
+
+----------
+
+old cruft:
+
+ SingleVer ::= ( Operator )? ( Category / ) PackageName ( - Version )?
+ Operator ::= = | > | >= | < | <= | ~ | !
+ Category ::= PackageName
+ PackageName ::= NamePart ( - NamePart )+
+ NamePart ::= [a-zA-Z+]+
+ Version ::= VersionPart ( - VersionPart )+ ( _ VersionSuffix )? ( - Revision )?
+ VersionSuffix ::= ( pre | rc | beta | alpha ) ( Number ) ?
+
+ old style: >=dev-java/ant-1.0*
+
+
--- /dev/null
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# Copyright (c) 2004, Gentoo Foundation
+#
+# Licensed under the GNU General Public License, v2
+
+function tempfilename() {
+ fn=$(date "+%s")
+ if [ ! -f ${fn}.tmp ] ; then
+ echo ${fn}.tmp
+ fi
+}
+
+function report_pass() {
+ printf "%-40s - passed\n" ${1}
+}
+
+function report_failure() {
+ printf "%-40s - FAILED!\n" ${1}
+}
+
+function assert_samefile() {
+ diff $2 $3 && report_pass $1 || report_failure $1
+}
+
+function assert_eq() {
+ if [ $2 -eq $3 ] ; then
+ report_pass $1
+ else
+ printf "FAIL: $2 ! -eq $3\n"
+ report_failure $1
+ fi
+}
+
+function assert_ge() {
+ if [ $2 -ge $3 ] ; then
+ report_pass $1
+ else
+ printf "FAIL: $2 ! -ge $3\n"
+ report_failure $1
+ fi
+}
\ No newline at end of file
--- /dev/null
+List all packages owning a particular set of files
+
+Note: Normally, only one package will own a file. If multiple packages own the same file, it usually consitutes a problem, and should be reported.
+
+Syntax:
+ belongs <local-opts> filename
+<local-opts> is either of:
+ -c, --category cat - only search in category cat
+ -f, --full-regex - supplied query is a regex
+ -e, --earlyout - stop when first match is found
+
--- /dev/null
+Check package's files against recorded MD5 sums and timestamps
+Syntax:
+ size pkgspec
--- /dev/null
+List all direct dependencies matching a query pattern
+Syntax:
+ depends <local-opts> pkgspec
+<local-opts> is either of:
+ -d, --direct - search direct dependencies only (default)
+ -D, --indirect - search indirect dependencies (VERY slow)
+ -i, --only-installed - search installed in installed packages only
+
--- /dev/null
+Display a dependency tree for a given package
+
+Syntax:
+ depgraph <local-opts> pkgspec
+<local-opts> is either of:
+ -U, --no-useflags - do not show USE flags
+ -l, --linear - do not use fancy formatting
--- /dev/null
+List files owned by a particular package
+
+Syntax:
+ files <local-opts> <cat/>packagename<-version>
+
+Note: category and version parts are optional.
+
+<local-opts> is either of:
+ --timestamp - append timestamp
+ --md5sum - append md5sum
+ --type - prepend file type
--- /dev/null
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# Copyright (c) 2004, Gentoo Foundation
+#
+# Licensed under the GNU General Public License, v2
+
+. common-functions.sh
+
+tmpfile=$(tempfilename)
+
+strip_versioned_files() {
+ grep -v "/usr/share/doc"
+}
+
+test_files() {
+ equery files bash > ${tmpfile}
+
+ x=$(grep man ${tmpfile} | wc -l)
+ assert_ge ${FUNCNAME} $x 5
+
+ x=$(cat ${tmpfile} | wc -l)
+ assert_ge ${FUNCNAME} $x 25
+}
+
+test_files_timestamp() {
+ equery files --timestamp bash > ${tmpfile}
+}
+
+test_files_md5sum() {
+ equery files --md5sum bash > ${tmpfile}
+}
+
+test_files_type() {
+
+ equery files --type bash > ${tmpfile}
+
+ x=$(grep "file.*/bin/bash$" ${tmpfile} | wc -l)
+ assert_eq ${FUNCNAME} $x 1
+
+ x=$(grep "symlink.*/bin/rbash" ${tmpfile} | wc -l)
+ assert_eq ${FUNCNAME} $x 1
+
+ x=$(grep "dir.*/usr/share/man" ${tmpfile} | wc -l)
+ assert_ge ${FUNCNAME} $x 1
+}
+
+# Run tests
+
+test_files
+test_files_timestamp
+test_files_md5sum
+test_files_type
+
+rm ${tmpfile}
\ No newline at end of file
--- /dev/null
+List all packages with a particular USE flag
+Syntax:
+ list <local-opts> useflag
+<local-opts> is either of:
+ -i, --installed - search installed packages (default)
+ -I, --exclude-installed - do not search installed packages
+ -p, --portage-tree - also search in portage tree (/usr/portage)
+ -o, --overlay-tree - also search in overlay tree (/usr/local/portage /usr/local/overlays/gentoo-boblycat)
+
--- /dev/null
+Usage: equery <global-opts> command <local-opts>
+where <global-opts> is one of
+ -q, --quiet - minimal output
+ -C, --nocolor - turn off colours
+ -h, --help - this help screen
+ -V, --version - display version info
+where command(short) is one of
+ belongs(b) <local-opts> files... - list all packages owning files...
+ changes(c) - not implemented yet
+ check(k) pkgspec - check MD5sums and timestamps of pkgspec's files
+ depends(d) <local-opts> pkgspec - list all direct dependencies matching pkgspec
+ depgraph(g) <local-opts> pkgspec - display a dependency tree for pkgspec
+ files(f) <local-opts> pkgspec - list files owned by pkgspec
+ glsa(a) - not implemented yet
+ hasuses(h) <local-opts> pkgspec - list all packages with useflag
+ list(l) <local-opts> pkgspec - list all packages matching pkgspec
+ size(s) <local-opts> pkgspec - print size of files contained in package pkgspec
+ stats(t) - not implemented yet
+ uses(u) <local-opts> pkgspec - display USE flags for pkgspec
+ which(w) pkgspec - print full path to ebuild for package pkgspec
+
--- /dev/null
+#! /bin/sh
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# Copyright (c) 2004, Gentoo Foundation
+#
+# Licensed under the GNU General Public License, v2
+
+. common-functions.sh
+
+tmpfile=$(tempfilename)
+
+test_equery_help() {
+ equery --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-help.out
+
+}
+
+test_belongs_help() {
+ equery belongs --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-belongs-help.out
+}
+
+test_changes_help() {
+ equery changes --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-changes-help.out
+}
+
+test_check_help() {
+ equery check --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-check-help.out
+}
+
+test_depends_help() {
+ equery depends --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-depends-help.out
+}
+
+test_depgraph_help() {
+ equery depgraph --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-depgraph-help.out
+}
+
+test_files_help() {
+ equery files --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-files-help.out
+}
+
+test_glsa_help() {
+ equery glsa --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-glsa-help.out
+}
+
+test_hasuses_help() {
+ equery hasuses --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-hasuses-help.out
+}
+
+test_list_help() {
+ equery list --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-list-help.out
+}
+
+test_size_help() {
+ equery size --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-size-help.out
+}
+
+test_stats_help() {
+ equery stats --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-stats-help.out
+}
+
+test_uses_help() {
+ equery uses --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-uses-help.out
+}
+
+test_which_help() {
+ equery which --help > ${tmpfile}
+ assert_samefile ${FUNCNAME} ${tmpfile} test-which-help.out
+}
+
+
+# run tests
+
+if [ "`hostname`" != "sky" ] ; then
+ echo "Testing framework is beta and machine dependent; some tests will fail!"
+fi
+
+test_equery_help
+test_belongs_help
+test_check_help
+test_changes_help
+test_depends_help
+test_depgraph_help
+test_files_help
+test_glsa_help
+test_hasuses_help
+test_list_help
+test_size_help
+test_stats_help
+test_uses_help
+test_which_help
+
+rm -f *.tmp
\ No newline at end of file
--- /dev/null
+List all packages matching a query pattern
+Syntax:
+ list <local-opts> pkgspec
+<local-opts> is either of:
+ -i, --installed - search installed packages (default)
+ -I, --exclude-installed - do not search installed packages
+ -p, --portage-tree - also search in portage tree (/usr/portage)
+ -o, --overlay-tree - also search in overlay tree (/usr/local/portage /usr/local/overlays/gentoo-boblycat)
+
--- /dev/null
+Print size total size of files contained in a given package
+Syntax:
+ size <local-opts> pkgspec
+<local-opts> is either of:
+ -b, --bytes - report size in bytes
+
--- /dev/null
+Display USE flags for a given package
+
+Syntax:
+ uses <local-opts> pkgspec
+<local-opts> is either of:
+ -a, --all - include non-installed packages
+
--- /dev/null
+Print full path to ebuild for a given package
+Syntax:
+ size pkgspec