]> Pileus Git - ~andy/gtk/blob - docs/tutorial/package-db-tutorial.sh
create split package files
[~andy/gtk] / docs / tutorial / package-db-tutorial.sh
1 #! /bin/sh
2 # package-db-tutorial.sh - Package up the tutorial into various formats
3 # Copyright (C) Tony Gale 2000-2002
4 # Contact: gale@gtk.org
5 #
6 # NOTE: This script requires the following to be installed:
7 #            o DocBook
8 #            o DocBook-Utils
9 #            o Jade
10 #            o Jadetex
11
12 TARGETDIR=`pwd`/2.0/
13
14 SOURCE=`pwd`/gtk-tut.sgml
15 IMAGES="`pwd`/images"
16 IMAGESDIR="images"
17 EXAMPLES=`pwd`/../../examples
18
19 DATE=`date '+%Y%m%d'`
20 BUILDDIR=gtk-tutorial.$DATE
21
22 PATH=`pwd`:$PATH
23
24 # Check target directory
25 if [ ! -d $TARGETDIR ]; then
26   if [ -e $TARGETDIR ]; then
27     echo "ERROR: target directory is not a directory"
28     exit
29   fi
30   if ! mkdir $TARGETDIR; then
31     echo "mkdir for target directory failed"
32     exit
33   fi
34 fi
35
36 # Check top level build directory
37 if [ ! -d $BUILDDIR ]; then
38   if [ -e $BUILDDIR ]; then
39     echo "ERROR: build directory is not a directory"
40     exit
41   fi
42   if ! mkdir $BUILDDIR; then
43     echo "mkdir of build directory failed"
44     exit 1
45   fi
46 fi 
47
48 if ! cd $BUILDDIR; then
49   echo "cd to build directory failed"
50   exit 1
51 fi
52
53 cp $SOURCE .
54 cp -R $IMAGES .
55
56 # SGML Format
57 echo -n "Copy SGML and images.... "
58 if [ ! -d gtk-tutorial.sgml ]; then
59   if [ -e gtk-tutorial.sgml ]; then
60     echo "ERROR: gtk-tutorial.sgml is not a directory"
61     exit
62   fi
63   mkdir gtk-tutorial.sgml
64 fi
65
66 (cd gtk-tutorial.sgml && cp $SOURCE . && cp -R $IMAGES . && rm -rf $IMAGESDIR/CVS)
67 tar cvfz $TARGETDIR/gtk-tutorial.sgml.tgz gtk-tutorial.sgml
68 echo "done"
69
70 # HTML Format
71 echo -n "Formatting into HTML.... " 
72 if [ ! -d gtk-tutorial.html ]; then
73   if [ -e gtk-tutorial.html ]; then
74     echo "ERROR: gtk-tutorial.html is not a directory"
75     exit
76   fi
77   mkdir gtk-tutorial.html
78 fi
79
80 (db2html -o gtk-tutorial.html $SOURCE && cp -R $IMAGES gtk-tutorial.html && rm gtk-tutorial.html/$IMAGESDIR/*.eps) > /dev/null
81 (cd gtk-tutorial.html && rm -rf $IMAGESDIR/CVS && ln -s book1.html index.html)
82 tar cvfz $TARGETDIR/gtk-tutorial.html.tgz gtk-tutorial.html
83 echo "done"
84
85 # PS and PDF Format
86 echo -n "Formatting into PS and PDF.... "
87 if [ ! -d gtk-tutorial.ps ]; then
88   if [ -e gtk-tutorial.ps ]; then
89     echo "ERROR: gtk-tutorial.ps is not a directory"
90     exit
91   fi
92   mkdir gtk-tutorial.ps
93 fi
94
95 if [ ! -d gtk-tutorial.pdf ]; then
96   if [ -e gtk-tutorial.pdf ]; then
97     echo "ERROR: gtk-tutorial.pdf is not a directory"
98     exit
99   fi
100   mkdir gtk-tutorial.pdf
101 fi
102
103 sed "s/images\/\(.*\)\.png/images\/\1.eps/g" $SOURCE > gtk-tutorial.ps/gtk-tut.sgml
104 cp -R $IMAGES gtk-tutorial.ps
105 (cd gtk-tutorial.ps && db2dvi gtk-tut.sgml && dvips gtk-tut.dvi -o gtk-tut.ps && dvipdf gtk-tut.dvi ../gtk-tutorial.pdf/gtk-tut.pdf)
106 gzip -c gtk-tutorial.ps/gtk-tut.ps > $TARGETDIR/gtk-tutorial.ps.gz
107 gzip -c gtk-tutorial.pdf/gtk-tut.pdf > $TARGETDIR/gtk-tutorial.pdf.gz
108 echo "done"
109
110 # RTF Format
111 #echo -n "Formatting into RTF.... "
112 #if [ ! -d gtk-tutorial.rtf ]; then
113 #  if [ -e gtk-tutorial.rtf ]; then
114 #    echo "ERROR:  is not a directory"
115 #    exit
116 #  fi
117 #  mkdir gtk-tutorial.rtf
118 #fi
119
120 #cp -R $IMAGES gtk-tutorial.rtf
121 #(cd gtk-tutorial.rtf && db2rtf $SOURCE) # > /dev/null
122 #gzip -c gtk-tutorial.rtf/gtk-tut.rtf > $TARGETDIR/gtk-tutorial.rtf.gz
123 #echo "done"
124
125 # Copy examples
126 echo -n "Copying examples"
127 cp -R $EXAMPLES .
128 (cd examples && make clean && rm -rf CVS */CVS */.cvsignore README.1ST extract.awk extract.sh find-examples.sh)
129 tar cfz $TARGETDIR/examples.tgz examples
130 echo "done"
131
132 cd ..
133 rm -rf $BUILDDIR
134
135 echo
136 echo Packages created.
137 echo