-
Notifications
You must be signed in to change notification settings - Fork 52
/
win32-developer-setup.pl
executable file
·1345 lines (1180 loc) · 52 KB
/
win32-developer-setup.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!c:/perl/bin/perl.exe -w
##############################################################################
### =file
### win32-developer.pl
###
### =location
### http://svn.xxxx.org/svn/trunk/xxxxx/xxxx/xxxx/win32-developer.pl
###
### =description
### Tool for automating setup of Msys/Mingw builds on MS Windows XP (and compatible)
### based heavily on win32-packager from the MythTv project
### ( by the same author)
###
### =examples
### win32-developer.pl -h
### => Print usage
### win32-developer.pl
### => based on latest "tested" SVN trunk (ie a known-good win32 build)
### win32-developer.pl -r head
### => based on trunk head
### win32-developer.pl -b
### => based on release-021-fixes branch
### win32-developer.pl -b -t
### => include some patches which are not accepted, but needed for Win32
### win32-developer.pl -b -t -k
### =>Same but package and create setup.exe at the end
###
### =revision
### $Id$
###
### =author
### David Bussenschutt
##############################################################################
use strict;
use LWP::UserAgent;
use IO::File;
use Data::Dumper;
use File::Copy qw(cp);
use Getopt::Std;
use Digest::MD5;
$SIG{INT} = sub { die "Interrupted\n"; };
$| = 1; # autoflush stdout;
# this script was last tested to work with this version, on other versions YMMV.
#my $SVNRELEASE = '23137'; # Recent trunk
#my $SVNRELEASE = 'HEAD'; # If you are game, go forth and test the latest!
# We allow SourceForge to tell us which server to download from,
# rather than assuming specific server/s
my $sourceforge = 'downloads.sourceforge.net'; # auto-redirect to a
# mirror of SF's choosing,
# hopefully close to you
# alternatively you can choose your own mirror:
#my $sourceforge = 'optusnet.dl.sourceforge.net'; # Australia
#my $sourceforge = 'internap.dl.sourceforge.net'; # USA,California
#my $sourceforge = 'easynews.dl.sourceforge.net'; # USA,Arizona,Phoenix,
#my $sourceforge = 'jaist.dl.sourceforge.net'; # Japan
#my $sourceforge = 'mesh.dl.sourceforge.net'; # Germany
#my $sourceforge = 'transact.dl.sourceforge.net'; # Germany
# Set this to the empty string for no-proxy:
my $proxy = '';
#my $proxy = 'http://enter.your.proxy.here:8080';
# Subversion proxy settings are configured in %APPDATA%\Subversion\servers
my $NOISY = 1; # Set to 0 for less output to the screen
my $package = 0; # Create a Win32 Distribution package? 1 for yes
my $compile_type = "profile"; # compile options: debug, profile or release
my $tickets = 0; # Apply specific win32 tickets -
# usually those not merged into SVN
my $dbconf = 0; # Configure MySQL as part of the build process.
# Required only for testing
my $makeclean = 0; # Flag to make clean
#my $svnlocation = "trunk"; # defaults to trunk unless -b specified
my $qtver = 4; # default to 4 until we can test otherwise
my $continuous = 0 ; # by default the app pauses to notify you what
# it's about to do, -y overrides for batch usage.
my $GitUrl = "https://github.com/timschmidt/repsnapper.git";
##############################################################################
# get command line options
my $opt_string = 'vhogkp:r:c:tldby';
my %opt = ();
getopts( "$opt_string", \%opt );
usage() if $opt{h};
$package = 1 if defined $opt{k};
$NOISY = 1 if defined $opt{v};
$tickets = 1 if defined $opt{t};
$proxy = $opt{p} if defined $opt{p};
#$SVNRELEASE = $opt{r} if defined $opt{r};
$dbconf = 1 if defined $opt{d};
$makeclean = 1 if defined $opt{l};
$continuous = 1 if defined $opt{y};
if (defined $opt{c}) {
$compile_type = $opt{c} if ($opt{c} eq "release") ;
$compile_type = $opt{c} if ($opt{c} eq "profile") ;
}
#if (defined $opt{b}) {
# my @num = split /\./, $version;
#$svnlocation = "branches/release-$num[0]-$num[1]-fixes";
#
# Releases like 0.23.1 are actually tags, and use a different location:
#if ($version =~ m/-\d$/) {
# $svnlocation = "tags/release-$num[0]-$num[1]-$num[2]";
#}
#} else {
# $svnlocation = "trunk";
#}
# Try to use parallel make
my $numCPU = $ENV{'NUMBER_OF_PROCESSORS'} or 1;
my $parallelMake = 'make';
if ( $numCPU gt 1 ) {
# Pre-queue one extra job to keep the pipeline full:
$parallelMake = 'make -j '. ($numCPU + 1);
}
# "Config:\n\tQT version: $qtver\n\tDLLs will be labeled as: $version\n";
if ( $numCPU gt 1 ) {
print "\tBuilding with ", $numCPU, " processors\n";
}
print "\n\tWelcome to the Win32 MSYS/MINGW helper script for repsnapper!\n ".
"\tWe are about to try to install everything for you! \n".
"\n\tHere are the relevant paths were thing will be installed:\n\n";
#print "\tComponents to build: ";
#foreach my $comp( @components ) { print "$comp " }
#print "\n\nPress [enter] to continue, or [ctrl]-c to exit now....\n";
#getc() unless $continuous;
# this will be used to test if we the same
# basic build type/layout as previously.
#my $is_same = "$compile_type-$svnlocation-$qtver.same";
#$is_same =~ s#/#-#g; # don't put dir slashes in a filename!
# TODO - we should try to autodetect these paths, rather than assuming
# the defaults - perhaps from environment variables like this:
# die "must have env variable SOURCES pointing to your sources folder"
# unless $ENV{SOURCES};
# my $sources = $ENV{SOURCES};
# TODO - although theoretically possible to change these paths,
# it has NOT been tested much,
# and will with HIGH PROBABILITY fail somewhere.
# - Only $mingw is tested and most likely is safe to change.
# Perl compatible paths. DOS style, but forward slashes, and must end in slash:
# TIP: using paths with spaces in them is NOT supported, and will break.
# patches welcome.
my $msys = 'C:/MSys/1.0/';
my $sources = 'C:/MSys/1.0/sources/';
my $mingw = 'C:/MinGW/';
my $approot = 'C:/repsnapper/'; # this is where the entire SVN checkout lives
# so c:/app/app/ is the main codebase.
my $build = 'C:/repsnapper/repsnapper/src/'; # where 'make install' installs into
# Where is the users home?
#my $doshome = '';
#if ( ! exists $ENV{'HOMEPATH'} || $ENV{'HOMEPATH'} eq '\\' ) {
# $doshome = $ENV{'USERPROFILE'};
#} else {
# $doshome = $ENV{HOMEDRIVE}.$ENV{HOMEPATH};
#}
#my $home = $doshome;
#$home =~ s#\\#/#g;
#$home =~ s/ /\\ /g;
#$home .= '/'; # all paths should end in a slash
# Where are program files (32-bit)?
my $dosprogramfiles = '';
if ( $ENV{'ProgramFiles(x86)'} ) {
$dosprogramfiles = $ENV{'ProgramFiles(x86)'};
} else {
$dosprogramfiles = $ENV{'ProgramFiles'};
}
my $programfiles = $dosprogramfiles;
$programfiles =~ s#\\#/#g;
# DOS executable CMD.exe versions of the paths (for when we shell to DOS mode):
my $dosmsys = perl2dos($msys);
my $dossources = perl2dos($sources);
my $dosmingw = perl2dos($mingw);
my $dosapp = perl2dos($approot);
# Unix/MSys equiv. versions of the paths (for when we shell to MSYS/UNIX mode):
my $unixmsys = '/'; # MSys root is always mounted here,
# irrespective of where DOS says it really is.
my $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)
my $unixsources = perl2unix($sources);
my $unixapp = perl2unix($approot);
#my $unixhome = perl2unix($home);
my $unixprogramfiles = perl2unix($programfiles);
my $unixbuild = perl2unix($build);
# The installer for MinGW:
my $MinGWinstaller = 'MinGW-5.1.6.exe';
my $installMinGW = $dossources.$MinGWinstaller;
# Qt4 directory
#my $qt4dir = 'C:/qt/4.5.3/';
#my $dosqt4dir = perl2dos($qt4dir);
#my $unixqt4dir = perl2unix($qt4dir);
#NOTE: IT'S IMPORTANT that the PATHS use the correct SLASH-ing method for
#the type of action:
# for [exec] actions, use standard DOS paths, with single BACK-SLASHES
# '\' (unless in double quotes, then double the backslashes)
# for [shell] actions, use standard UNIX paths, with single
# FORWARD-SLASHES '/'
#
#NOTE: when referring to variables in paths, try to keep them out of double
#quotes, or the slashing can get confused:
# [exec] actions should always refer to $dosXXX path variables
# [shell] actions should always refer to $unixXXX path variables
# [dir],[file],[mkdirs],[archive] actions should always refer to
# default perl compatible paths
# NOTE: The architecture of this script is based on cause-and-event.
# There are a number of "causes" (or expectations) that can trigger
# an event/action.
# There are a number of different actions that can be taken.
#
# eg: [ dir => "c:/MinGW", exec => $dossources.'MinGW-5.1.4.exe' ],
#
# means: expect there to be a dir called "c:/MinGW", and if there isn't
# execute the file MinGW-5.1.4.exe. (clearly there needs to be a file
# MinGW-5.1.4.exe on disk for that to work, so there is an earlier
# declaration to 'fetch' it)
#build expectations (causes) :
# missing a file (given an expected path) [file]
# missing folder [dir]
# missing source archive (version of 'file' to fetch from the web) [archive]
# apply a perl pattern match and if it DOESNT match execute 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).
# 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.
# 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.
# execute the action only if a file or directory exists [exists]
# stop the run, useful for script debugging [stop]
# pause the run, await a enter [pause]
# always execute the action (try to minimise the use of this!) [always]
#build actions (events) are:
# fetch a file from the web (to a location) [fetch]
# execute a DOS/Win32 exe/command and wait to complete [exec]
# 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 ]
# extract a .tar .tar.gz or .tar.bz2 or ,zip file ( to a location) [extract]
# - (note that .gz and .bz2 are thought equivalent)
# write a small patch/config/script file directly to disk [write]
# make directory tree upto the path specified [mkdirs]
# copy a new version of a file, set mtime to the original [copy]
#TODO:
# copy a set of files (path/filespec, destination) not-yet-impl
# => use exec => 'copy /Y xxx.* yyy'
# apply a diff not-yet-impl
# => use shell => 'patch -p0 < blah.patch'
# search-replace text in a file not-yet-impl
# => use grep => ['pattern',subject],
# exec => shell 'patch < etc to replace it'
# NOTES on specific actions:
# '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.
# 'exec' actually runs all your commands inside a single cmd.exe
# command-line. To link commands use '&&'
# 'shell' actually runs all your commands inside a bash shell with -c "(
# cmd;cmd;cmd )" so be careful about quoting.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# DEFINE OUR EXPECTATIONS and the related ACTIONS:
# - THIS IS THE GUTS OF THE APPLICATION!
# - A SET OF DECLARATIONS THAT SHOULD RESULT IN A WORKING WIN32 INSTALATION
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
my $expect;
push @{$expect},
[ dir => [$sources] ,
mkdirs => [$sources],
comment => 'We will download all the files from the web, and save them here:'],
[ pause => '.... press [enter] to continue !'],
[ archive => $sources.$MinGWinstaller,
'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/'.$MinGWinstaller,
comment => 'Get mingw and addons first, or we cant do [shell] requests!' ],
[ archive => $sources.'mingw-utils-0.3.tar.gz',
'fetch' => 'http://'.$sourceforge.
'/sourceforge/mingw/mingw-utils-0.3.tar.gz' ],
# ffmpeg complains if gcc < 4.2, so download a newer version
# As of 20090626 MinGW gcc >= 4.3 do NOT work with ffmpeg (MinGW bug #2812588)
[ archive => $sources.'gcc-4.2.4-tdm-1-core.tar.gz',
'fetch' => 'http://'.$sourceforge.
'/sourceforge/tdm-gcc/gcc-4.2.4-tdm-1-core.tar.gz' ],
[ archive => $sources.'gcc-4.2.4-tdm-1-g++.tar.gz',
'fetch' => 'http://'.$sourceforge.
'/sourceforge/tdm-gcc/gcc-4.2.4-tdm-1-g++.tar.gz' ],
[ dir => $mingw,
exec => $installMinGW,
comment => 'install MinGW (be sure to install g++, g77 and ming '.
'make too. Leave the default directory at c:\mingw ) '.
'- 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?
[ file => $mingw."bin/gcc.exe",
exec => $installMinGW,
comment => 'unable to find a gcc.exe where expected, '.
'rerunning MinGW installer!' ],
[ archive => $sources.'MSYS-1.0.11.exe',
'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw/MSYS-1.0.11.exe',
comment => 'Get the MSYS and addons:' ] ,
[ 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' ] ,
[ archive => $sources.'zlib-1.2.3-MSYS-1.0.11.tar.bz2',
'fetch' => 'http://easynews.dl.sourceforge.net'.
'/sourceforge/mingw/zlib-1.2.3-MSYS-1.0.11.tar.bz2' ] ,
[ 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' ] ,
[ archive => $sources.'mktemp-1.5-MSYS.tar.bz2',
'fetch' => 'http://'.$sourceforge.'/sourceforge/mingw'.
'/mktemp-1.5-MSYS.tar.bz2' ] ,
# install MSYS, it supplies the 'tar' executable, among others:
[ file => $msys.'bin/tar.exe',
exec => $dossources.'MSYS-1.0.11.exe',
comment => 'Install MSYS, it supplies the tar executable, among others. You '.
'should follow prompts, AND do post-install in DOS box.' ] ,
# don't use the [shell] or [copy] actions here,
# as neither are avail til bash is installed!
[ 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' ],
# prior to this point you can't use the 'extract' 'copy' or 'shell' features!
# 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
[ file => $mingw.'bin/mingw32-make.exe',
exec => $installMinGW,
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.' ],
[ file => $mingw.'bin/g++.exe',
exec => $installMinGW,
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.' ],
[ file => $mingw.'bin/g77.exe',
exec => $installMinGW,
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.' ],
#[ 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
# now that we have the 'extract' feature, we can finish ...
[ file => $mingw.'/bin/reimp.exe',
extract => [$sources.'mingw-utils-0.3.tar', $mingw],
comment => 'Now we can finish all the mingw and msys addons:' ],
[ file => $msys.'bin/bash.exe',
extract => [$sources.'bash-3.1-MSYS-1.0.11-1.tar', $msys] ],
[ file => $mingw.'bin/mingw32-gcc-4.2.4.exe',
extract => [$sources.'gcc-4.2.4-tdm-1-core.tar', $mingw] ],
[ file => $mingw.'include/c++/4.2.4/cstdlib',
extract => [$sources.'gcc-4.2.4-tdm-1-g++.tar', $mingw] ],
[ dir => $sources.'coreutils-5.97',
extract => [$sources.'coreutils-5.97-MSYS-1.0.11-snapshot.tar'] ],
[ file => $msys.'bin/pr.exe',
shell => ["cd ".$unixsources."coreutils-5.97","cp -r * / "] ],
[ file => $msys.'bin/mktemp.exe',
extract => [$sources.'mktemp-1.5-MSYS.tar', $msys] ],
[ dir => $msys."lib" , mkdirs => $msys.'lib' ],
[ dir => $msys."include" , mkdirs => $msys.'include' ],
#get gdb
[ archive => $sources.'gdb-6.8-mingw-3.tar.bz2',
'fetch' => 'http://'.$sourceforge.
'/sourceforge/mingw/gdb-6.8-mingw-3.tar.bz2',
comment => 'Get gdb for possible debugging later' ],
[ file => $msys.'bin/gdb.exe',
extract => [$sources.'gdb-6.8-mingw-3.tar.bz2', $msys] ],
# (alternate would be from the gnuwin32 project,
# which is actually from same source)
# run it into a 'unzip' folder, because it doesn't extract to a folder:
[ dir => $sources."unzip",
mkdirs => $sources.'unzip',
comment => 'unzip.exe - Get a precompiled '.
'native Win32 version from InfoZip' ],
[ archive => $sources.'unzip/unz552xN.exe',
'fetch' => 'ftp://ftp.info-zip.org/pub/infozip/win32/unz552xn.exe'],
[ file => $sources.'unzip/unzip.exe',
exec => 'chdir '.$dossources.'unzip && '.
$dossources.'unzip/unz552xN.exe' ],
# we could probably put the unzip.exe into the path...
# get GIT from the msys git project
[ archive => $sources.'Git-1.7.3.1-preview20101002.exe',
'fetch' => 'http://msysgit.googlecode.com/files/Git-1.7.3.1-preview20101002.exe',
comment => 'Get GIT for use later.' ],
# install GIT exe, to C:\Program Files\Git :
[ file => 'C:/Progra~1/Git/bin/git.exe',
exec => $dossources.'Git-1.7.3.1-preview20101002.exe',
comment => 'Install GIT. You should follow the DEFAULT prompts ... dont change them! ...' ] ,
#[ pause => '.... press [enter] to continue !'],
# :
[ 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' ],
[ dir => $sources."zlib/usr",
extract => [$sources.'zlib-1.2.3-MSYS-1.0.11.tar', $sources."zlib"] ],
# install to /usr:
[ file => $msys.'lib/libz.a',
exec => ["copy /Y ".$dossources.'zlib\usr\lib\* '.$dosmsys."lib"] ],
[ file => $msys.'bin/msys-z.dll',
exec => ["copy /Y ".$dossources.'zlib\usr\bin\* '.$dosmsys."bin"] ],
[ file => $msys.'include/zlib.h',
exec => ["copy /Y ".$dossources.'zlib\usr\include\* '.
$dosmsys."include"] ],
# make sure that /mingw is mounted in MSYS properly before trying
# to use the /mingw folder. this is supposed to happen as part
# of the MSYS post-install, but doesnt always work.
[ file => $msys.'etc/fstab',
write => [$msys.'etc/fstab',
"$mingw /mingw
" ],
comment => 'correct a MinGW bug that prevents the /etc/fstab from existing'],
# apply sspi.h patch
[ file => $mingw.'include/sspi_h.patch',
write => [$mingw.'include/sspi_h.patch',
'*** sspi.h Sun Jan 25 17:55:57 2009
--- sspi.h.new Sun Jan 25 17:55:51 2009
***************
*** 8,13 ****
--- 8,15 ----
extern "C" {
#endif
+ #include <subauth.h>
+
#define SECPKG_CRED_INBOUND 1
#define SECPKG_CRED_OUTBOUND 2
#define SECPKG_CRED_BOTH (SECPKG_CRED_OUTBOUND|SECPKG_CRED_INBOUND)
' ],comment => 'write the patch for the the sspi.h file'],
# apply it!?
[ grep => ['subauth.h',$mingw.'include/sspi.h'],
shell => ["cd /mingw/include","patch -p0 < sspi_h.patch"],
comment => 'Apply sspi.h patch file, if not already applied....' ],
#[ pause => 'check patch.... press [enter] to continue !'],
# apply sched.h patch
[ always => $mingw.'include/sched_h.patch',
write => [$mingw.'include/sched_h.patch',
"--- include/sched.h.org Thu Dec 4 12:00:16 2008
+++ include/sched.h Wed Dec 3 13:42:54 2008
@@ -124,8 +124,17 @@
typedef int pid_t;
#endif
-/* Thread scheduling policies */
+/* pid_t again! */
+#if defined(__MINGW32__) || defined(_UWIN)
+/* Define to `int' if <sys/types.h> does not define. */
+/* GCC 4.x reportedly defines pid_t. */
+#ifndef _PID_T_
+#define _PID_T_
+#define pid_t int
+#endif
+#endif
+/* Thread scheduling policies */
enum {
SCHED_OTHER = 0,
SCHED_FIFO,
" ],comment => 'write the patch for the the sched.h file'],
# apply it!?
[ grep => ['GCC 4.x reportedly defines pid_t',$mingw.'include/sched.h'],
shell => ["cd /mingw/include","patch -p1 < sched_h.patch"],
comment => 'Apply sched.h patch file, if not already applied....' ],
#[ pause => 'check patch.... press [enter] to continue !'],
;
# if packaging is selected, get innosetup
if ($package == 1) {
push @{$expect},
[ archive => $sources.'isetup-5.2.3.exe',
fetch => 'http://files.jrsoftware.org/ispack/ispack-5.2.3.exe',
comment => 'fetch inno setup setup' ],
[ file => $programfiles.'/Inno Setup 5/iscc.exe',
exec => $dossources.'isetup-5.2.3.exe', #/silent is broken!
comment => 'Install innosetup - install ISTool, '.
'ISSP, AND encryption support.' ],
# Get advanced uninstall
[ archive => $sources.'UninsHs.rar',
fetch => 'http://www.uninshs.com/down/UninsHs.rar',
comment => 'fetch uninstall for innosetup' ],
[ archive => $sources.'unrar-3.4.3-bin.zip',
fetch => 'http://downloads.sourceforge.net/gnuwin32/unrar-3.4.3-bin.zip',
comment => 'fetching unrar'],
[ file => $sources.'bin/unrar.exe',
shell => ["cd ".$sources, "unzip/unzip.exe unrar-3.4.3-bin.zip"]],
[ file => $programfiles.'/Inno Setup 5/UninsHs.exe',
shell => ['cd "'.$unixprogramfiles.'/inno setup 5"',
$sources.'bin/unrar.exe e '.$sources.'UninsHs.rar'],
comment => 'Install innosetup' ],
[ archive => $sources.'istool-5.2.1.exe',
fetch => 'http://downloads.sourceforge.net/sourceforge'.
'/istool/istool-5.2.1.exe',
comment => 'fetching istool' ],
[ file => $programfiles.'/ISTool/isxdl.dll',
exec => $dossources.'istool-5.2.1.exe /silent',
comment => 'Install istool'],
[ archive => $sources.'logo_mysql_sun.gif',
fetch => 'http://www.mysql.com/common/logos/logo_mysql_sun.gif',
comment => 'Download MySQL logo for an install page in the package' ],
[ exists => $approot.'build/package_flag',
shell => ["rm ".$unixapp."build/package_flag"],
comment => '' ],
;
}
#----------------------------------------
# now we do each of the source library dependencies in turn:
# download,extract,build/install
# TODO - ( and just pray that they all work?) These should really be more
# detailed, and actually check that we got it installed properly.
#
# Most of these look for a Makefile as a sign that the ./configure was
# successful (not necessarily true, but it's a start) but this requires that
# the .tar.gz didn't come with a Makefile in it.
push @{$expect},
#[ archive => $sources.'freetype-2.3.5.tar.gz',
# fetch => 'http://download.savannah.gnu.org'.
# '/releases-noredirect/freetype/freetype-2.3.5.tar.gz'],
#[ dir => $sources.'freetype-2.3.5',
# extract => $sources.'freetype-2.3.5.tar' ],
## caution... freetype comes with a Makefile in the .tar.gz, so work around it!
#[ file => $sources.'freetype-2.3.5/Makefile__',
# shell => ["cd $unixsources/freetype-2.3.5",
# "./configure --prefix=/usr",
# "touch $unixsources/freetype-2.3.5/Makefile__"],
# comment => 'building freetype' ],
#
## 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!
#[ file => $sources.'freetype-2.3.5/objs/.libs/libfreetype.a',
# shell => ["cd $unixsources/freetype-2.3.5",
# "make"],
# comment => 'checking freetype' ],
#[ file => $msys.'lib/libfreetype.a',
# shell => ["cd $unixsources/freetype-2.3.5",
# "make install"],
# comment => 'installing freetype' ],
#[ file => $msys.'bin/libfreetype-6.dll',
# shell => ["cp $unixsources/freetype-2.3.5/objs/.libs/libfreetype-6.dll ".
# "$msys/bin/"] ],
#
##here's a classic "configure; make; make-install" script, but specifying the PREFIX.
#[ archive => $sources.'lame-398-2.tar.gz',
# fetch => 'http://'.$sourceforge.'/sourceforge/lame/lame-398-2.tar.gz'],
#[ dir => $sources.'lame-398-2',
# extract => $sources.'lame-398-2.tar' ],
#[ file => $msys.'lib/libmp3lame.a',
# shell => ["cd $unixsources/lame-398-2",
# "./configure --prefix=/usr",
# "make",
# "make install"],
# comment => 'building and installing: msys lame' ],
#
# get fluid binary: from http://www.muquit.com/muquit/software/fluid_hack/fluid.exe
#[ archive => $sources.'fluid.exe',
# 'fetch' => 'http://www.muquit.com/muquit/software/fluid_hack/fluid.exe',
# comment => 'Get FLUID for use later.' ],
#[ file => $msys.'bin/fluid.exe',
# exec => 'copy /Y '.$dossources.'fluid.exe '.$dosmsys.'bin\fluid.exe'],
# get fltk sources to compile against:
# http://ftp.easysw.com/pub/fltk/1.1.10/fltk-1.1.10-source.tar.gz
# install into /mingw as installing to /usr seems to not quite work right?
[ archive => $sources.'fltk-1.1.10-source.tar.gz',
'fetch' => 'http://ftp.easysw.com/pub/fltk/1.1.10/fltk-1.1.10-source.tar.gz',
comment => 'Get FLTK 1.1.10 for use later.' ],
[ dir => $sources.'fltk-1.1.10',
extract => $sources.'fltk-1.1.10-source.tar' ],
[ file => $mingw.'lib/libfltk.a',
shell => ["cd $unixsources/fltk-1.1.10",
"./configure --prefix=/mingw",
"make",
"make install"],
comment => 'building and installing: msys fltk-1.1.10-source' ],
# get vmmlib:
[ pause => 'check patch.... press [enter] to continue !'],
;
#----------------------------------------
# get app sources, if we don't already have them
# download all the files from the web, and save them here:
#----------------------------------------
push @{$expect},
[ dir => $approot,
mkdirs => $approot,
comment => 'make app dir'],
# if no files , pull from main GIT repo ( no support for alternative repos presently
[ file => $build.'Makefile',
shell => ['cd '.$approot,
'C:/Progra~1/Git/bin/git.exe clone '.$GitUrl],
comment => 'CLONE git repo!'],
# NOTE: if there are already files in the folder, we assume you just want to build them as-is
# and we don't muck with them.!
#[ pause => '.... press [enter] to continue !'],
#----------------------------------------
# now we actually build app!
#----------------------------------------
#
[ file => $build.'repsnapper', # is the binary present?!
shell => ['cd '.$unixbuild,
'make'],
comment => 'Build the app! ' ],
;
# make
# check that the date stamp on your target dll's is newenough, or delete it and try again.
# repeat for each dll ( not shown here )
#[ newer => [$approot."app/libs/libmyth/libmyth-$version.dll",
# $approot.'app/last_build.txt'],
# shell => ['rm '.$unixapp."app/libs/libmyth/libmyth-$version.dll",
# 'source '.$unixapp.'qt'.$qtver.'_env.sh',
# 'cd '.$unixapp.'app', $parallelMake],
# comment => 'libs/libmyth/libmyth-$version.dll - '.
# 'redo make unless all these files exist, '.
# 'and are newer than the last_build.txt identifier' ],
# Archive old build before we create a new one with make install:
#[ exists => $approot.'build_old',
# shell => ['rm -fr '.$unixapp.'build_old'],
# comment => 'Deleting old build backup'],
#[ exists => $build,
# shell => ['mv '.$unixbuild.' '.$unixapp.'build_old'],
# comment => 'Renaming build to build_old for backup....'],
# re-install to /c/app/build if we have a newer app build
# ready:
#[ newer => [$build.'bin/mythfrontend.exe',
# $approot.'app/programs/mythfrontend/mythfrontend.exe'],
# shell => ['source '.$unixapp.'qt'.$qtver.'_env.sh',
# 'cd '.$unixapp.'app',
# 'make install'],
# comment => 'was the last configure successful? then install app ' ],
# -------------------------------
# Prepare Readme.txt for distribution file - temporary for now
# -------------------------------
push @{$expect},
[ file => $approot.'repsnapper/readme.win32.txt',
write => [$approot.'repsnapper/readme.win32.txt',
'PLACEHOLDER README for Win32 Installation of XXXX version
=============================================================
The current installation very basic:
- All exe and dlls will be installed to %PROGRAMFILES% - TODO
','nocheck'],comment => ''],
[ file => $approot.'repsnapper/readme.win32.txt',
shell => ['unix2dos '.$unixapp.'repsnapper/readme.win32.txt', 'nocheck'],
comment => 'Create a WIN32 readme.txt file, if there isnt one' ],
;
#if ($package == 1) {
# push @{$expect},
# # Create directories
# [ dir => [$approot.'setup'] , #
# mkdirs => [$approot.'setup'],
# comment => 'Create Packaging directory'],
# [ dir => [$approot.'build/isfiles'] ,
# mkdirs => [$approot.'build/isfiles'],
# comment => 'Create Packaging directory'],
# # Move required files from inno setup to setup directory
# [ file => $approot."build/isfiles/UninsHs.exe",
# exec => 'copy /Y "'.$dosprogramfiles.'\Inno Setup 5\UninsHs.exe" '.#
# $dosapp.'build\isfiles\UninsHs.exe',
# comment => 'Copy UninsHs to setup directory' ],
# [ file => $approot."build/isfiles/isxdl.dll",
# exec => 'copy /Y "'.$dosprogramfiles.'\ISTool\isxdl.dll" '.
# $dosapp.'build\isfiles\isxdl.dll',
# comment => 'Copy isxdl.dll to setup directory' ],
# [ file => $approot."build/isfiles/WizModernSmallImage-IS.bmp",
# exec => 'copy /Y "'.$dosprogramfiles.'\Inno Setup 5'.
# '\WizModernSmallImage-IS.bmp" '.
# $dosapp.'build\isfiles\WizModernSmallImage-IS.bmp',
# comment => 'Copy WizModernSmallImage-IS.bmp to setup directory' ],
# # Copy required files from sources or packaging to setup directory:
# [ filesame => [$approot.'build/isfiles/appsetup.iss',
# $approot.'packaging/win32/build/appsetup.iss'],
# copy => [''=>'',
# comment => 'appsetup.iss'] ],
# [ filesame => [$approot.'build/isfiles/mysql.gif',
# $sources.'logo_mysql_sun.gif'],
# copy => [''=>'',
# comment => 'mysql.gif'] ],
# # Create on-the-fly files required
# [ file => $approot.'build/isfiles/configuremysql.vbs',
# write => [$approot.'build/isfiles/configuremysql.vbs',
#'WScript.Echo "Currently Unimplemented"
#' ],
# comment => 'Write a VB script to configure MySQL' ],
## [ always => [],#
## write => [$approot.'build/isfiles/versioninfo.iss', '
##define MyAppName "MythTv"
##define MyAppVerName "MythTv '.$version.'(svn_'.$SVNRELEASE .')"
##define MyAppPublisher "Mythtv"
##define MyAppURL "http://www.app.org"
##define MyAppExeName "Win32MythTvInstall.exe"
##' ],
# comment => 'write the version information for the setup'],
# [ file => $approot.'genfiles.sh',
# write => [$approot.'genfiles.sh','
#cd '.$unixapp.'build
#find . -type f -printf "Source: '.$approot.'build/%h/%f; Destdir: {app}/%h\n" | sed "s/\.\///" | grep -v ".svn" | grep -#v "isfiles" | grep -v "include" > '.$unixapp.'/build/isfiles/files.iss
#',],
# comment => 'write script to generate setup files'],
# [ newer => [$approot.'build/isfiles/files.iss',
# $approot.'app/last_build.txt'],
# shell => [$unixapp.'genfiles.sh'] ],
## Run setup
## [ newer => [$approot.'setup/MythTvSetup.exe',
## $approot.'app/last_build.txt'],
## exec => ['"'.$dosprogramfiles.'\Inno Setup 5\Compil32.exe" /cc "'.
## $dosapp.'build\isfiles\appsetup.iss"' ]],
# [ newer => [$approot.'setup/MythTvSetup.exe',
# $approot.'app/last_build.txt'],
# exec => ['cd '.$dosapp.'build\isfiles && '.
# '"'.$dosprogramfiles.'\Inno Setup 5\iscc.exe" "'.
# $dosapp.'build\isfiles\appsetup.iss"' ]],
#
#;
#}
#------------------------------------------------------------------------------
; # END OF CAUSE->ACTION DEFINITIONS
#------------------------------------------------------------------------------
sub _end {
# comment("This version of the Win32 Build script ".
# "last was last tested on: $SVNRELEASE");
print << 'END';
#
# SCRIPT TODO/NOTES: - further notes on this scripts direction....
END
}
#------------------------------------------------------------------------------
# this is the mainloop that iterates over the above definitions and
# determines what to do:
# cause:
foreach my $dep ( @{$expect} ) {
my @dep = @{$dep};
#print Dumper(\@dep);
my $causetype = $dep[0];
my $cause = $dep[1];
my $effecttype = $dep[2];
my $effectparams = $dep[3] || '';
die "too many parameters in cause->event declaration (".join('|',@dep).")"
if defined $dep[4] && $dep[4] ne 'comment';
# four pieces: cause => [blah] , effect => [blah]
my $comment = $dep[5] || '';
if ( $comment && $NOISY ) {
comment($comment);
}
my @cause;
if (ref($cause) eq "ARRAY" ) {
@cause = @{$cause};
} else {
push @cause, $cause ;
}
# six pieces: cause => [blah] , effect => [blah] , comment => ''
die "too many parameters in cause->event declaration (@dep)"
if defined $dep[6];
my @effectparams = ();
if (ref($effectparams) eq "ARRAY" ) {
@effectparams = @{$effectparams};
} else {
push @effectparams, $effectparams ;
}
# if a 'nocheck' parameter is passed through, dont pass it through to
# the 'effect()', use it to NOT check if the file/dir exists at the end.
my @nocheckeffectparams = grep { ! /nocheck/i } @effectparams;
my $nocheck = 0;
if ( $#nocheckeffectparams != $#effectparams ) { $nocheck = 1; }
if ( $causetype eq 'archive' ) {
die "archive only supports type fetch ($cause)($effecttype)"
unless $effecttype eq 'fetch';
if ( -f $cause[0] ) {print "file exists: $cause[0]\n"; next;}
# 2nd and 3rd params get squashed into
# a single array on passing to effect();
effect($effecttype,$cause[0],@nocheckeffectparams);
if ( ! -f $cause[0] && $nocheck == 0) {
die "EFFECT FAILED ($causetype -> $effecttype): unable to ".
"locate expected file ($cause[0]) that was to be ".
"fetched from $nocheckeffectparams[0]\n";
}
} elsif ( $causetype eq 'dir' ) {
if ( -d $cause[0] ) {
print "directory exists: $causetype,$cause[0]\n"; next;
}
effect($effecttype,@nocheckeffectparams);
if ( ! -d $cause[0] && $nocheck == 0) {
die "EFFECT FAILED ($causetype -> $effecttype): unable to ".
"locate expected directory ($cause[0]).\n";
}
} elsif ( $causetype eq 'file' ) {
if ( -f $cause[0] ) {print "file already exists: $cause[0]\n"; next;}
effect($effecttype,@nocheckeffectparams);
if ( ! -f $cause[0] && $nocheck == 0) {
die "EFFECT FAILED ($causetype -> $effecttype): unable to ".
"locate expected file ($cause[0]).\n";
}
} elsif ( $causetype eq 'filesame' ) {
# NOTE - we check file mtime, byte size, AND MD5 of contents
# as without the MD5, the script can break in some circumstances.
my ( $size,$mtime,$md5)=fileinfo($cause[0]);
my ( $size2,$mtime2,$md5_2)=fileinfo($cause[1]);
if ( $mtime != $mtime2 || $size != $size2 || $md5 ne $md5_2 ) {
if ( ! $nocheckeffectparams[0] ) {
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';
print "no parameters defined, so applying effect($effecttype) as ".
"( 2nd src parameter => 1st src parameter)!\n";
effect($effecttype,$cause[1],$cause[0]);
} else {
effect($effecttype,@nocheckeffectparams);
# do something else if the files are not 100% identical?
if ( $nocheck == 0 ) {
# now verify the effect was successful
# at matching the file contents!:
undef $size; undef $size2;
undef $mtime; undef $mtime2;
undef $md5; undef $md5_2;
( $size,$mtime,$md5)=fileinfo($cause[0]);
( $size2,$mtime2,$md5_2)=fileinfo($cause[1]);
if ( $mtime != $mtime2 || $size != $size2 || $md5 ne $md5_2 ) {
die("effect failed, files NOT identical size,mtime, ".
"and MD5: ($cause[0] => $cause[1]).\n");
} else {
print "files ($cause[0] => $cause[1]) now ".
"identical - successful! \n";
}
}
}
}else {
print "effect not required files already up-to-date/identical: ".
"($cause[0] => $cause[1]).\n";
}
undef $size; undef $size2;
undef $mtime; undef $mtime2;
undef $md5; undef $md5_2;
} elsif ( $causetype eq 'newer' ) {
my $mtime = 0;
if ( -f $cause[0] ) {
$mtime = (stat($cause[0]))[9]
|| warn("$cause[0] could not be stated");
}
if (! ( -f $cause[1]) ) {
die "cause: $causetype requires it's SECOND filename to exist ".
"for comparison: $cause[1].\n";
}
my $mtime2 = (stat($cause[1]))[9];
if ( $mtime < $mtime2 ) {
effect($effecttype,@nocheckeffectparams);
if ( $nocheck == 0 ) {
# confirm it worked, mtimes should have changed now:
my $mtime3 = 0;
if ( -f $cause[0] ) {
$mtime3 = (stat($cause[0]))[9];
}
my $mtime4 = (stat($cause[1]))[9];
if ( $mtime3 < $mtime4 ) {
die "EFFECT FAILED ($causetype -> $effecttype): mtime of file".
" ($cause[0]) should be greater than file ($cause[1]).\n".
"[$mtime3] [$mtime4]\n";
}
}
} else {
print "file ($cause[0]) has same or newer mtime than ".
"($cause[1]) already, no action taken\n";
}
undef $mtime;
undef $mtime2;
} elsif ( $causetype eq 'grep' ) {
print "grep-ing for pattern($cause[0]) in file($cause[1]):\n"
if $NOISY >0;
if ( ! _grep($cause[0],$cause[1]) ) {
# grep actually needs two parameters on the source side of the action
effect($effecttype,@nocheckeffectparams);
} else {
print "grep - already matched source file($cause[1]), ".
"with pattern ($cause[0]) - no action reqd\n";
}
if ( (! _grep($cause[0],$cause[1])) && $nocheck == 0 ) {
die "EFFECT FAILED ($causetype -> $effecttype): unable to locate regex pattern ($cause[0]) in file ($cause[1])\n";
}
} elsif ( $causetype eq 'exists' ) {
print "testing if '$cause[0]' exists...\n" if $NOISY >0;
if ( -e $cause[0] ) {
effect($effecttype,@nocheckeffectparams);
}
} elsif ( $causetype eq 'always' ) {
effect($effecttype,@nocheckeffectparams);
} elsif ( $causetype eq 'stop' ){