#! /bin/sh # findpkg - Find files and packages in Debian # Copyright (c) 2000,3,5,6,9 Martin Schulze # # 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 of the License, 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 # Updates: http://www.infodrom.org/Infodrom/tools/findpkg.html # Default settings # server=ftp.debian.org protocol=http dist=stable basedir=debian wgetopts= arch=$(dpkg --print-architecture) function usage(){ cat <] -u|--update update local database using server repository database -h|--help this help screen EOF } # Overwrite the defaults with values from inside the config file # if [ -s /etc/dpkg/findpkg.conf ] then . /etc/dpkg/findpkg.conf fi contents=/var/lib/dpkg/Contents-${arch}.gz if [ $# -gt 0 ] then case $1 in --help|-h) usage exit ;; --update|-u) if ! touch $contents 2> /dev/null then echo "Can't write to $contents" exit 1 fi tmp=`tempfile` trap "rm -f $tmp; exit" INT EXIT set -e wget ${wgetopts} -O $tmp ${protocol}://${server}/${basedir}/dists/${dist}/Contents-${arch}.gz set +e cp $tmp $contents chmod 644 $contents ;; -*) echo "No such parameter \`$1'" ;; *) if [ ! -f $contents ] then echo "No $contents found, execute program with -u first" exit 1 fi zgrep "$@" ${contents} ;; esac else usage fi