/[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 24560 by fjpop-guest, Fri Dec 24 20:31:30 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 "$destdir" ]; then
32      destination="results/unofficial-manual"      destdir="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
64      echo "<!ENTITY kernelversion \"${kernelversion}\">" >> $dynamic      echo "<!ENTITY kernelversion \"${kernelversion}\">" >> $dynamic
65      echo "<!ENTITY altkernelversion \"${altkernelversion}\">" >> $dynamic      echo "<!ENTITY altkernelversion \"${altkernelversion}\">" >> $dynamic
   
66      sed "s:##SRCPATH##:$source_path:" templates/docstruct.ent >> $dynamic      sed "s:##SRCPATH##:$source_path:" templates/docstruct.ent >> $dynamic
     sed "s/##LANG##/$language/g" templates/install.xml.template | \  
     sed "s:##ENTPATH##:$entities_path:g" | \  
     sed "s:##SRCPATH##:$source_path:" > $tempdir/install.${language}.xml  
   
     ## Create the profiles xml file  
     $xsltprocessor \  
         --xinclude \  
         --stringparam profile.arch "$archspec" \  
         --stringparam profile.condition "$condition" \  
         --output $tempdir/install.${language}.profiled.xml \  
         $stylesheet_profile \  
         $tempdir/install.${language}.xml  
67    
68      checkresult $?      sed "s:##LANG##:$language:g" templates/install.xml.template | \
69            sed "s:##TEMPDIR##:$tempdir:g" | \
70            sed "s:##ENTPATH##:$entities_path:g" | \
71            sed "s:##SRCPATH##:$source_path:" > $tempdir/install.${language}.xml
72    
73        # Create the profiled xml file
74        /usr/bin/xsltproc \
75            --xinclude \
76            --stringparam profile.arch "$archspec" \
77            --stringparam profile.condition "$condition" \
78            --output $tempdir/install.${language}.profiled.xml \
79            $stylesheet_profile \
80            $tempdir/install.${language}.xml
81        RET=$?; [ $RET -ne 0 ] && return $RET
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 $destdir/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        return 0
98    }
99    
100      checkresult $?  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:–:-:g        # n-dash
115             s:—:--:g       # m-dash
116             s:“:\&quot;:g  # different types of quotes
117             s:”:\&quot;:g
118             s:„:\&quot;:g
119             s:…:...:g      # ellipsis
120             s:™: (tm):g    # trademark" \
121            $tempdir/install.${language}.html >$tempdir/install.${language}.corr.html
122        RET=$?; [ $RET -ne 0 ] && return $RET
123    
124        echo "Info: creating .txt file..."
125    
126        # Set encoding for output file
127        case "$language" in
128            cs)
129                CHARSET=ISO-8859-2
130                ;;
131            ja)
132                CHARSET=EUC-JP
133                ;;
134            ru)
135                CHARSET=KOI8-R
136                ;;
137            *)
138                CHARSET=ISO-8859-1
139                ;;
140        esac
141    
142        /usr/bin/w3m -dump $tempdir/install.${language}.corr.html \
143            -o display_charset=$CHARSET \
144            >$destdir/install.${language}.txt
145        RET=$?; [ $RET -ne 0 ] && return $RET
146    
147        return 0
148  }  }
149    
150  create_dvi ()  {  create_dvi () {
151    
152      create_profiled      [ -x /usr/bin/openjade ] || return 9
153          # And use openjade to convert generate a .tex file      [ -x /usr/bin/jadetex ] || return 9
154          export SP_ENCODING="utf-8"  
155          openjade -t tex \      # Skip this step if the .dvi file already exists
156                  -b utf-8 \      [ -f "$tempdir/install.${language}.dvi" ] && return
157                  -o $tempdir/install.${language}.tex \  
158                  -d $stylesheet_dsssl \      echo "Info: creating temporary .tex file..."
159                  -V tex-backend \  
160                  $tempdir/install.${language}.profiled.xml      # And use openjade to generate a .tex file
161        export SP_ENCODING="utf-8"
162          # Next we use jadetext to generate a .dvi file      /usr/bin/openjade -t tex \
163          # This needs three passes to properly generate the index (pagenumbering)          -b utf-8 \
164            -o $tempdir/install.${language}.tex \
165          cd $tempdir          -d $stylesheet_dsssl \
166          jadetex install.${language}.tex >/dev/null          -V tex-backend \
167          jadetex install.${language}.tex >/dev/null          $tempdir/install.${language}.profiled.xml
168          jadetex install.${language}.tex >/dev/null      RET=$?
169          cd ..      if [ $RET -eq 1 ] && [ -s $tempdir/install.${language}.tex ] ; then
170            echo "Warning: recieved error $RET from 'openjade'; probably non-fatal so ignoring."
171        else
172            [ $RET -ne 0 ] && return $RET
173        fi
174    
175        echo "Info: creating temporary .dvi file..."
176    
177        # Next we use jadetext to generate a .dvi file
178        # This needs three passes to properly generate the index (page numbering)
179        cd $tempdir
180        for PASS in 1 2 3 ; do
181            /usr/bin/jadetex install.${language}.tex >/dev/null
182            RET=$?; [ $RET -ne 0 ] && break
183        done
184        cd ..
185        [ $RET -ne 0 ] && return $RET
186    
187        return 0
188  }  }
189    
190  create_pdf() {  create_pdf() {
191    
192      create_profiled      [ -x /usr/bin/dvipdf ] || return 9
193    
194      create_dvi      create_dvi
195      mkdir -p $basedir/pdf      RET=$?; [ $RET -ne 0 ] && return $RET
196      dvipdf $tempdir/install.${language}.dvi  
197      mv install.${language}.pdf $basedir/pdf      echo "Info: creating .pdf file..."
198    
199        /usr/bin/dvipdf $tempdir/install.${language}.dvi
200        RET=$?; [ $RET -ne 0 ] && return $RET
201        mv install.${language}.pdf $destdir/
202    
203        return 0
204  }  }
205    
206  create_ps() {  create_ps() {
207    
208      create_profiled      [ -x /usr/bin/dvips ] || return 9
209    
210      create_dvi      create_dvi
211      mkdir -p $basedir/ps      RET=$?; [ $RET -ne 0 ] && return $RET
212      dvips $tempdir/install.${language}.dvi  
213      mv install.${language}.ps $basedir/ps      echo "Info: creating .ps file..."
214    
215        /usr/bin/dvips -q $tempdir/install.${language}.dvi
216        RET=$?; [ $RET -ne 0 ] && return $RET
217        mv install.${language}.ps $destdir/
218    
219        return 0
220  }  }
221    
222  mkdir -p $tempdir  ## MAINLINE
223    
224  basedir=$destination/${language}/${arch}  # Clean old builds
225    rm -rf $tempdir
226    rm -rf $destdir
227    
228  case ${format} in  [ -d "$manual_path/$language" ] || {
229        echo "Error: unknown language '$language'"
230        exit 1
231    }
232    
233      html) create_html;;  mkdir -p $tempdir
234      ps)   create_ps;;  mkdir -p $destdir
235      pdf)  create_pdf;;  
236      *) echo "Format unknown or not supported yet!";;  # Create profiled XML. This is needed for all output formats.
237    create_profiled
238    RET=$?; [ $RET -ne 0 ] && exit 1
239    
240    BUILD_OK=""
241    BUILD_FAIL=""
242    for format in $formats ; do
243        if [ "$language" = "ja" ] && [ "$format" = "pdf" -o "$format" = "ps" ] ; then
244            echo "Warning: pdf and ps formats are currently not supported for Japanese"
245            BUILD_SKIP="$BUILD_SKIP $format"
246            continue
247        fi
248    
249  esac      case $format in
250            html)  create_html;;
251            ps)    create_ps;;
252            pdf)   create_pdf;;
253            txt)   create_text;;
254            *)
255                echo "Error: format $format unknown or not yet supported!"
256                exit 1
257                ;;
258        esac
259    
260        RET=$?
261        case $RET in
262            0)
263                BUILD_OK="$BUILD_OK $format"
264                ;;
265            9)
266                BUILD_FAIL="$BUILD_FAIL $format"
267                echo "Error: build of $format failed because of missing build dependencies"
268                ;;
269            *)
270                BUILD_FAIL="$BUILD_FAIL $format"
271                echo "Error: build of $format failed with error code $RET"
272                ;;
273        esac
274    done
275    
276    # Clean up
277    rm -r $tempdir
278    
279    # Evaluate the overall results
280    [ -n "$BUILD_SKIP" ] && echo "Info: The following formats were skipped:$BUILD_SKIP"
281    [ -z "$BUILD_FAIL" ] && exit 0            # Build successful for all formats
282    echo "Warning: The following formats failed to build:$BUILD_FAIL"
283    [ -n "$BUILD_OK" ] && exit 2              # Build failed for some formats
284    exit 1                                    # Build failed for all formats

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

  ViewVC Help
Powered by ViewVC 1.1.5