Fixed '/net/jsc-nfs.czech.sun.com/export/jscqa-local' override preference.
authorshort <>
Mon, 1 Mar 2004 23:13:35 +0000 (23:13 +0000)
committershort <>
Mon, 1 Mar 2004 23:13:35 +0000 (23:13 +0000)
+rpm(1) emulation for Solaris.

.bashrc

diff --git a/.bashrc b/.bashrc
index 9844dd4..95a48dc 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -55,7 +55,7 @@ _bash_profile_addpath -f MANPATH         "/usr/X11R6/man"
 _bash_profile_addpath -f MANPATH         "/usr/share/man"
 _bash_profile_addpath -f MANPATH         "/usr/local/man"
 [ "`uname`" = "SunOS" ] && _bash_profile_addpath -f LD_LIBRARY_PATH "$HOME/Netscape/dist/lib"
-for family in "$HOME" "/net/jes-v65-0.czech.sun.com/export/jscqa-local";do
+for family in "/net/jsc-nfs.czech.sun.com/export/jscqa-local" "$HOME";do
        for arch in "$family" $family/`uname -p`;do
                # Do not "-f": We use /net !
                _bash_profile_addpath PATH            "$arch/bin"
@@ -186,6 +186,48 @@ function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install
 function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; };export -f exx
 function revlines { perl -e 'my @r=();push @r,$_ while (<>);print pop @r while @r;'; }; export -f revlines
 
+[ "`uname`" = "SunOS" ] && function rpm
+{
+       _OPTIND="$OPTIND"
+       _opt_q=0;_opt_a=0;_opt_l=0;_opt_f=0
+       OPTIND=1;while getopts qalfv got;do
+               case "$got" in
+                       [qalf]) eval "_opt_$got=1" ;;
+                       v) ;;
+                       *) exit 1 ;;
+                       esac
+               done
+       shift $[$OPTIND-1]
+       if [ $_opt_q = 0 ];then echo >&2 "rpm: No -q!";return 1;fi
+       if [ $_opt_a = 1 -a $# != 0 ];then echo >&2 "rpm: -a but some arguments!";return 1;fi
+       if [ $_opt_a = 0 -a $#  = 0 ];then echo >&2 "rpm: -a but no arguments!";return 1;fi
+       if [ $_opt_l = 1 -a $_opt_f  = 1 ];then echo >&2 "rpm: Both -l and -f given!";return 1;fi
+       if [ $_opt_f = 1 ];then
+               for file in "$@";do
+                       if [ "$file" = "${file#/}" ];then
+                               file="$PWD/$file"
+                       fi
+                       _out="`pkgchk -l -p "$file"`"
+                       if [ -z "$_out" ];then
+                               echo >&2 "file $file is not owned by any package!"
+                       else
+                               echo -n "$_out"|awk '
+                                               /^[^\t]/{p=0}
+                                               /^Referenced by the following packages:$/{p=1}
+                                               /^\t/{if (p) { print; } }
+                                               '
+                       fi
+                       unset _out
+               done
+       elif [ $_opt_l = 1 ];then
+               pkgchk -l `pkginfo "$@"|awk '{print $2}'`|sed -n 's/^Pathname: //p'
+       else
+               pkginfo "$@"|awk '{print $2}'
+       fi
+       unset _opt_q _opt_a _opt_l _opt_f
+       OPTIND="$_OPTIND";unset _OPTIND
+} && export -f rpm
+
 ulimit -c 0
 set +H
 shopt -s mailwarn