#!/bin/bash #Copyright 2005 William Stearns Usage () { echo "$0: /path/to/isofile /dir/where/packages/should/show/up/" >&2 exit 1 } #Needed utils: find grep ln mktemp mount sudo xargs if [ -z "$2" -o -n "$3" ]; then echo "Incorrect number of arguments." >&2 Usage fi if [ ! -r "$1" ]; then echo "File $1 is not readable." >&2 Usage fi if [ ! -d "$2" ]; then echo "$2 is not a directory." >&2 Usage fi TmpDir=`mktemp -d -t isomount.XXXXXX` if [ $? -ne 0 ]; then echo 'Failed to make a temporary directory, exiting.' >&2 exit 1 fi if [ "$EUID" != "0" ] && type -path sudo >/dev/null 2>/dev/null ; then Sudo='sudo ' fi $Sudo mount -r -o loop -t iso9660 "$1" "$TmpDir" find "$TmpDir" -type f -size +0c \( -name '*.rpm' -a \! -name '*.src.rpm' \) -print0 \ | xargs --null -r -n 20 ln -sf --target-directory="$2"