openpkg/man.sh

Sun, 29 May 2011 16:29:06 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sun, 29 May 2011 16:29:06 +0200
changeset 344
e33c1efbd60f
child 428
f880f219c566
permissions
-rw-r--r--

Update, correct, improve build configuration and packaging logic.
Update to new version of vendor software, bump copyright date, remove implicit
gcc dependency, add comments for Trolltech bug tracking, correct enforced
dynamic library linkage, and install mysterious process stub binary.

michael@13 1 #!@l_prefix@/lib/openpkg/bash
michael@13 2 ##
michael@13 3 ## man -- OpenPKG Tool Chain "man" command
michael@13 4 ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
michael@13 5 ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
michael@13 6 ##
michael@13 7 ## Permission to use, copy, modify, and distribute this software for
michael@13 8 ## any purpose with or without fee is hereby granted, provided that
michael@13 9 ## the above copyright notice and this permission notice appear in all
michael@13 10 ## copies.
michael@13 11 ##
michael@13 12 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@13 13 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@13 14 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@13 15 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@13 16 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@13 17 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@13 18 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@13 19 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@13 20 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@13 21 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@13 22 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@13 23 ## SUCH DAMAGE.
michael@13 24 ##
michael@13 25
michael@13 26 # configuration
michael@13 27 prefix="@l_prefix@"
michael@13 28
michael@13 29 # minimum command line parsing
michael@13 30 opt_h=no
michael@13 31 while [ 1 ]; do
michael@13 32 case "$1" in
michael@13 33 -h | --help ) opt_h=yes; shift ;;
michael@13 34 * ) break ;;
michael@13 35 esac
michael@13 36 done
michael@13 37 if [ ".$opt_h" = .yes ]; then
michael@13 38 echo "openpkg:man:USAGE: openpkg man [--help] [<section>] <command>"
michael@13 39 exit 0
michael@13 40 fi
michael@13 41 if [ $# -eq 1 ]; then
michael@13 42 man_page="$1"
michael@13 43 elif [ $# -eq 2 ]; then
michael@13 44 man_sect="$1"
michael@13 45 man_page="$2"
michael@13 46 else
michael@13 47 echo "openpkg:man:ERROR: invalid number of arguments" 1>&2
michael@13 48 exit 1
michael@13 49 fi
michael@13 50
michael@13 51 # determine path to commands
michael@13 52 openpkg_tools="${OPENPKG_TOOLS}"
michael@13 53 openpkg_tools_cmdpath="${OPENPKG_TOOLS_CMDPATH}"
michael@13 54 if [ ".${openpkg_tools}" != . -a ".${openpkg_tools_cmdpath}" = . ]; then
michael@13 55 openpkg_tools_cmdpath="${openpkg_tools}/cmd:@"
michael@13 56 fi
michael@13 57 cmdpath="${prefix}/libexec/openpkg"
michael@13 58 if [ -d "${prefix}/libexec/openpkg-tools" ]; then
michael@13 59 cmdpath="${prefix}/libexec/openpkg-tools:${cmdpath}"
michael@13 60 fi
michael@13 61 if [ -d "${prefix}/libexec/openpkg-audit" ]; then
michael@13 62 cmdpath="${prefix}/libexec/openpkg-audit:${cmdpath}"
michael@13 63 fi
michael@13 64 if [ ".${openpkg_tools_cmdpath}" != . ]; then
michael@13 65 cmdpath=`echo "${openpkg_tools_cmdpath}" | sed -e "s;@;${cmdpath};"`
michael@13 66 fi
michael@13 67 openpkg_tools_cmdpath=`echo "${cmdpath}" | sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`
michael@13 68
michael@13 69 # search for manual page in OpenPKG Tool Chain
michael@13 70 man_file=""
michael@13 71 man_type=""
michael@13 72 OIFS="$IFS"; IFS=":"
michael@13 73 for dir in ${openpkg_tools_cmdpath}; do
michael@13 74 IFS="$OIFS"
michael@13 75 for file in $dir/$man_page.${man_sect-"1"} $dir/$man_page.[1-9]; do
michael@13 76 if [ -f "$file" ]; then
michael@13 77 man_file="$file"
michael@13 78 man_type="roff"
michael@13 79 if [ ".$man_sect" = . ]; then
michael@13 80 man_sect=`echo "$man_file" |\
michael@13 81 sed -e 's;^;X;' -e 's;^X.*\.\([1-9]\)$;\1;' -e 's;^X.*;;'`
michael@13 82 fi
michael@13 83 break
michael@13 84 fi
michael@13 85 done
michael@13 86 if [ ".$man_type" = . ]; then
michael@13 87 for file in $dir/$man_page.pod $dir/$man_page.pl $dir/$man_page.sh; do
michael@13 88 if [ -f "$file" ]; then
michael@13 89 if [ ".`grep '^=pod' $file`" != . ]; then
michael@13 90 man_file="$file"
michael@13 91 man_type="pod"
michael@13 92 break
michael@13 93 fi
michael@13 94 fi
michael@13 95 done
michael@13 96 fi
michael@13 97 if [ ".$man_type" != . ]; then
michael@13 98 break
michael@13 99 fi
michael@13 100 done
michael@13 101 IFS="$OIFS"
michael@13 102 if [ ".$man_type" != . ]; then
michael@13 103 # determine POD to Roff converter
michael@13 104 pod2roff=""
michael@13 105 if [ ".$man_type" = .pod ]; then
michael@13 106 pod2roff=`$prefix/lib/openpkg/shtool path -p "$prefix/bin:$PATH" pod2man`
michael@13 107 if [ ".$pod2roff" = . ]; then
michael@13 108 echo "openpkg:man:ERROR: unable to find POD to Roff converter (pod2man)" 1>&2
michael@13 109 exit 1
michael@13 110 fi
michael@13 111 if [ ".$man_sect" = . ]; then
michael@13 112 man_sect=1
michael@13 113 fi
michael@13 114 pod2roff="$pod2roff --section=${man_sect}"
michael@13 115 pod2roff="$pod2roff --release=\"$man_page(${man_sect})\""
michael@13 116 pod2roff="$pod2roff --center=OpenPKG --date=OpenPKG"
michael@13 117 pod2roff="$pod2roff --quotes=none"
michael@13 118 fi
michael@13 119
michael@13 120 # determine Roff to ASCII converter
michael@13 121 roff2ascii=`$prefix/lib/openpkg/shtool path -p "$prefix/bin:$PATH" nroff groff`
michael@13 122 if [ ".$roff2ascii" = . ]; then
michael@13 123 echo "openpkg:man:ERROR: unable to find Roff to ASCII converter (nroff, groff)" 1>&2
michael@13 124 exit 1
michael@13 125 fi
michael@13 126 roff2ascii="$roff2ascii -man"
michael@13 127 case "$roff2ascii" in
michael@13 128 */groff ) roff2ascii="$roff2ascii -Tascii" ;;
michael@13 129 esac
michael@13 130
michael@13 131 # determine pager
michael@13 132 pager="$PAGER"
michael@13 133 if [ ".$pager" = . ]; then
michael@13 134 pager=`$prefix/lib/openpkg/shtool path -p "$prefix/bin:$PATH" less more cat`
michael@13 135 fi
michael@13 136 if [ ".$pager" = . ]; then
michael@13 137 echo "openpkg:man:ERROR: unable to find text viewer ($PAGER, less, more, cat)" 1>&2
michael@13 138 exit 1
michael@13 139 fi
michael@13 140
michael@13 141 # render the manual page to the TTY
michael@13 142 if [ ".$man_type" = .roff ]; then
michael@13 143 eval "$roff2ascii $man_file | $pager"
michael@13 144 elif [ ".$man_type" = .pod ]; then
michael@13 145 eval "$pod2roff $man_file | $roff2ascii | $pager"
michael@13 146 fi
michael@13 147 exit 0
michael@13 148 fi
michael@13 149
michael@13 150 # fallback to the man(1) command
michael@13 151 MANPATH="$prefix/man:$prefix/local/man:${MANPATH-/usr/man}:/usr/man:/usr/share/man"
michael@13 152 export MANPATH
michael@13 153 eval "exec man $man_sect $man_page"
michael@13 154

mercurial