#!/bin/sh -f # a script to transform a tag name, a list of tag names (ANDed then), # or a complex boolean expression into a list of package list names. # examples of expected stdin: # # kde # live gnome # (base && (kernel || apt || alterator)) # # NB: tags are processed using word boundaries, # so avoid using "-" in tag names DIR="${1:?need base directory}" warn() { echo "$0: WARNING: $*" >&2 exit } [ -d "$DIR" ] || warn "$DIR nonexistent" cd "$DIR" || warn "cannot change to $DIR" # NB: care with quoting transformed="$(sed \ -e "s,\([^&|! ()']\+\),-regex ^.*\\\\<\1\\\\>.*$,g" \ -e "s, *&& *, -a ,g" \ -e "s, *|| *, -o ,g" \ -e "s, *! *, ! ,g" \ -e "s, *( *, ( ,g" \ -e "s, *) *, ) ,g")" [ "$DEBUG" = 2 ] && echo "`basename $0`: transformed = \"$transformed\"" >&2 [ -z "$transformed" ] || find $transformed \ | sed 's,^\./,,' \ | egrep -v '(\.sw.|~)$'