File: dglob

package info (click to toggle)
debian-goodies 0.27+etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 160 kB
  • ctags: 61
  • sloc: sh: 518; python: 370; makefile: 43
file content (50 lines) | stat: -rwxr-xr-x 1,566 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh -e

# dglob - Expand package names matching a pattern and conditions

# Copyright (C) 2001 Matt Zimmerman <mdz@debian.org>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#

ARGS=`getopt -o af0reiXv -n dglob -- "$@"`
eval set -- "$ARGS"


filter="grep-dctrl -FStatus ' installed'"
expand="cat"
grep_dctrl_options=""
while true; do
    case "$1" in
        -a) filter="cat"  ; shift ;;
        -0) SEP=0 ; shift ;;
        -r|-e|-i|-X|-v) grep_dctrl_options="$grep_dctrl_options $1"; shift ;;
        -f) expand="xargs dpkg --listfiles | perl -nl${SEP}e 'print if -f'"
            shift
            ;;
        
        --) shift ; break ;;
    esac
done

# Does the package exist?
packages=`eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1"`
if [ -z "$packages" ] ; then
	exit 1
fi

eval $filter /var/lib/dpkg/status | grep-dctrl -PnsPackage $grep_dctrl_options "$1" |
(eval $expand)