Ticket #4397: win32-packager.14.2.patch

File win32-packager.14.2.patch, 52.8 KB (added by David Bussenschutt <davidbuzz@…>, 12 years ago)

superceedes patch 13 (incorporated), diff is against current SVN head. many enhancements, see trac log.

  • contrib/Win32/win32-packager.pl

    old new  
    2121use LWP::UserAgent;
    2222use IO::File;
    2323use Data::Dumper;
     24use File::Copy qw(cp);
    2425
    2526my $NOISY = 1; # set to 0 for less output to the screen
    2627
    2728$| = 1; # autoflush stdout;
    2829
    29 my $SVNRELEASE = '15367' ;# this scipt was last tested to work with this version, on other versions YMMV.
     30my $SVNRELEASE = '15433' ;# this scipt was last tested to work with this version, on other versions YMMV.
    3031
    3132# We allow SourceForge to tell us which server to download from,
    3233# rather than assuming specific server/s
     
    4748# TODO using the proxy here WILL cause any Subversion (SVN) commands to fail,
    4849#      you will need to do that by hand.
    4950my $proxy = '';
    50 #my $proxy = 'http://prx-bne.qmtechnologies.com:8080';
     51#my $proxy = 'http://enter.your.proxy.here:8080';
    5152
    5253# TODO -  use this list to define the components to build -
    5354my @components = ( 'mythtv', 'myththemes', 'mythplugins' );
     
    7576
    7677# unix/msys equivalent versions of the paths (for when we shell to MSYS/UNIX mode):
    7778my $unixmsys = '/'; # msys root is always mounted here, irrespective of where DOS says it really is.
    78 my $unixmingw = '/mingw/'; # mingw is always mounted here under unix, if you setup mingw right in msys. (see /etc/fstab)
     79my $unixmingw = '/mingw/'; # mingw is always mounted here under unix, if you setup mingw right in msys, so we will usually just say /mingw in the code, not '.$unixmingw.' or similar (see /etc/fstab)
    7980my $unixsources = perl2unix($sources); $unixsources =~ s#$unixmsys#/#i;  #strip leading msys path, if there, it's unnecessary as it's mounted under /
    8081my $unixmythtv  = perl2unix($mythtv);
    8182
    8283
    83 #NOTE: ITS IMPORTANT THAT ALL PATHS use FORWARD SLASHES in the declarations below, the code depends on it.
    84 #      ... and much of the path separator code is fragile!
    85 #      In some places we regex these into double backslashes, and at other times to a single
    86 #      backslash so that the call-outs to different environments (DOS/msys/perlticks) work.  hopefully. 
    87 #      (The only exception to "always forwardslash" is the contents of the file/s that are created with the 'write' action.)
    88 
    89 #NOTE: [exec]   actions should always refer to  $dosXXX paths
    90 #      [shell]  actions should always refer to $unixXXX paths
     84#NOTE: ITS IMPORTANT that the PATHS use the correct SLASH-ing method for the type of action:
     85#      for [exec] actions, use standard DOS paths, with single BACK-SLASHES '\' (unless in double quotes, then double the backslashes)
     86#      for [shell] actions, use standard UNIX paths, with single FORWARD-SLASHES '/'
     87#
     88#NOTE: when refering to variables in paths, try to keep them out of double quotes, or the slashing can get confused:       
     89#      [exec]   actions should always refer to  $dosXXX path variables
     90#      [shell]  actions should always refer to $unixXXX path  variables
    9191#      [dir],[file],[mkdirs],[archive] actions should always refer to default perl compatible paths
    9292
    9393# NOTE:  The architecture of this script is based on cause-and-event. 
    9494#        There are a number of "causes" (or expectations) that can trigger an event/action.
    9595#        There are a number of different actions that can be taken.
    9696#
    97 # eg: [ dir  => "c:/MinGW", exec => $sources.'MinGW-5.1.3.exe' ],
     97# eg: [ dir  => "c:/MinGW", exec => $dossources.'MinGW-5.1.3.exe' ],
    9898#
    9999# means: expect there to be a dir called "c:/MinGW", and if there isn't execute the file MinGW-5.1.3.exe.
    100100# (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)
     
    105105#  missing folder                                                          [dir]
    106106#  missing source archive (fancy version of 'file' to fetch from the web)  [archive]
    107107#  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]
     108#  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.
     109#  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.
    108110
    109111#build actions (events) are:
    110112#  fetch a file from the web (to a location)                         [fetch]
     
    114116#  extract a .tar .tar.gz or .tar.bz2 or ,zip file ( to a location)  [extract] - (note that .gz and .bz2 are thought equivalent)
    115117#  write a small patch/config/script file directly to disk           [write]
    116118#  make directory tree upto the path specified                       [mkdirs]
     119#  copy a new version of a file, set mtime to the original           [copy]
     120
    117121#TODO:
    118122#  copy a file or set of files (path/filespec,  destination)         not-yet-impl.  use exec => 'copy /Y xxx yyy'
    119123#  apply a diff                                                      not-yet-impl   use shell => 'patch -p0 < blah.patch'
    120 #  search-replace text in a file                                     not-yet-impl
     124#  search-replace text in a file                                     not-yet-impl   use grep => ['pattern',subject], exec => shell 'patch < etc to replace it'
    121125
    122126
    123127# NOTES on specific actions:
    124 # 'extract' now requires a all paths to be perl compatible (like all other commands)  If not supplied, it extracts into the folder the .tar.gz is in.
    125 # 'exec' actually runs all your commands inside a bash shell with -c "( cmd;cmd;cmd )" so be careful about quoting.
     128# '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.
     129# 'exec' actually runs all your commands inside a single cmd.exe command-line. To link commands use '&&'
     130# 'shell' actually runs all your commands inside a bash shell with -c "( cmd;cmd;cmd )" so be careful about quoting.
    126131
    127132
    128133#------------------------------------------------------------------------------
     
    145150[ archive => $sources.'mingw-utils-0.3.tar.gz', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/mingw-utils-0.3.tar.gz' ],
    146151
    147152
    148 [ dir  => $mingw, exec => $sources.'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?
    149 [ file  => $mingw."bin/gcc.exe", exec => $sources.'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?
     153[ 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?
     154[ 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?
    150155
    151156[ archive => $sources.'MSYS-1.0.10.exe', 'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/MSYS-1.0.10.exe',comment => 'Get the MSYS and addons:' ] ,
    152157[ 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' ] ,
     
    154159[ 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' ] ,
    155160
    156161# install MSYS, it supplies the 'tar' executable, among others:
    157 [ file => $msys.'bin/tar.exe', 'exec' => $sources.'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.' ] ,
     162[ 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.' ] ,
    158163
    159 #  don't use the [shell] action here, as it's not available until bash is installed!
    160 [ 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' ],
    161 
    162 # prior to this point you can't use the 'extract' feature, or the 'shell' feature!
     164#  don't use the [shell] or [copy] actions here, as neither are available until bash is installed!
     165[ 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' ],
    163166
     167# prior to this point you can't use the 'extract' 'copy' or 'shell' features!
    164168
    165169# 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
    166 [ file => $mingw.'bin/mingw32-make.exe',  exec => $sources.'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.' ],
    167 [ file => $mingw.'bin/g++.exe', exec => $sources.'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.' ],
    168 [ file => $mingw.'bin/g77.exe', exec => $sources.'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.' ],
     170[ 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.' ],
     171[ 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.' ],
     172[ 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.' ],
    169173
    170174#[ 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
    171175
     
    183187#  run it into a 'unzip' folder, becuase it doesn't extract to a folder:
    184188[ dir => $sources."unzip" ,  mkdirs => $sources.'unzip',comment => 'unzip.exe - Get a precompiled native Win32 version from InfoZip' ],
    185189[ archive => $sources.'unzip/unz552xN.exe',  fetch => 'ftp://tug.ctan.org/tex-archive/tools/zip/info-zip/WIN32/unz552xN.exe'],
    186 [ file => $sources.'unzip/unzip.exe', exec => "cd ".$dossources."unzip/ && ".$dossources."unzip/unz552xN.exe " ],
     190[ file => $sources.'unzip/unzip.exe', exec => 'chdir '.$dossources.'unzip && '.$dossources.'unzip/unz552xN.exe' ],
    187191# we could probably put the unzip.exe into the path...
    188192
    189193
     
    197201[ 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' ],
    198202[ dir => $sources."zlib/usr",  extract => [$sources.'zlib-1.2.3-MSYS-1.0.11.tar', $sources."zlib"] ],
    199203# install to /usr:
    200 [ file => $msys.'lib/libz.a',  exec => "copy /Y ".$dossources."zlib/usr/lib/* ".$dosmsys."lib/" ],
    201 [ file => $msys.'bin/msys-z.dll',  exec => "copy /Y ".$dossources."zlib/usr/bin/* ".$dosmsys."bin/" ],
    202 [ file => $msys.'include/zlib.h',  exec => "copy /Y ".$dossources."zlib/usr/include/* ".$dosmsys."include/" ],
     204[ file => $msys.'lib/libz.a',      exec => ["copy /Y ".$dossources.'zlib\usr\lib\* '.$dosmsys."lib"] ],
     205[ file => $msys.'bin/msys-z.dll',  exec => ["copy /Y ".$dossources.'zlib\usr\bin\* '.$dosmsys."bin"] ],
     206[ file => $msys.'include/zlib.h',  exec => ["copy /Y ".$dossources.'zlib\usr\include\*', $dosmsys."include"] ],
    203207# taglib also requires zlib in /mingw , so we'll put it there too, why not!
    204 [ file => $msys.'lib/libz.a',  exec => "copy /Y ".$dossources."zlib/usr/lib/* ".$dosmingw."lib/" ],
    205 [ file => $msys.'bin/msys-z.dll',  exec => "copy /Y ".$dossources."zlib/usr/bin/* ".$dosmingw."bin/" ],
    206 [ file => $msys.'include/zlib.h',  exec => "copy /Y ".$dossources."zlib/usr/include/* ".$dosmingw."include/" ],
     208[ file => $msys.'lib/libz.a',      exec => ["copy /Y ".$dossources.'zlib\usr\lib\* '.$dosmingw."lib"] ],
     209[ file => $msys.'bin/msys-z.dll',  exec => ["copy /Y ".$dossources.'zlib\usr\bin\*', $dosmingw."bin"] ],
     210[ file => $msys.'include/zlib.h',  exec => ["copy /Y ".$dossources.'zlib\usr\include\* '.$dosmingw."include"] ],
     211
     212
    207213
    208214# fetch mysql
    209215# 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/
    210216[ 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' ],
    211 [ file => $mingw.'bin/libmySQL.dll', exec => $sources.'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" ' ],
     217[ 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" ' ],
    212218
    213 # TODO after install (not done yet)
    214 [ file => $mingw.'bin/libmySQL.dll',  exec => "copy /Y \"c:/Program Files/MySQL/MySQL Server 5.0/bin/libmySQL.dll\" $dosmingw/bin/",comment => 'post-mysql-install' ],
    215 [ file => $mingw.'include/mysql.h',  exec => "copy /Y \"c:/Program Files/MySQL/MySQL Server 5.0/include/*\" $dosmingw/include/" ],
    216 [ file => $mingw.'lib/libmysql.lib',  exec => "copy /Y \"c:/Program Files/MySQL/MySQL Server 5.0/lib/opt/libmysql.lib\" $dosmingw/lib/" ],
     219# after mysql install
     220[ filesame => [$mingw.'bin/libmySQL.dll','c:/Program Files/MySQL/MySQL Server 5.0/bin/libmySQL.dll'],  copy => [''=>'',comment => 'post-mysql-install'] ],
     221[ filesame => [$mingw.'lib/libmySQL.dll','c:/Program Files/MySQL/MySQL Server 5.0/bin/libmySQL.dll'],  copy => [''=>'',comment => 'post-mysql-install'] ],
     222[ filesame => [$mingw.'lib/libmysql.lib','c:/Program Files/MySQL/MySQL Server 5.0/lib/opt/libmysql.lib'],  copy => [''=>''] ],
     223[ file => $mingw.'include/mysql.h'  ,   exec => 'copy /Y "c:\Program Files\MySQL\MySQL Server 5.0\include\*" '.$dosmingw."include" ],
    217224# cp /c/Program\ Files/MySQL/MySQL\ Server\ 5.0/include/* /c/MinGW/include/
    218225# cp /c/Program\ Files/MySQL/MySQL\ Server\ 5.0/bin/libmySQL.dll /c/MinGW/lib
    219226# cp /c/Program\ Files/MySQL/MySQL\ Server\ 5.0/lib/opt/libmysql.lib /c/MinGW/lib
    220227
    221 #
    222 # TIP: we use a special file (with an extra _ ) as a marker to do this action every the time, it's harmless to do it more often that required. "nocheck" means continue even if the cause doesn't exist after.
    223 [ file => $mingw.'lib/libmysql.lib__',  shell => ["cd $unixmingw/lib","reimp -d libmysql.lib","dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a","nocheck"],comment => ' rebuild libmysql.a' ],
    224 
     228#
     229# TIP: we use a special file (with an extra _ ) as a marker to do this action every the time, it's harmless to do it more often that required. 'nocheck' means continue even if the cause doesn't exist after.
     230[ file => $mingw.'lib/libmysql.lib__',  shell => ["cd /mingw/lib","reimp -d libmysql.lib","dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a",'nocheck'],comment => ' rebuild libmysql.a' ],
    225231
    226232
    227233# grep => [pattern,file] , actions/etc
    228 [ file => $mingw.'include/mysql__h.patch', write => [$mingw.'include/mysql__h.patch',
    229 '*** orig_mysql.h       Fri Jul  6 13:24:56 2007
    230 *** mysql.h_orig        Fri Jan  4 19:35:33 2008
    231 --- mysql.h     Fri Jan  4 16:45:46 2008
    232 ***************
    233 *** 45,51 ****
    234   #include <winsock.h>                          /* For windows */
    235   #endif
    236   typedef char my_bool;
    237 ! #if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
    238   #define __WIN__
    239   #endif
    240   #if !defined(__WIN__)
    241 --- 45,51 ----
    242   #include <winsock.h>                          /* For windows */
    243   #endif
    244   typedef char my_bool;
    245 ! #if (defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__)) && !defined(__WIN__)
    246   #define __WIN__
    247   #endif
    248   #if !defined(__WIN__)
    249 ' ],comment => 'write the patch to the the mysql.h file'],
     234[ file => $mingw.'include/mysql___h.patch', write => [$mingw.'include/mysql___h.patch',
     235'--- mysql.h_orig       Fri Jan  4 19:35:33 2008
     236+++ mysql.h     Tue Jan  8 14:48:36 2008
     237@@ -41,11 +41,9 @@
     238
     239 #ifndef _global_h                              /* If not standard header */
     240 #include <sys/types.h>
     241-#ifdef __LCC__
     242 #include <winsock.h>                           /* For windows */
     243-#endif
     244 typedef char my_bool;
     245-#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
     246+#if (defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__)) && !defined(__WIN__)
     247 #define __WIN__
     248 #endif
     249 #if !defined(__WIN__)
     250 
     251 ' ],comment => 'write the patch for the the mysql.h file'],
    250252
    251253
    252 [ grep => ['\|\| defined\(__MINGW32__\)',$mingw.'include/mysql.h'], shell => ["cd $unixmingw/include","patch -p0 < mysql__h.patch"],comment => 'Apply mysql.h patch file, if not already applied....' ],
     254[ 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....' ],
    253255
    254256
    255257# fetch it
    256258[ dir =>     $sources.'pthread', mkdirs => $sources.'pthread' ],
    257259[ archive => $sources.'pthread/libpthread.a',   'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/libpthreadGC2.a',comment => 'libpthread is precompiled, we just download it to the right place ' ],
    258260[ archive => $sources.'pthread/pthreadGC2.dll', 'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/pthreadGC2.dll' ],
    259 [ file    => $sources.'pthread/pthread.dll',       exec => "copy /Y ".$sources."pthread/pthreadGC2.dll ".$sources."pthread/pthread.dll" ],
     261[ filesame    => [$sources.'pthread/pthread.dll',$sources."pthread/pthreadGC2.dll"],  copy => [''=>''] ],
    260262[ archive => $sources.'pthread/pthread.h',      'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/pthread.h' ],
    261263[ archive => $sources.'pthread/sched.h',        'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/sched.h' ],
    262264[ archive => $sources.'pthread/semaphore.h',    'fetch' => 'ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/semaphore.h' ],
    263265# install it:
    264 [ file => $mingw.'lib/libpthread.a',    exec => "copy /Y ".$dossources."pthread/libpthread.a ".$dosmingw.'lib/libpthread.a',comment => 'install pthread' ],
    265 [ file => $mingw.'bin/pthreadGC2.dll',  exec => "copy /Y ".$dossources."pthread/pthreadGC2.dll ".$dosmingw.'bin/pthreadGC2.dll' ],
    266 [ file => $mingw.'bin/pthread.dll',     exec => "copy /Y ".$dossources."pthread/pthread.dll ".$dosmingw.'bin/pthread.dll' ],
    267 [ file => $mingw.'include/pthread.h',   exec => "copy /Y ".$dossources."pthread/pthread.h ".$dosmingw.'include/pthread.h' ],
    268 [ file => $mingw.'include/sched.h',     exec => "copy /Y ".$dossources."pthread/sched.h ".$dosmingw.'include/sched.h' ],
    269 [ file => $mingw.'include/semaphore.h', exec => "copy /Y ".$dossources."pthread/semaphore.h ".$dosmingw.'include/semaphore.h' ],
    270 
    271 
    272 ## download the MS directX SDK
    273 ##  believe it or not, the above exe(dxsdk_november2007.exe) is actually just a zip archive(containing dxsdk_nov2007.exe) with
    274 ## a "read the licence and click OK to unzip", so we just unzip it with a few magic incantations of command lines:
    275 ## and the contents (dxsdk_nov2007.exe) is actually just a zip file too, so we unzip it (again) in a subfolder.   finally, the files!
    276 #[ archive => $sources.'dxsdk_november2007.exe','fetch' => 'http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=4b78a58a-e672-4b83-a28e-72b5e93bd60a&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fb%2fe%2f7%2fbe7ffe34-903c-410b-bdbc-ee6c018df45c%2fdxsdk_november2007.exe' ],
    277 #[ dir => $sources."dxsdk/", mkdirs => $sources.'dxsdk' ],
    278 ## command to extract this .zip file to a folder (this outer wrapper is NOT unzip.exe compatible!):
    279 #[ file => $sources."dxsdk/dxsdk_nov2007.exe", exec => $dossources."dxsdk_november2007.exe /C /Q /T:".$dossources."dxsdk" ],
    280 ## extract this  - it's a "winzip self extracter" - which IS "unzip.exe compatible"
    281 #[ file => $sources."dxsdk/Include/dsound.h", exec => "cd ".$dossources."dxsdk/ && ".$dossources."unzip/unzip.exe dxsdk_nov2007.exe" ],
    282 ## relocate the dxsdk header files to the folder :
    283 ## put ddraw.h dinput.h dsound.h into C:\MinGW\Include
    284 #[ file => $mingw.'include/dsound.h', exec => "copy /Y ".$dossources."dxsdk/Include/dsound.h $dosmingw/include/dsound.h" ],
    285 #[ file => $mingw.'include/dinput.h', exec => "copy /Y ".$dossources."dxsdk/Include/dinput.h $dosmingw/include/dinput.h" ],
    286 #[ file => $mingw.'include/ddraw.h', exec => "copy /Y ".$dossources."dxsdk/Include/ddraw.h $dosmingw/include/ddraw.h" ],
    287 ## not sure if we need this too, but it doesn't hurt:
    288 #[ file => $mingw.'include/dsetup.h', exec => "copy /Y ".$dossources."dxsdk/Include/dsetup.h $dosmingw/include/dsetup.h" ],
     266[ filesame => [$mingw.'lib/libpthread.a',   $sources."pthread/libpthread.a"],      copy => [''=>'',comment => 'install pthread'] ],
     267[ filesame => [$mingw.'bin/pthreadGC2.dll', $sources."pthread/pthreadGC2.dll"],    copy => [''=>''] ],
     268[ filesame => [$mingw.'bin/pthread.dll',    $sources."pthread/pthread.dll"],       copy => [''=>''] ],
     269[ filesame => [$mingw.'include/pthread.h',  $sources."pthread/pthread.h"],         copy => [''=>''] ],
     270[ filesame => [$mingw.'include/sched.h',    $sources."pthread/sched.h"],           copy => [''=>''] ],
     271[ filesame => [$mingw.'include/semaphore.h',$sources."pthread/semaphore.h"],       copy => [''=>''] ],
     272
    289273
    290274#   ( save bandwidth compare to the above full SDK where they came from:
    291275[ 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' ],
    292276[ dir => $sources.'DX9SDK_dsound_Include_subset', extract => $sources.'DX9SDK_dsound_Include_subset.zip' ],
    293 [ file => $mingw.'include/dsound.h', exec => "copy /Y ".$dossources."DX9SDK_dsound_Include_subset/dsound.h ".$dosmingw."include/dsound.h" ],
    294 [ file => $mingw.'include/dinput.h', exec => "copy /Y ".$dossources."DX9SDK_dsound_Include_subset/dinput.h ".$dosmingw."include/dinput.h" ],
    295 [ file => $mingw.'include/ddraw.h', exec =>  "copy /Y ".$dossources."DX9SDK_dsound_Include_subset/ddraw.h ".$dosmingw."include/ddraw.h" ],
    296 [ file => $mingw.'include/dsetup.h', exec => "copy /Y ".$dossources."DX9SDK_dsound_Include_subset/dsetup.h ".$dosmingw."include/dsetup.h" ],
    297 
     277[ filesame => [$mingw.'include/dsound.h',$sources."DX9SDK_dsound_Include_subset/dsound.h"], copy => [''=>''] ],
     278[ filesame => [$mingw.'include/dinput.h',$sources."DX9SDK_dsound_Include_subset/dinput.h"], copy => [''=>''] ],
     279[ filesame => [$mingw.'include/ddraw.h', $sources."DX9SDK_dsound_Include_subset/ddraw.h"],  copy => [''=>''] ],
     280[ filesame => [$mingw.'include/dsetup.h',$sources."DX9SDK_dsound_Include_subset/dsetup.h"], copy => [''=>''] ],
    298281
    299282
    300283#----------------------------------------
     
    307290[ archive => $sources.'freetype-2.3.5.tar.gz',  fetch => 'http://download.savannah.nongnu.org/releases/freetype/freetype-2.3.5.tar.gz'],
    308291[ dir => $sources.'freetype-2.3.5', extract => $sources.'freetype-2.3.5.tar' ],
    309292# caution... freetype comes with a Makefile in the .tar.gz, so work around it!
    310 [ file => $sources.'freetype-2.3.5/Makefile_', shell => ["cd $unixsources/freetype-2.3.5","./configure --prefix=/mingw","make","make install","touch $unixsources/freetype-2.3.5/Makefile_"] ],
     293[ file => $sources.'freetype-2.3.5/Makefile_', shell => ["cd $unixsources/freetype-2.3.5","./configure --prefix=/mingw","touch $unixsources/freetype-2.3.5/Makefile_"] ],
     294# 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!
     295[ file => $sources.'freetype-2.3.5/objs/.libs/libfreetype.a', shell => ["cd $unixsources/freetype-2.3.5","make"] ],
     296[ file => $mingw.'lib/libfreetype.a', shell => ["cd $unixsources/freetype-2.3.5","make install"] ],
    311297
    312298
    313299[ archive => $sources.'lame-3.97.tar.gz',  fetch => 'http://'.$sourceforge.'/sourceforge/lame/lame-3.97.tar.gz'],
    314300[ dir => $sources.'lame-3.97', extract => $sources.'lame-3.97.tar' ],
    315 [ file => $sources.'lame-3.97/Makefile', shell => ["cd $unixsources/lame-3.97","./configure --prefix=$unixmingw","make","make install"] ],
     301[ file => $sources.'lame-3.97/Makefile', shell => ["cd $unixsources/lame-3.97","./configure --prefix=/mingw","make","make install"] ],
    316302
    317303[ archive => $sources.'libmad-0.15.1b.tar.gz',  fetch => 'http://'.$sourceforge.'/sourceforge/mad/libmad-0.15.1b.tar.gz'],
    318304[ dir => $sources.'libmad-0.15.1b', extract => $sources.'libmad-0.15.1b.tar' ],
     
    386372[ archive => $sources.'qt-3.3.x-p8.tar.bz2',  fetch => 'http://'.$sourceforge.'/sourceforge/qtwin/qt-3.3.x-p8.tar.bz2'],
    387373[ dir => $msys.'qt-3.3.x-p8', extract => [$sources.'qt-3.3.x-p8.tar', $msys] ],
    388374
    389 #
    390 
    391375# two older patches
    392376#[ archive => 'qt.patch.gz' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4270/qt.patch.gz'],
    393377#[ archive => 'qt2.patch' , 'fetch' => 'http://tanas.ca/qt2.patch'],
    394378# OR:
    395379# equivalent patch:
    396380[ archive => $sources.'qt.patch' , 'fetch' => 'http://tanas.ca/qt.patch',comment => ' patch the QT sources'],
    397 [ file => $msys.'qt-3.3.x-p8/qt.patch', exec => "copy /Y ".$dossources."qt.patch ".$msys."qt-3.3.x-p8" ],
     381[ filesame => [$msys.'qt-3.3.x-p8/qt.patch',$sources."qt.patch"], copy => [''=>''] ],
    398382[ 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"] ],
    399383
    400384
    401385[ 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! ' ] ,
    402386
    403 # write a batch script to build the QT sources here:
    404 # the double slashes in the paths here are because this string is in double quotes (the variables need interpolating, so the slashes geet it too)
    405 [ file => $msys.'qt-3.3.x-p8/qtsetup.bat', write => [$msys.'qt-3.3.x-p8/qtsetup.bat',
    406 'set QTDIR='.$dosmsys.'qt-3.3.x-p8
     387# write a batch script for the QT environment under DOS:
     388[ file => $msys.'qt-3.3.x-p8/qt_env.bat', write => [$msys.'qt-3.3.x-p8/qt_env.bat',
     389'rem a batch script for the QT environment under DOS:
     390set QTDIR='.$dosmsys.'qt-3.3.x-p8
    407391set MINGW='.$dosmingw.'
    408392set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH%
    409393set QMAKESPEC=win32-g++
    410394cd %QTDIR%
    411 rem rename '.$dosmsys.'bin\sh.exe sh_.exe
    412 configure.bat -thread -plugin-sql-mysql -opengl -no-sql-sqlite
    413 mingw32-make
    414 mingw32-make install
    415 rem rename '.$dosmsys.'bin\sh_.exe sh.exe
    416 ']],
     395'
     396],comment=>'write a batch script for the QT environment under DOS'],
     397
     398
     399[ 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!)' ],
     400
     401[ 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!' ],
     402
     403# did the configure finish?  - run mingw32-make to get it to finish properly.
     404# 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
     405[ 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!)' ],
    417406
     407# TODO - do we have an action we can take to build just this one file/dll if it fails? 
     408# For now, we will just test if it built, and abort if it didn't!
     409[ 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?) '],
     410[ 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'],
     411[ 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'],
     412[ 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'],
    418413
    419 [ file => $msys.'qt-3.3.x-p8/lib/libqt-mt3.dll', exec => $dosmsys.'qt-3.3.x-p8/qtsetup.bat',comment => 'Execute qtsetup.bat script to actually build QT now! ' ],
     414
     415# TODO "make install" qt - where to?, will this work? (not sure, it sometimes might, but it's not critical?)
     416#[ 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' ],
     417# 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?:
    420418
    421419
    422420#  (back to sh.exe ) now that we are done !
    423421[ file => $msys.'bin/sh.exe', shell => ["mv ".$unixmsys."bin/sh_.exe ".$unixmsys."bin/sh.exe"],comment => 'rename msys sh_.exe back again!' ] ,
    424422
    425 #Copy libqt-mt3.dll to libqt-mt.dll  - but always do it(nocheck), or we could be using an old version:
    426 [ file => $msys.'qt-3.3.x-p8/lib/libqt-mt.dll', shell => ["cp ".$unixmsys."qt-3.3.x-p8/lib/libqt-mt3.dll ".$unixmsys."qt-3.3.x-p8/lib/libqt-mt.dll","nocheck"],comment => 'Copy libqt-mt3.dll to libqt-mt.dll' ] ,
     423#Copy libqt-mt3.dll to libqt-mt.dll  , if there is any date/size change!
     424[ 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' ] ,
    427425
    428426
    429427#----------------------------------------
     
    433431[ dir => $mythtv.'mythtv', mkdirs => $mythtv.'mythtv' ],
    434432
    435433
    436 [ 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....' ],
     434[ 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....' ],
    437435
    438436# 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)
    439437# this is some nasty in-line batch-script code, but it works.
     
    441439# mythtv,mythplugins,myththemes
    442440foreach my $comp( @components ) {
    443441push @{$expect},
    444 [ 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 ];
     442[ 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 ];
    445443}
    446444push @{$expect},
    447445# now lets write some build scripts to help with mythtv itself
     
    454452export PATH=$QTDIR/bin:$PATH
    455453' ],comment => 'write a script that we can source later when inside msys to setup the environment variables'],
    456454
    457 #
    458 [ file => $mythtv.'make_run.sh', write => [$mythtv.'make_run.sh',
    459 '#!/bin/bash
    460 source '.$unixmythtv.'qt_env.sh
    461 cd '.$unixmythtv.'/mythtv
    462 # keep around just one earlier verion in run_old:
    463 rm -rf run_old
    464 mv run run_old
    465 mkdir run
    466 # copy exes and dlls to the run folder:
    467 find . -name \\*.exe  | xargs -n1 -i__ cp __ ./run/
    468 find . -name \\*.dll  | xargs -n1 -i__ cp __ ./run/ 
    469 # mythtv expects the dll to NOT have the 3 in it.
    470 cp '.$unixmsys.'qt-3.3.x-p8/lib/libqt-mt3.dll '.$unixmsys.'qt-3.3.x-p8/lib/libqt-mt.dll
    471 # mythtv needs the qt dlls at runtime:
    472 cp '.$unixmsys.'qt-3.3.x-p8/lib/*.dll '.$unixmythtv.'mythtv/run
    473 # qt mysql connection dll has to exist in a subfolder called sqldrivers:
    474 mkdir '.$unixmythtv.'mythtv/run/sqldrivers
    475 cp '.$unixmsys.'qt-3.3.x-p8/plugins/sqldrivers/libqsqlmysql.dll '.$unixmythtv.'mythtv/run/sqldrivers
    476 # pthread dlls and mingwm10.dll are copied from here:
    477 cp '.$unixmingw.'bin/*.dll '.$unixmythtv.'mythtv/run
    478 ' ],comment => 'script that will copy all the files necessary for running mythtv out of the build folder into the ./run folder'],
    479 
    480 #
    481 [ file => $mythtv.'build_myth.sh', write => [$mythtv.'build_myth.sh',
    482 '#!/bin/bash
    483 source '.$unixmythtv.'qt_env.sh
    484 cd '.$unixmythtv.'mythtv
    485 make clean
    486 make distclean
    487 touch '.$unixmythtv.'mythtv/config/config.pro
    488 ./configure --prefix=/usr --disable-dbox2 --disable-hdhomerun --disable-dvb --disable-ivtv --disable-iptv --disable-joystick-menu --disable-xvmc-vld --disable-x11 --disable-xvmc --enable-directx --enable-memalign-hack --cpu=k8 --compile-type=debug && make && make install
    489 #make
    490 #make install
    491 #cd ..
    492 ' ],comment => 'write a script to build main mythtv'],
     455##
     456#[ file => $mythtv.'make_run.sh', write => [$mythtv.'make_run.sh',
     457#'#!/bin/bash
     458#source '.$unixmythtv.'qt_env.sh
     459#cd '.$unixmythtv.'/mythtv
     460## keep around just one earlier verion in run_old:
     461#rm -rf run_old
     462#mv run run_old
     463#mkdir run
     464## copy exes and dlls to the run folder:
     465#find . -name \\*.exe  | grep -v run | xargs -n1 -i__ cp __ ./run/
     466#find . -name \\*.dll  | grep -v run | xargs -n1 -i__ cp __ ./run/ 
     467## mythtv needs the qt dlls at runtime:
     468#cp '.$unixmsys.'qt-3.3.x-p8/lib/*.dll '.$unixmythtv.'mythtv/run
     469## qt mysql connection dll has to exist in a subfolder called sqldrivers:
     470#mkdir '.$unixmythtv.'mythtv/run/sqldrivers
     471#cp '.$unixmsys.'qt-3.3.x-p8/plugins/sqldrivers/libqsqlmysql.dll '.$unixmythtv.'mythtv/run/sqldrivers
     472## pthread dlls and mingwm10.dll are copied from here:
     473#cp /mingw/bin/*.dll '.$unixmythtv.'mythtv/run
     474#' ],comment => 'script that will copy all the files necessary for running mythtv out of the build folder into the ./run folder'],
    493475
    494476#
    495477[ file => $mythtv.'build_plugins.sh', write => [$mythtv.'build_plugins.sh',
     
    502484' ],comment => 'write a script to build mythtv plugins'],
    503485
    504486# chmod the shell scripts, everytime
    505 [ file => $mythtv.'_' , shell => ["cd $mythtv","chmod 755 *.sh","nocheck"] ],
     487[ file => $mythtv.'_' , shell => ["cd $mythtv","chmod 755 *.sh",'nocheck'] ],
    506488
    507489#----------------------------------------
    508490# now we build mythtv!
     
    511493# SVN update every time, before patches, unless we are using a proxy
    512494foreach my $comp( @components ) {
    513495push @{$expect},
    514 [ file => $mythtv.'using_proxy_cannot_do_SVN.txt', exec => ["cd ".$dosmythtv."$comp && ".$dosmsys."bin/svn.exe update","nocheck"],comment => 'getting SVN updates for:'.$comp ],
     496[ file => $mythtv.'using_proxy_cannot_do_SVN.txt', exec => ['cd '.$dosmythtv."$comp && ".$dosmsys.'bin\svn.exe update','nocheck'],comment => 'getting SVN updates for:'.$comp ],
    515497}
    516498push @{$expect},
    517499
     
    519501# apply any outstanding win32 patches - this section will be hard to keep upwith HEAD/SVN:
    520502
    521503#fixed/closed:
    522 
    523 #4390 -  stuff
    524 #[ archive => $sources.'videoout_embedding.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4390/videoout_embedding.patch'],
    525 #[ file => $mythtv.'mythtv/videoout_embedding.patch', exec => "copy /Y $sources/videoout_embedding.patch $mythtv/mythtv/" ],
    526 #[ file => $mythtv.'mythtv/videoout_embedding.patch_', shell => ["cd /c/mythtv/mythtv/","patch -p0 < videoout_embedding.patch","touch videoout_embedding.patch_"] ],
    527 
    528 # in SVN at 7th Jan 2008
    529 #[ archive => $sources.'setup.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4391/setup.patch'],
    530 #[ file => $mythtv.'mythtv/setup.patch', exec => "copy /Y ".$dossources."setup.patch ".$dosmythtv."mythtv",comment => '4391: - configgroups patch' ],
    531 #[ grep => ['children\[i\] \&\& children\[i\]->isVisible\(\)',$mythtv.'mythtv/libs/libmyth/mythconfiggroups.cpp'], shell => ["cd ".$unixmythtv."mythtv/","patch -p0 < setup.patch"] ],
    532 
    533 ##
    534 
    535 # in SVN at 7th Jan 2008
    536 #[ archive => $sources.'mythwelcome.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4409/mythwelcome.patch'],
    537 #[ file => $mythtv.'mythtv/mythwelcome.patch', exec => "copy /Y ".$dossources."mythwelcome.patch ".$dosmythtv."mythtv",comment => '4409 mythwelcome patch: (MinGW SIGHUP undefined)' ],
    538 #[ grep => ['\#include \"libmyth\/compat\.h\"',$mythtv.'mythtv/programs/mythwelcome/main.cpp'], shell => ["cd ".$unixmythtv."mythtv/","patch -p0 < mythwelcome.patch"] ],
    539 
    540 # no longer required as at [15335] - 7th jan 2008
    541 #[ archive => $sources.'themereload_win32.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4411/themereload_win32.patch'],
    542 #[ file => $mythtv.'mythtv/themereload_win32.patch', exec => "copy /Y ".$dossources."themereload_win32.patch ".$dosmythtv."mythtv",comment => '4411 changeset 15290 is incompatible with Win32' ],
    543 #[ grep => ['\#ifndef _WIN32',$mythtv.'mythtv/programs/mythfrontend/main.cpp'], shell => ["cd ".$unixmythtv."mythtv/","patch -p0 < themereload_win32.patch"] ],
    544 
    545 # in SVN at 7th Jan 2008
    546 #[ archive => $sources.'dlerr.win.patch' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4422/dlerr.win.patch'],
    547 #[ file => $mythtv.'mythtv/dlerr.win.patch', exec => "copy /Y ".$dossources."dlerr.win.patch ".$dosmythtv."mythtv",comment => '4422 fixes error: "call of overloaded QString(DWORD) is ambiguous" ' ],
    548 #[ grep => ['inline const char \*dlerror(void)',$mythtv.'mythtv/libs/libmyth/compat.h'], shell => ["cd ".$unixmythtv."mythtv/","patch -p0 < dlerr.win.patch"] ],
    549 
    550 
    551 [ archive => $sources.'backend.patch.gz' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/4392/backend.patch.gz'],
    552 [ file => $mythtv.'mythtv/backend.patch.gz', exec => "copy /Y ".$dossources."backend.patch.gz ".$dosmythtv."mythtv",comment => '4392: - backend connections being accepted patch ' ],
     504[ 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'],
     505[ filesame => [$mythtv.'mythtv/backend.patch.gz',$sources."backend.patch.gz"], copy => [''=>'',comment => '4392: - backend connections being accepted patch '] ],
    553506[ 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"] ],
    554507
    555508
    556 [ archive => $sources.'importicons_windows_2.diff' , 'fetch' => 'http://svn.mythtv.org/trac/raw-attachment/ticket/3334/importicons_windows_2.diff'],
    557 [ file => $mythtv.'mythtv/importicons_windows_2.diff', exec => "copy /Y ".$dossources."importicons_windows_2.diff ".$dosmythtv."mythtv",comment => '3334 fixes error with mkdir() unknown. ' ],
     509[ 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'],
     510[ filesame => [$mythtv.'mythtv/importicons_windows_2.diff',$sources."importicons_windows_2.diff"], copy => [''=>'',comment => '3334 fixes error with mkdir() unknown.'] ],
    558511[ grep => ['\#include <qdir\.h>',$mythtv.'mythtv/libs/libmythtv/importicons.cpp'], shell => ["cd ".$unixmythtv."mythtv/","patch -p0 < importicons_windows_2.diff"] ],
    559512
     513
     514[ 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'],
     515
    560516# next the build process:
     517# the old way:
     518#[ file => $mythtv.'no_rebuild_mythtv.txt', shell => ["cd ".$unixmythtv,'./build_myth.sh','touch no_rebuild_mythtv.txt'],comment => 'execute the mythtv build script (we wrote it earlier), unless its already been built once before ( ie the no_rebuild_mythtv.txt file exists! )' ],
     519
     520# the new way, with a bit better dependancy resolution:
     521# total cleanup:
     522#[ file => $mythtv.'mythtv/Makefile', shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make distclean','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...'],
     523# minor cleanup (keep the configuration)
     524#[ file => $mythtv.'mythtv/Makefile', shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make clean','make distclean','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...'],
     525# config
     526[ file => $mythtv.'mythtv/Makefile', shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','./configure --prefix=/usr --disable-dbox2 --disable-hdhomerun --disable-dvb --disable-ivtv --disable-iptv --disable-joystick-menu --disable-xvmc-vld --disable-x11 --disable-xvmc --enable-directx --enable-memalign-hack --cpu=k8 --compile-type=debug'], comment => 'do we already have a Makefile for mythtv?' ],
     527# make
     528[ newer => [$mythtv.'mythtv/libs/libmyth/libmyth-0.20.dll',$mythtv.'mythtv/Makefile'], shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make'], comment => 'libs/libmyth/libmyth-0.20.dll - redo make unless all these files exist, and are newer than the Makefile' ],
     529[ newer => [$mythtv.'mythtv/libs/libmythtv/libmythtv-0.20.dll',$mythtv.'mythtv/Makefile'], shell => ['source '.$unixmythtv.'qt_env.sh','cd '.$unixmythtv.'mythtv','make'], comment => 'libs/libmythtv/libmythtv-0.20.dll - redo make unless all these files exist, and are newer than the Makefile' ],
     530[ newer => [$mythtv.'mythtv/programs/mythfrontend/mythfrontend.exe',$mythtv.'mythtv/Makefile'], shell => ['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 Makefile' ],
     531[ newer => [$mythtv.'mythtv/programs/mythbackend/mythbackend.exe',$mythtv.'mythtv/Makefile'], shell => ['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 Makefile' ],
     532
     533# re-install to msys /usr/bin folders etc, if we have a newer mythtv build ready:
     534[ 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 ' ],
     535
     536# install some themes? does a 'make install' do that adequately (no, not if running outside msys)?
     537
     538
    561539#
    562 [ file => $mythtv.'no_rebuild_mythtv.txt', shell => ["cd ".$unixmythtv,'./build_myth.sh','touch no_rebuild_mythtv.txt'],comment => 'execute the mythtv build script (we wrote it earlier), unless its already been built once before ( ie the no_rebuild_mythtv.txt file exists! )' ],
     540[ file => $mythtv.'make_run.sh', write => [$mythtv.'make_run.sh',
     541'#!/bin/bash
     542source '.$unixmythtv.'qt_env.sh
     543cd '.$unixmythtv.'mythtv
     544# keep around just one earlier verion in run_old:
     545rm -rf run_old
     546mv run run_old
     547mkdir run
     548# copy exes and dlls to the run folder:
     549find . -name \\*.exe  | grep -v run | xargs -n1 -i__ cp __ ./run/
     550find . -name \\*.dll  | grep -v run | xargs -n1 -i__ cp __ ./run/ 
     551# mythtv needs the qt dlls at runtime:
     552cp '.$unixmsys.'qt-3.3.x-p8/lib/*.dll '.$unixmythtv.'mythtv/run
     553# qt mysql connection dll has to exist in a subfolder called sqldrivers:
     554mkdir '.$unixmythtv.'mythtv/run/sqldrivers
     555cp '.$unixmsys.'qt-3.3.x-p8/plugins/sqldrivers/libqsqlmysql.dll '.$unixmythtv.'mythtv/run/sqldrivers
     556# pthread dlls and mingwm10.dll are copied from here:
     557cp /mingw/bin/*.dll '.$unixmythtv.'mythtv/run
     558'
     559],comment => 'write a script that will copy all the files necessary for running mythtv out of the build folder into the ./run folder'],
    563560
    564 #------------------------------------------------------------------------------
    565561
    566 ;
     562[ 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' ],
    567563
    568564
     565
     566#----------------------------------------
     567
     568; # END OF CAUSE->ACTION DEFINITIONS
     569
     570#------------------------------------------------------------------------------
     571
    569572sub _end {
    570573       
    571574        comment("This verson of the Win32 Build script last was last tested on: $SVNRELEASE");
     
    573576print << "END";   
    574577#
    575578# SCRIPT TODO/NOTES:  - further notes on this scripts direction....
     579# if the build was successful then try running the 'mythfrontend.exe' and 'mythbackend.exe' from the 'C:\mythtv\mythtv\run' folder.
    576580# ok, how about the test-run process? 
    577 # execute the $mythtv.'make_run.sh' to put all the exe's and dll's in one place
    578581# create a vanilla mysql.txt file
    579582# check that the local mysql server is running, and configure it:
    580583# we should run: 'C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\MySQLInstanceConfig.exe'
     
    595598    my $causetype = $dep[0];
    596599    my $cause =  $dep[1];
    597600    my $effecttype = $dep[2];
    598     my $effectparams = $dep[3];
     601    my $effectparams = $dep[3] || '';
    599602    die "too many parameters in cause->event declaration (@dep)" if defined $dep[4] && $dep[4] ne 'comment';  # four pieces: cause => [blah] , effect => [blah]
    600603    my $comment = $dep[5] || '';
    601604
     
    614617    die "too many parameters in cause->event declaration (@dep)"
    615618        if defined $dep[6];
    616619
    617     my @effectparams;
     620    my @effectparams = ();
    618621    if (ref($effectparams) eq "ARRAY" ) {
    619622        @effectparams = @{$effectparams};
    620623    } else {
     
    652655        if ( ! -f $cause[0] && $nocheck == 0) {
    653656            die "file -> EFFECT FAILED: $causetype,$cause[0],$effecttype\n";
    654657        }
    655 
     658    } elsif ( $causetype eq 'filesame' ) {
     659        # TODO - currently we check file mtime, and byte size, but not MD5/CRC32 or contents,  this is "good enough" for most circumstances.
     660        my ( $size,$mtime)=(0,0);
     661        if ( -f $cause[0] ) {
     662          $size = (stat($cause[0]))[7];
     663          $mtime  = (stat($cause[0]))[9];
     664        }
     665        if (! (-f $cause[1] ) ) {  die "cause: $causetype requires its SECOND filename to exist for comparison: $cause[1] \n"; }
     666        my $size2 = (stat($cause[1]))[7];
     667        my $mtime2  = (stat($cause[1]))[9];
     668        if ( $mtime != $mtime2 || $size != $size2) {
     669          if ( ! $nocheckeffectparams[0] ) {
     670            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';
     671            print "no parameters defined, so applying effect($effecttype) as ( 2nd src parameter => 1st src parameter)!\n";
     672            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.
     673          } else {
     674            effect($effecttype,@nocheckeffectparams); # do something else if the files are not 100% identical?
     675          } 
     676        }else {
     677           print "effect not requiredm files already up-to-date/identical: ($cause[0] => $cause[1]) \n";
     678        }
     679        undef $size; undef $mtime;
     680        undef $size2; undef $mtime2;
     681       
     682    } elsif ( $causetype eq 'newer' ) {
     683        my $mtime = 0;
     684        if ( -f $cause[0] ) {
     685          $mtime   = (stat($cause[0]))[9];
     686        }
     687        if (! ( -f $cause[1]) ) {  die "cause: $causetype requires it's SECOND filename to exist for comparison: $cause[1]\n"; }
     688        my $mtime2  = (stat($cause[1]))[9];
     689        if ( $mtime < $mtime2 ) {
     690          effect($effecttype,@nocheckeffectparams);
     691          if ( $nocheck == 0 ) {
     692            # confirm it worked, mtimes should have changed now:
     693            my $mtime3   = (stat($cause[0]))[9];
     694            my $mtime4  = (stat($cause[1]))[9];
     695            if ( $mtime3 < $mtime4  ) {
     696                die "file -> EFFECT FAILED: $causetype,$cause[0],$cause[1],$effecttype\n";
     697            }
     698          }
     699        } else {
     700           print "file ($cause[0]) has same or newer mtime than ($cause[1]) already, no action taken\n";
     701        }
     702        undef $mtime;
     703        undef $mtime2;
     704       
    656705    } elsif ( $causetype eq 'grep' ) {
    657706        if ( ! _grep($cause[0],$cause[1]) ) { # grep actually needs two parameters on the source side of the action
    658707            effect($effecttype,@nocheckeffectparams);   
    659708        } else {
    660709            print "grep - already matched source file($cause[1]), with pattern ($cause[0]) - no action reqd\n";
    661710        }
     711        if ( ! _grep($cause[0],$cause[1]) ) {
     712           die "grep -> EFFECT FAILED: $causetype,$effecttype,$cause[0],$cause[1]\n";
     713        }
    662714
    663715    } else {
    664716        die " unknown causetype $causetype \n";
     
    694746
    695747        } elsif ($effecttype eq 'exec') { # execute a DOS command
    696748            my $cmd = shift @effectparams;
    697 
    698             $cmd =~ s#/#\\#g; # convert all forward to SINGLE backward slashes
    699                               # (TODO - might be overkill to do all slashes ?)
    700 
    701             # this next set of regex's is YUCK, but it actually works well,
    702             # if it breaks, we'll just add another special case like these:
    703 
    704             $cmd =~ s#\s\\Y\s# /Y #ig; # it is overkill, so undo specific case/s
    705                                        # (eg: the /Y flag to the copy command)
    706             $cmd =~ s#\s\\C\s# /C #ig; # the /C /Q and /T options
    707                                        # used to extract the dxsdk
    708             $cmd =~ s#\s\\Q\s# /Q #ig;
    709             $cmd =~ s#\s\\T# /T#ig;
    710             $cmd =~ s#http:\\\\#http://#ig; # dont backslash web addresses
    711             if ($cmd =~ m/http:/ ) {
    712                 # next three lines will return any incorrectly backslashed
    713                 # slashes in a URL like: http://blah\blah\blah
    714                 #                     to http://blah/blah/blah as it should be:
    715                 $cmd =~ s#^(.*)(http://.*$)#$2#i;
    716                 my $pre = $1;
    717                 $cmd =~ s#\\#/#g;
    718                 print "pre:$pre\ncmd:$cmd\n";
    719                 $cmd = $pre.$cmd;
    720             }
    721 
    722749            #print `$cmd`;
    723750            print "exec:$cmd\n";
    724             open F, "$cmd |"  || die "err: $!";
     751            open F, $cmd." |"  || die "err: $!";
    725752            while (<F>) {
    726753                print;
    727754            }   
    728755
    729756        } elsif ($effecttype eq 'shell') {
    730757            shell(@effectparams);
     758           
     759        } elsif ($effecttype eq 'copy') {
     760            die "Can not copy non-existant file ($effectparams[0])\n" unless -f $effectparams[0];
     761            print "copying file ($effectparams[0] => $effectparams[1]) \n";
     762            cp($effectparams[0],$effectparams[1]);
     763            # make destn mtime the same as the original for ease of comparison:
     764            shell("touch --reference=".perl2unix($effectparams[0])." ".perl2unix($effectparams[1]));
    731765
    732766        } elsif ($effecttype eq 'mkdirs') {
    733767            mkdirs(shift @effectparams);