Ticket #4397: win32-packager.23.patch

File win32-packager.23.patch, 17.6 KB (added by Buzz <davidbuzz@…>, 12 years ago)

v23 - superceeds all previous vers. patch against current file at: http://svn.mythtv.org/svn/trunk/mythtv/contrib/Win32/win32-packager.pl

  • win32-packager.pl

    old new  
    2828$| = 1; # autoflush stdout;
    2929
    3030# this script was last tested to work with this version, on other versions YMMV.
    31 my $SVNRELEASE = '16789'; # Latest build that has been confirmed to run,
     31#my $SVNRELEASE = '16789'; # Latest build that has been confirmed to run,
    3232                          # but seems to work best with some patches
    3333                          # (included below). This is the last version that is
    3434                          # Qt 3 based. Qt 4 merges began immediately after.
    3535#my $SVNRELEASE = '16973'; # Recent 0-21-fixes
     36my $SVNRELEASE = '17011'; # Recent trunk
    3637#my $SVNRELEASE = 'HEAD'; # If you are game, go forth and test the latest!
    3738
    3839
     
    9798    $svnlocation = "trunk";
    9899}
    99100
     101# force us to QT4 if we are on trunk above the point where QT4 patches were merged
    100102$qtver = 4 if ( $SVNRELEASE > 16789 && $svnlocation eq 'trunk' );
    101 print "using QT version: $qtver\n";
     103# force us to label the DLL's as 0.21 if we are on the release 21 branch!
     104$version = '0.21' if   $svnlocation eq "branches/release-0-21-fixes";
     105
     106print "Config:\n\tQT version: $qtver\n\tDLL's will be labeled as: $version\n\tSVN location is: $svnlocation\n\n";
    102107
    103108# TODO -  use this list to define the components to build - only the first of these currently works well.
    104109my @components = ( 'mythtv', 'myththemes', 'mythplugins' );
    105110
    106 # Where is the users home?
    107 # Script later creates %HOMEPATH%\.mythtv\mysql.txt
    108 if ( ! exists $ENV{'HOMEPATH'} || $ENV{'HOMEPATH'} eq '\\' )
    109 {   $ENV{'HOMEPATH'} = $ENV{'USERPROFILE'}   }
    110 my $doshome = $ENV{HOMEPATH};
    111 my $home = $doshome;
    112 $home =~ s#\\#/#g;
    113 $home =~ s/ /\\ /g;
    114 $home .= '/'; # all paths should end in a slash
    115 my $unixhome = perl2unix($home);
    116111
    117112# TODO - we should try to autodetect these paths, rather than assuming
    118113#        the defaults - perhaps from environment variables like this:
     
    129124my $mingw = 'C:/MinGW/'; # must end in slash, and use forward slashes /
    130125my $mythtv = 'C:/mythtv/';  # this is where the entire SVN checkout lives so c:/mythtv/mythtv/ is the main codebase.  # must end in slash, and use forward slashes /
    131126
     127# Where is the users home?
     128# Script later creates $home\.mythtv\mysql.txt
     129my $doshome = '';
     130if ( ! exists $ENV{'HOMEPATH'} || $ENV{'HOMEPATH'} eq '\\' ) {   
     131        $doshome = $ENV{'USERPROFILE'}; 
     132} else {
     133  $doshome = $ENV{HOMEDRIVE}.$ENV{HOMEPATH};
     134}
     135my $home = $doshome;
     136$home =~ s#\\#/#g;
     137$home =~ s/ /\\ /g;
     138$home .= '/'; # all paths should end in a slash
     139my $unixhome = perl2unix($home);
     140
     141
    132142# DOS executable CMD.exe versions of the paths (for when we shell to DOS mode):
    133143my $dosmsys    = perl2dos($msys);
    134144my $dossources = perl2dos($sources);
     
    175185#  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).
    176186#  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.
    177187#  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.
    178 #  stop the run, useful for script debugging                         [stop]
    179 #  pause the run, await a enter                                      [pause]
     188#  stop the run, useful for script debugging                               [stop]
     189#  pause the run, await a enter                                            [pause]
    180190
    181191#build actions (events) are:
    182192#  fetch a file from the web (to a location)                         [fetch]
    183 #  set an environment variable (name, value pair)                    not-yet-impl
    184193#  execute a DOS/Win32 exe/command and wait to complete              [exec]
    185194#  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 ]
    186195#  extract a .tar .tar.gz or .tar.bz2 or ,zip file ( to a location)  [extract] - (note that .gz and .bz2 are thought equivalent)
     
    480489if ( $qtver == 3  ) {
    481490push @{$expect},
    482491
     492[ pause => 'press [enter] to build QT3 next!'],
    483493[ archive => $sources.'qt-3.3.x-p8.tar.bz2',  fetch => 'http://'.$sourceforge.'/sourceforge/qtwin/qt-3.3.x-p8.tar.bz2'],
    484494[ dir => $msys.'qt-3.3.x-p8', extract => [$sources.'qt-3.3.x-p8.tar', $msys] ],
    485495
     
    508518
    509519
    510520[ file => $msys.'qt-3.3.x-p8/lib/libqt-mt3.dll', exec => $dosmsys.'qt-3.3.x-p8\qt3_env.bat && configure.bat -thread -plugin-sql-mysql -opengl -no-sql-sqlite',comment => 'Execute qt3_env.bat  && the configure command to actually build QT now!  - ie configures qt and also makes it, hopefully! WARNING SLOW (MAY TAKE HOURS!)' ],
     521[ file => $mingw.'bin/sh_.exe', shell => ["mv ".$unixmingw."bin/sh.exe ".$unixmingw."bin/sh_.exe"],comment => 'rename mingw sh.exe out of the way before building QT! ' ] ,
    511522
    512523[ 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!' ],
    513524
     
    534545
    535546#  (back to sh.exe ) now that we are done !
    536547[ file => $msys.'bin/sh.exe', shell => ["mv ".$unixmsys."bin/sh_.exe ".$unixmsys."bin/sh.exe"],comment => 'rename msys sh_.exe back again!' ] ,
     548[ file => $mingw.'bin/sh.exe', shell => ["mv ".$unixmingw."bin/sh_.exe ".$unixmingw."bin/sh.exe"],comment => 'rename mingw sh_.exe back again!' ] ,
    537549
    538550#Copy libqt-mt3.dll to libqt-mt.dll  , if there is any date/size change!
    539551[ 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' ] ,
     
    548560
    549561if ( $qtver == 4  ) {
    550562push @{$expect},
     563[ pause => 'press [enter] to build QT4 next!'],
     564
    551565[ archive => $sources.'qt-win-opensource-src-4.3.4.zip',  fetch => 'ftp://ftp.trolltech.com/qt/source/qt-win-opensource-src-4.3.4.zip'],
    552566[ dir => $msys.'qt-win-opensource-src-4.3.4', extract => [$sources.'qt-win-opensource-src-4.3.4.zip', $msys] ],
    553567
    554568[dir => $msys.'qt-win-opensource-src-4.3.4_examples', shell => 'mv '.$unixmsys.'qt-win-opensource-src-4.3.4/examples '.$unixmsys.'qt-win-opensource-src-4.3.4_examples',
    555569  comment => 'after extracting the qt sources, there is no need for us to build the examples, so we will just move the folder out of the way (we could just delete it but dont)! ' ] ,
    556570
    557 # write a batch script for the QT environment under DOS:
    558 [ file => $msys.'qt-win-opensource-src-4.3.4/qt4_env.bat', write => [$msys.'qt-win-opensource-src-4.3.4/qt4_env.bat',
     571# qt recommend NOT having sh.exe in the path when building QT (yes this applies to QT4 too!)
     572[ 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! ' ] ,
     573[ file => $mingw.'bin/sh_.exe', shell => ["mv ".$unixmingw."bin/sh.exe ".$unixmingw."bin/sh_.exe"],comment => 'rename mingw sh.exe out of the way before building QT! ' ] ,
     574
     575# Write a batch script for the QT environment under DOS:
     576# TODO - the configure script pauses until you press 'y' to continue!
     577[ file => $msys.'qt-win-opensource-src-4.3.4/qt4_env.bat_', write => [$msys.'qt-win-opensource-src-4.3.4/qt4_env.bat',
    559578'rem a batch script for the QT environment under DOS:
    560579set QTDIR='.$dosmsys.'qt-win-opensource-src-4.3.4
    561580set MINGW='.$dosmingw.'
    562581set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH%
    563582set QMAKESPEC=win32-g++
    564583cd %QTDIR%
    565 configure -plugin-sql-mysql -no-sql-sqlite -release -fast -no-sql-odbc -nomake examples -nomake demos -no-nis -no-cups -noqdbus
     584configure -plugin-sql-mysql -no-sql-sqlite -release -fast -no-sql-odbc -no-qdbus
    566585rem mingw32-make
    567 '
     586','nocheck'
    568587],comment=>'write a batch script for the QT4 environment under DOS'],
    569588
    570589# test if the core .dll is built, and build QT if it isn't!
     
    575594[ file => $msys.'qt-win-opensource-src-4.3.4/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'],
    576595[ file => $msys.'qt-win-opensource-src-4.3.4/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'],
    577596[ file => $msys.'qt-win-opensource-src-4.3.4/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'],
     597
     598
     599#  move it (back to sh.exe ) now that we are done !
     600[ file => $msys.'bin/sh.exe', shell => ["mv ".$unixmsys."bin/sh_.exe ".$unixmsys."bin/sh.exe"],comment => 'rename msys sh_.exe back again!' ] ,
     601[ file => $mingw.'bin/sh.exe', shell => ["mv ".$unixmingw."bin/sh_.exe ".$unixmingw."bin/sh.exe"],comment => 'rename mingw sh_.exe back again!' ] ,
     602
    578603;
     604
    579605}
    580606
    581607
     
    656682foreach my $comp( @components ) {
    657683  push @{$expect},
    658684  [ file => 'always',
    659     exec => ["$dosmsys\\bin\\svn.exe -r $SVNRELEASE update $dosmythtv$comp",
     685    exec => [$dosmsys."bin\\svn.exe -r $SVNRELEASE update $dosmythtv$comp",
    660686             'nocheck'],
    661687    comment => "Getting SVN updates for:$comp on $svnlocation" ];
    662688}
     
    757783[ file => $mythtv.'mythtv/config/config.pro', shell => ['touch '.$unixmythtv.'mythtv/config/config.pro'],
    758784        comment => 'create an empty config.pro or the mythtv build will fail'],
    759785
    760 # do a make clean before? Yes, if the SVN revision has changed (it deleted the file for us), or the user deleted the file manually, to request it.
    761 [ file => $mythtv.'delete_to_do_make_clean.txt', shell => ['source '.$unixmythtv.'qt'.$qtver.'_env.sh','cd '.$unixmythtv.'mythtv','make clean','find . -type f -name \*.dll | grep -v build | xargs -n1 rm','find . -type f -name \*.a | grep -v build | xargs -n1 rm','touch '.$unixmythtv.'delete_to_do_make_clean.txt','nocheck'], comment => 'do a "make clean" first? not strictly necessary in all cases, and the build will be MUCH faster without it, but it is safer with it... ( we do a make clean if the SVN revision changes) '],
     786# do a make clean (nd re-configure) before going any further? Yes, if the SVN revision has changed (it deleted the file for us), or the user deleted the file manually, to request it.
     787[ file => $mythtv.'delete_to_do_make_clean.txt', shell => ['source '.$unixmythtv.'qt'.$qtver.'_env.sh','cd '.$unixmythtv.'mythtv','make clean','find . -type f -name \*.dll | grep -v build | xargs -n1 rm','find . -type f -name \*.a | grep -v build | xargs -n1 rm','rm Makefile','touch '.$unixmythtv.'delete_to_do_make_clean.txt','nocheck'], comment => 'do a "make clean" first? not strictly necessary in all cases, and the build will be MUCH faster without it, but it is safer with it... ( we do a make clean if the SVN revision changes) '],
    762788
    763 #broken Makefile, delete it
     789#broken Makefile?, delete it
    764790[ grep => ['Makefile|MAKEFILE',$mythtv.'mythtv/Makefile'], shell => ['rm '.$unixmythtv.'mythtv/Makefile','nocheck'], comment => 'broken Makefile, delete it' ],
    765791
    766 # fix a bug in Makefile and make COPY_DIR cp -fr instead of cp -f
    767 [ file => $mythtv.'mythtv/fix_makefile.sh', write => [$mythtv.'mythtv/fix_makefile.sh',
    768 'cd '.$unixmythtv.'mythtv
    769 cat Makefile | sed  "s/\(^COPY_DIR\W*\=\W*cp\)\(\W\-f\)/\1 -fr/" > Makefile_new
    770 cp Makefile_new Makefile
    771 ', 'nocheck',
    772 ],comment => 'write a script to fix Makefile'],
    773 
    774792# configure
    775793[ file => $mythtv.'mythtv/Makefile', shell => ['source '.$unixmythtv.'qt'.$qtver.'_env.sh','cd '.$unixmythtv.'mythtv','./configure --prefix=/usr --disable-dbox2 --disable-hdhomerun --disable-iptv --disable-joystick-menu --disable-xvmc-vld --disable-xvmc --enable-directx --cpu=k8 --compile-type='.$compile_type], comment => 'do we already have a Makefile for mythtv?' ],
    776794# make
     
    799817            'cd '.$unixmythtv.'mythtv','make'],
    800818  comment => 'programs/mythbackend/mythbackend.exe - redo make unless all these files exist, and are newer than the last_build.txt identifier' ],
    801819
     820
     821# fix a bug in Makefile and make COPY_DIR cp -fr instead of cp -f
     822[ file => $mythtv.'mythtv/fix_makefile.sh', write => [$mythtv.'mythtv/fix_makefile.sh',
     823'cd '.$unixmythtv.'mythtv
     824cat Makefile | sed  "s/\(^COPY_DIR\W*\=\W*cp\)\(\W\-f\)/\1 -fr/" > Makefile_new
     825cp Makefile_new Makefile
     826', 'nocheck',
     827],comment => 'write a script to fix Makefile'],
     828
     829
    802830# re-install to msys /usr/bin folders etc, if we have a newer mythtv build
    803831# ready:
    804832[ newer => [$msys.'bin/mythfrontend.exe',
     
    11481176}
    11491177
    11501178
    1151 #----------------------------------------
     1179#------------------------------------------------------------------------------
    11521180
    11531181; # END OF CAUSE->ACTION DEFINITIONS
    11541182
     
    12981326    } elsif ( $causetype eq 'stop' ){
    12991327        die "Stop found \n";
    13001328    } elsif ( $causetype eq 'pause' ){
     1329          comment("PAUSED! : ".$cause);
    13011330        my $temp = getc();
    13021331    } else {
    13031332        die " unknown causetype $causetype \n";
    13041333    }
    13051334}
    1306 
    13071335print "\nall done\n";
    1308 
    13091336_end();
    13101337
    13111338#------------------------------------------------------------------------------
    1312 
    13131339# each cause has an effect, this is where we do them:
    13141340sub effect {
    13151341    my ( $effecttype, @effectparams ) = @_;
     
    13661392            die " unknown effecttype $effecttype from cause 'dir'\n";
    13671393        }
    13681394}
    1369 #------------------------------------------------------------------------------
    13701395
     1396#------------------------------------------------------------------------------
    13711397# kinda like a directory search for blah.tar* but faster/easier.
    13721398#  only finds .tar.gz, .tar.bz2, .zip
    13731399sub findtar {
     
    13841410    return $t if -f $t;
    13851411    die "findtar failed to match a file from:($t)\n";
    13861412}
    1387 #------------------------------------------------------------------------------
    1388 
    13891413
     1414#------------------------------------------------------------------------------
    13901415# given a ($t) .tar.gz, .tar.bz2, .zip extract it to the directory ( $d)
    13911416# changes current directory to $d too
    13921417sub extracttar {
     
    14461471        print;
    14471472    }   
    14481473}
    1449 #------------------------------------------------------------------------------
    1450 
    14511474
     1475#------------------------------------------------------------------------------
    14521476# get the $url (typically a .tar.gz or similar) , and save it to $file
    14531477sub _fetch {
    14541478    my ( $file,$url ) = @_;
     
    14741498      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.");
    14751499    }
    14761500}
    1477 #------------------------------------------------------------------------------
    1478 
    14791501
     1502#------------------------------------------------------------------------------
    14801503# execute a sequence of commands in a bash shell.
    14811504# we explicitly add the /bin and /mingw/bin to the path
    14821505# because at this point they aren't likely to be there
     
    15011524        print;
    15021525    }
    15031526}
     1527
    15041528#------------------------------------------------------------------------------
    15051529# recursively make folders, requires perl-compatible folder separators
    15061530# (ie forward slashes)
     
    15181542}
    15191543
    15201544#------------------------------------------------------------------------------
    1521 
    1522 
     1545# unix compatible  versions of the perl paths (for when we [shell] to unix/bash mode):
    15231546sub perl2unix  {
    15241547    my $p = shift;
     1548    print "perl2unix: $p\n";
    15251549    $p =~ s#$msys#/#i;  # remove superfluous msys folders if they are there
    15261550    $p =~ s#^([CD]):#/$1#ig;  #change c:/ into /c  (or a D:)   so c:/msys becomes /c/msys etc.
    15271551    $p =~ s#//#/#ig; # reduce any double forward slashes to single ones.
    15281552    return $p;
    15291553}
    1530 # DOS executable CMD.exe versions of the paths (for when we shell to DOS mode):
     1554
     1555#------------------------------------------------------------------------------
     1556# DOS executable CMD.exe versions of the paths (for when we [exec] to DOS mode):
    15311557sub perl2dos {
    15321558    my $p = shift;
    15331559    $p =~ s#/#\\#g; # single forward to single backward
    15341560    return $p;
    15351561}
    1536 #------------------------------------------------------------------------------
    15371562
     1563#------------------------------------------------------------------------------
     1564# find a pattern in a file and return if it was found or not. Absent file assumes pattern was not found.
    15381565sub _grep {
    15391566    my ($pattern,$file) = @_;
    15401567    #$pattern = qw($pattern);
     
    15501577}
    15511578
    15521579#------------------------------------------------------------------------------
    1553 
     1580# where is this script?
    15541581sub scriptpath {
    15551582  return "" if ($0 eq "");
    15561583  my @path = split /\\/, $0;
     
    15601587}
    15611588
    15621589#------------------------------------------------------------------------------
    1563 
     1590# display stuff to the user in a manner that unclutters it from the other compilation messages that will be scrolling past!
    15641591sub comment {
    15651592    my $comment = shift;
    15661593    print "\nCOMMENTS:";
     
    15731600}
    15741601
    15751602#------------------------------------------------------------------------------
    1576 
     1603# how? what the?   oh! like that!  I get it now, I think.
    15771604sub usage {
    15781605    print << 'END_USAGE';
    15791606-h             This message