Altering the MANPATH in RPM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 25 Apr 2002, James Olin Oden wrote:
> I guess since know one has responded to this question concerning a
> clean way for an RPM to alter the MANPATH (i.e. alter it non-destructively
> and using a safe mechanism to do so) says that there is not such a
> clean method (please someone correct me if I am wrong).  If this is the case
> then perhaps a later RedHat release could consider this.  I can think of a
> few ways of acomplishing this, but probably the simplest would be to
> do something like HP does, which I mentioned in the P.S. of my previous
> email:
>
> 	P.S. on HP/UX the system MANPATH was constructed from the file
> 	/etc/MANPATH which contained a : delimited list of directories,
> 	which made it very easy for depots (HP rpms) to alter the MANPATH,
> 	and was very necessary in an architecture where most every package
> 	gets its own directory under /opt.
>
The /opt/package/{etc,bin,man} practise can lead to quite riducule
length with PATH, MANPATH etc. components when you have plenty
of softare in your system, so beware.

The Written Word, see [ http://www.thewrittenword.com/, has
created quite a nice symlink workaround with native HP-UX packages,
see ftp://ftp.thewrittenword.com/packages/INSTALL.pdf and
check how COMMON_BASE option can ease the PATH pollution.

The second problem with /etc/MANPATH and /etc/PATH with
HP-UX is that fairly many especially third-party vendor
packages (depots) that I have seen screwed up badly while
editing those files, even packages from some HP departments
have had these problems (ever tried JetDirect and HPNP packages?).
Most common problems I have met are:

 - when reinstalling you often have duplicate paths added.

 - I've met many times // had been added there.

 - does not provide means of checking first that the
   filesystem is mounted before reference to path is added

This was just to point that the HP-UX practis IMHO is far
from ideal.

> The key problem I see with this method is that I don't believe gnu man supports
> this (again I would like to be wrong), but what I think could easily be done is
> add a command that at startup would alter the man.config to contain the
> the MANPATH found in this file.  On the other hand, another approach that
> may be better would be to provide command on a redhat system that would allow
> one to add a MANPATH statement to the man.config.  This thing command would
> be fully aware of the man.config syntax, so that it could:
>
> 	- add the MANPATH in clean way.
> 	- make sure that it had not already been added.
>
I don't think you need that stuff at all ...

I'd prefer this stuff done at /etc/profile.d/ with appropriate
scripts, those are executed after login.

Let's say I have /etc/profile.d/localpath.sh

# strip 'local' PATH components
IFS=":"; NPATH=""
for i in $PATH ; do
    case $i in
        /usr/local/bin|\
        /usr/local/sbin|\
        /usr/sbin|\
        /sbin)  # strip these first, add again later
		;;
            *)  # store rest to NPATH, if they exist
		if [ -d "$i" ]; then
		   if [ -z "$NPATH" ]; then
                      NPATH="$i"
                   else
                      NPATH="$NPATH:$i"
                   fi
                fi
                ;;
    esac
done
IFS="
"
export IFS

# prepend local path to ordinary users, set TMOUT to root
case $LOGNAME in
    root) PATH="/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:$NPATH"
          if [ -t ]; then
                TMOUT=600
          fi
          export PATH TMOUT
          ;;
       *) PATH="/usr/local/bin:$NPATH"
          export PATH
          ;;
esac

You can traverse nicely the PATH with setting the shell
field separatore (IFS) to : and then later construct new
variable later. A nice and portable way too :)

You should always remember to think that when runing commands via
ssh (rsh) from remote machine too, hence the -t test for control-
ling tty is very important!

The same suff for {,t}csh shells

# strip local PATH components
set npath=()
foreach i ( $path )
    switch ( $i )
        case /usr/local/bin:
        case /usr/local/sbin:
        case /usr/sbin:
        case /sbin:
             breaksw
        default:
	     if ( -d $i ) then
                set npath=( $npath $i )
             endif
    endsw
end

prepend local path to ordinary users
switch ($LOGNAME)
    case root:
          set path=(/usr/local/sbin /usr/local/bin /sbin /usr/sbin $npath)
          /usr/bin/tty -s >& /dev/null
          if ( ! $status ) then
                setenv TMOUT 600
                set autologout=10
          endif
          breaksw
    default:
          set path=(/usr/local/bin $npath)
endsw

unset npath


Some platforms like HP-UX (since 10.20) the POSIX shell compound
expressions like [[ expression ]], the problem with these extensions
are portability. Not all unixen have POSIX conformant shell yet for
root, most notably the Solaris 8 and before has sticked with bare
Bourne shell :/

Anyway to show how compound expressions work consider something like
this, first on HP-UX you have somewhere included with profile which
includes gnu.sh

# $Id: gnu.sh,v 1.1 2000/06/27 09:34:05 mesrik Exp $

GNU() {
 if [[ $PATH != */opt/gnu/bin* ]]; then
    [ -f /opt/gnu/gnurc.sh ] && . /opt/gnu/gnurc.sh
 fi
}
# eof

this will not yet interfere to the standard environment
any way (important often by mission critical software
support contracts), but if you are lucky enough that
you are allowed to add utilities on some specified
location like /opt/gnu as long as it is kept separate
and not added to std PATH etc ...

Right, then you have /opt/gnu/gnurc.ksh

# $Id: gnurc.sh,v 1.2 2000/06/27 09:42:07 mesrik Exp $
# prepare GNU environment for POSIX shell

GNUHOME=/opt/gnu

IFS=
export IFS

if [[ $PATH != *$GNUHOME/bin* ]]; then
    PATH="$GNUHOME/bin:$PATH"
    CC=gcc
    export PATH CC GNUHOME
fi

if [[ $MANPATH != *$GNUHOME/man* ]]; then
    MANPATH="$GNUHOME/man:$MANPATH"
    export MANPATH
fi

# eof

Another snippet, simple way of checking the existence of
wether you have already have X fontpath containing some
component ...

# $Id: xfonts.sh,v 1.1 2000/06/27 09:44:28 mesrik Exp $
# include CDE fonts

FSCONF=/usr/local/etc/fontserver.conf

if [ ! -z "$DISPLAY" -a -f $FSCONF ]; then
    FONTSERVER="`sed 1q $FSCONF`"
    [[ `xset q` != *tcp/$FONTSERVER* ]] &&
    xset fp+ tcp/$FONTSERVER
fi

# eof

It's shame that all Unix vendors have not yet
picked setting the POSIX shell for root, it
would make our lives much easier :|

HTH,

:-) riku

-- 
    [ This .signature intentionally left blank ]






[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux