Ticket #4397: win32-packager.23.patch
File win32-packager.23.patch, 17.6 KB (added by , 18 years ago) |
---|
-
win32-packager.pl
old new 28 28 $| = 1; # autoflush stdout; 29 29 30 30 # 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, 32 32 # but seems to work best with some patches 33 33 # (included below). This is the last version that is 34 34 # Qt 3 based. Qt 4 merges began immediately after. 35 35 #my $SVNRELEASE = '16973'; # Recent 0-21-fixes 36 my $SVNRELEASE = '17011'; # Recent trunk 36 37 #my $SVNRELEASE = 'HEAD'; # If you are game, go forth and test the latest! 37 38 38 39 … … 97 98 $svnlocation = "trunk"; 98 99 } 99 100 101 # force us to QT4 if we are on trunk above the point where QT4 patches were merged 100 102 $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 106 print "Config:\n\tQT version: $qtver\n\tDLL's will be labeled as: $version\n\tSVN location is: $svnlocation\n\n"; 102 107 103 108 # TODO - use this list to define the components to build - only the first of these currently works well. 104 109 my @components = ( 'mythtv', 'myththemes', 'mythplugins' ); 105 110 106 # Where is the users home?107 # Script later creates %HOMEPATH%\.mythtv\mysql.txt108 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 slash115 my $unixhome = perl2unix($home);116 111 117 112 # TODO - we should try to autodetect these paths, rather than assuming 118 113 # the defaults - perhaps from environment variables like this: … … 129 124 my $mingw = 'C:/MinGW/'; # must end in slash, and use forward slashes / 130 125 my $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 / 131 126 127 # Where is the users home? 128 # Script later creates $home\.mythtv\mysql.txt 129 my $doshome = ''; 130 if ( ! exists $ENV{'HOMEPATH'} || $ENV{'HOMEPATH'} eq '\\' ) { 131 $doshome = $ENV{'USERPROFILE'}; 132 } else { 133 $doshome = $ENV{HOMEDRIVE}.$ENV{HOMEPATH}; 134 } 135 my $home = $doshome; 136 $home =~ s#\\#/#g; 137 $home =~ s/ /\\ /g; 138 $home .= '/'; # all paths should end in a slash 139 my $unixhome = perl2unix($home); 140 141 132 142 # DOS executable CMD.exe versions of the paths (for when we shell to DOS mode): 133 143 my $dosmsys = perl2dos($msys); 134 144 my $dossources = perl2dos($sources); … … 175 185 # 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). 176 186 # 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. 177 187 # 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] 180 190 181 191 #build actions (events) are: 182 192 # fetch a file from the web (to a location) [fetch] 183 # set an environment variable (name, value pair) not-yet-impl184 193 # execute a DOS/Win32 exe/command and wait to complete [exec] 185 194 # 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 ] 186 195 # extract a .tar .tar.gz or .tar.bz2 or ,zip file ( to a location) [extract] - (note that .gz and .bz2 are thought equivalent) … … 480 489 if ( $qtver == 3 ) { 481 490 push @{$expect}, 482 491 492 [ pause => 'press [enter] to build QT3 next!'], 483 493 [ archive => $sources.'qt-3.3.x-p8.tar.bz2', fetch => 'http://'.$sourceforge.'/sourceforge/qtwin/qt-3.3.x-p8.tar.bz2'], 484 494 [ dir => $msys.'qt-3.3.x-p8', extract => [$sources.'qt-3.3.x-p8.tar', $msys] ], 485 495 … … 508 518 509 519 510 520 [ 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! ' ] , 511 522 512 523 [ 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!' ], 513 524 … … 534 545 535 546 # (back to sh.exe ) now that we are done ! 536 547 [ 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!' ] , 537 549 538 550 #Copy libqt-mt3.dll to libqt-mt.dll , if there is any date/size change! 539 551 [ 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' ] , … … 548 560 549 561 if ( $qtver == 4 ) { 550 562 push @{$expect}, 563 [ pause => 'press [enter] to build QT4 next!'], 564 551 565 [ 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'], 552 566 [ dir => $msys.'qt-win-opensource-src-4.3.4', extract => [$sources.'qt-win-opensource-src-4.3.4.zip', $msys] ], 553 567 554 568 [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', 555 569 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)! ' ] , 556 570 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', 559 578 'rem a batch script for the QT environment under DOS: 560 579 set QTDIR='.$dosmsys.'qt-win-opensource-src-4.3.4 561 580 set MINGW='.$dosmingw.' 562 581 set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH% 563 582 set QMAKESPEC=win32-g++ 564 583 cd %QTDIR% 565 configure -plugin-sql-mysql -no-sql-sqlite -release -fast -no-sql-odbc -no make examples -nomake demos -no-nis -no-cups -noqdbus584 configure -plugin-sql-mysql -no-sql-sqlite -release -fast -no-sql-odbc -no-qdbus 566 585 rem mingw32-make 567 ' 586 ','nocheck' 568 587 ],comment=>'write a batch script for the QT4 environment under DOS'], 569 588 570 589 # test if the core .dll is built, and build QT if it isn't! … … 575 594 [ 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'], 576 595 [ 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'], 577 596 [ 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 578 603 ; 604 579 605 } 580 606 581 607 … … 656 682 foreach my $comp( @components ) { 657 683 push @{$expect}, 658 684 [ file => 'always', 659 exec => [ "$dosmsys\\bin\\svn.exe -r $SVNRELEASE update $dosmythtv$comp",685 exec => [$dosmsys."bin\\svn.exe -r $SVNRELEASE update $dosmythtv$comp", 660 686 'nocheck'], 661 687 comment => "Getting SVN updates for:$comp on $svnlocation" ]; 662 688 } … … 757 783 [ file => $mythtv.'mythtv/config/config.pro', shell => ['touch '.$unixmythtv.'mythtv/config/config.pro'], 758 784 comment => 'create an empty config.pro or the mythtv build will fail'], 759 785 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) '], 762 788 763 #broken Makefile , delete it789 #broken Makefile?, delete it 764 790 [ grep => ['Makefile|MAKEFILE',$mythtv.'mythtv/Makefile'], shell => ['rm '.$unixmythtv.'mythtv/Makefile','nocheck'], comment => 'broken Makefile, delete it' ], 765 791 766 # fix a bug in Makefile and make COPY_DIR cp -fr instead of cp -f767 [ file => $mythtv.'mythtv/fix_makefile.sh', write => [$mythtv.'mythtv/fix_makefile.sh',768 'cd '.$unixmythtv.'mythtv769 cat Makefile | sed "s/\(^COPY_DIR\W*\=\W*cp\)\(\W\-f\)/\1 -fr/" > Makefile_new770 cp Makefile_new Makefile771 ', 'nocheck',772 ],comment => 'write a script to fix Makefile'],773 774 792 # configure 775 793 [ 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?' ], 776 794 # make … … 799 817 'cd '.$unixmythtv.'mythtv','make'], 800 818 comment => 'programs/mythbackend/mythbackend.exe - redo make unless all these files exist, and are newer than the last_build.txt identifier' ], 801 819 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 824 cat Makefile | sed "s/\(^COPY_DIR\W*\=\W*cp\)\(\W\-f\)/\1 -fr/" > Makefile_new 825 cp Makefile_new Makefile 826 ', 'nocheck', 827 ],comment => 'write a script to fix Makefile'], 828 829 802 830 # re-install to msys /usr/bin folders etc, if we have a newer mythtv build 803 831 # ready: 804 832 [ newer => [$msys.'bin/mythfrontend.exe', … … 1148 1176 } 1149 1177 1150 1178 1151 #---------------------------------------- 1179 #------------------------------------------------------------------------------ 1152 1180 1153 1181 ; # END OF CAUSE->ACTION DEFINITIONS 1154 1182 … … 1298 1326 } elsif ( $causetype eq 'stop' ){ 1299 1327 die "Stop found \n"; 1300 1328 } elsif ( $causetype eq 'pause' ){ 1329 comment("PAUSED! : ".$cause); 1301 1330 my $temp = getc(); 1302 1331 } else { 1303 1332 die " unknown causetype $causetype \n"; 1304 1333 } 1305 1334 } 1306 1307 1335 print "\nall done\n"; 1308 1309 1336 _end(); 1310 1337 1311 1338 #------------------------------------------------------------------------------ 1312 1313 1339 # each cause has an effect, this is where we do them: 1314 1340 sub effect { 1315 1341 my ( $effecttype, @effectparams ) = @_; … … 1366 1392 die " unknown effecttype $effecttype from cause 'dir'\n"; 1367 1393 } 1368 1394 } 1369 #------------------------------------------------------------------------------1370 1395 1396 #------------------------------------------------------------------------------ 1371 1397 # kinda like a directory search for blah.tar* but faster/easier. 1372 1398 # only finds .tar.gz, .tar.bz2, .zip 1373 1399 sub findtar { … … 1384 1410 return $t if -f $t; 1385 1411 die "findtar failed to match a file from:($t)\n"; 1386 1412 } 1387 #------------------------------------------------------------------------------1388 1389 1413 1414 #------------------------------------------------------------------------------ 1390 1415 # given a ($t) .tar.gz, .tar.bz2, .zip extract it to the directory ( $d) 1391 1416 # changes current directory to $d too 1392 1417 sub extracttar { … … 1446 1471 print; 1447 1472 } 1448 1473 } 1449 #------------------------------------------------------------------------------1450 1451 1474 1475 #------------------------------------------------------------------------------ 1452 1476 # get the $url (typically a .tar.gz or similar) , and save it to $file 1453 1477 sub _fetch { 1454 1478 my ( $file,$url ) = @_; … … 1474 1498 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."); 1475 1499 } 1476 1500 } 1477 #------------------------------------------------------------------------------1478 1479 1501 1502 #------------------------------------------------------------------------------ 1480 1503 # execute a sequence of commands in a bash shell. 1481 1504 # we explicitly add the /bin and /mingw/bin to the path 1482 1505 # because at this point they aren't likely to be there … … 1501 1524 print; 1502 1525 } 1503 1526 } 1527 1504 1528 #------------------------------------------------------------------------------ 1505 1529 # recursively make folders, requires perl-compatible folder separators 1506 1530 # (ie forward slashes) … … 1518 1542 } 1519 1543 1520 1544 #------------------------------------------------------------------------------ 1521 1522 1545 # unix compatible versions of the perl paths (for when we [shell] to unix/bash mode): 1523 1546 sub perl2unix { 1524 1547 my $p = shift; 1548 print "perl2unix: $p\n"; 1525 1549 $p =~ s#$msys#/#i; # remove superfluous msys folders if they are there 1526 1550 $p =~ s#^([CD]):#/$1#ig; #change c:/ into /c (or a D:) so c:/msys becomes /c/msys etc. 1527 1551 $p =~ s#//#/#ig; # reduce any double forward slashes to single ones. 1528 1552 return $p; 1529 1553 } 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): 1531 1557 sub perl2dos { 1532 1558 my $p = shift; 1533 1559 $p =~ s#/#\\#g; # single forward to single backward 1534 1560 return $p; 1535 1561 } 1536 #------------------------------------------------------------------------------1537 1562 1563 #------------------------------------------------------------------------------ 1564 # find a pattern in a file and return if it was found or not. Absent file assumes pattern was not found. 1538 1565 sub _grep { 1539 1566 my ($pattern,$file) = @_; 1540 1567 #$pattern = qw($pattern); … … 1550 1577 } 1551 1578 1552 1579 #------------------------------------------------------------------------------ 1553 1580 # where is this script? 1554 1581 sub scriptpath { 1555 1582 return "" if ($0 eq ""); 1556 1583 my @path = split /\\/, $0; … … 1560 1587 } 1561 1588 1562 1589 #------------------------------------------------------------------------------ 1563 1590 # display stuff to the user in a manner that unclutters it from the other compilation messages that will be scrolling past! 1564 1591 sub comment { 1565 1592 my $comment = shift; 1566 1593 print "\nCOMMENTS:"; … … 1573 1600 } 1574 1601 1575 1602 #------------------------------------------------------------------------------ 1576 1603 # how? what the? oh! like that! I get it now, I think. 1577 1604 sub usage { 1578 1605 print << 'END_USAGE'; 1579 1606 -h This message