#!/bin/sh # # warnpkg -- a tool to scan Slackware packages for files that would be # overwritten # # Copyright (c) 2007 Brian "Beej Jorgensen" Hall # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # if [ $# -ne 1 ]; then echo "usage: `basename $0` package.tgz" exit 1 fi if [ ! -e $1 ]; then echo "`basename $0`: $1: file not found." exit 2 fi #echo "Checking package $1..." allfiles=`tar tzvf $1 | grep -v ^d | awk '{print "/" $6}'` if ( echo $allfiles | grep install/doinst.sh > /dev/null ); then rmrffiles=`tar -O -xzvf $1 install/doinst.sh 2>/dev/null | grep ' rm -rf' | awk '{print "/" $3 "/" $7}'` else rmrffiles='' fi sep='15c554f9-5351-4d4f-913a-156a08556202' # random unique mode=0 first=1 for a in $rmrffiles $sep $allfiles do if [ $a = $sep ]; then mode=1 continue fi if [ -e $a ]; then if [ $first -eq 1 ]; then first=0 echo -n "Existing files that will be affected are" if [ "x$rmrffiles" != "x" ]; then echo -n " (*** means rm -rf!)" fi echo ":" fi echo -n " $a" if [ $mode -eq 0 ]; then echo " [***]" else echo "" fi fi done if [ $first -eq 1 ]; then echo "No existing files will be affected." fi exit 0