00001 #!c:/perl/bin/perl.exe -w
00002 ##############################################################################
00003 ### =file
00004 ### win32-packager.pl
00005 ###
00006 ### =location
00007 ### http://svn.mythtv.org/svn/trunk/mythtv/contrib/Win32/win32-packager.pl
00008 ###
00009 ### =description
00010 ### Tool for automating frontend builds on MS Windows XP (and compatible)
00011 ### originally based loosely on osx-packager.pl, but now is its own beast.
00012 ###
00013 ### =revision
00014 ### $Id: win32-packager.pl 17459 2008-06-12 03:09:18Z nigel $
00015 ###
00016 ### =author
00017 ### David Bussenschutt
00018 ##############################################################################
00019
00020 use strict;
00021 use LWP::UserAgent;
00022 use IO::File;
00023 use Data::Dumper;
00024 use File::Copy qw(cp);
00025
00026 my $NOISY = 1; # set to 0 for less output to the screen
00027
00028 $| = 1; # autoflush stdout;
00029
00030 # this scipt was last tested to work with this version, on other versions YMMV.
00031 #my $SVNRELEASE = '15528'; #builds and runs with 3x patches commented out below
00032 #my $SVNRELEASE = '15586'; # builds and runs without patches except backend.gz
00033 my $SVNRELEASE = '15699'; # latest build that seemed to run without any additional patches, YMMV.
00034 #my $SVNRELEASE = 'HEAD' ;# if you are game, go forth and test the latest release!
00035
00036 # We allow SourceForge to tell us which server to download from,
00037 # rather than assuming specific server/s
00038 my $sourceforge = 'downloads.sourceforge.net'; # auto-redirect to a
00039 # mirror of SF's choosing,
00040 # hopefully close to you
00041 # alternatively you can choose your own mirror:
00042 #my $sourceforge = 'optusnet.dl.sourceforge.net'; # australia
00043 #my $sourceforge = 'internap.dl.sourceforge.net'; # USA,California
00044 #my $sourceforge = 'easynews.dl.sourceforge.net'; # USA,Arizona,Phoenix,
00045 #my $sourceforge = 'jaist.dl.sourceforge.net'; # Japan
00046 #my $sourceforge = 'mesh.dl.sourceforge.net'; # Germany
00047
00048 # Set this to the empty string for no-proxy:
00049 # TODO - proxy code is broken for SVN actions,
00050 # however downloads/etc will still work fine.
00051 # TODO using the proxy here WILL cause any Subversion (SVN) commands to fail,
00052 # you will need to do that by hand.
00053 # TIP if you want to get a 'tarball' of a specific SVN version of the sourcecode, from behind a non-SVN friendly proxy, TRAC can do it for you like this: (eg.is for SVN version 16599)
00054 # http://svn.mythtv.org/trac/changeset?format=zip&new=15699&old=2&new_path=trunk%2Fmythtv&old_path=trunk%2Fmythtv
00055 my $proxy = '';
00056 #my $proxy = 'http://enter.your.proxy.here:8080';
00057
00058 # TODO - use this list to define the components to build - only the first of these currently works well.
00059 my @components = ( 'mythtv', 'myththemes', 'mythplugins' );
00060
00061
00062 # TODO - we should try to autodetect these paths, rather than assuming
00063 # the defaults - perhaps from environment variables like this:
00064 # die "must have env variable SOURCES pointing to your sources folder"
00065 # unless $ENV{SOURCES};
00066 # my $sources = $ENV{SOURCES};
00067 # TODO - although theoretically possible to change these paths,
00068 # it has NOT been tested much, and will with HIGH PROBABILITY fail somewhere.
00069 # TODO - Only $mingw is tested and most likely is safe to change.
00070
00071 # Perl compatible paths. DOS style, but forward slashes, and must end in slash:
00072 my $msys = 'C:/MSys/1.0/';
00073 my $sources = 'C:/msys/1.0/sources/';
00074 my $mingw = 'C:/MinGW/';
00075 my $mythtv = 'C:/mythtv/'; # this is where the entire SVN checkout lives
00076 # so c:/mythtv/mythtv/ is the main codebase.
00077 my $build = 'C:/mythtv/build/'; # where 'make install' installs into
00078
00079 # DOS executable CMD.exe versions of the paths (for when we shell to DOS mode):
00080 my $dosmsys = perl2dos($msys);
00081 my $dossources = perl2dos($sources);
00082 my $dosmingw = perl2dos($mingw);
00083 my $dosmythtv = perl2dos($mythtv);
00084
00085 # Unix/MSys equiv. versions of the paths (for when we shell to MSYS/UNIX mode):
00086 my $unixmsys = '/'; # MSys root is always mounted here,
00087 # irrespective of where DOS says it really is.
00088 my $unixmingw = '/mingw/'; # MinGW is always mounted here under unix,
00089 # if you setup mingw right in msys,
00090 # so we will usually just say /mingw in the code,
00091 # not '.$unixmingw.' or similar (see /etc/fstab)
00092 my $unixsources = perl2unix($sources);
00093 $unixsources =~ s#$unixmsys#/#i; #strip leading msys path, if there, it's unnecessary as it's mounted under /
00094 my $unixmythtv = perl2unix($mythtv);
00095 my $unixbuild = perl2unix($build);
00096
00097
00098 #NOTE: ITS IMPORTANT that the PATHS use the correct SLASH-ing method for the type of action:
00099 # for [exec] actions, use standard DOS paths, with single BACK-SLASHES '\' (unless in double quotes, then double the backslashes)
00100 # for [shell] actions, use standard UNIX paths, with single FORWARD-SLASHES '/'
00101 #
00102 #NOTE: when refering to variables in paths, try to keep them out of double quotes, or the slashing can get confused:
00103 # [exec] actions should always refer to $dosXXX path variables
00104 # [shell] actions should always refer to $unixXXX path variables
00105 # [dir],[file],[mkdirs],[archive] actions should always refer to default perl compatible paths
00106
00107 # NOTE: The architecture of this script is based on cause-and-event.
00108 # There are a number of "causes" (or expectations) that can trigger an event/action.
00109 # There are a number of different actions that can be taken.
00110 #
00111 # eg: [ dir => "c:/MinGW", exec => $dossources.'MinGW-5.1.3.exe' ],
00112 #
00113 # means: expect there to be a dir called "c:/MinGW", and if there isn't execute the file MinGW-5.1.3.exe.
00114 # (clearly there needs to be a file MinGW-5.1.3.exe on disk for that to work, so there is an earlier declaration to 'fetch' it)
00115
00116
00117 #build expectations (causes) :
00118 # missing a file (given an expected path) [file]
00119 # missing folder [dir]
00120 # missing source archive (fancy version of 'file' to fetch from the web) [archive]
00121 # apply a perl pattern match and if it DOESNT match execute the action [grep] - this 'cause' actually needs two parameters in an array [ pattern, file]. If the file is absent, the pattern is assumed to not match (and emits a warning).
00122 # test the file/s are totally the same (by size and mtime) [filesame] - if first file is non-existant then that's permitted, it causes the action to trigger.
00123 # test the first file is newer(mtime) than the second one [newer] - if given 2 existing files, not necessarily same size/content, and the first one isn't newer, execute the action!. If the first file is ABSENT, run the action too.
00124
00125 #build actions (events) are:
00126 # fetch a file from the web (to a location) [fetch]
00127 # set an environment variable (name, value pair) not-yet-impl
00128 # execute a DOS/Win32 exe/command and wait to complete [exec]
00129 # execute a MSYS/Unix script/command in bash and wait to complete [shell]- this 'effect' actually accepts many parameters in an array [ cmd1, cmd2, etc ]
00130 # extract a .tar .tar.gz or .tar.bz2 or ,zip file ( to a location) [extract] - (note that .gz and .bz2 are thought equivalent)
00131 # write a small patch/config/script file directly to disk [write]
00132 # make directory tree upto the path specified [mkdirs]
00133 # copy a new version of a file, set mtime to the original [copy]
00134
00135 #TODO:
00136 # copy a set of files (path/filespec, destination) not-yet-impl. use exec => 'copy /Y xxx.* yyy'
00137 # apply a diff not-yet-impl use shell => 'patch -p0 < blah.patch'
00138 # search-replace text in a file not-yet-impl use grep => ['pattern',subject], exec => shell 'patch < etc to replace it'
00139
00140
00141 # NOTES on specific actions:
00142 # 'extract' now requires all paths to be perl compatible (like all other commands) If not supplied, it extracts into the folder the .tar.gz is in.
00143 # 'exec' actually runs all your commands inside a single cmd.exe command-line. To link commands use '&&'
00144 # 'shell' actually runs all your commands inside a bash shell with -c "( cmd;cmd;cmd )" so be careful about quoting.
00145
00146
00147 #------------------------------------------------------------------------------
00148 #------------------------------------------------------------------------------
00149 # DEFINE OUR EXPECTATIONS and the related ACTIONS:
00150 # - THIS IS THE GUTS OF THE APPLICATION!
00151 # - A SET OF DECLARATIONS THAT SHOULD RESULT IN A WORKING WIN32 INSTALATION
00152 #------------------------------------------------------------------------------
00153 #------------------------------------------------------------------------------
00154
00155 my $expect;
00156
00157 push @{$expect},
00158
00159 [ dir => [$sources] , mkdirs => [$sources], comment => 'We download all the files from the web, and save them here:'],
00160
00161
00162 [ archive => $sources.'MinGW-5.1.3.exe', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/MinGW-5.1.3.exe',comment => 'Get mingw and addons first, or we cant do [shell] requests!' ],
00163 #[ archive => $sources.'mingw32-make-3.81-2.tar', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/mingw32-make-3.81-2.tar.gz' ], - not needed if you select it during the MinGW install
00164 [ archive => $sources.'mingw-utils-0.3.tar.gz', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/mingw-utils-0.3.tar.gz' ],
00165
00166
00167 [ dir => $mingw, exec => $dossources.'MinGW-5.1.3.exe',comment => 'install MinGW (be sure to install g++, g77 and ming make too) - it will require user interaction, but once completed, will return control to us....' ], # interactive, supposed to install g++ and ming make too, but people forget to select them?
00168 [ file => $mingw."bin/gcc.exe", exec => $dossources.'MinGW-5.1.3.exe',comment => 'unable to gind a gcc.exe where expected, rerunning MinGW installer!' ], # interactive, supposed to install g++ and ming make too, but people forget to select them?
00169
00170 [ archive => $sources.'MSYS-1.0.10.exe', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/MSYS-1.0.10.exe',comment => 'Get the MSYS and addons:' ] ,
00171 [ archive => $sources.'bash-3.1-MSYS-1.0.11-1.tar.bz2', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/bash-3.1-MSYS-1.0.11-1.tar.bz2' ] ,
00172 [ archive => $sources.'zlib-1.2.3-MSYS-1.0.11.tar.bz2', 'fetch' => 'http://easynews.dl.sourceforge.net/sourceforge/mingw/zlib-1.2.3-MSYS-1.0.11.tar.bz2' ] ,
00173 [ archive => $sources.'coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2' ] ,
00174
00175 # install MSYS, it supplies the 'tar' executable, among others:
00176 [ file => $msys.'bin/tar.exe', exec => $dossources.'MSYS-1.0.10.exe',comment => 'Install MSYS, it supplies the tar executable, among others. You should follow prompts, AND do post-install in DOS box.' ] ,
00177
00178 # don't use the [shell] or [copy] actions here, as neither are available until bash is installed!
00179 [ file => $msys.'bin/sh2.exe', exec => 'copy /Y '.$dosmsys.'bin\sh.exe '.$dosmsys.'bin\sh2.exe',comment => 'make a copy of the sh.exe so that we can utilise it when we extract later stuff' ],
00180
00181 # prior to this point you can't use the 'extract' 'copy' or 'shell' features!
00182
00183 # if you did a default-install of MingW, then you need to try again, as we really need g++ and mingw32-make, and g77 is needed for fftw
00184 [ file => $mingw.'bin/mingw32-make.exe', exec => $dossources.'MinGW-5.1.3.exe',comment => 'Seriously? You must have done a default install of MinGW. go try again! You MUST choose the custom installed and select the mingw make, g++ and g77 optional packages.' ],
00185 [ file => $mingw.'bin/g++.exe', exec => $dossources.'MinGW-5.1.3.exe',comment => 'Seriously? You must have done a default install of MinGW. go try again! You MUST choose the custom installed and select the mingw make, g++ and g77 optional packages.' ],
00186 [ file => $mingw.'bin/g77.exe', exec => $dossources.'MinGW-5.1.3.exe',comment => 'Seriously? You must have done a default install of MinGW. go try again! You MUST choose the custom installed and select the mingw make, g++ and g77 optional packages.' ],
00187
00188 #[ file => 'C:/MinGW/bin/mingw32-make.exe', extract => $sources.'mingw32-make-3.81-2.tar',"C:/MinGW" ], - optionally we could get mingw32-make from here
00189
00190 # now that we have the 'extract' feature, we can finish ...
00191 [ file => $mingw.'/bin/reimp.exe', extract => [$sources.'mingw-utils-0.3.tar', $mingw],comment => 'Now we can finish all the mingw and msys addons:' ],
00192 [ file => $msys.'bin/bash.exe', extract => [$sources.'bash-3.1-MSYS-1.0.11-1.tar', $msys] ],
00193 [ dir => $sources.'coreutils-5.97', extract => [$sources.'coreutils-5.97-MSYS-1.0.11-snapshot.tar'] ],
00194 [ file => $msys.'bin/pr.exe', shell => ["cd ".$unixsources."coreutils-5.97","cp -r * / "] ],
00195
00196 [ dir => $msys."lib" , mkdirs => $msys.'lib' ],
00197 [ dir => $msys."include" , mkdirs => $msys.'include' ],
00198
00199 #get gdb
00200 [ archive => $sources.'gdb-6.7.50.20071127-mingw.tar.bz2', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/gdb-6.7.50.20071127-mingw.tar.bz2',comment => 'Get gdb for possible debugging later' ],
00201 [ file => $msys.'bin/gdb.exe', extract => [$sources.'gdb-6.7.50.20071127-mingw.tar.bz2', $msys] ],
00202
00203
00204 # (alternate would be from the gnuwin32 project, which is actually from same source)
00205 # run it into a 'unzip' folder, becuase it doesn't extract to a folder:
00206 [ dir => $sources."unzip" , mkdirs => $sources.'unzip',comment => 'unzip.exe - Get a precompiled native Win32 version from InfoZip' ],
00207 [ archive => $sources.'unzip/unz552xN.exe', fetch => 'ftp://tug.ctan.org/tex-archive/tools/zip/info-zip/WIN32/unz552xN.exe'],
00208 [ file => $sources.'unzip/unzip.exe', exec => 'chdir '.$dossources.'unzip && '.$dossources.'unzip/unz552xN.exe' ],
00209 # we could probably put the unzip.exe into the path...
00210
00211
00212 [ archive => $sources.'svn-win32-1.4.6.zip', fetch => 'http://subversion.tigris.org/files/documents/15/41077/svn-win32-1.4.6.zip',comment => 'Subversion comes as a zip file, so it cant be done earlier than the unzip tool!'],
00213 [ dir => $sources.'svn-win32-1.4.6', extract => $sources.'svn-win32-1.4.6.zip' ],
00214
00215
00216 [ file => $msys.'bin/svn.exe', shell => ["cp -R $unixsources/svn-win32-1.4.6/* ".$unixmsys],comment => 'put the svn.exe executable into the path, so we can use it easily later!' ],
00217
00218 # :
00219 [ dir => $sources."zlib" , mkdirs => $sources.'zlib',comment => 'the zlib download is a bit messed-up, and needs some TLC to put everything in the right place' ],
00220 [ dir => $sources."zlib/usr", extract => [$sources.'zlib-1.2.3-MSYS-1.0.11.tar', $sources."zlib"] ],
00221 # install to /usr:
00222 [ file => $msys.'lib/libz.a', exec => ["copy /Y ".$dossources.'zlib\usr\lib\* '.$dosmsys."lib"] ],
00223 [ file => $msys.'bin/msys-z.dll', exec => ["copy /Y ".$dossources.'zlib\usr\bin\* '.$dosmsys."bin"] ],
00224 [ file => $msys.'include/zlib.h', exec => ["copy /Y ".$dossources.'zlib\usr\include\* '.$dosmsys."include"] ],
00225 # taglib also requires zlib in /mingw , so we'll put it there too, why not!
00226 [ file => $mingw.'lib/libz.a', exec => ["copy /Y ".$dossources.'zlib\usr\lib\* '.$dosmingw."lib"] ],
00227 [ file => $mingw.'bin/msys-z.dll', exec => ["copy /Y ".$dossources.'zlib\usr\bin\* '. $dosmingw."bin"] ],
00228 [ file => $mingw.'include/zlib.h', exec => ["copy /Y ".$dossources.'zlib\usr\include\* '.$dosmingw."include"] ],
00229
00230
00231
00232 # fetch mysql
00233 # primary server site is: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-essential-5.0.45-win32.msi/from/http://mysql.mirrors.ilisys.com.au/
00234 [ archive => $sources.'mysql-essential-5.0.45-win32.msi', 'fetch' => 'http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.0/mysql-essential-5.0.45-win32.msi',comment => 'fetch mysql binaries - this is a big download(23MB) so it might take a while' ],
00235 [ file => "c:/Program Files/MySQL/MySQL Server 5.0/bin/libmySQL.dll", exec => $dossources.'mysql-essential-5.0.45-win32.msi',comment => 'Install mysql - be sure to choose to do a "COMPLETE" install. You should also choose NOT to "configure the server now" ' ],
00236
00237 # after mysql install
00238 [ filesame => [$mingw.'bin/libmySQL.dll','c:/Program Files/MySQL/MySQL Server 5.0/bin/libmySQL.dll'], copy => [''=>'',comment => 'post-mysql-install'] ],
00239 [ filesame => [$mingw.'lib/libmySQL.dll','c:/Program Files/MySQL/MySQL Server 5.0/bin/libmySQL.dll'], copy => [''=>'',comment => 'post-mysql-install'] ],
00240 [ filesame => [$mingw.'lib/libmysql.lib','c:/Program Files/MySQL/MySQL Server 5.0/lib/opt/libmysql.lib'], copy => [''=>''] ],
00241 [ file => $mingw.'include/mysql.h' , exec => 'copy /Y "c:\Program Files\MySQL\MySQL Server 5.0\include\*" '.$dosmingw."include" ],
00242 # cp /c/Program\ Files/MySQL/MySQL\ Server\ 5.0/include
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 #include <sys/types.h>
00259 -#ifdef __LCC__
00260 #include <winsock.h>
00261 -#endif
00262 typedef char my_bool;
00263 -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
00264 +#if (defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__)) && !defined(__WIN__)
00265 #define __WIN__
00266 #endif
00267 #if !defined(__WIN__)
00268
00269 ' ],comment => 'write the patch for the the mysql.h file'],
00270
00271
00272 [ grep => ['\|\| defined\(__MINGW32__\)',$mingw.'include/mysql.h'], shell => ["cd /mingw/include","patch -p0 < mysql___h.patch"],comment => 'Apply mysql.h patch file, if not already applied....' ],
00273
00274
00275 # fetch it
00276 [ dir => $sources.'pthread', mkdirs => $sources.'pthread' ],
00277 [ archive => $sources.'pthread/libpthread.a', 'fetch' => 'ftp:
00278 [ archive => $sources.'pthread/pthreadGC2.dll', 'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/pthreadGC2.dll' ],
00279 [ filesame => [$sources.'pthread/pthread.dll',$sources."pthread/pthreadGC2.dll"], copy => [''=>''] ],
00280 [ archive => $sources.'pthread/pthread.h', 'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/pthread.h' ],
00281 [ archive => $sources.'pthread/sched.h', 'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/sched.h' ],
00282 [ archive => $sources.'pthread/semaphore.h', 'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/semaphore.h' ],
00283 # install it:
00284 [ filesame => [$mingw.'lib/libpthread.a', $sources."pthread/libpthread.a"], copy => [''=>'',comment => 'install pthread'] ],
00285 [ filesame => [$mingw.'bin/pthreadGC2.dll', $sources."pthread/pthreadGC2.dll"], copy => [''=>''] ],
00286 [ filesame => [$mingw.'bin/pthread.dll', $sources."pthread/pthread.dll"], copy => [''=>''] ],
00287 [ filesame => [$mingw.'include/pthread.h', $sources."pthread/pthread.h"], copy => [''=>''] ],
00288 [ filesame => [$mingw.'include/sched.h', $sources."pthread/sched.h"], copy => [''=>''] ],
00289 [ filesame => [$mingw.'include/semaphore.h',$sources."pthread/semaphore.h"], copy => [''=>''] ],
00290
00291
00292 # ( save bandwidth compare to the above full SDK where they came from:
00293 [ archive => $sources.'DX9SDK_dsound_Include_subset.zip', 'fetch' => 'http://davidbuzz.googlepages.com/DX9SDK_dsound_Include_subset.zip',comment => 'We download just the required Include files for DX9' ],
00294 [ dir => $sources.'DX9SDK_dsound_Include_subset', extract => $sources.'DX9SDK_dsound_Include_subset.zip' ],
00295 [ filesame => [$mingw.'include/dsound.h',$sources."DX9SDK_dsound_Include_subset/dsound.h"], copy => [''=>''] ],
00296 [ filesame => [$mingw.'include/dinput.h',$sources."DX9SDK_dsound_Include_subset/dinput.h"], copy => [''=>''] ],
00297 [ filesame => [$mingw.'include/ddraw.h', $sources."DX9SDK_dsound_Include_subset/ddraw.h"], copy => [''=>''] ],
00298 [ filesame => [$mingw.'include/dsetup.h',$sources."DX9SDK_dsound_Include_subset/dsetup.h"], copy => [''=>''] ],
00299
00300
00301 #----------------------------------------
00302 # now we do each of the source library dependancies in turn: download,extract,build/install
00303 # TODO - ( and just prey that they all work?) These should really be more detailed, and actually check that we got it installed properly.
00304
00305 # Most of these look for a Makefile as a sign that the ./configure was successful (not necessarily true, but it's a start)
00306 # but this requires that the .tar.gz didn't come with a Makefile in it.
00307
00308 [ archive => $sources.'freetype-2.3.5.tar.gz', fetch => 'http://download.savannah.nongnu.org/releases/freetype/freetype-2.3.5.tar.gz'],
00309 [ dir => $sources.'freetype-2.3.5', extract => $sources.'freetype-2.3.5.tar' ],
00310 # caution... freetype comes with a Makefile in the .tar.gz, so work around it!
00311 [ file => $sources.'freetype-2.3.5/Makefile_', shell => ["cd $unixsources/freetype-2.3.5","./configure --prefix=/mingw","touch $unixsources/freetype-2.3.5/Makefile_"] ],
00312 # here's an example of specifying the make and make install steps separately, for apps that can't be relied on to have the make step work!
00313 [ file => $sources.'freetype-2.3.5/objs/.libs/libfreetype.a', shell => ["cd $unixsources/freetype-2.3.5","make"] ],
00314 [ file => $mingw.'lib/libfreetype.a', shell => ["cd $unixsources/freetype-2.3.5","make install"] ],
00315
00316
00317 [ archive => $sources.'lame-3.97.tar.gz', fetch => 'http://'.$sourceforge.'/sourceforge/lame/lame-3.97.tar.gz'],
00318 [ dir => $sources.'lame-3.97', extract => $sources.'lame-3.97.tar' ],
00319 [ file => $sources.'lame-3.97/Makefile', shell => ["cd $unixsources/lame-3.97","./configure --prefix=/mingw","make","make install"] ],
00320
00321 [ archive => $sources.'libmad-0.15.1b.tar.gz', fetch => 'http://'.$sourceforge.'/sourceforge/mad/libmad-0.15.1b.tar.gz'],
00322 [ dir => $sources.'libmad-0.15.1b', extract => $sources.'libmad-0.15.1b.tar' ],
00323 [ file => $sources.'libmad-0.15.1b/Makefile', shell => ["cd $unixsources/libmad-0.15.1b","./configure --prefix=/usr","make","make install"] ],
00324
00325
00326 [ archive => $sources.'taglib-1.4.tar.gz', fetch => 'http://developer.kde.org/~wheeler/files/src/taglib-1.4.tar.gz'],
00327 [ dir => $sources.'taglib-1.4', extract => $sources.'taglib-1.4.tar' ],
00328 [ file => $sources.'taglib-1.4/Makefile', shell => ["cd $unixsources/taglib-1.4","./configure --prefix=/mingw","make","make install"] ],
00329 # TODO tweak makefiles:
00330 # INSTALL = C:/msys/1.0/bin/install -c -p
00331 # INSTALL = ../C:/msys/1.0/bin/install -c -p
00332 # INSTALL = ../../C:/msys/1.0/bin/install -c -p
00333
00334
00335 [ archive => $sources.'libao-0.8.8.tar.gz', fetch => 'http://downloads.xiph.org/releases/ao/libao-0.8.8.tar.gz'],
00336 [ dir => $sources.'libao-0.8.8', extract => $sources.'libao-0.8.8.tar' ],
00337 [ file => $sources.'libao-0.8.8/Makefile', shell => ["cd $unixsources/libao-0.8.8","./configure --prefix=/usr","make","make install"] ],
00338
00339 [ archive => $sources.'libogg-1.1.3.tar.gz', fetch => 'http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz'],
00340 [ dir => $sources.'libogg-1.1.3', extract => $sources.'libogg-1.1.3.tar' ],
00341 [ file => $sources.'libogg-1.1.3/Makefile', shell => ["cd $unixsources/libogg-1.1.3","./configure --prefix=/usr","make","make install"] ],
00342
00343 [ archive => $sources.'libvorbis-1.2.0.tar.gz', fetch => 'http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz'],
00344 [ dir => $sources.'libvorbis-1.2.0', extract => $sources.'libvorbis-1.2.0.tar' ],
00345 [ file => $sources.'libvorbis-1.2.0/Makefile', shell => ["cd $unixsources/libvorbis-1.2.0","./configure --prefix=/usr --disable-shared","make","make install"] ],
00346
00347
00348 [ archive => $sources.'flac-1.2.1.tar.gz', fetch => 'http://'.$sourceforge.'/sourceforge/flac/flac-1.2.1.tar.gz'],
00349 [ dir => $sources.'flac-1.2.1', extract => $sources.'flac-1.2.1.tar' ],
00350 [ grep => ['\#define SIZE_T_MAX UINT_MAX',$mingw.'include/limits.h'], shell => "echo \\#define SIZE_T_MAX UINT_MAX >> $mingw/include/limits.h" ],
00351 [ file => $sources.'flac-1.2.1/Makefile', shell => ["cd $unixsources/flac-1.2.1","./configure --prefix=/mingw","make","make install"] ],
00352
00353 # skip doing pthreads from source, we use binaries that were fetched earlier:
00354 #[ archive => $sources.'pthreads-w32-2-8-0-release.tar.gz', fetch => 'ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.tar.gz'],
00355 #[ dir => $sources.'pthreads-w32-2-8-0-release', extract => $sources.'pthreads-w32-2-8-0-release.tar' ],
00356
00357 [ archive => $sources.'SDL-1.2.12.tar.gz', fetch => 'http://www.libsdl.org/release/SDL-1.2.12.tar.gz'],
00358 [ dir => $sources.'SDL-1.2.12', extract => $sources.'SDL-1.2.12.tar.gz' ],
00359 [ file => $sources.'SDL-1.2.12/Makefile', shell => ["cd $unixsources/SDL-1.2.12","./configure --prefix=/usr","make","make install"] ],
00360
00361
00362 [ archive => $sources.'tiff-3.8.2.tar.gz', fetch => 'ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.8.2.tar.gz'],
00363 [ dir => $sources.'tiff-3.8.2', extract => $sources.'tiff-3.8.2.tar' ],
00364 [ file => $sources.'tiff-3.8.2/Makefile', shell => ["cd $unixsources/tiff-3.8.2","./configure --prefix=/usr","make","make install"] ],
00365
00366
00367 [ archive => $sources.'libexif-0.6.16.tar.gz', fetch => 'http://'.$sourceforge.'/sourceforge/libexif/libexif-0.6.16.tar.gz'],
00368 [ dir => $sources.'libexif-0.6.16', extract => $sources.'libexif-0.6.16.tar' ],
00369 [ file => $sources.'libexif-0.6.16/Makefile', shell => ["cd $unixsources/libexif-0.6.16","./configure --prefix=/usr","make","make install"] ],
00370
00371
00372 [ archive => $sources.'libvisual-0.4.0.tar.gz', fetch => 'http://'.$sourceforge.'/sourceforge/libvisual/libvisual-0.4.0.tar.gz'],
00373 [ dir => $sources.'libvisual-0.4.0', extract => $sources.'libvisual-0.4.0.tar' ],
00374 [ file => $sources.'libvisual-0.4.0/Makefile', shell => ["cd $unixsources/libvisual-0.4.0","./configure --prefix=/usr","make","make install"] ],
00375
00376
00377 [ archive => $sources.'fftw-3.1.2.tar.gz', fetch => 'http://www.fftw.org/fftw-3.1.2.tar.gz'],
00378 [ dir => $sources.'fftw-3.1.2', extract => $sources.'fftw-3.1.2.tar' ],
00379 [ file => $sources.'fftw-3.1.2/Makefile', shell => ["cd $unixsources/fftw-3.1.2","./configure --prefix=/mingw","make","make install"] ],
00380
00381
00382 # typical template:
00383 #[ archive => $sources.'xxx.tar.gz', fetch => ''],
00384 #[ dir => $sources.'xxx', extract => $sources.'xxx.tar' ],
00385 #[ file => $sources.'xxx/Makefile', shell => ["cd $unixsources/xxx","./configure --prefix=/usr","make","make install"] ],
00386
00387 #----------------------------------------
00388 # Building QT is complicated!
00389
00390 [ archive => $sources.'qt-3.3.x-p8.tar.bz2', fetch => 'http://'.$sourceforge.'/sourceforge/qtwin/qt-3.3.x-p8.tar.bz2'],
00391 [ dir => $msys.'qt-3.3.x-p8', extract => [$sources.'qt-3.3.x-p8.tar', $msys] ],
00392
00393 # two older patches
00394 #[ archive => 'qt.patch.gz' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4270/qt.patch.gz'],
00395 #[ archive => 'qt2.patch' , 'fetch' => 'http://tanas.ca/qt2.patch'],
00396 # OR:
00397 # equivalent patch:
00398 [ archive => $sources.'qt.patch' , 'fetch' => 'http://tanas.ca/qt.patch',comment => ' patch the QT sources'],
00399 [ filesame => [$msys.'qt-3.3.x-p8/qt.patch',$sources."qt.patch"], copy => [''=>''] ],
00400 [ grep => ["\-lws2_32", $msys.'qt-3.3.x-p8/mkspecs/win32-g++/qmake.conf'], shell => ["cd ".$unixmsys."qt-3.3.x-p8/","patch -p1 < qt.patch"] ],
00401
00402
00403 [ file => $msys.'bin/sh_.exe', shell => ["mv ".$unixmsys."bin/sh.exe ".$unixmsys."bin/sh_.exe"],comment => 'rename msys sh.exe out of the way before building QT! ' ] ,
00404
00405 # write a batch script for the QT environment under DOS:
00406 [ file => $msys.'qt-3.3.x-p8/qt_env.bat', write => [$msys.'qt-3.3.x-p8/qt_env.bat',
00407 'rem a batch script for the QT environment under DOS:
00408 set QTDIR='.$dosmsys.'qt-3.3.x-p8
00409 set MINGW='.$dosmingw.'
00410 set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH%
00411 set QMAKESPEC=win32-g++
00412 cd %QTDIR%
00413 '
00414 ],comment=>'write a batch script for the QT environment under DOS'],
00415
00416
00417 [ file => $msys.'qt-3.3.x-p8/lib/libqt-mt3.dll', exec => $dosmsys.'qt-3.3.x-p8\qt_env.bat && configure.bat -thread -plugin-sql-mysql -opengl -no-sql-sqlite',comment => 'Execute qt_env.bat && the configure command to actually build QT now! - ie configures qt and also makes it, hopefully! WARNING SLOW (MAY TAKE HOURS!)' ],
00418
00419 [ filesame => [$msys.'qt-3.3.x-p8/bin/libqt-mt3.dll',$msys.'qt-3.3.x-p8/lib/libqt-mt3.dll'], copy => [''=>''], comment => 'is there a libqt-mt3.dll in the "lib" folder of QT? if so, copy it to the the "bin" folder for uic.exe to use!' ],
00420
00421 # did the configure finish? - run mingw32-make to get it to finish properly.
00422 # HINT: the very last file built in a successful QT build env is the C:\msys\1.0\qt-3.3.x-p8\examples\xml\tagreader-with-features\tagreader-with-features.exe
00423 [ file => $msys.'qt-3.3.x-p8/examples/xml/tagreader-with-features/tagreader-with-features.exe', exec => $dosmsys.'qt-3.3.x-p8\qt_env.bat && mingw32-make',comment => 'we try to finish the build of QT with mingw32-make, incase it was just a build dependancy issue? WARNING SLOW (MAY TAKE HOURS!)' ],
00424
00425 # TODO - do we have an action we can take to build just this one file/dll if it fails?
00426 # For now, we will just test if it built, and abort if it didn't!
00427 [ file => $msys.'qt-3.3.x-p8/plugins/sqldrivers/libqsqlmysql.dll', exec => '', comment => 'lib\libqsqlmysql.dll - here we are just validating some basics of the the QT install, and if any of these components are missing, the build must have failed ( is the sql driver built properly?) '],
00428 [ file => $msys.'qt-3.3.x-p8/bin/qmake.exe', exec => '', comment => 'bin\qmake.exe - here we are just validating some basics of the the QT install, and if any of these components are missing, the build must have failed'],
00429 [ file => $msys.'qt-3.3.x-p8/bin/moc.exe', exec => '', comment => 'bin\moc.exe - here we are just validating some basics of the the QT install, and if any of these components are missing, the build must have failed'],
00430 [ file => $msys.'qt-3.3.x-p8/bin/uic.exe', exec => '', comment => 'bin\uic.exe - here we are just validating some basics of the the QT install, and if any of these components are missing, the build must have failed'],
00431
00432
00433 # TODO "make install" qt - where to?, will this work? (not sure, it sometimes might, but it's not critical?)
00434 #[ file => $msys.'qt-3.3.x-p8/lib/libqt-mt3.dll', exec => $dosmsys.'qt-3.3.x-p8\qt_env.bat && mingw32-make install',comment => 'install QT' ],
00435 # a manual method for "installing" QT would be to put all the 'bin' files into /mingw/bin and similarly for the 'lib' and 'include' folders to their respective mingw folders?:
00436
00437
00438 # (back to sh.exe ) now that we are done !
00439 [ file => $msys.'bin/sh.exe', shell => ["mv ".$unixmsys."bin/sh_.exe ".$unixmsys."bin/sh.exe"],comment => 'rename msys sh_.exe back again!' ] ,
00440
00441 #Copy libqt-mt3.dll to libqt-mt.dll , if there is any date/size change!
00442 [ filesame => [$msys.'qt-3.3.x-p8/lib/libqt-mt.dll',$msys.'qt-3.3.x-p8/lib/libqt-mt3.dll'], copy => [''=>''],comment => 'Copy libqt-mt3.dll to libqt-mt.dll' ] ,
00443
00444
00445 #----------------------------------------
00446
00447 # get mythtv sources, if we don't already have them
00448 # download all the files from the web, and save them here:
00449 [ dir => $mythtv.'mythtv', mkdirs => $mythtv.'mythtv' ],
00450
00451
00452 [ file => $mythtv.'svn_', shell => ["rm ".$unixmythtv."using_proxy_cannot_do_SVN.txt; if [ -n '$proxy' ] ; then touch ".$unixmythtv."using_proxy_cannot_do_SVN.txt; fi",'nocheck'],comment => 'disable SVN code fetching if we are using a proxy....' ],
00453
00454 # if we dont have the sources at all, get them all from SVN! (do a checkout, but only if we don't already have the .pro file as a sign of an earlier checkout)
00455 # this is some nasty in-line batch-script code, but it works.
00456 ;
00457 # mythtv,mythplugins,myththemes
00458 foreach my $comp( @components ) {
00459 push @{$expect},
00460 [ file => $mythtv.'using_proxy_cannot_do_SVN.txt', exec => ['set PATH='.$dosmsys.'bin;%PATH% && cd '.$dosmythtv.' && IF NOT EXIST '.$dosmythtv.'mythtv\mythtv.pro svn checkout http://svn.mythtv.org/svn/trunk/'."$comp $comp",'nocheck'],comment => 'Get all the mythtv sources from SVN!:'.$comp ];
00461 }
00462 push @{$expect},
00463 # now lets write some build scripts to help with mythtv itself
00464
00465 #
00466 [ file => $mythtv.'qt_env.sh', write => [$mythtv.'qt_env.sh',
00467 'export QTDIR='.$unixmsys.'qt-3.3.x-p8
00468 export QMAKESPEC=$QTDIR/mkspecs/win32-g++
00469 export LD_LIBRARY_PATH=$QTDIR/lib:/usr/lib:/mingw/lib:/lib
00470 export PATH=$QTDIR/bin:$PATH
00471 ' ],comment => 'write a script that we can source later when inside msys to setup the environment variables'],
00472
00473
00474 # chmod the shell scripts, everytime
00475 [ file => $mythtv.'_' , shell => ["cd $mythtv","chmod 755 *.sh",'nocheck'] ],
00476
00477 #----------------------------------------
00478 # now we build mythtv!
00479 ;
00480
00481 # SVN update every time, before patches, unless we are using a proxy
00482 foreach my $comp( @components ) {
00483 push @{$expect},
00484 [ file => $mythtv.'using_proxy_cannot_do_SVN.txt', exec => ['cd '.$dosmythtv."$comp && ".$dosmsys.'bin\svn.exe -r '.$SVNRELEASE.' update','nocheck'],comment => 'getting SVN updates for:'.$comp ],
00485 }
00486 push @{$expect},
00487
00488 # always get svn num
00489 [ file => $mythtv.'_', exec => ['cd '.$dosmythtv.'mythtv && '.$dosmsys.'bin\svn.exe info > '.$dosmythtv.'mythtv\svn_info.new','nocheck'], comment => 'fetching the SVN number to a text file, if we can'],
00490 [ filesame => [$mythtv.'mythtv\svn_info.txt',$mythtv.'mythtv\svn_info.new'], shell => ['touch -r '.$unixmythtv.'mythtv/svn_info.txt '.$unixmythtv.'mythtv/svn_info.new'], comment => 'match the datetime of these files, so that the contents only can be compared next' ],
00491
00492 # is svn num (ie file contents) changed since last run, if so, do a 'make clean' (overkill, I know, but safer)!
00493 [ filesame => [$mythtv.'mythtv\svn_info.txt',$mythtv.'mythtv\svn_info.new'], shell => ['touch '.$unixmythtv.'mythtv/last_build.txt','cat '.$unixmythtv.'mythtv/svn_info.new >'.$unixmythtv.'mythtv/svn_info.txt','touch -r '.$unixmythtv.'mythtv/svn_info.txt '.$unixmythtv.'mythtv/svn_info.new'], comment => 'if the SVN number is changed, then remember that, AND arrange for a full re-make of mythtv. (overkill, I know, but safer)' ],
00494
00495 # apply any outstanding win32 patches - this section will be hard to keep upwith HEAD/SVN:
00496
00497 # 15586 and earlier need this patch:
00498 #[ archive => $sources.'backend.patch.gz' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4392/backend.patch.gz', comment => 'backend.patch.gz - apply any outstanding win32 patches - this section will be hard to keep upwith HEAD/SVN'],
00499 #[ filesame => [$mythtv.'mythtv/backend.patch.gz',$sources."backend.patch.gz"], copy => [''=>'',comment => '4392: - backend connections being accepted patch '] ],
00500 #[ grep => ['unsigned\* Indexes = new unsigned\[n\]\;',$mythtv.'mythtv/libs/libmyth/mythsocket.cpp'], shell => ["cd ".$unixmythtv."mythtv/","gunzip -f backend.patch.gz","patch -p0 < backend.patch"] ],
00501
00502 # these next 3 patches are needed for 15528 (and earlier)
00503 #[ archive => $sources.'importicons_windows_2.diff' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/3334/importicons_windows_2.diff', comment => 'importicons_windows_2.diff - apply any outstanding win32 patches - this section will be hard to keep upwith HEAD/SVN'],
00504 #[ filesame => [$mythtv.'mythtv/importicons_windows_2.diff',$sources."importicons_windows_2.diff"], copy => [''=>'',comment => '3334 fixes error with mkdir() unknown.'] ],
00505 #
00506 #[ grep => ['\#include <qdir\.h>',$mythtv.'mythtv/libs/libmythtv/importicons.cpp'], shell => ["cd ".$unixmythtv."mythtv/","patch -p0 < importicons_windows_2.diff"] ],
00507 #[ archive => $sources.'mingw.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4516/mingw.patch', comment => 'mingw.patch - apply any outstanding win32 patches - this section will be hard to keep upwith HEAD/SVN'],
00508 #[ filesame => [$mythtv.'mythtv/mingw.patch',$sources."mingw.patch"], copy => [''=>'',comment => '4516 fixes build'] ],
00509 #[ grep => ['LIBS \+= -lmyth-\$\$LIBVERSION',$mythtv.'mythtv/libs/libmythui/libmythui.pro'], shell => ["cd ".$unixmythtv."mythtv/","patch -p0 < mingw.patch"] ]
00510 #
00511 # (fixed in 15547)
00512 #[ archive => $sources.'util_win32.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4497/util_win32.patch', comment => 'util_win32.patch - apply any outstanding win32 patches - this section will be hard to keep upwith HEAD/SVN'],
00513 #[ filesame => [$mythtv.'mythtv/util_win32.patch',$sources."util_win32.patch"], copy => [''=>'',comment => '4497 fixes build'] ],
00514 #[ grep => ['\#include "compat.h"',$mythtv.'mythtv/libs/libmyth/util.h'], shell => ["cd ".$unixmythtv."mythtv/libs/libmyth/","patch -p0 < ".$unixmythtv."mythtv/util_win32.patch"] ],
00515
00516 # post 15528, pre 15568 needs this: equivalent to: svn merge -r 15541:15540 .
00517 #[ archive => $sources.'15541_undo.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/XXXX/15541_undo.patch', comment => 'util_win32.patch - apply any outstanding win32 patches - this section will be hard to keep upwith HEAD/SVN'],
00518 #[ filesame => [$mythtv.'mythtv/15541_undo.patch',$sources."15541_undo.patch"], copy => [''=>'',comment => 'XXXX'] ],
00519 #[ grep => ['\#include \"compat.h\"',$mythtv.'mythtv/libs/libmythui/mythpainter.cpp'], shell => ["cd ".$unixmythtv."mythtv/libs/libmyth/","patch -p2 < ".$unixmythtv."mythtv/15541_undo.patch"] , comment => 'currently need this patch too, equivalemnt of: svn merge -r 15541:15540 .'],
00520
00521
00522 [ file => $mythtv.'mythtv/config/config.pro', shell => ['touch '.$unixmythtv.'mythtv/config/config.pro'], comment => 'create an empty config.pro or the mythtv build will fail'],
00523
00524 # do a make clean before?
00525 [ file => $mythtv.'delete_to_do_make_clean.txt', shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make clean','make distclean','touch '.$unixmythtv.'delete_to_do_make_clean.txt','nocheck'], comment => 'do a "make clean" first? not strictly necessary, and the build will be MUCH faster without it, but it is safer with it...'],
00526
00527 #broken Makefile, delete it
00528 [ grep => ['Makefile|MAKEFILE',$mythtv.'mythtv/Makefile'], shell => ['rm '.$unixmythtv.'mythtv/Makefile','nocheck'], comment => 'broken Makefile, delete it' ],
00529
00530 # configure
00531 [ file => $mythtv.'mythtv/Makefile',
00532 shell => ['source '.$unixmythtv.'qt_env.sh',
00533 'cd '.$unixmythtv.'mythtv',
00534 './configure --prefix='.$unixbuild.' --runtime-prefix=..'.
00535 ' --disable-dbox2 --disable-hdhomerun'.
00536 ' --disable-dvb --disable-ivtv --disable-iptv'.
00537 ' --disable-joystick-menu --disable-xvmc-vld --disable-x11'.
00538 ' --disable-xvmc --enable-directx'.
00539 ' --enable-memalign-hack --cpu=k8 --compile-type=debug'],
00540 comment => 'do we already have a Makefile for mythtv?' ],
00541 # make
00542 [ newer => [$mythtv.'mythtv/libs/libmyth/libmyth-0.21.dll',$mythtv.'mythtv/last_build.txt'], shell => ['rm '.$unixmythtv.'mythtv/libs/libmyth/libmyth-0.21.dll','source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make'], comment => 'libs/libmyth/libmyth-0.21.dll - redo make unless all these files exist, and are newer than the last_build.txt identifier' ],
00543 [ newer => [$mythtv.'mythtv/libs/libmythtv/libmythtv-0.21.dll',$mythtv.'mythtv/last_build.txt'], shell => ['rm '.$unixmythtv.'mythtv/libs/libmythtv/libmythtv-0.21.dll','source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make'], comment => 'libs/libmythtv/libmythtv-0.21.dll - redo make unless all these files exist, and are newer than the last_build.txt identifier' ],
00544 [ newer => [$mythtv.'mythtv/programs/mythfrontend/mythfrontend.exe',$mythtv.'mythtv/last_build.txt'], shell => ['rm '.$unixmythtv.'mythtv/programs/mythfrontend/mythfrontend.exe','source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make'], comment => 'programs/mythfrontend/mythfrontend.exe - redo make unless all these files exist, and are newer than the last_build.txt identifier' ],
00545 [ newer => [$mythtv.'mythtv/programs/mythbackend/mythbackend.exe',$mythtv.'mythtv/last_build.txt'], shell => ['rm '.$unixmythtv.'mythtv/programs/mythbackend/mythbackend.exe','source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make'], comment => 'programs/mythbackend/mythbackend.exe - redo make unless all these files exist, and are newer than the last_build.txt identifier' ],
00546
00547 # re-install to msys /usr/bin folders etc, if we have a newer mythtv build ready:
00548 [ newer => [$msys.'bin/mythfrontend.exe',$mythtv.'mythtv/programs/mythfrontend/mythfrontend.exe'], shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make install'], comment => 'was the last configure successful? then install mythtv ' ],
00549
00550 # it seems that mythverbose.h isn't installed as it should be.... (needed by the plugins compile)
00551 [ filesame => [$msys.'include/mythtv/mythverbose.h',$mythtv.'mythtv/libs/libmyth/mythverbose.h'], copy => [''=>''], comment => 'mythverbose.h ist installed properly yet...' ],
00552
00553
00554 # install some themes? does a 'make install' do that adequately (no, not if running outside msys)?
00555 # copy the basic themes somewhere that mythtv can get at it.
00556 # TODO this should really be independant of the msys folders, but it's not at present?
00557 [ dir => $msys.'share\mythtv\themes\G.A.N.T', shell => ['mkdir /usr/share/mythtv','mkdir /usr/share/mythtv/themes','cp -r /c/mythtv/mythtv/themes/* /usr/share/mythtv/themes/'], comment => 'copy the basic themes somewhere that mythtv can get at it.' ],
00558
00559 #
00560 [ file => $mythtv.'make_run.sh_', write => [$mythtv.'make_run.sh',
00561 '#!/bin/bash
00562 source '.$unixmythtv.'qt_env.sh
00563 cd '.$unixmythtv.'mythtv
00564 # keep around just one earlier verion in run_old:
00565 rm -rf run_old
00566 mv run run_old
00567 mkdir run
00568 # copy exes and dlls to the run folder:
00569 find . -name \\*.exe | grep -v run | xargs -n1 -i__ cp __ ./run/
00570 find . -name \\*.dll | grep -v run | xargs -n1 -i__ cp __ ./run/
00571 # mythtv needs the qt dlls at runtime:
00572 cp '.$unixmsys.'qt-3.3.x-p8/lib/*.dll '.$unixmythtv.'mythtv/run
00573 # qt mysql connection dll has to exist in a subfolder called sqldrivers:
00574 mkdir '.$unixmythtv.'mythtv/run/sqldrivers
00575 cp '.$unixmsys.'qt-3.3.x-p8/plugins/sqldrivers/libqsqlmysql.dll '.$unixmythtv.'mythtv/run/sqldrivers
00576 # pthread dlls and mingwm10.dll are copied from here:
00577 cp /mingw/bin/*.dll '.$unixmythtv.'mythtv/run
00578 ','nocheck'
00579 ],comment => 'write a script that will copy all the files necessary for running mythtv out of the build folder into the ./run folder'],
00580
00581
00582 [ newer => [$mythtv.'mythtv/run/mythfrontend.exe',$mythtv.'mythtv/programs/mythfrontend/mythfrontend.exe'], shell => [$unixmythtv.'make_run.sh'], comment => 'create a natively runnable version: with the make_run.sh script' ],
00583
00584 # create the mysql.txt file at: %HOMEPATH%\.mythtv\mysql.txt
00585 [ file => $ENV{HOMEPATH}.'\.mythtv\mysql.txt_', write => [$ENV{HOMEPATH}.'\.mythtv\mysql.txt',
00586 '#
00587 DBHostName=127.0.0.1
00588 DBHostPing=no
00589 DBUserName=mythtv
00590 DBPassword=mythtv
00591 DBName=mythconverg
00592 DBType=QMYSQL3
00593 #LocalHostName=my-unique-identifier-goes-here
00594 ','nocheck'],
00595 comment => 'create a mysql.txt file at: %HOMEPATH%\.mythtv\mysql.txt' ],
00596
00597
00598 #execute and capture output: C:\Program Files\MySQL\MySQL Server 5.0\bin>mysqlshow.exe -u mythtv --password=mythtv
00599 # example response: mysqlshow.exe: Can't connect to MySQL server on 'localhost' (10061)
00600 # if this is doing an anonymous connection, so the BEST we should expect is an "access denied" message if the server is running properly.
00601
00602 [ file => $mythtv.'testmysql.bat_', write => [ $mythtv.'testmysql.bat',
00603 '@echo off
00604 echo testing connection to a local mysql server...
00605 sleep 5
00606 del '.$dosmythtv.'_mysqlshow_err.txt
00607 "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqlshow.exe" -u mythtv --password=mythtv 2> '.$dosmythtv.'_mysqlshow_err.txt > '.$dosmythtv.'_mysqlshow_out.txt
00608 type '.$dosmythtv.'_mysqlshow_out.txt >> '.$dosmythtv.'_mysqlshow_err.txt
00609 del '.$dosmythtv.'_mysqlshow_out.txt
00610 sleep 1
00611 ','nocheck']],
00612
00613 # try to connect as mythtv/mythtv first (the best case scenario)
00614 [ file => $mythtv.'skipping_db_tests.txt', exec => [$mythtv.'testmysql.bat','nocheck'], comment => 'First check - is the local mysql server running, accepting connections, and all that? (follow the bouncing ball on the install, a standard install is OK, remember the root password that you set, start it as a service!)' ],
00615
00616 # if the connection was good, or the permissions were wrong, but the server was there, there's no need to reconfigure the server!
00617 [ grep => ['(\+--------------------\+|Access denied for user)',$mythtv.'_mysqlshow_err.txt'], exec => ['C:\Program Files\MySQL\MySQL Server 5.0\bin\MySQLInstanceConfig.exe','nocheck'], comment => 'See if we couldnt connect to a local mysql server. Please re-configure the MySQL server to start as a service.'],
00618
00619 # try again to connect as mythtv/mythtv first (the best case scenario) - the connection info should have changed!
00620 [ file => $mythtv.'skipping_db_tests.txt', exec => [$mythtv.'testmysql.bat','nocheck'], comment => 'Second check - that the local mysql server is at least now now running?' ],
00621
00622
00623 #set/reset mythtv/mythtv password!
00624 [ file => $mythtv.'resetmythtv.bat_', write => [ $mythtv.'resetmythtv.bat',
00625 "\@echo off
00626 echo stopping mysql service:
00627 net stop MySQL
00628 sleep 2
00629 echo writing script to reset mythtv/mythtv passwords:
00630 echo USE mysql; >resetmythtv.sql
00631 echo. >>resetmythtv.sql
00632 echo INSERT IGNORE INTO user VALUES ('localhost','mythtv', PASSWORD('mythtv'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); >>resetmythtv.sql
00633 echo REPLACE INTO user VALUES ('localhost','mythtv', PASSWORD('mythtv'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); >>resetmythtv.sql
00634 echo INSERT IGNORE INTO user VALUES ('\%\%','mythtv', PASSWORD('mythtv'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); >>resetmythtv.sql
00635 echo REPLACE INTO user VALUES ('\%\%','mythtv', PASSWORD('mythtv'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); >>resetmythtv.sql
00636 echo trying to reset mythtv/mythtv passwords:
00637 \"C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqld-nt.exe\" --no-defaults --bind-address=127.0.0.1 --bootstrap --console --skip-grant-tables --skip-innodb --standalone <resetmythtv.sql
00638 del resetmythtv.sql
00639 echo trying to re-start mysql
00640 rem net stop MySQL
00641 net start MySQL
00642 rem so that the server has time to start before we query it again
00643 sleep 5
00644 echo.
00645 echo Password for user 'mythtv' was reset to 'mythtv'
00646 echo.
00647 ",'nocheck'],
00648 comment => 'writing a script to create the mysql user (mythtv/mythtv) without needing to ask you for the root password ...'],
00649
00650 # reset passwords, this give the myhttv user FULL access to the entire mysql instance!
00651 # TODO give specific access to just the the mythconverg DB, as needed.
00652 [ grep => ['(\+--------------------\+)',$mythtv.'_mysqlshow_err.txt'], exec => [$dosmythtv.'resetmythtv.bat','nocheck'], comment => 'Resetting the mythtv/mythtv permissions to mysql - if the user already has successful login access to the mysql server, theres no need to run this' ],
00653
00654
00655 # try again to connect as mythtv/mythtv first (the best case scenario) - the connection info should have changed!
00656 [ file => $mythtv.'skipping_db_tests.txt', exec => [$mythtv.'testmysql.bat','nocheck'], comment => 'Third check - that the local mysql server is fully accepting connections?' ],
00657
00658 # create DB:
00659 # this has the 'nocheck' flag because the creation of the DB doesn't instantly reflect in the .txt file we are looking at:
00660 [ grep => ['mythconverg',$mythtv.'_mysqlshow_err.txt'], exec => [ 'echo create database mythconverg; | "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe" -u mythtv --password=mythtv','nocheck'], comment => ' does the mythconverg database exist? (and can this user see it?) '],
00661
00662 #----------------------------------------
00663
00664 # build the mythplugins now:
00665 #
00666
00667 # get mythtv sources, if we don't already have them
00668 # download all the files from the web, and save them here:
00669 #[ dir => $mythtv.'mythplugins', mkdirs => $mythtv.'mythplugins' ],
00670 #
00671 ## config:
00672 #[ file => $mythtv.'mythplugins/Makefile', shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythplugins','./configure --prefix=/usr --disable-mythgallery --disable-mythmusic --disable-mytharchive --disable-mythbrowser --disable-mythflix --disable-mythgame --disable-mythnews --disable-mythphone --disable-mythzoneminder --disable-mythweb --enable-aac --enable-libvisual --enable-fftw --compile-type=debug'], comment => 'do we already have a Makefile for myth plugins?' ],
00673 ## make
00674 #[ newer => [$mythtv.'mythplugins/mythmovies/mythmovies/libmythmovies.dll',$mythtv.'mythtv/last_build.txt'], shell => ['rm '.$unixmythtv.'mythplugins/mythmovies/mythmovies/libmythmovies.dll','source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythplugins','make'], comment => 'PLUGINS! redo make if we need to (see the last_build.txt identifier)' ],
00675
00676
00677 # re-install to msys /usr/bin folders etc, if we have a newer mythtv build ready:
00678 #[ newer => [$msys.'bin/mythfrontend.exeXXXXX',$mythtv.'mythplugins/mythmovies/mythmovies/XXXXX'], shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythplugins','make install'], comment => 'plugins - was the last configure successful? then install mythtv ' ],
00679
00680
00681
00682 #----------------------------------------
00683
00684 ; # END OF CAUSE->ACTION DEFINITIONS
00685
00686 #------------------------------------------------------------------------------
00687
00688 sub _end {
00689
00690 comment("This verson of the Win32 Build script last was last tested on: $SVNRELEASE");
00691
00692 print << 'END';
00693 #
00694 # SCRIPT TODO/NOTES: - further notes on this scripts direction....
00695 # * if the build was successful then try running the 'mythfrontend.exe' and 'mythbackend.exe' from the 'C:/mythtv/mythtv/run' folder.
00696 # * ok, how about the test-run process?
00697 # * check that mythtv/mythtv/mythconverg will access the mysql database
00698 # * mythplugins build isn't currently working, so disabled.
00699 # * myththemes build isn't tried at all
00700 END
00701 }
00702
00703 #------------------------------------------------------------------------------
00704
00705 # this is the mainloop that itterates over the above definitions and determines what to do:
00706 # cause:
00707 foreach my $dep ( @{$expect} ) {
00708 my @dep = @{$dep};
00709
00710 #print Dumper(\@dep);
00711
00712 my $causetype = $dep[0];
00713 my $cause = $dep[1];
00714 my $effecttype = $dep[2];
00715 my $effectparams = $dep[3] || '';
00716 die "too many parameters in cause->event declaration (".join('|',@dep).")" if defined $dep[4] && $dep[4] ne 'comment'; # four pieces: cause => [blah] , effect => [blah]
00717 my $comment = $dep[5] || '';
00718
00719 if ( $comment && $NOISY ) {
00720 comment($comment);
00721 }
00722
00723 my @cause;
00724 if (ref($cause) eq "ARRAY" ) {
00725 @cause = @{$cause};
00726 } else {
00727 push @cause, $cause ;
00728 }
00729
00730 # six pieces: cause => [blah] , effect => [blah] , comment => ''
00731 die "too many parameters in cause->event declaration (@dep)"
00732 if defined $dep[6];
00733
00734 my @effectparams = ();
00735 if (ref($effectparams) eq "ARRAY" ) {
00736 @effectparams = @{$effectparams};
00737 } else {
00738 push @effectparams, $effectparams ;
00739 }
00740 # if a 'nocheck' parameter is passed through, dont pass it through to
00741 # the 'effect()', use it to NOT check if the file/dir exists at the end.
00742 my @nocheckeffectparams = grep { ! /nocheck/i } @effectparams;
00743 my $nocheck = 0;
00744 if ( $#nocheckeffectparams != $#effectparams ) { $nocheck = 1; }
00745
00746 if ( $causetype eq 'archive' ) {
00747 die "archive only supports type fetch ($cause)($effecttype)"
00748 unless $effecttype eq 'fetch';
00749 if ( -f $cause[0] ) {print "file exists: $cause[0]\n"; next;}
00750 # 2nd and 3rd params get squashed into
00751 # a single array on passing to effect();
00752 effect($effecttype,$cause[0],@nocheckeffectparams);
00753 if ( ! -f $cause[0] && $nocheck == 0) {
00754 die "EFFECT FAILED ($causetype -> $effecttype): unable to locate expected file ($cause[0]) that was to be fetched from $nocheckeffectparams[0]\n";
00755 }
00756
00757 } elsif ( $causetype eq 'dir' ) {
00758 if ( -d $cause[0] ) {
00759 print "directory exists: $causetype,$cause[0]\n"; next;
00760 }
00761 effect($effecttype,@nocheckeffectparams);
00762 if ( ! -d $cause[0] && $nocheck == 0) {
00763 die "EFFECT FAILED ($causetype -> $effecttype): unable to locate expected directory ($cause[0]).\n";
00764 }
00765
00766 } elsif ( $causetype eq 'file' ) {
00767 if ( -f $cause[0] ) {print "file exists: $cause[0]\n"; next;}
00768 effect($effecttype,@nocheckeffectparams);
00769 if ( ! -f $cause[0] && $nocheck == 0) {
00770 die "EFFECT FAILED ($causetype -> $effecttype): unable to locate expected file ($cause[0]).\n";
00771 }
00772 } elsif ( $causetype eq 'filesame' ) {
00773 # TODO - currently we check file mtime, and byte size, but not MD5/CRC32 or contents, this is "good enough" for most circumstances.
00774 my ( $size,$mtime)=(0,0);
00775 if ( -f $cause[0] ) {
00776 $size = (stat($cause[0]))[7];
00777 $mtime = (stat($cause[0]))[9];
00778 }
00779 if (! (-f $cause[1] ) ) { die "cause: $causetype requires its SECOND filename to exist for comparison: ($cause[1]).\n"; }
00780 my $size2 = (stat($cause[1]))[7];
00781 my $mtime2 = (stat($cause[1]))[9];
00782 if ( $mtime != $mtime2 || $size != $size2) {
00783 if ( ! $nocheckeffectparams[0] ) {
00784 die "sorry but you can not leave the arguments list empty for anything except the 'copy' action (and only when used with the 'filesame' cause)" unless $effecttype eq 'copy';
00785 print "no parameters defined, so applying effect($effecttype) as ( 2nd src parameter => 1st src parameter)!\n";
00786 effect($effecttype,$cause[1],$cause[0]); #copy the requested file[1] to the requested destn[0], now the [0] file exists and is the same.
00787 } else {
00788 effect($effecttype,@nocheckeffectparams); # do something else if the files are not 100% identical?
00789 }
00790 }else {
00791 print "effect not required files already up-to-date/identical: ($cause[0] => $cause[1]).\n";
00792 }
00793 undef $size; undef $mtime;
00794 undef $size2; undef $mtime2;
00795
00796 } elsif ( $causetype eq 'newer' ) {
00797 my $mtime = 0;
00798 if ( -f $cause[0] ) {
00799 $mtime = (stat($cause[0]))[9];
00800 }
00801 if (! ( -f $cause[1]) ) { die "cause: $causetype requires it's SECOND filename to exist for comparison: $cause[1].\n"; }
00802 my $mtime2 = (stat($cause[1]))[9];
00803 if ( $mtime < $mtime2 ) {
00804 effect($effecttype,@nocheckeffectparams);
00805 if ( $nocheck == 0 ) {
00806 # confirm it worked, mtimes should have changed now:
00807 my $mtime3 = 0;
00808 if ( -f $cause[0] ) {
00809 $mtime3 = (stat($cause[0]))[9];
00810 }
00811 my $mtime4 = (stat($cause[1]))[9];
00812 if ( $mtime3 < $mtime4 ) {
00813 die "EFFECT FAILED ($causetype -> $effecttype): mtime of file ($cause[0]) should be greater than file ($cause[1]).\n";
00814 }
00815 }
00816 } else {
00817 print "file ($cause[0]) has same or newer mtime than ($cause[1]) already, no action taken\n";
00818 }
00819 undef $mtime;
00820 undef $mtime2;
00821
00822 } elsif ( $causetype eq 'grep' ) {
00823 if ( ! _grep($cause[0],$cause[1]) ) { # grep actually needs two parameters on the source side of the action
00824 effect($effecttype,@nocheckeffectparams);
00825 } else {
00826 print "grep - already matched source file($cause[1]), with pattern ($cause[0]) - no action reqd\n";
00827 }
00828 if ( (! _grep($cause[0],$cause[1])) && $nocheck == 0 ) {
00829 die "EFFECT FAILED ($causetype -> $effecttype): unable to locate regex pattern ($cause[0]) in file ($cause[1])\n";
00830 }
00831
00832 } else {
00833 die " unknown causetype $causetype \n";
00834 }
00835 }
00836
00837 print "\nall done\n";
00838
00839 _end();
00840
00841 #------------------------------------------------------------------------------
00842
00843 # each cause has an effect, this is where we do them:
00844 sub effect {
00845 my ( $effecttype, @effectparams ) = @_;
00846
00847 if ( $effecttype eq 'fetch') {
00848 # passing two parameters that came in via the array
00849 _fetch(@effectparams);
00850
00851 } elsif ( $effecttype eq 'extract') {
00852 my $tarfile = $effectparams[0];
00853 my $destdir = $effectparams[1] || '';
00854 if ($destdir eq '') {
00855 $destdir = $tarfile;
00856 # strip off everything after the final forward slash
00857 $destdir =~ s#[^/]*$##;
00858 }
00859 my $t = findtar($tarfile);
00860 print "found equivalent: ($t) -> ($tarfile)\n" if $t ne $tarfile;
00861 print "extracttar($t,$destdir);\n";
00862 extracttar($t,$destdir);
00863
00864 } elsif ($effecttype eq 'exec') { # execute a DOS command
00865 my $cmd = shift @effectparams;
00866 #print `$cmd`;
00867 print "exec:$cmd\n";
00868 open F, $cmd." |" || die "err: $!";
00869 while (<F>) {
00870 print;
00871 }
00872
00873 } elsif ($effecttype eq 'shell') {
00874 shell(@effectparams);
00875
00876 } elsif ($effecttype eq 'copy') {
00877 die "Can not copy non-existant file ($effectparams[0])\n" unless -f $effectparams[0];
00878 print "copying file ($effectparams[0] => $effectparams[1]) \n";
00879 cp($effectparams[0],$effectparams[1]);
00880 # make destn mtime the same as the original for ease of comparison:
00881 shell("touch --reference=".perl2unix($effectparams[0])." ".perl2unix($effectparams[1]));
00882
00883 } elsif ($effecttype eq 'mkdirs') {
00884 mkdirs(shift @effectparams);
00885
00886 } elsif ($effecttype eq 'write') {
00887 # just dump the requested content from the array to the file.
00888 my $filename = shift @effectparams;
00889 my $fh = new IO::File ("> $filename")
00890 || die "error opening $filename for writing: $!\n";
00891 $fh->binmode();
00892 $fh->print(join('',@effectparams));
00893 $fh->close();
00894
00895 } else {
00896 die " unknown effecttype $effecttype from cause 'dir'\n";
00897 }
00898 }
00899 #------------------------------------------------------------------------------
00900
00901 # kinda like a directory search for blah.tar* but faster/easier.
00902 # only finds .tar.gz, .tar.bz2, .zip
00903 sub findtar {
00904 my $t = shift;
00905 return "$t.gz" if -f "$t.gz";
00906 return "$t.bz2" if -f "$t.bz2";
00907
00908 if ( -f "$t.zip" || $t =~ m/\.zip$/ ) {
00909 die "no unzip.exe found ! - yet" unless -f $sources."unzip/unzip.exe";
00910 # TODO - a bit of a special test, should be fixed better.
00911 return "$t.zip" if -f "$t.zip";
00912 return $t if -f $t;
00913 }
00914 return $t if -f $t;
00915 die "findtar failed to match a file from:($t)\n";
00916 }
00917 #------------------------------------------------------------------------------
00918
00919
00920 # given a ($t) .tar.gz, .tar.bz2, .zip extract it to the directory ( $d)
00921 # changes current directory to $d too
00922 sub extracttar {
00923 my ( $t, $d) = @_;
00924
00925 # both $t and $d at this point should be perl-compatible-forward-slashed
00926 die "extracttar expected forward-slashes only in pathnames ($t,$d)"
00927 if $t =~ m#\\# || $d =~ m#\\#;
00928
00929 unless ( $t =~ m/zip/ ) {
00930 # the unzip tool need the full DOS path,
00931 # the msys commands need that stripped off.
00932 $t =~ s#^$msys#/#i;
00933 }
00934
00935 print "extracting to: $d\n";
00936
00937 # unzipping happens in DOS as it's a dos utility:
00938 if ( $t =~ /\.zip$/ ) {
00939 #$d =~ s#/#\\#g; # the chdir command MUST have paths with backslashes,
00940 # not forward slashes.
00941 $d = perl2dos($d);
00942 $t = perl2dos($t);
00943 my $cmd = 'chdir '.$d.' && '.$dossources.'unzip\unzip.exe -o '.$t;
00944 print "extracttar:$cmd\n";
00945 open F, "$cmd |" || die "err: $!";
00946 while (<F>) {
00947 print;
00948 }
00949 return;
00950 }
00951
00952 $d = perl2unix($d);
00953 $t = perl2unix($t);
00954 # untarring/gzipping/bunzipping happens in unix/msys mode:
00955 die "unable to locate sh2.exe" unless -f $dosmsys.'bin/sh2.exe';
00956 my $cmd = $dosmsys.'bin\sh2.exe -c "( export PATH=/bin:/mingw/bin:$PATH ; ';
00957 $cmd .= "cd $d;";
00958 if ( $t =~ /\.gz$/ ) {
00959 $cmd .= $unixmsys."bin/tar.exe -zxvpf $t";
00960 } elsif ( $t =~ /\.bz2$/ ) {
00961 $cmd .= $unixmsys."bin/tar.exe -jxvpf $t";
00962 } elsif ( $t =~ /\.tar$/ ) {
00963 $cmd .= $unixmsys."bin/tar.exe -xvpf $t";
00964 } else {
00965 die "extract tar failed on ($t,$d)\n";
00966 }
00967 $cmd .= ')"'; # end-off the brackets around the shell commands.
00968
00969 # execute the cmd, and capture the output!
00970 # this is a glorified version of "print `$cmd`;"
00971 # except it doesn't buffer the output, if $|=1; is set.
00972 # $t should be a msys compatible path ie /sources/etc
00973 print "extracttar:$cmd\n";
00974 open F, "$cmd |" || die "err: $!";
00975 while (<F>) {
00976 print;
00977 }
00978 }
00979 #------------------------------------------------------------------------------
00980
00981
00982 # get the $url (typically a .tar.gz or similar) , and save it to $file
00983 sub _fetch {
00984 my ( $file,$url ) = @_;
00985
00986 #$file =~ s#/#\\\\#g;
00987 print "already exists: $file \n" if -f $file;
00988 return undef if -f $file;
00989
00990 print "fetching $url to $file (please wait)...\n";
00991 my $ua = LWP::UserAgent->new;
00992 $ua->proxy(['http', 'ftp'], $proxy);
00993
00994 my $req = HTTP::Request->new(GET => $url);
00995 my $res = $ua->request($req);
00996
00997 if ($res->is_success) {
00998 my $f = new IO::File "> $file" || die "_fetch: $!\n";
00999 $f->binmode();
01000 $f->print($res->content);
01001 $f->close();
01002 }
01003 if ( ! -s $file ) {
01004 die ("ERR: Unable to automatically fetch file!\nPerhaps manually downloading from the URL to the filename (both listed above) might work, or you might want to choose your own SF mirror (edit this script for instructions), or perhaps this version of the file is no longer available.");
01005 }
01006 }
01007 #------------------------------------------------------------------------------
01008
01009
01010 # execute a sequence of commands in a bash shell.
01011 # we explicitly add the /bin and /mingw/bin to the path
01012 # because at this point they aren't likely to be there
01013 # (cause we are in the process of installing them)
01014 sub shell {
01015 my @cmds = @_;
01016 my $cmd = $dosmsys.'bin\bash.exe -c "( export PATH=/bin:/mingw/bin:$PATH;'.join(';',@cmds).') 2>&1 "';
01017 print "shell:$cmd\n";
01018 # execute the cmd, and capture the output! this is a glorified version
01019 # of "print `$cmd`;" except it doesn't buffer the output if $|=1; is set.
01020 open F, "$cmd |" || die "err: $!";
01021 while (<F>) {
01022 if (! $NOISY ) {
01023 # skip known spurious messages from going to the screen unnecessarily
01024 next if /redeclared without dllimport attribute after being referenced with dllimpo/;
01025 next if /warning: overriding commands for target `\.\'/;
01026 next if /warning: ignoring old commands for target `\.\'/;
01027 next if /Nothing to be done for `all\'/;
01028 next if /^cd .* \&\& \\/;
01029 next if /^make -f Makefile/;
01030 }
01031 print;
01032 }
01033 }
01034 #------------------------------------------------------------------------------
01035 # recursively make folders, requires perl-compatible folder separators
01036 # (ie forward slashes)
01037 #
01038 sub mkdirs {
01039 my $path = shift;
01040 die "backslash in foldername not allowed in mkdirs function:($path)\n"
01041 if $path =~ m#\\#;
01042 $path = perl2dos($path);
01043 print "mkdir $path\n";
01044 # reduce path to just windows,
01045 # incase we have a rogue unix mkdir command elsewhere!
01046 print `set PATH=C:\\WINDOWS\\system32;c:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem && mkdir $path`;
01047
01048 }
01049
01050 #------------------------------------------------------------------------------
01051
01052
01053 sub perl2unix {
01054 my $p = shift;
01055 $p =~ s#$msys#/#i; # remove superflouus msys folders if they are there
01056 $p =~ s#^([CD]):#/$1#ig; #change c:/ into /c (or a D:) so c:/msys becomes /c/msys etc.
01057 $p =~ s#//#/#ig; # reduce any double forward slashes to single ones.
01058 return $p;
01059 }
01060 # DOS executable CMD.exe versions of the paths (for when we shell to DOS mode):
01061 sub perl2dos {
01062 my $p = shift;
01063 $p =~ s#/#\\#g; # single forward to single backward
01064 return $p;
01065 }
01066 #------------------------------------------------------------------------------
01067
01068 sub _grep {
01069 my ($pattern,$file) = @_;
01070 #$pattern = qw($pattern);
01071 print "grep-ing for pattern($pattern) in file($file)\n";
01072 my $fh = IO::File->new("< $file");
01073 unless ( $fh) { print "WARNING: Unable to read file ($file) when searching for pattern:($pattern), assumed to NOT match pattern\n"; return 0; }
01074 my $found = 0;
01075 while ( my $contents = <$fh> ) {
01076 if ( $contents =~ m/$pattern/ ) { $found= 1; }
01077 }
01078 $fh->close();
01079 return $found;
01080 }
01081 #------------------------------------------------------------------------------
01082
01083 sub comment {
01084 my $comment = shift;
01085 print "\nCOMMENTS:";
01086 print "-"x30;
01087 print "\n";
01088 print "COMMENTS:$comment\nCOMMENTS:";
01089 print "-"x30;
01090 print "\n";
01091 print "\n";
01092 }