Skip to content

Commit 16f768f

Browse files
committedAug 25, 2013
creatensis.pl: allow installation from other osgeo4w url and collect license texts
1 parent b05abdf commit 16f768f

File tree

2 files changed

+116
-21
lines changed

2 files changed

+116
-21
lines changed
 

‎ms-windows/QGIS-Installer.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ FunctionEnd
219219

220220
!define MUI_WELCOMEPAGE_TITLE_3LINES
221221
!insertmacro MUI_PAGE_WELCOME
222-
!insertmacro MUI_PAGE_LICENSE ".\Installer-Files\LICENSE.txt"
222+
!insertmacro MUI_PAGE_LICENSE ${LICENSE_FILE}
223223

224224
!define MUI_PAGE_CUSTOMFUNCTION_PRE CheckUpdate
225225
!insertmacro MUI_PAGE_DIRECTORY

‎ms-windows/osgeo4w/creatensis.pl

Lines changed: 115 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
my $keep = 0;
2222
my $verbose = 0;
2323

24-
my $packagename;
24+
my $packagename = "QGIS";
2525
my $releasename;
26-
my $shortname;
26+
my $shortname = "qgis";
2727
my $version;
2828
my $binary;
29+
my $root = "http://download.osgeo.org/osgeo4w";
2930
my $ininame = "setup.ini";
3031
my $help;
3132

@@ -38,33 +39,35 @@
3839
"packagename=s" => \$packagename,
3940
"shortname=s" => \$shortname,
4041
"ininame=s" => \$ininame,
42+
"mirror=s" => \$root,
4143
"help" => \$help
4244
);
4345

44-
if( $help ) {
45-
pod2usage(1);
46-
}
46+
pod2usage(1) if $help;
4747

4848
my $wgetopt = $verbose ? "" : "-q";
4949

5050
unless(-f "nsis/System.dll") {
5151
mkdir "nsis", 0755 unless -d "nsis";
5252
system "wget $wgetopt -Onsis/System.dll http://qgis.org/downloads/System.dll";
53+
die "download of System.dll failed" if $?;
5354
}
5455

5556
mkdir "packages", 0755 unless -d "packages";
5657
chdir "packages";
5758

58-
my $root = "http://download.osgeo.org/osgeo4w";
5959

6060
system "wget $wgetopt -c http://nsis.sourceforge.net/mediawiki/images/9/9d/Untgz.zip" unless -f "Untgz.zip";
61-
system "wget $wgetopt -c http://www.nirsoft.net/utils/nircmd.zip" unless -f "nircmd.zip";
61+
die "download of Untgz.zip failed" if $?;
6262

6363
my %dep;
6464
my %file;
65+
my %lic;
66+
my %sdesc;
6567
my $package;
6668

6769
system "wget $wgetopt -O setup.ini -c $root/$ininame";
70+
die "download of setup.ini failed" if $?;
6871
open F, "setup.ini" || die "setup.ini not found";
6972
while(<F>) {
7073
chop;
@@ -74,6 +77,10 @@
7477
@{$dep{$package}} = split / /, $1;
7578
} elsif( /^install:\s+(\S+)\s+/) {
7679
$file{$package} = $1 unless exists $file{$package};
80+
} elsif( /^license:\s+(\S+)\s+/) {
81+
$lic{$package} = $1 unless exists $lic{$package};
82+
} elsif( /^sdesc:\s*"(.*)"\s*$/) {
83+
$sdesc{$package} = $1 unless exists $sdesc{$package};
7784
}
7885
}
7986
close F;
@@ -105,16 +112,30 @@ sub getDeps {
105112
getDeps("gdal-ecw")
106113
}
107114

115+
my @lic;
116+
my @desc;
108117
foreach my $p ( keys %pkgs ) {
109-
my $f = "$root/$file{$p}";
110-
$f =~ s/\/\.\//\//g;
118+
my @f;
119+
push @f, "$root/$file{$p}";
120+
121+
if( exists $lic{$p} ) {
122+
push @f, "$root/$lic{$p}";
123+
my($l) = $lic{$p} =~ /([^\/]+)$/;
124+
push @lic, $l;
125+
push @desc, $sdesc{$p};
126+
}
111127

112-
my($file) = $f =~ /([^\/]+)$/;
128+
for my $f (@f) {
129+
$f =~ s/\/\.\//\//g;
113130

114-
next if -f $file;
115-
116-
print "Downloading $file [$f]...\n" if $verbose;
117-
system "wget $wgetopt -c $f";
131+
my($file) = $f =~ /([^\/]+)$/;
132+
133+
next if -f $file;
134+
135+
print "Downloading $file [$f]...\n" if $verbose;
136+
system "wget $wgetopt -c $f";
137+
die "download of $f failed" if $?;
138+
}
118139
}
119140

120141
chdir "..";
@@ -145,19 +166,29 @@ sub getDeps {
145166

146167
print "Unpacking $p...\n" if $verbose;
147168
system "tar $taropt -C unpacked -xjf $p";
169+
die "unpacking of $p failed" if $?;
148170
}
149171

150172
chdir "unpacked";
151173

152174
mkdir "bin", 0755;
153-
mkdir "apps", 0755;
154-
mkdir "apps/nircmd", 0755;
155175

156-
system "cd apps/nircmd; unzip ../../../packages/nircmd.zip && mv nircmd.exe ../../bin";
176+
unless( -f "bin/nircmd.exe" ) {
177+
unless( -f "../../../packages/nircmd.zip" ) {
178+
system "cd ../../../packages; wget $wgetopt -c http://www.nirsoft.net/utils/nircmd.zip";
179+
die "download of nircmd.zip failed" if $?;
180+
}
181+
182+
mkdir "apps", 0755;
183+
mkdir "apps/nircmd", 0755;
184+
system "cd apps/nircmd; unzip ../../../packages/nircmd.zip && mv nircmd.exe ../../bin";
185+
die "unpacking of nircmd failed" if $?;
186+
}
157187

158188
if( -d "../addons" ) {
159189
print " Including addons...\n" if $verbose;
160190
system "tar -C ../addons -cf - . | tar $taropt -xf -";
191+
die "copying of addons failed" if $?;
161192
}
162193

163194
chdir "..";
@@ -250,12 +281,73 @@ sub getDeps {
250281
}
251282
}
252283

253-
system "unzip packages/Untgz.zip" unless -d "untgz";
284+
unless(-d "untgz") {
285+
system "unzip packages/Untgz.zip";
286+
die "unpacking Untgz.zip failed" if $?;
287+
}
254288

255289
chdir "..";
256290

257-
$packagename = "QGIS" unless defined $packagename;
258-
$shortname = "qgis" unless defined $shortname;
291+
292+
print "Creating license file\n" if $verbose;
293+
open O, ">license.tmp";
294+
my $lic;
295+
for my $l ( ( "osgeo4w/unpacked/apps/$shortname/doc/LICENSE", "../COPYING", "./Installer-Files/LICENSE.txt" ) ) {
296+
next unless -f $l;
297+
$lic = $l;
298+
last;
299+
}
300+
301+
die "no license found" unless defined $lic;
302+
303+
my $i = 0;
304+
if( @lic ) {
305+
print O "License overview:\n";
306+
print O "1. QGIS\n";
307+
for my $l ( @desc ) {
308+
print O ++$i . ". $l\n";
309+
}
310+
$i = 0;
311+
print O "\n\n----------\n\n" . ++$i . ". License of 'QGIS'\n\n";
312+
}
313+
314+
print " Including QGIS license $lic\n" if $verbose;
315+
open I, $lic;
316+
while(<I>) {
317+
s/\s*$/\n/;
318+
print O;
319+
}
320+
close I;
321+
322+
for my $l (@lic) {
323+
print " Including license $l\n" if $verbose;
324+
325+
open I, "osgeo4w/packages/$l" or die "License $l not found.";
326+
print O "\n\n----------\n\n" . ++$i . ". License of '" . shift(@desc) . "'\n\n";
327+
while(<I>) {
328+
s/\s*$/\n/;
329+
print O;
330+
}
331+
close I;
332+
}
333+
334+
close O;
335+
336+
my $license = "license.tmp";
337+
if( -f "osgeo4w/unpacked/apps/$shortname/doc/LICENSE" ) {
338+
open O, ">osgeo4w/unpacked/apps/$shortname/doc/LICENSE";
339+
open I, $license;
340+
while(<I>) {
341+
print O;
342+
}
343+
close O;
344+
close I;
345+
346+
$license = "osgeo4w/unpacked/apps/$shortname/doc/LICENSE";
347+
}
348+
349+
350+
print "Running NSIS\n" if $verbose;
259351

260352
my $cmd = "makensis";
261353
$cmd .= " -V$verbose";
@@ -269,9 +361,11 @@ sub getDeps {
269361
$cmd .= " -DSHORTNAME='$shortname'";
270362
$cmd .= " -DINSTALLER_TYPE=OSGeo4W";
271363
$cmd .= " -DPACKAGE_FOLDER=osgeo4w/unpacked";
364+
$cmd .= " -DLICENSE_FILE='$license'";
272365
$cmd .= " QGIS-Installer.nsi";
273366

274367
system $cmd;
368+
die "running nsis failed" if $?;
275369

276370
open P, ">osgeo4w/binary-$version";
277371
print P $binary;
@@ -297,6 +391,7 @@ =head1 SYNOPSIS
297391
-ininame=filename name of the setup.ini (defaults to setup.ini)
298392
-packagename=s name of package (defaults to 'QGIS')
299393
-shortname=s shortname used for batch file (defaults to 'qgis')
394+
-mirror=s default mirror (defaults to 'http://download.osgeo.org/osgeo4w')
300395
-help this help
301396
302397
If no packages are given 'qgis-full' and it's dependencies will be retrieved

0 commit comments

Comments
 (0)
Please sign in to comment.