Navigation Menu

Skip to content

Commit

Permalink
creatensis.pl: allow installation from other osgeo4w url and collect …
Browse files Browse the repository at this point in the history
…license texts
  • Loading branch information
jef-n committed Aug 25, 2013
1 parent b05abdf commit 16f768f
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ms-windows/QGIS-Installer.nsi
Expand Up @@ -219,7 +219,7 @@ FunctionEnd

!define MUI_WELCOMEPAGE_TITLE_3LINES
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ".\Installer-Files\LICENSE.txt"
!insertmacro MUI_PAGE_LICENSE ${LICENSE_FILE}

!define MUI_PAGE_CUSTOMFUNCTION_PRE CheckUpdate
!insertmacro MUI_PAGE_DIRECTORY
Expand Down
135 changes: 115 additions & 20 deletions ms-windows/osgeo4w/creatensis.pl
Expand Up @@ -21,11 +21,12 @@
my $keep = 0;
my $verbose = 0;

my $packagename;
my $packagename = "QGIS";
my $releasename;
my $shortname;
my $shortname = "qgis";
my $version;
my $binary;
my $root = "http://download.osgeo.org/osgeo4w";
my $ininame = "setup.ini";
my $help;

Expand All @@ -38,33 +39,35 @@
"packagename=s" => \$packagename,
"shortname=s" => \$shortname,
"ininame=s" => \$ininame,
"mirror=s" => \$root,
"help" => \$help
);

if( $help ) {
pod2usage(1);
}
pod2usage(1) if $help;

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

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

mkdir "packages", 0755 unless -d "packages";
chdir "packages";

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

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

my %dep;
my %file;
my %lic;
my %sdesc;
my $package;

system "wget $wgetopt -O setup.ini -c $root/$ininame";
die "download of setup.ini failed" if $?;
open F, "setup.ini" || die "setup.ini not found";
while(<F>) {
chop;
Expand All @@ -74,6 +77,10 @@
@{$dep{$package}} = split / /, $1;
} elsif( /^install:\s+(\S+)\s+/) {
$file{$package} = $1 unless exists $file{$package};
} elsif( /^license:\s+(\S+)\s+/) {
$lic{$package} = $1 unless exists $lic{$package};
} elsif( /^sdesc:\s*"(.*)"\s*$/) {
$sdesc{$package} = $1 unless exists $sdesc{$package};
}
}
close F;
Expand Down Expand Up @@ -105,16 +112,30 @@ sub getDeps {
getDeps("gdal-ecw")
}

my @lic;
my @desc;
foreach my $p ( keys %pkgs ) {
my $f = "$root/$file{$p}";
$f =~ s/\/\.\//\//g;
my @f;
push @f, "$root/$file{$p}";

if( exists $lic{$p} ) {
push @f, "$root/$lic{$p}";
my($l) = $lic{$p} =~ /([^\/]+)$/;
push @lic, $l;
push @desc, $sdesc{$p};
}

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

next if -f $file;

print "Downloading $file [$f]...\n" if $verbose;
system "wget $wgetopt -c $f";
my($file) = $f =~ /([^\/]+)$/;

next if -f $file;

print "Downloading $file [$f]...\n" if $verbose;
system "wget $wgetopt -c $f";
die "download of $f failed" if $?;
}
}

chdir "..";
Expand Down Expand Up @@ -145,19 +166,29 @@ sub getDeps {

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

chdir "unpacked";

mkdir "bin", 0755;
mkdir "apps", 0755;
mkdir "apps/nircmd", 0755;

system "cd apps/nircmd; unzip ../../../packages/nircmd.zip && mv nircmd.exe ../../bin";
unless( -f "bin/nircmd.exe" ) {
unless( -f "../../../packages/nircmd.zip" ) {
system "cd ../../../packages; wget $wgetopt -c http://www.nirsoft.net/utils/nircmd.zip";
die "download of nircmd.zip failed" if $?;
}

mkdir "apps", 0755;
mkdir "apps/nircmd", 0755;
system "cd apps/nircmd; unzip ../../../packages/nircmd.zip && mv nircmd.exe ../../bin";
die "unpacking of nircmd failed" if $?;
}

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

chdir "..";
Expand Down Expand Up @@ -250,12 +281,73 @@ sub getDeps {
}
}

system "unzip packages/Untgz.zip" unless -d "untgz";
unless(-d "untgz") {
system "unzip packages/Untgz.zip";
die "unpacking Untgz.zip failed" if $?;
}

chdir "..";

$packagename = "QGIS" unless defined $packagename;
$shortname = "qgis" unless defined $shortname;

print "Creating license file\n" if $verbose;
open O, ">license.tmp";
my $lic;
for my $l ( ( "osgeo4w/unpacked/apps/$shortname/doc/LICENSE", "../COPYING", "./Installer-Files/LICENSE.txt" ) ) {
next unless -f $l;
$lic = $l;
last;
}

die "no license found" unless defined $lic;

my $i = 0;
if( @lic ) {
print O "License overview:\n";
print O "1. QGIS\n";
for my $l ( @desc ) {
print O ++$i . ". $l\n";
}
$i = 0;
print O "\n\n----------\n\n" . ++$i . ". License of 'QGIS'\n\n";
}

print " Including QGIS license $lic\n" if $verbose;
open I, $lic;
while(<I>) {
s/\s*$/\n/;
print O;
}
close I;

for my $l (@lic) {
print " Including license $l\n" if $verbose;

open I, "osgeo4w/packages/$l" or die "License $l not found.";
print O "\n\n----------\n\n" . ++$i . ". License of '" . shift(@desc) . "'\n\n";
while(<I>) {
s/\s*$/\n/;
print O;
}
close I;
}

close O;

my $license = "license.tmp";
if( -f "osgeo4w/unpacked/apps/$shortname/doc/LICENSE" ) {
open O, ">osgeo4w/unpacked/apps/$shortname/doc/LICENSE";
open I, $license;
while(<I>) {
print O;
}
close O;
close I;

$license = "osgeo4w/unpacked/apps/$shortname/doc/LICENSE";
}


print "Running NSIS\n" if $verbose;

my $cmd = "makensis";
$cmd .= " -V$verbose";
Expand All @@ -269,9 +361,11 @@ sub getDeps {
$cmd .= " -DSHORTNAME='$shortname'";
$cmd .= " -DINSTALLER_TYPE=OSGeo4W";
$cmd .= " -DPACKAGE_FOLDER=osgeo4w/unpacked";
$cmd .= " -DLICENSE_FILE='$license'";
$cmd .= " QGIS-Installer.nsi";

system $cmd;
die "running nsis failed" if $?;

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

0 comments on commit 16f768f

Please sign in to comment.