r12040: merging packaging fixes from release branch
[samba.git] / source3 / script / installman.sh
1 #!/bin/sh
2 #5 July 96 Dan.Shearer@unisa.edu.au  removed hardcoded values
3 #
4 # 13 Aug 2001  Rafal Szczesniak <mimir@spin.ict.pwr.wroc.pl>
5 #   modified to accomodate international man pages (inspired
6 #   by Japanese edition's approach)
7
8 MANDIR=`echo $1 | sed 's/\/\//\//g'`
9 SRCDIR=$2/
10 langs=$3
11
12 if [ $# -ge 4 ] ; then
13   GROFF=$4                    # sh cmd line, including options 
14 fi
15
16 if test ! -d $SRCDIR../docs/manpages; then
17         echo "No manpages present.  SVN development version maybe?"
18         exit 0
19 fi
20
21 # Get the configured feature set
22 test -f "${SRCDIR}/config.log" && eval `grep '^[A-Za-z0-9]*=.*' ${SRCDIR}/config.log`
23
24 for lang in $langs; do
25     if [ "X$lang" = XC ]; then
26         echo Installing default man pages in $MANDIR/
27         lang=.
28     else
29         echo Installing \"$lang\" man pages in $MANDIR/lang/$lang
30     fi
31
32     langdir=$MANDIR/$lang
33     for d in $MANDIR $langdir $langdir/man1 $langdir/man5 $langdir/man7 $langdir/man8; do
34         if [ ! -d $d ]; then
35             mkdir $d
36             if [ ! -d $d ]; then
37                 echo Failed to make directory $d, does $USER have privileges?
38                 exit 1
39             fi
40         fi
41     done
42
43     for sect in 1 5 7 8 ; do
44         for m in $langdir/man$sect ; do
45             for s in $SRCDIR../docs/manpages/$lang/*$sect; do
46             MP_BASENAME=`basename $s`
47
48             # Check if this man page if required by the configured feature set
49             case "${MP_BASENAME}" in
50                 smbsh.1) test -z "${SMBWRAPPER}" && continue ;;
51                 *) ;;
52             esac
53
54             FNAME="$m/${MP_BASENAME}"
55
56             # Test for writability.  Involves 
57             # blowing away existing files.
58  
59             if (rm -f $FNAME && touch $FNAME); then
60                 if [ "x$GROFF" = x ] ; then
61                     cp $s $m            # Copy raw nroff 
62                 else
63                     echo "\t$FNAME"     # groff'ing can be slow, give the user
64                                         #   a warm fuzzy.
65                     $GROFF $s > $FNAME  # Process nroff, because man(1) (on
66                                         #   this system) doesn't .
67                 fi
68                 chmod 0644 $FNAME
69             else
70                 echo Cannot create $FNAME... does $USER have privileges?
71             fi
72             done
73         done
74     done
75 done
76 cat << EOF
77 ======================================================================
78 The man pages have been installed. You may uninstall them using the command
79 the command "make uninstallman" or make "uninstall" to uninstall binaries,
80 man pages and shell scripts.
81 ======================================================================
82 EOF
83
84 exit 0
85