pkgxtra

August 2nd, 2005 Stephen Lau

a while ago i wrote a stupid little shell script called pkgxtra that lets me easily list files owned by a package (either by .pkg filename, or package name (like SUNWcsl)). it also provides a shortcut to see which package owns a given pathname/filename.

here it is, in all its glory:

#!/bin/bash

show_help() {
        echo "usage: $0 [-lfp] ";
        echo "  -l  lists files belonging to package";
        echo "  -f  lists files contained in .pkg file";
        echo "  -p     show package owner of ";
}

while getopts "lpfh" flag
do
        if [ "$flag" == "l" ]; then
                MODE=0;
        fi
        if [ "$flag" == "p" ]; then
                MODE=1;
        fi
        if [ "$flag" == "f" ]; then
                MODE=2;
        fi
        if [ "$flag" == "h" ]; then
                show_help
                exit 1;
        fi
done

shift $(($OPTIND - 1))

if [ "$#" -eq "0" ]; then
        show_help
        exit 1;
fi

case "$MODE" in
        0)      pkgchk -l $1|awk '/^Pathname/ {print $2}';;
        1)      pkgchk -l -p $1;;
        2)      pkgchk -l -d $1|awk '/^Pathname/ {print $2}';;
esac

[tags: Code, OpenSolaris]


Leave a Comment

Required

Required, hidden



Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to comments via RSS Feed

Search

Pages


New Photos

2008-07-24 The After After Party @ OpenSourcery by Stephen Lau2008-07-24 Beerforge (The Songbird Party) by Stephen Lau
2008-07-24 OSCON Day 2 at the Booth by Stephen Lau2008-07-23 John Plocher vs. Jörg Schilling Sumo Wrestle by Stephen Lau
2008-07-23 OSCON Day 1 by Stephen Lau2008-07-22 OSCON Day 0 by Stephen Lau
2008-07-21 Bummin' Around Portland by Stephen Lau2008 Photos of Char-siu by Koshi by Stephen Lau
2008-07-05 Climbing Six Toe Rock at Castle Crags by Stephen Lau2008-06-28 Neighbourhood Beagles by Stephen Lau

Categories