#!/bin/sh # debsummer - Create md5sums file for given package(s) # # Copyright (C) 2002 Patrick L. Bernier # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2, as # published by the Free Software Foundation. # # 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 # # v1.0 (2002/10/12) -- Initial attempt # v1.1 (2002/12/14) -- Quoted some filenames # v1.2 (2008/10/06) -- True Bourne shell syntax; allow empty md5sums # # Source: http://www.TZoNE.ORG/~pat/sw/debsummer/ PATH=/usr/bin:/bin usage() { cat >&2 <&2 return 1 fi fi if [ ! -f "$listfile" ]; then echo "Package '$pkgname' not found." >&2 return 1 fi if [ ! -r "$listfile" ]; then echo "Can't read $listfile" >&2 return 1 fi [ $verbose -gt 0 ] && echo "$pkgname" : > "$md5file" cat $listfile | while read f do if [ -f "$f" ]; then [ "$skipconf" -eq 1 -a -f "$conffile" ] && if grep -- "$f" "$conffile" >/dev/null 2>&1; then [ $verbose -gt 0 ] && echo "skipping conffile $f" continue fi if [ "$nobody" -eq 1 ]; then if su nobody -c "test -r \"$f\""; then : else [ $verbose -gt 0 ] && echo "skipping world-unreadable $f" continue fi fi if [ $verbose -gt 1 ]; then md5sum -- "$f" | sed -e 's#/##' | tee -a -- "$md5file" else md5sum -- "$f" | sed -e 's#/##' >> "$md5file" fi fi done } if [ ! -r /etc/debian_version ]; then echo "I think you're not running Debian... debsummer can't help you." fi dpkginfo=/var/lib/dpkg/info md5dir=$dpkginfo force=0 verbose=0 nobody=0 skipconf=0 while getopts cfi:m:ov opt do case $opt in c) skipconf=1 ;; f) force=1 ;; i) dpkginfo=$OPTARG ;; m) md5dir=$OPTARG ;; o) nobody=1 ;; v) verbose=$(($verbose+1)) ;; \?) usage; exit 1 ;; esac done shift `expr $OPTIND - 1` if [ "$#" -lt 1 ]; then usage exit 1 fi if [ ! -d "$dpkginfo" -o ! -r "$dpkginfo" ]; then echo "Cannot read $dpkginfo" >&2 exit 1 fi if [ ! -d "$md5dir" -o ! -w "$md5dir" -o ! -r "$md5dir" ]; then echo "Cannot read/write $md5dir" >&2 exit 1 fi error=0 while [ "$1" != "" ]; do process "$1" [ $? -ne 0 ] && error=1 shift done exit $error ### debsummer ###