~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to packages/win32-innosetup/tools/mk_svndoc.pl

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!perl
 
2
##########################################################################
 
3
# FILE       mk_svndoc
 
4
# PURPOSE    Making MS HTML-help from the Subversion source documentation
 
5
# ====================================================================
 
6
# Copyright (c) 2000-2005 CollabNet.  All rights reserved.
 
7
#
 
8
# This software is licensed as described in the file COPYING, which
 
9
# you should have received as part of this distribution.  The terms
 
10
# are also available at http://subversion.tigris.org/license-1.html.
 
11
# If newer versions of this license are posted there, you may use a
 
12
# newer version instead, at your option.
 
13
#
 
14
# This software consists of voluntary contributions made by many
 
15
# individuals.  For exact contribution history, see the revision
 
16
# history and logs, available at http://subversion.tigris.org/.
 
17
# ====================================================================
 
18
 
 
19
##########################################################################
 
20
# INCLUDED LIBRARY FILES
 
21
use strict;
 
22
use File::Basename;
 
23
use Cwd;
 
24
use Win32;
 
25
require 'cmn.pl';
 
26
 
 
27
##########################################################################
 
28
# FUNCTION DECLARATIONS
 
29
sub Main;
 
30
sub CheckForProgs;
 
31
sub CopyAndEolU2W;
 
32
sub MkDirP;
 
33
 
 
34
##########################################################################
 
35
# CONSTANTS AND GLOBAL VARIABLES
 
36
# Sorces and destinations
 
37
my $g_PathDocRoot=&cmn_ValuePathfile('path_svnbook');
 
38
my $g_PathMiscIn=&cmn_ValuePathfile('path_setup_in');
 
39
my %g_FilesToCpAndConv=
 
40
    (
 
41
        'COPYING', 'subversion\SubversionLicense.txt',
 
42
        'README', 'subversion\Readme.dist',
 
43
        'doc\user\lj_article.txt', 'doc\lj_article.txt',
 
44
        'doc\programmer\WritingChangeLogs.txt', 'doc\WritingChangeLogs.txt', 
 
45
    );
 
46
 
 
47
# Programs needed for making the documentation
 
48
my $g_Prog_hhc='';
 
49
my %g_ProgsInPath=
 
50
    (
 
51
        'libxslt is needed for converting the XML-documentaion.',
 
52
            'xsltproc.exe',
 
53
        'iconv is needed by libxslt and libxslt for converting the XML-documentaion.',
 
54
            'iconv.exe',
 
55
        'libxml2 is needed by libxslt for converting the XML-documentaion.',
 
56
            'libxml2.dll'
 
57
    );
 
58
 
 
59
##########################################################################
 
60
# PROGRAM ENTRANCE
 
61
Main;
 
62
 
 
63
##########################################################################
 
64
# FUNCTION DEFINITIONS
 
65
#-------------------------------------------------------------------------
 
66
# FUNCTION   Main
 
67
# DOES       This is the program's main function
 
68
sub Main
 
69
{
 
70
    my $CntMkHtmBat='';
 
71
    my %Values;
 
72
    my $RootSvnBook=&cmn_ValuePathfile('path_svnbook');
 
73
    my $DocOut=&cmn_ValuePathfile('path_setup_in');
 
74
    my $PathWinIsPack='';
 
75
    my $Pwd='';
 
76
    my $CntVerXml='';
 
77
 
 
78
    # Get absolute path of the current PWD's parent
 
79
    $PathWinIsPack=getcwd;
 
80
    $Pwd=basename($PathWinIsPack);
 
81
    $PathWinIsPack =~ s/\//\\/g;
 
82
    $PathWinIsPack =~ s/\\$Pwd$//;
 
83
 
 
84
    # Make $DocOut to an absolute path
 
85
    if ($DocOut eq 'in')
 
86
      {
 
87
        $DocOut = "$PathWinIsPack\\in\\doc";
 
88
      }
 
89
 
 
90
    #Make the out dir in "$RootSvnBook\src if needed
 
91
    &MkDirP ("$RootSvnBook\\src\\out") unless (-e "$RootSvnBook\\src\\out");
 
92
 
 
93
    #Check for needed programs
 
94
    &CheckForProgs;
 
95
    &CopyAndEolU2W;
 
96
 
 
97
    #Create the mk_htmlhelp.bat file from ..\templates\\mk_htmlhelp.bat and
 
98
    #collected data, save it to $RootSvnBook\src\out\mk_htmlhelp.bat
 
99
    %Values =
 
100
      (
 
101
        tv_path_hhc => $g_Prog_hhc,
 
102
        tv_bookdest => $DocOut
 
103
      );
 
104
 
 
105
    $CntMkHtmBat=&cmn_Template("$PathWinIsPack\\templates\\mk_htmlhelp.bat", \%Values);
 
106
 
 
107
    open (FH_HHP, ">" . "$RootSvnBook\\src\\out\\mk_htmlhelp.bat");
 
108
        print FH_HHP $CntMkHtmBat;
 
109
    close (FH_HHP);
 
110
 
 
111
    #Copy style sheet and background image to $RootSvnBook\src\out
 
112
    system ("copy /Y ..\\templates\\svn-doc.css $RootSvnBook\\src\\out");
 
113
    system ("copy /Y ..\\images\\svn_bck.png $RootSvnBook\\src\\out");
 
114
 
 
115
    # Set the revision number in $RootSvnBook\src\en\book\version.xml
 
116
    chdir "$RootSvnBook\\src\\en";
 
117
    $CntVerXml=`svnversion .`;
 
118
    chomp($CntVerXml);
 
119
 
 
120
    open (FH_VERXML, ">" . "$RootSvnBook\\src\\en\\book\\version.xml");
 
121
        print FH_VERXML "<!ENTITY svn.version \"Revision $CntVerXml\">";
 
122
    close (FH_VERXML);
 
123
 
 
124
    # Make the chm file
 
125
    chdir "$RootSvnBook\\src\\out";
 
126
    system ("$RootSvnBook\\src\\out\\mk_htmlhelp.bat");
 
127
    chdir $Pwd;
 
128
}
 
129
 
 
130
#-------------------------------------------------------------------------
 
131
# FUNCTION   CheckForProgs
 
132
# DOES       Checking if required programs exists
 
133
sub CheckForProgs
 
134
{
 
135
    my @MissingProgs;
 
136
    my @SysPath;
 
137
    my $bMissingProgs=0;
 
138
    my $Prog2CheckDesc='';
 
139
    my $Prog2Check='';
 
140
 
 
141
    # Fill the %PATH% in @SysPath
 
142
    @SysPath = split (/;/, $ENV{PATH});
 
143
 
 
144
    # Check for the needed programs who should be in the %PATH%
 
145
    while (($Prog2CheckDesc, $Prog2Check) = each %g_ProgsInPath)
 
146
      {
 
147
        my $bProg2CheckExists=0;
 
148
 
 
149
        for (@SysPath)
 
150
          {
 
151
            if (-e "$_\\$Prog2Check")
 
152
              {
 
153
                $bProg2CheckExists=1;
 
154
                last;
 
155
              }
 
156
          }
 
157
 
 
158
        if (! $bProg2CheckExists)
 
159
          {
 
160
            $bMissingProgs = 1;
 
161
            push @MissingProgs, $Prog2CheckDesc;
 
162
          }
 
163
      }
 
164
 
 
165
    # Check for MS HTML help compiler
 
166
    $g_Prog_hhc = &cmn_ValuePathfile('path_hhc');
 
167
    $g_Prog_hhc = "$g_Prog_hhc\\hhc.exe";
 
168
 
 
169
    if (! -e $g_Prog_hhc)
 
170
      {
 
171
        $bMissingProgs = 1;
 
172
        push @MissingProgs, 'Microsoft HTML Help Workshop is needed for making the HTML-help file';
 
173
      }
 
174
    $g_Prog_hhc = "\"$g_Prog_hhc\"";
 
175
 
 
176
    if ($bMissingProgs)
 
177
      {
 
178
        my $Msg="One or more required programs needed for making the docs are missing:\n\n";
 
179
   
 
180
        for (@MissingProgs)
 
181
          {
 
182
            $Msg=$Msg . "  - $_\n";
 
183
          }
 
184
          
 
185
          $Msg=$Msg . "\nPlease, check that everything are installed properly as described in\n";
 
186
          $Msg=$Msg . "the documentation in packages\\win32-innosetup\\tools\\readme.txt\n";
 
187
          Win32::MsgBox($Msg, 0+MB_ICONSTOP, 'ERROR: Missing required programs.');
 
188
          exit 1;
 
189
      }
 
190
}
 
191
 
 
192
#-------------------------------------------------------------------------
 
193
# FUNCTION   CopyAndEolU2W
 
194
# DOES       Converts Unix eol's to Windows eol's in a file and saves it to
 
195
#            another location.
 
196
sub CopyAndEolU2W
 
197
{
 
198
    my $FileSrc='';
 
199
    my $FileDest='';
 
200
    my $FileCnt='';
 
201
 
 
202
    while (($FileSrc, $FileDest) = each %g_FilesToCpAndConv)
 
203
      {
 
204
        $FileSrc = "$g_PathDocRoot\\$FileSrc";
 
205
        $FileDest = "$g_PathMiscIn\\$FileDest";
 
206
        print "Copying and converting EOL's from $FileSrc to $FileDest\n";
 
207
 
 
208
        open (FH_SRC, $FileSrc);
 
209
            while (<FH_SRC>)
 
210
              {
 
211
                chomp($_);
 
212
                $_ = "$_\r\n";
 
213
                
 
214
                if ($FileCnt)
 
215
                  {
 
216
                    $FileCnt = $FileCnt . $_;
 
217
                  }
 
218
                else
 
219
                  {
 
220
                    $FileCnt = $_;
 
221
                  }
 
222
              }
 
223
         close (FH_SRC);
 
224
 
 
225
        open (FH_DEST, ">" . $FileDest);
 
226
            print FH_DEST $FileCnt;
 
227
        close (FH_DEST);
 
228
 
 
229
        $FileCnt='';
 
230
      }
 
231
}
 
232
 
 
233
#-------------------------------------------------------------------------
 
234
# FUNCTION   MkDirP
 
235
# DOES       Making a directory. Similar to unix's mkdir -p
 
236
sub MkDirP
 
237
{
 
238
    my $Dir=$_[0];
 
239
    my @SubPaths;
 
240
 
 
241
    
 
242
    
 
243
    if (! -e $Dir)
 
244
      {
 
245
        @SubPaths = split (/\\/, $Dir);
 
246
        my $Dir2Make='';
 
247
        for (@SubPaths)
 
248
          {
 
249
            if ($Dir2Make)
 
250
              {
 
251
                $Dir2Make = "$Dir2Make\\$_";
 
252
              }
 
253
            else
 
254
              {
 
255
                $Dir2Make = $_;
 
256
              }
 
257
 
 
258
            if (! -e $Dir2Make)
 
259
              {
 
260
                system ("mkdir $Dir2Make");
 
261
              }
 
262
          }
 
263
      }
 
264
}