]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/install-info-html.sh
PO: fetch Swedish from the FTP
[lilypond.git] / scripts / build / install-info-html.sh
1 #!@BASH@
2
3 name=install-info-html
4 version=1.0
5
6 all=
7 index_dir=.
8
9 #
10 # debugging
11 #
12 debug_echo=:
13
14
15 #
16 # print usage
17 #
18 help ()
19 {
20         cat << EOF
21 $name $version
22 Install HTML info document.
23
24 Usage: $name [OPTIONS]... [DOCUMENT-DIR]...
25
26 Options:
27   -a, --all            assume all subdirectories of index to be DOCUMENT-DIRs
28   -d, --dir=DIR        set index directory to DIR (default=.)
29   -D, --debug          print debugging info
30   -h, --help           show this help text
31   -v, --version        show version
32 EOF
33 }
34  
35
36 cleanup ()
37 {
38         $debug_echo "cleaning ($?)..."
39 }
40
41 trap cleanup 0 9 15
42
43 #
44 # Find command line options and switches
45 #
46
47 # "x:" x takes argument
48 #
49 options="adhvW:"
50 #
51 # ugh, "\-" is a hack to support long options
52 # must be in double quotes for bash-2.0
53
54 while getopts "\-:$options" O
55 do
56         $debug_echo "O: \`$O'"
57         $debug_echo "arg: \`$OPTARG'"
58         case $O in
59                 a)
60                         all=yes
61                         ;;
62                 D)
63                         [ "$debug_echo" = "echo" ] && set -x
64                         debug_echo=echo
65                         ;;
66                 h)
67                         help;
68                         exit 0
69                         ;;
70                 v)
71                         echo $name $version
72                         exit 0
73                         ;;
74                 d)
75                         index_dir=$OPTARG
76                         ;;
77         # a long option!
78         -)
79                 case "$OPTARG" in
80                         a*|-a*)
81                                 all=yes
82                                 ;;
83                         de*|-de*)
84                                 [ "$debug_echo" = "echo" ] && set -x
85                                 debug_echo=echo
86                                 ;;
87                         h*|-h*)
88                                 help;
89                                 exit 0
90                                 ;;
91                         di*|-di*)
92                                 index_dir="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`"
93                                 ;;
94                         version|-version)
95                                 echo $name $version
96                                 exit 0
97                                 ;;
98                         *|-*)
99                                 echo "$0: invalid option -- \"$OPTARG\""
100                                 help;
101                                 exit -1
102                                 ;;
103                 esac
104         esac
105 done
106 shift `expr $OPTIND - 1`
107
108 #
109 # Input file name
110 #
111 if [ -z "$all" -a -z "$1" ]; then
112         help
113         echo "$name: No HTML documents given"
114         exit 2
115 fi
116
117 if [ -n "$all" -a -n "$1" ]; then
118         echo "$name: --all specified, ignoring DIRECTORY-DIRs"
119 fi
120
121 if [ -n "$all" ]; then
122         document_dirs=`/bin/ls -d1 $index_dir`
123 else
124         document_dirs=$*
125 fi
126
127 index_file=$index_dir/index.html
128 rm -f $index_file
129 printf "%s: Writing index: %s..." "$name" "$index_file"
130
131 # head
132 cat >> $index_file <<EOF
133 <html> 
134 <title>Info documentation index</title>
135 <body>
136 <h1>Info documentation index</h1>
137 <p>
138 This is the directory file \`index.html' a.k.a. \`DIR', which contains the
139 topmost node of the HTML Info hierarchy.
140 </p>
141 <ul>
142 EOF
143
144 #list
145 for i in $document_dirs; do
146     cat <<EOF
147 <li> <a href="$i/index.html">$i</a> (<a href="$i.html">$i as one big page</a>)</li>
148 EOF
149 done >> $index_file
150
151 # foot
152 cat >> $index_file <<EOF
153 </ul>
154 </body>
155 </html>
156 EOF
157 echo