File: release.pl

package info (click to toggle)
sdlperl 1.20.3dfsg-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,808 kB
  • ctags: 2,171
  • sloc: perl: 7,394; ansic: 232; makefile: 76; sh: 1
file content (148 lines) | stat: -rw-r--r-- 2,954 bytes parent folder | download | duplicates (3)
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
#!perl -w

use strict;
use File::Find;


$ENV{SDL_PERL_RELEASE_ID} = "SDL_perl-1.20.3.win32";
$ENV{TAR}      = 'C:\cygwin\bin\tar.exe';
$ENV{GZIP}     = 'C:\cygwin\bin\gzip.exe';
$ENV{MAKENSIS} = '"c:\Program Files\NSIS\makensis.exe"';
$ENV{NSISCFG}  = 'sdlperl.nsi';
$ENV{NSISCFGENV} = $ENV{NSISCFG}. ".env";
$ENV{PPDFILE}    = "SDL_perl.ppd";
$ENV{MAKE}    = "nmake";
$ENV{PERL}    = "perl";
$ENV{RM}    = "del";



my $tarFile = $ENV{SDL_PERL_RELEASE_ID}. ".tar";
my $nsisCfg = $ENV{NSISCFG}; 
my $sdlDll  = $ENV{SDL_DLL_PATH}; 

my @foundDLLs = ();

my @ignoreDLLs = (
				  '.*\visualc\win32bin\SDL.dll$',
				  '.*\visualc\win32bin\sdl_sound_d.dll$',
				  );

scan_dll(FOUND_DLL => \@foundDLLs, 
		 IGNORE_DLL => \@ignoreDLLs);


system($ENV{MAKE}      , 'clean');
system($ENV{PERL}      , 'Makefile.PL');
system($ENV{MAKE});


system $ENV{RM},  $tarFile.".gz";
system $ENV{RM},  $ENV{PPDFILE};

system($ENV{TAR}       , 'cvf' , $tarFile, 'blib');
system($ENV{GZIP}      , '--best', '--force', $tarFile);

system($ENV{MAKE}      , 'ppd'); # "BINARY_LOCATION=$tarFile.gz");
envreplace_ppd();

envreplace_nsiscfg(DLLS => \@foundDLLs);

system($ENV{MAKENSIS}  , $nsisCfg);


exit;





sub envreplace_ppd
{
	local $/ = undef;
	open PPD,  "<$ENV{PPDFILE}" or die "$!";
	my $text = <PPD>;
	close PPD;

	$text =~ s/CODEBASE HREF=""/CODEBASE HREF="$ENV{SDL_PERL_RELEASE_ID}.tar.gz"/m;

	open PPD,  ">$ENV{PPDFILE}" or die "$!";
	print PPD $text;
	close PPD;
}



				
sub scan_dll
{
	my %args = ( @_
				);
	my $dll        = $args{FOUND_DLL};
	my $ignoreDlls = $args{IGNORE_DLL};
# find the SDL DLLS'

find( sub 
{
	my $fullPath=$File::Find::name;
	$fullPath =~ s/\//\\/g;
	if ($fullPath =~ /\.dll$/i)
	{
		my $foundIgnoreDll = 0 ;
		foreach my $regexOrg (@$ignoreDlls)
		{
			my $regex = $regexOrg;
			$regex =~ s/\\/\\\\/g;
			#print "********** checking against : $regex\n";
			$foundIgnoreDll = 1 if $fullPath =~/$regex/;
		}
		push @$dll, $fullPath if not $foundIgnoreDll;  
	}
	#print $fullPath."\n";
} , split ';', $sdlDll);

}


# perform env substitution on 
sub envreplace_nsiscfg
{
	my %args = ( @_
				);
	
	my @dll = @{$args{DLLS}};
open NSIS_IN,  "<$ENV{NSISCFGENV}" or die "$!";
open NSIS_OUT, ">$ENV{NSISCFG}"    or die "$!";

while (my $line = <NSIS_IN>)
{
	if ( $line =~ /\%LIST:DLLFiles\%/)
	{
		print ">>>> FILE REP\n";
		print NSIS_OUT map { "File \"$_\"\n"; } @dll;		
	}
	elsif ($line =~ /\%(.*)\%/)
	{
		print ">>>> ENV REPL $1\n";
		my $var = $ENV{$1} or die "No value set in ENV for variable named $1";
		$line =~ s/\%$1\%/$var/g;
		print NSIS_OUT $line;
	}
	else
	{
		print ">>>> WRITE\n";
		
		print NSIS_OUT $line;
	}
	print ">>>>>>>>>> ".$line;
}
close NSIS_IN;
close NSIS_OUT;


print ">" x 80 ."\n";
print "DLLS: \n", join "\n", @dll;
print "\n";
#print "<" x 80 ."\n";		

}