summaryrefslogtreecommitdiff
path: root/package/man
blob: 6b79049ffa78b2d50b4c52b604fb5c24c6420892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/sh
shout() { echo "$0: $@" >&2; }
barf() { shout "fatal: $@"; exit 111; }
safe() { "$@" || barf "cannot $@"; }

me=`cat package/path | cut -d'/' -f2`
unix=`uname -a | cut -d' ' -f1 | tr [a-z] [A-Z]`
mandir=""
usemanpath=0
usemandoc=0

if [ `which manpath` 2>/dev/null ]
then
	usemanpath=1
fi

if [ `which mandoc`  2>/dev/null ]
then 
  usemandoc=1
  shout "Using mandoc facility for man files."
fi

safe umask 022
[ -d man ] || barf "no man directory"

if [ -f conf-man ]
then
   mandir=`head -1 conf-man`
   if [ -d "$mandir" ]
   then
     shout "Setting manual man-dir: $mandir."
   else
     if [ $usemanpath -eq 0 ]
     then
       barf "`manpath` not available; use conf-man instead."
     fi
     mandir=`manpath | awk -F: '{print $1}'`
     if [ -d "$mandir" ]
     then
       shout "Setting manpath man-dir: $mandir."
     else
       barf "can't determine man-path directory."
     fi
  fi
else 
	barf "can't determine man-path directory."
	exit 1
fi

cd man
if [ $usemandoc -eq 1 ]
then
  safe make -f Makefile.mandoc
else
  safe make 
fi

if [ $usemandoc -eq 0 ]
then
  shout "Installing ${me} compressed man-files in ${mandir}."
else
  shout "Installing ${me} un-compressed man-files in ${mandir}."
fi

for i in `find . -name "*[1-8]"`
do
  all="$all $i"
done

for manfile in $all
do
  dir="man`echo $manfile | awk -F. '{print $NF}'`"
  [ -d $mandir/$dir ] || safe mkdir $mandir/$dir
  if [ $usemandoc -eq 0 ]
  then
    safe gzip $manfile && \
         install -m 644 "$manfile.gz" $mandir/$dir/"${manfile#*/}.gz"
  else
    safe install -m 644 $manfile $mandir/$dir/${manfile#*./}
  fi
done

## nroff: Required for old catman systems only 

if [ $usemandoc -eq 0 ]
then
  shout "Installing ${me} nroff'ed man-files in ${mandir}/catX."

  all=""
  for i in `find . -name "*0"`
  do
    all="$all $i"
  done

  for manfile in $all
  do
    catname=${manfile%.0}
    catfiles=`ls -1 ${catname}* | grep -v '.0' | grep -v '.9'`

    for catfile in $catfiles
    do
      dir="$mandir/cat`echo $catfile | awk -F. '{print $(NF-1)}'`"
      safe mkdir -p $dir
      safe install -m 644 $manfile $dir/${manfile#*/}
    done
  done
else
  if [ `which makewhatis` 2>/dev/null ]
  then
     makewhatis $mandir
     shout "Installing ${me} mandoc files in db (makewhatis)."
  elif [ `which catman` 2>/dev/null ]
  then
     catman $mandir
     shout "Installing ${me} mandoc files in db (catman)."
  else 
     man -w $mandir
     shout "Installing ${me} mandoc files in db (man -w)."
  fi 
fi

cd ..

exit 0