/[d-i]/trunk/manual/build/buildone.sh
ViewVC logotype

Diff of /trunk/manual/build/buildone.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/installer/doc/manual/build/new-generation/build revision 22882 by fjpop-guest, Fri Oct 8 14:02:46 2004 UTC trunk/installer/doc/manual/build/buildone.sh revision 24223 by fjpop-guest, Sun Dec 5 22:46:15 2004 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2    
3  if [ "$1" = "--help" ]; then  if [ "$1" = "--help" ]; then
4      echo "$0: Generate the HTML version of the Debian Installer Manual"      echo "$0: Generate the Debian Installer Manual in several different formats"
5      echo "Usage: $0 [arch] [lang] [format]"      echo "Usage: $0 [arch] [lang] [format]"
6      exit 1      echo "[format] may consist of multiple formats provided they are quoted (e.g. \"html pdf\")"
7        echo "Supported formats: html, ps, pdf, txt"
8        exit 0
9  fi  fi
10    
11  arch=${1:-i386}  arch=${1:-i386}
12  language=${2:-en}  language=${2:-en}
13  format=${3:-html}  formats=${3:-html}
14    
15  # Configuration  ## Configuration
16    basedir="$(cd "$(dirname $0)"; pwd)"
17    manual_path="$(echo $basedir | sed "s:/build$::")"
18    build_path="$manual_path/build"
19    cd $build_path
20    
21  stylesheet_dir="stylesheets"  stylesheet_dir="$build_path/stylesheets"
22  stylesheet_profile="$stylesheet_dir/style-profile.xsl"  stylesheet_profile="$stylesheet_dir/style-profile.xsl"
23  stylesheet_html="$stylesheet_dir/style-html.xsl"  stylesheet_html="$stylesheet_dir/style-html.xsl"
24    stylesheet_html_single="$stylesheet_dir/style-html-single.xsl"
25  stylesheet_fo="$stylesheet_dir/style-fo.xsl"  stylesheet_fo="$stylesheet_dir/style-fo.xsl"
26  stylesheet_dsssl="$stylesheet_dir/style-print.dsl"  stylesheet_dsssl="$stylesheet_dir/style-print.dsl"
27    
28  main_path="$PWD/`dirname $0`"  entities_path="$build_path/entities"
29  entities_path="$main_path/entities"  source_path="$manual_path/$language"
 source_path="$main_path/../../${language}"  
   
 xsltprocessor=/usr/bin/xsltproc  
30    
31  if [ -z $destination ]; then  if [ -z $destination ]; then
32      destination="results/unofficial-manual"      destination="build.out"
33  fi  fi
34    
35  tempdir=${language}.temp  tempdir="build.tmp"
36  dynamic="${tempdir}/dynamic.ent"  dynamic="${tempdir}/dynamic.ent"
37    
38    create_profiled () {
39    
40  ## Function to check result of executed programs and exit on error      [ -x /usr/bin/xsltproc ] || return 9
 checkresult () {  
     if [ ! "$1" = "0" ]; then  
         exit $1  
     fi  
 }  
41    
42  create_profiled () {      echo "Info: creating temporary profiled .xml file..."
43    
44      if [ ! "$official_build" ]; then      if [ ! "$official_build" ]; then
45          unofficial_build="FIXME;unofficial-build"          unofficial_build="FIXME;unofficial-build"
# Line 47  create_profiled () { Line 47  create_profiled () {
47          unofficial_build=""          unofficial_build=""
48      fi      fi
49    
50      ## Now we source the profiling information for the selected architecture      # Now we source the profiling information for the selected architecture
51      if [ ! -f arch-options/${arch} ]      [ -f arch-options/${arch} ] || {
52      then          echo "Error: unknown architecture $arch!"
53          echo "Unknown architecture ${arch}! Please elaborate."          return 1
54          exit 1 ;      }
55      fi      . arch-options/$arch
     . arch-options/${arch}  
56    
57      ## Join all architecture options into one big variable      # Join all architecture options into one big variable
58      condition="$fdisk;$network;$boot;$smp;$other;$goodies;$unofficial_build;$status"      condition="$fdisk;$network;$boot;$smp;$other;$goodies;$unofficial_build;$status"
59    
60      ## Write dynamic non-profilable entities into the file      # Write dynamic non-profilable entities into the file
61      echo "<!-- arch- and lang-specific non-profilable entities -->" > $dynamic      echo "<!-- arch- and lang-specific non-profilable entities -->" > $dynamic
62      echo "<!ENTITY langext \".${language}\">" >> $dynamic      echo "<!ENTITY langext \".${language}\">" >> $dynamic
63      echo "<!ENTITY architecture \"${arch}\">" >> $dynamic      echo "<!ENTITY architecture \"${arch}\">" >> $dynamic
# Line 66  create_profiled () { Line 65  create_profiled () {
65      echo "<!ENTITY altkernelversion \"${altkernelversion}\">" >> $dynamic      echo "<!ENTITY altkernelversion \"${altkernelversion}\">" >> $dynamic
66    
67      sed "s:##SRCPATH##:$source_path:" templates/docstruct.ent >> $dynamic      sed "s:##SRCPATH##:$source_path:" templates/docstruct.ent >> $dynamic
68      sed "s/##LANG##/$language/g" templates/install.xml.template | \      sed "s:##LANG##:$language:g" templates/install.xml.template | \
69        sed "s:##TEMPDIR##:$tempdir:g" | \
70      sed "s:##ENTPATH##:$entities_path:g" | \      sed "s:##ENTPATH##:$entities_path:g" | \
71      sed "s:##SRCPATH##:$source_path:" > $tempdir/install.${language}.xml      sed "s:##SRCPATH##:$source_path:" > $tempdir/install.${language}.xml
72    
73      ## Create the profiles xml file      # Create the profiled xml file
74      $xsltprocessor \      /usr/bin/xsltproc \
75          --xinclude \          --xinclude \
76          --stringparam profile.arch "$archspec" \          --stringparam profile.arch "$archspec" \
77          --stringparam profile.condition "$condition" \          --stringparam profile.condition "$condition" \
78          --output $tempdir/install.${language}.profiled.xml \          --output $tempdir/install.${language}.profiled.xml \
79          $stylesheet_profile \          $stylesheet_profile \
80          $tempdir/install.${language}.xml          $tempdir/install.${language}.xml
81        RET=$?; [ $RET -ne 0 ] && return $RET
     checkresult $?  
82    
83        return 0
84  }  }
85    
86  create_html () {  create_html () {
87    
88      create_profiled      echo "Info: creating .html files..."
89    
90      $xsltprocessor \      /usr/bin/xsltproc \
91          --xinclude \          --xinclude \
92          --stringparam base.dir ./$basedir/html/ \          --stringparam base.dir $destination/html/ \
93          $stylesheet_html \          $stylesheet_html \
94          $tempdir/install.${language}.profiled.xml          $tempdir/install.${language}.profiled.xml
95        RET=$?; [ $RET -ne 0 ] && return $RET
96    
97      checkresult $?      return 0
98    }
99    
100    create_text () {
101    
102        [ -x /usr/bin/w3m ] || return 9
103    
104        echo "Info: creating temporary .html file..."
105    
106        /usr/bin/xsltproc \
107            --xinclude \
108            --output $tempdir/install.${language}.html \
109            $stylesheet_html_single \
110            $tempdir/install.${language}.profiled.xml
111        RET=$?; [ $RET -ne 0 ] && return $RET
112    
113        # Replace some unprintable characters
114        sed "s:\&#8211;:-:g        # n-dash
115             s:\&#8212;:--:g       # m-dash
116             s:\&#8220;:\&quot;:g  # different types of quotes
117             s:\&#8221;:\&quot;:g
118             s:\&#8222;:\&quot;:g
119             s:«\|»:\&quot;:g      # quotes in Russian translation
120             s:\&#8230;:...:g      # ellipsis
121             s:\&#8482;: (tm):g    # trademark" \
122            $tempdir/install.${language}.html >$tempdir/install.${language}.corr.html
123        RET=$?; [ $RET -ne 0 ] && return $RET
124    
125        echo "Info: creating .txt file..."
126    
127        # Set encoding for output file
128        case $language in
129            cs)
130                CHARSET=ISO-8859-2
131                ;;
132            ja)
133                CHARSET=EUC-JP
134                ;;
135            ru)
136                CHARSET=KOI8-R
137                ;;
138            *)
139                CHARSET=ISO-8859-1
140                ;;
141        esac
142    
143        /usr/bin/w3m -dump $tempdir/install.${language}.corr.html \
144            -o display_charset=$CHARSET \
145            >$destination/install.${language}.txt
146        RET=$?; [ $RET -ne 0 ] && return $RET
147    
148        return 0
149  }  }
150    
151  create_dvi ()  {  create_dvi () {
152    
153      create_profiled      [ -x /usr/bin/openjade ] || return 9
154          # And use openjade to convert generate a .tex file      [ -x /usr/bin/jadetex ] || return 9
155          export SP_ENCODING="utf-8"  
156          openjade -t tex \      # Skip this step if the .dvi file already exists
157                  -b utf-8 \      [ -f $tempdir/install.${language}.dvi ] && return
158                  -o $tempdir/install.${language}.tex \  
159                  -d $stylesheet_dsssl \      echo "Info: creating temporary .tex file..."
160                  -V tex-backend \  
161                  $tempdir/install.${language}.profiled.xml      # And use openjade to generate a .tex file
162        export SP_ENCODING="utf-8"
163          # Next we use jadetext to generate a .dvi file      /usr/bin/openjade -t tex \
164          # This needs three passes to properly generate the index (pagenumbering)          -b utf-8 \
165            -o $tempdir/install.${language}.tex \
166          cd $tempdir          -d $stylesheet_dsssl \
167          jadetex install.${language}.tex >/dev/null          -V tex-backend \
168          jadetex install.${language}.tex >/dev/null          $tempdir/install.${language}.profiled.xml
169          jadetex install.${language}.tex >/dev/null      RET=$?
170          cd ..      if [ $RET -eq 1 ] && [ -s $tempdir/install.${language}.tex ] ; then
171            echo "Warning: recieved error $RET from 'openjade'; probably non-fatal so ignoring."
172        else
173            [ $RET -ne 0 ] && return $RET
174        fi
175    
176        echo "Info: creating temporary .dvi file..."
177    
178        # Next we use jadetext to generate a .dvi file
179        # This needs three passes to properly generate the index (page numbering)
180        cd $tempdir
181        for PASS in 1 2 3 ; do
182            /usr/bin/jadetex install.${language}.tex >/dev/null
183            RET=$?; [ $RET -ne 0 ] && break
184        done
185        cd ..
186        [ $RET -ne 0 ] && return $RET
187    
188        return 0
189  }  }
190    
191  create_pdf() {  create_pdf() {
192    
193      create_profiled      [ -x /usr/bin/dvipdf ] || return 9
194    
195      create_dvi      create_dvi
196      mkdir -p $basedir/pdf      RET=$?; [ $RET -ne 0 ] && return $RET
197      dvipdf $tempdir/install.${language}.dvi  
198      mv install.${language}.pdf $basedir/pdf      echo "Info: creating .pdf file..."
199    
200        /usr/bin/dvipdf $tempdir/install.${language}.dvi
201        RET=$?; [ $RET -ne 0 ] && return $RET
202        mv install.${language}.pdf $destination/
203    
204        return 0
205  }  }
206    
207  create_ps() {  create_ps() {
208    
209      create_profiled      [ -x /usr/bin/dvips ] || return 9
210    
211      create_dvi      create_dvi
212      mkdir -p $basedir/ps      RET=$?; [ $RET -ne 0 ] && return $RET
213      dvips $tempdir/install.${language}.dvi  
214      mv install.${language}.ps $basedir/ps      echo "Info: creating .ps file..."
215    
216        /usr/bin/dvips -q $tempdir/install.${language}.dvi
217        RET=$?; [ $RET -ne 0 ] && return $RET
218        mv install.${language}.ps $destination/
219    
220        return 0
221  }  }
222    
223  mkdir -p $tempdir  ## MAINLINE
224    
225  basedir=$destination/${language}/${arch}  # Clean old builds
226    rm -rf $tempdir
227    rm -rf $destination
228    
229  case ${format} in  [ -d $manual_path/$language ] || {
230        echo "Error: unknown language $language"
231        exit 1
232    }
233    
234      html) create_html;;  mkdir -p $tempdir
235      ps)   create_ps;;  mkdir -p $destination
236      pdf)  create_pdf;;  
237      *) echo "Format unknown or not supported yet!";;  # Create profiled XML. This is needed for all output formats.
238    create_profiled
239    RET=$?; [ $RET -ne 0 ] && exit 1
240    
241    BUILD_OK=""
242    BUILD_FAIL=""
243    for format in $formats ; do
244        if [ "$language" = "ja" ] && [ "$format" = "pdf" -o "$format" = "ps" ] ; then
245            echo "Warning: pdf and ps formats are currently not supported for Japanese"
246            BUILD_SKIP="$BUILD_SKIP $format"
247            continue
248        fi
249    
250  esac      case $format in
251            html)  create_html;;
252            ps)    create_ps;;
253            pdf)   create_pdf;;
254            txt)   create_text;;
255            *)
256                echo "Error: format $format unknown or not yet supported!"
257                exit 1
258                ;;
259        esac
260    
261        RET=$?
262        case $RET in
263            0)
264                BUILD_OK="$BUILD_OK $format"
265                ;;
266            9)
267                BUILD_FAIL="$BUILD_FAIL $format"
268                echo "Error: build of $format failed because of missing build dependencies"
269                ;;
270            *)
271                BUILD_FAIL="$BUILD_FAIL $format"
272                echo "Error: build of $format failed with error code $RET"
273                ;;
274        esac
275    done
276    
277    # Clean up
278    rm -r $tempdir
279    
280    # Evaluate the overall results
281    [ -n "$BUILD_SKIP" ] && echo "Info: The following formats were skipped:$BUILD_SKIP"
282    [ -z "$BUILD_FAIL" ] && exit 0            # Build successful for all formats
283    echo "Warning: The following formats failed to build:$BUILD_FAIL"
284    [ -n "$BUILD_OK" ] && exit 2              # Build failed for some formats
285    exit 1                                    # Build failed for all formats

Legend:
Removed from v.22882  
changed lines
  Added in v.24223

  ViewVC Help
Powered by ViewVC 1.1.5