#!/bin/bash # # The purpose of this software/script is to allow the user # to view the contents of a Slackware package with out having # to install, or untar (explode) the package. # # This software is released and licensed under the GPL v2, for # further documentation look at http://www.gnu.org/copyleft/gpl.html # Some minor parts of this script were taken from the /sbin/installpkg # on a Slackware 10.1 system. Those parts are protected by the copyright # and disclaimer below. # # Copyright 1994, 1998, 2000 Patrick Volkerding, Concord, CA, USA # Copyright 2001, 2003 Slackware Linux, Inc., Concord, CA, USA # All rights reserved. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Author: James Caffrey # Version: 1.4.2 # # Version of viewpkg VER=1.4.2 CWD=`pwd` PAGER=${PAGER:-/usr/bin/less} usage() { #displays how to use viewpkg cat << EOF viewpkg $VER A tool to view the contents of a Slackware package. Similar to explodepkg but without writing the whole package to your hard disk. Viewpkg is used for examining and debugging. Options: -h|--help Displays this help message -v|--version Displays version information Usage: `basename $0` [options] package_name EOF } crunch() { # This function, and the implementation that # it serves was borrowed from /sbin/installpkg. # Thanks Pat. :) while read foo do echo $foo done } #if no args, bomb out if [ $# = 0 ]; then usage exit 1 fi # Parse the args while [ "$1" ] do case $1 in -h|--help) usage exit 1 ;; -v|--version) echo "viewpkg $VER" exit 1 ;; *) #we use basename, so if user passes a #package name that is not in pwd PKGDIR="`dirname $1`" PKGNAME="`basename $1`" if [ ! -e $1 ]; then echo echo "ERROR: package does not exist" echo exit 1 fi shift ;; esac done # Check to see if is a package, not # just a tar gzip'd archive cd $PKGDIR if [ "`echo $PKGNAME | rev | cut -f 1 -d . | rev`" != "tgz" ]; then echo echo "ERROR: package name given, is not a package" echo " it do not have a .tgz extension" echo exit 2 fi # Some temp files TMPPERM="/tmp/`basename $0`-$$-1" TMPFILE="/tmp/`basename $0`-$$-2" # Breakdown the package name NAME=`basename $PKGNAME .tgz | rev | cut -f 4- -d - | rev` #currently not using these, but maybe for future use #VERSION=`basename $PKGNAME .tgz | rev | cut -f 3 -d - | rev` #ARCH=`basename $PKGNAME .tgz | rev | cut -f 2 -d - | rev` #BUILD=`basename $PKGNAME .tgz | rev | cut -f 1 -d - | rev` ( # Give a nice header echo "Package Name: `basename $PKGNAME .tgz`" COMPRESSED=`gzip -l $PKGNAME | grep -v ratio | crunch | cut -f 1 -d ' '` echo "Compressed Package Size: `expr $COMPRESSED / 1024` K" UNCOMPRESSED=`gzip -l $PKGNAME | grep -v ratio | crunch | cut -f 2 -d ' '` echo "Uncompressed Package Size: `expr $UNCOMPRESSED / 1024` K" echo "Package Location: $PKGDIR/$PKGNAME" echo "Package Description:" # Find and print out slack-desc cd $PKGDIR tar -ztvf $PKGNAME | grep "slack-desc" > /dev/null if [ $? = 0 ]; then tar -zxOf $PKGNAME install/slack-desc | grep $NAME else echo echo "No slack-desc file found in package. I guess" echo "that is problem one with this package. :)" echo fi # Print out all files in archive echo echo "File List:" #this gets permissions and ownerships tar -ztvf $PKGNAME | cut -b 1-23 > $TMPPERM #this gets directories and files tar -ztvf $PKGNAME | cut -f 3 -d : | cut -c 4- > $TMPFILE #lets put them together paste $TMPPERM $TMPFILE #this worked most of the time, execpt with #files that were large you would see part #of the file size listed #tar -ztvf $PKGNAME | cut -b 1-24,52- # Find and print out doinst.sh echo echo "Installation Script:" tar -ztvf $PKGNAME | grep "doinst.sh" > /dev/null if [ $? = 0 ]; then tar -zxOf $PKGNAME install/doinst.sh fi ) | $PAGER # Cleanup rm -f $TMPPERM rm -f $TMPFILE cd $CWD #########################ChangeLog############################### # # # 20050508 1.4.2 # # *Simplified the implementation of breaking # # down the package name, no more loop # # # # 20050424 1.4.1 # # *Simplify the implementation of checking # # for if file is a Slackware package. # # *Minor code clean up; elminated an if # # statement by using parameter expansion # # # # 20050405 1.4 # # *Added showing of compressed and # # uncompressed package size, mostly # # borrowed from /sbin/installpkg, # # thanks Pat. :) # # # # 20050326 1.3 # # *Added checking it see if file given # # is a Slackware package. Other wise # # any gzip'd tar file would work but # # but give errors # # # # 20050318 1.2 # # *Updated engine which displays # # file list # # # # 20050315 1.1 # # *Bug fixes, improper detection # # of slack-desc and doinst.sh files # # # # 20050310 1.0 # # *Initial release # # # #################################################################