Skip to content

Commit 9e5ee58

Browse files
author
jef
committedJun 5, 2010
add script to build nsis standalone installer from OSGeo4W packages
git-svn-id: http://svn.osgeo.org/qgis/trunk@13664 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 61ff6ad commit 9e5ee58

File tree

2 files changed

+269
-8
lines changed

2 files changed

+269
-8
lines changed
 

‎ms-windows/QGIS-Installer.nsi

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
;Quantum GIS Installer for Windows
44
;Written by Marco Pasetti
55
;Mail to: marco.pasetti@alice.it
6+
;
7+
;Extended for creatensis.pl by Jürgen E. Fischer <jef@norbit.de>
68

79
;----------------------------------------------------------------------------------------------------------------------------
810

911
;Select if you are building a "Development Version" or a "Release Version" of the Quantum GIS Installer
1012
;Change the INSTALLER_TYPE variable to Release or Development
1113

12-
!define INSTALLER_TYPE "Release-NoGrass"
13-
1414
;----------------------------------------------------------------------------------------------------------------------------
1515

1616
;Version variables
@@ -43,13 +43,10 @@ RequestExecutionLevel admin
4343

4444
;----------------------------------------------------------------------------------------------------------------------------
4545

46-
;define the QGIS Base Name
47-
!define RELEASE_QGIS_BASE "Quantum GIS Enceladus"
48-
!define DEV_QGIS_BASE "Quantum GIS Unstable Dev"
49-
5046
;Set the installer variables, depending on the selected version to build
5147

5248
!if ${INSTALLER_TYPE} == "Release"
49+
!define RELEASE_QGIS_BASE "Quantum GIS Enceladus"
5350
!define VERSION_NUMBER "${RELEASE_VERSION_NUMBER}"
5451
!define VERSION_NAME "${RELEASE_VERSION_NAME}"
5552
!define COMPLETE_NAME "${RELEASE_QGIS_BASE} ${RELEASE_VERSION_NUMBER} ${RELEASE_VERSION_NAME}"
@@ -74,6 +71,7 @@ RequestExecutionLevel admin
7471
!define INSTALLER_DISPLAYED_NAME "${COMPLETE_NAME}"
7572
!define PACKAGE_FOLDER ".\QGIS-Release-Package-No-Grass"
7673
!else if ${INSTALLER_TYPE} == "Development"
74+
!define DEV_QGIS_BASE "Quantum GIS Unstable Dev"
7775
!define VERSION_NUMBER "${DEV_VERSION_NUMBER}"
7876
!define VERSION_NAME "${DEV_VERSION_NAME}"
7977
!define COMPLETE_NAME "${DEV_QGIS_BASE} ${DEV_VERSION_NUMBER} ${DEV_VERSION_NAME}"
@@ -85,6 +83,12 @@ RequestExecutionLevel admin
8583
!define CHECK_INSTALL_NAME "${DEV_QGIS_BASE}"
8684
!define INSTALLER_DISPLAYED_NAME "${DISPLAYED_NAME}"
8785
!define PACKAGE_FOLDER ".\QGIS-Dev-Package"
86+
!else if ${INSTALLER_TYPE} == "OSGeo4W"
87+
!define COMPLETE_NAME "${QGIS_BASE} ${VERSION_NUMBER} ${VERSION_NAME}"
88+
!define CHECK_INSTALL_NAME "${QGIS_BASE}"
89+
!define INSTALLER_DISPLAYED_NAME "${DISPLAYED_NAME}"
90+
91+
!addplugindir osgeo4w/untgz
8892
!endif
8993

9094
;----------------------------------------------------------------------------------------------------------------------------
@@ -352,6 +356,10 @@ Section "Quantum GIS" SecQGIS
352356
File .\Installer-Files\QGIS_Web.ico
353357
SetOutPath "$INSTALL_DIR"
354358
File .\Installer-Files\QGIS-WebSite.url
359+
!if ${INSTALLER_TYPE} == "OSGeo4W"
360+
File .\Installer-Files\postinstall.bat
361+
File .\Installer-Files\preremove.bat
362+
!endif
355363

356364
;add Quantum GIS files
357365
SetOutPath "$INSTALL_DIR"
@@ -394,23 +402,39 @@ Section "Quantum GIS" SecQGIS
394402
;Create the Desktop Shortcut
395403
SetShellVarContext current
396404

405+
!if ${INSTALLER_TYPE} == "OSGeo4W"
406+
CreateShortCut "$DESKTOP\${QGIS_BASE}.lnk" "$INSTALL_DIR\bin\nircmd.exe" 'exec hide "$INSTALL_DIR\bin\qgis-dev.bat"' \
407+
"$INSTALL_DIR\icons\QGIS.ico" "" SW_SHOWNORMAL "" "Launch ${COMPLETE_NAME}"
408+
!else
397409
CreateShortCut "$DESKTOP\${QGIS_BASE}.lnk" "$INSTALL_DIR\bin\qgis.exe" ""\
398410
"$INSTALL_DIR\icons\QGIS.ico" "" SW_SHOWNORMAL "" "Launch ${COMPLETE_NAME}"
411+
!endif
399412

400413
;Create the Windows Start Menu Shortcuts
401414
SetShellVarContext all
402415

403416
CreateDirectory "$SMPROGRAMS\${QGIS_BASE}"
404417

418+
!if ${INSTALLER_TYPE} == "OSGeo4W"
419+
CreateShortCut "$SMPROGRAMS\${QGIS_BASE}\${QGIS_BASE}.lnk" "$INSTALL_DIR\bin\nircmd.exe" 'exec hide "$INSTALL_DIR\bin\qgis-dev.bat"' \
420+
"$INSTALL_DIR\icons\QGIS.ico" "" SW_SHOWNORMAL "" "Launch ${COMPLETE_NAME}"
421+
!else
405422
CreateShortCut "$SMPROGRAMS\${QGIS_BASE}\${QGIS_BASE}.lnk" "$INSTALL_DIR\bin\qgis.exe" ""\
406423
"$INSTALL_DIR\icons\QGIS.ico" "" SW_SHOWNORMAL "" "Launch ${COMPLETE_NAME}"
424+
!endif
407425

408426
CreateShortCut "$SMPROGRAMS\${QGIS_BASE}\Quantum GIS Web Site.lnk" "$INSTALL_DIR\QGIS-WebSite.url" ""\
409427
"$INSTALL_DIR\icons\QGIS_Web.ico" "" SW_SHOWNORMAL "" "Visit the Quantum GIS Web Site"
410428

411429
CreateShortCut "$SMPROGRAMS\${QGIS_BASE}\Uninstall ${QGIS_BASE}.lnk" "$INSTALL_DIR\Uninstall-QGIS.exe" ""\
412430
"$INSTALL_DIR\Uninstall-QGIS.exe" "" SW_SHOWNORMAL "" "Uninstall ${COMPLETE_NAME}"
413-
431+
432+
GetFullPathName /SHORT $0 $INSTALL_DIR
433+
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("OSGEO4W_ROOT", "$0").r0'
434+
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("OSGEO4W_STARTMENU", "$SMPROGRAMS\${QGIS_BASE}").r0'
435+
436+
ReadEnvStr $0 COMSPEC
437+
nsExec::ExecToLog '"$0" /c "$INSTALL_DIR\postinstall.bat"'
414438
SectionEnd
415439

416440
Function DownloadDataSet
@@ -524,6 +548,31 @@ SectionEnd
524548

525549
Section "Uninstall"
526550

551+
!if ${INSTALLER_TYPE} == "OSGeo4W"
552+
GetFullPathName /SHORT $0 $INSTDIR
553+
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("OSGEO4W_ROOT", "$0").r0'
554+
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("OSGEO4W_STARTMENU", "$SMPROGRAMS\${QGIS_BASE}").r0'
555+
556+
ReadEnvStr $0 COMSPEC
557+
nsExec::ExecToLog '"$0" /c "$INSTALL_DIR\preremove.bat"'
558+
559+
Delete "$INSTDIR\Uninstall-QGIS.exe"
560+
Delete "$INSTDIR\postinstall.bat.done"
561+
Delete "$INSTDIR\postinstall.bat"
562+
Delete "$INSTDIR\postinstall.log"
563+
564+
Delete "$INSTDIR\preremove.bat.done"
565+
Delete "$INSTDIR\preremove.bat"
566+
Delete "$INSTDIR\preremove.log"
567+
568+
RMDir /r "$INSTDIR\bin"
569+
RMDir /r "$INSTDIR\apps"
570+
RMDir /r "$INSTDIR\etc"
571+
RMDir /r "$INSTDIR\include"
572+
RMDir /r "$INSTDIR\lib"
573+
RMDir /r "$INSTDIR\share"
574+
RMDir /r "$INSTDIR\icons"
575+
!else
527576
;remove files
528577
Delete "$INSTDIR\Uninstall-QGIS.exe"
529578

@@ -563,6 +612,7 @@ Section "Uninstall"
563612
RMDir /r "$INSTDIR\themes"
564613
RMDir /r "$INSTDIR\proj"
565614
RMDir /r "$INSTDIR\epsg_csv"
615+
!endif
566616

567617
;if empty, remove the install folder
568618
RMDir "$INSTDIR"
@@ -578,7 +628,6 @@ Section "Uninstall"
578628
;remove the Registry Entries
579629
DeleteRegKey HKLM "Software\${QGIS_BASE}"
580630
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${QGIS_BASE}"
581-
582631
SectionEnd
583632

584633
;----------------------------------------------------------------------------------------------------------------------------

‎ms-windows/osgeo4w/creatensis.pl

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
#!/usr/bin/perl
2+
# creates a NSIS installer from OSGeo4W packages
3+
# note: works also on Unix
4+
5+
# Copyright (C) 2010 Jürgen E. Fischer <jef@norbit.de>
6+
7+
# This program is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 2 of the License, or
10+
# (at your option) any later version.
11+
12+
#
13+
# Download OSGeo4W packages
14+
#
15+
16+
mkdir "packages", 0755 unless -d "packages";
17+
chdir "packages";
18+
19+
my $root = "http://download.osgeo.org/osgeo4w";
20+
21+
system "wget -q -c http://nsis.sourceforge.net/mediawiki/images/9/9d/Untgz.zip" unless -f "Untgz.zip";
22+
system "wget -q -c http://www.nirsoft.net/utils/nircmd.zip" unless -f "nircmd.zip";
23+
24+
my %dep;
25+
my %file;
26+
27+
system "wget -q -c $root/setup.ini";
28+
open F, "setup.ini" || die "setup.ini not found";
29+
while(<F>) {
30+
chop;
31+
if(/^@ (\S+)/) {
32+
$package = $1;
33+
} elsif( /^requires: (.*)$/ ) {
34+
@{$dep{$package}} = split / /, $1;
35+
} elsif( /^install:\s+(\S+)\s+/) {
36+
$file{$package} = $1 unless exists $file{$package};
37+
}
38+
}
39+
close F;
40+
41+
my %pkgs;
42+
43+
sub getDeps {
44+
my ($pkg) = @_;
45+
46+
return if exists $pkgs{$pkg};
47+
48+
$pkgs{$pkg} = 1;
49+
50+
foreach my $p ( @{ $dep{$pkg} } ) {
51+
getDeps($p);
52+
}
53+
}
54+
55+
getDeps("qgis-dev");
56+
57+
if(-f "../addons/bin/NCSEcw.dll") {
58+
print "Enabling ECW support...\n";
59+
getDeps("gdal16-ecw")
60+
}
61+
62+
if(-f "../addons/bin/lti_dsdk_dll.dll") {
63+
print "Enabling MrSID support...\n";
64+
getDeps("gdal16-mrsid")
65+
}
66+
67+
delete $pkgs{"qgis-dev"};
68+
69+
70+
foreach my $p ( keys %pkgs ) {
71+
$f = "$root/$file{$p}";
72+
$f =~ s/\/\.\//\//g;
73+
74+
my($file) = $f =~ /([^\/]+)$/;
75+
76+
next if -f $file;
77+
78+
print "Downloading $file [$f]...\n";
79+
system "wget -q -c $f";
80+
}
81+
82+
chdir "..";
83+
84+
#
85+
# Unpack them
86+
# Add nircmd
87+
# Add addons
88+
#
89+
90+
91+
system "rm -rf unpacked" if -d "unpacked" && !grep(/^-k$/, @ARGV);
92+
93+
unless(-d "unpacked") {
94+
mkdir "unpacked", 0755;
95+
96+
for my $p (<packages/*.tar.bz2>) {
97+
print "Unpacking $p...\n";
98+
system "tar -C unpacked -xjf $p";
99+
}
100+
101+
chdir "unpacked";
102+
103+
mkdir "bin", 0755;
104+
mkdir "apps", 0755;
105+
mkdir "apps/nircmd", 0755;
106+
107+
system "cd apps/nircmd; unzip ../../../packages/nircmd.zip && mv nircmd.exe ../../bin";
108+
109+
system "tar -C ../addons -cf . | tar -xf -" if -d "../addons";
110+
111+
chdir "..";
112+
}
113+
114+
#
115+
# Create postinstall.bat
116+
#
117+
118+
unless(-f "../Installer-Files/postinstall.bat") {
119+
open F, ">../Installer-Files/postinstall.bat";
120+
121+
print F "\@echo off\r\n";
122+
print F "del postinstall.log>>postinstall.log\r\n";
123+
print F "echo OSGEO4W_ROOT=%OSGEO4W_ROOT%>>postinstall.log 2>&1\r\n";
124+
print F "echo OSGEO4W_STARTMENU=%OSGEO4W_STARTMENU%>>postinstall.log 2>&1\r\n";
125+
print F "set OSGEO4W_ROOT_MSYS=%OSGEO4W_ROOT:\\=/%\r\n";
126+
print F "if \"%OSGEO4W_ROOT_MSYS:~1,1%\"==\":\" set OSGEO4W_ROOT_MSYS=/%OSGEO4W_ROOT_MSYS:~0,1%/%OSGEO4W_ROOT_MSYS:~3%\r\n";
127+
print F "echo OSGEO4W_ROOT_MSYS=%OSGEO4W_ROOT_MSYS%>>postinstall.log 2>&1\r\n";
128+
print F "PATH %OSGEO4W_ROOT%\\bin;%PATH%>>postinstall.log 2>&1\r\n";
129+
print F "cd %OSGEO4W_ROOT%>>postinstall.log 2>&1\r\n";
130+
131+
chdir "unpacked";
132+
for my $p (<etc/postinstall/*.bat>) {
133+
$p =~ s/\//\\/g;
134+
my($dir,$file) = $p =~ /^(.+)\\([^\\]+)$/;
135+
136+
print F "echo Running postinstall $file...\r\n";
137+
print F "%COMSPEC% /c $p>>postinstall.log 2>&1\r\n";
138+
print F "ren $p $file.done>>postinstall.log 2>&1\r\n";
139+
}
140+
chdir "..";
141+
142+
print F "ren postinstall.bat postinstall.bat.done\r\n";
143+
144+
close F;
145+
}
146+
147+
unless(-f "../Installer-Files/preremove.bat") {
148+
open F, ">../Installer-Files/preremove.bat";
149+
150+
print F "\@echo off\r\n";
151+
print F "del preremove.log>>preremove.log\r\n";
152+
print F "echo OSGEO4W_ROOT=%OSGEO4W_ROOT%>>preremove.log 2>&1\r\n";
153+
print F "echo OSGEO4W_STARTMENU=%OSGEO4W_STARTMENU%>>preremove.log 2>&1\r\n";
154+
print F "set OSGEO4W_ROOT_MSYS=%OSGEO4W_ROOT:\\=/%\r\n";
155+
print F "if \"%OSGEO4W_ROOT_MSYS:~1,1%\"==\":\" set OSGEO4W_ROOT_MSYS=/%OSGEO4W_ROOT_MSYS:~0,1%/%OSGEO4W_ROOT_MSYS:~3%\r\n";
156+
print F "echo OSGEO4W_ROOT_MSYS=%OSGEO4W_ROOT_MSYS%>>preremove.log 2>&1\r\n";
157+
print F "PATH %OSGEO4W_ROOT%\\bin;%PATH%>>preremove.log 2>&1\r\n";
158+
print F "cd %OSGEO4W_ROOT%>>preremove.log 2>&1\r\n";
159+
160+
chdir "unpacked";
161+
for my $p (<etc/preremove/*.bat>) {
162+
$p =~ s/\//\\/g;
163+
my($dir,$file) = $p =~ /^(.+)\\([^\\]+)$/;
164+
165+
print F "echo Running preremove $file...\r\n";
166+
print F "%COMSPEC% /c $p>>preremove.log 2>&1\r\n";
167+
print F "ren $p $file.done>>preremove.log 2>&1\r\n";
168+
}
169+
chdir "..";
170+
171+
print F "ren preremove.bat preremove.bat.done\r\n";
172+
173+
close F;
174+
}
175+
176+
my($major, $minor, $patch, $release, $revision);
177+
178+
open F, "../../CMakeLists.txt";
179+
while(<F>) {
180+
print;
181+
if(/SET\(CPACK_PACKAGE_VERSION_MAJOR "(\d+)"\)/) {
182+
$major = $1;
183+
} elsif(/SET\(CPACK_PACKAGE_VERSION_MINOR "(\d+)"\)/) {
184+
$minor = $1;
185+
} elsif(/SET\(CPACK_PACKAGE_VERSION_PATCH "(\d+)"\)/) {
186+
$patch = $1;
187+
} elsif(/SET\(RELEASE_NAME "(.+)"\)/) {
188+
$release = $1;
189+
}
190+
}
191+
close F;
192+
193+
open F, "svnversion|";
194+
$revision = <F>;
195+
$revision =~ s/\D+$//g;
196+
close F;
197+
198+
chdir "..";
199+
200+
my $cmd = "makensis";
201+
$cmd .= " -DVERSION_NUMBER='$major.$minor.$patch'";
202+
$cmd .= " -DVERSION_NAME='$release'";
203+
$cmd .= " -DSVN_REVISION='$revision'";
204+
$cmd .= " -DQGIS_BASE='Quantum GIS $release'";
205+
$cmd .= " -DINSTALLER_NAME='QGIS-OSGeo4W-$major.$minor.$patch-$revision-Setup.exe'";
206+
$cmd .= " -DDISPLAYED_NAME='Quantum GIS OSGeo4W ($release)'";
207+
$cmd .= " -DBINARY_REVISION=1";
208+
$cmd .= " -DINSTALLER_TYPE=OSGeo4W";
209+
$cmd .= " -DPACKAGE_FOLDER=osgeo4w/unpacked";
210+
$cmd .= " QGIS-Installer.nsi";
211+
212+
system $cmd;

0 commit comments

Comments
 (0)
Please sign in to comment.