added PEAR (go-pear.phar)

added PEAR (go-pear.phar)

//
//          _\|/_
//          (o o)
// +-----oOO-{_}-OOo------------------------------------------------------+
// |                                                                      |
// |  WPN-XM Server Stack - Inno Setup Script File                        |
// |  --------------------------------------------                        |
// |                                                                      |
// |  WPN-XM is a free and open-source web server solution stack for      |
// |  professional PHP development on the Windows platform.               |
// |                                                                      |
// |  The groundation of this stack consists of NGINX, MariaDb and PHP.   |
// |                                                                      |
// |  The stack contains several additional tools you might install:      |
// |                                                                      |
// |   - Server Control Panel for controlling server daemons,             |
// |   - WPN-XM Webinterface for administration of the stack,             |
// |   - Xdebug, Xhprof, webgrind for php debugging purposes,             |
// |   - phpMyAdmin for MySQL database administration,                    |
// |   - memcached and APC for caching purposes,                          |
// |   - junctions for creating symlinks.                                 |
// |                                                                      |
// |  Author:   Jens-Andre Koch <jakoch@web.de>                           |
// |  Website:  http://wpn-xm.org                                         |
// |  License:  GNU/GPLv2+                                                |
// |                                                                      |
// |  Note for developers                                                 |
// |  -------------------                                                 |
// |  A good resource for developing and understanding                    |
// |  Inno Setup Script files is the official "Inno Setup Help".          |
// |  Website:  http://jrsoftware.org/ishelp/index.php                    |
// |                                                                      |
// +---------------------------------------------------------------------<3
//

// toggle for enabling/disabling the debug mode
# define DEBUG "@DEBUG@"

// defines the root folder
# define SOURCE_ROOT AddBackslash(SourcePath);

// defines for the setup section
#define AppName "WPN-XM Server Stack"
// the -APPVERSION- token is replaced during the nant build process
#define AppVersion "@APPVERSION@"
#define AppPublisher "Jens-Andr Koch"
#define AppURL "http://wpn-xm.org/"
#define AppSupportURL "https://github.com/jakoch/WPN-XM/issues/"

// we need to include the Sherlock Software\InnoTools\Downloader
# include SOURCE_ROOT + "..\bin\InnoToolsDownloader\it_download.iss"

[Setup]
AppId={{8E0B8E63-FF85-4B78-9C7F-109F905E1D3B}}
AppName={#AppName}
AppVerName={#AppName} {#AppVersion}
AppVersion={#AppVersion}
AppPublisher={#AppPublisher}
AppCopyright= {#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppSupportURL}
AppUpdatesURL={#AppURL}

// default installation folder is "c:\server". but user might change this via dialog.
DefaultDirName={sd}\server
DefaultGroupName="{#AppName}"
OutputBaseFilename="WPNXM-{#AppVersion}-Setup"
Compression=lzma/ultra
InternalCompressLevel=max
SolidCompression=true
CreateAppDir=true
ShowLanguageDialog=no
BackColor=clBlack
PrivilegesRequired=admin

// create a log file, see [code] procedure CurStepChanged
SetupLogging=yes

VersionInfoVersion={#AppVersion}
VersionInfoCompany={#AppPublisher}
VersionInfoDescription={#AppName} {#AppVersion}
VersionInfoTextVersion={#AppVersion}
VersionInfoCopyright=Copyright (C) 2011 - 2012 {#AppPublisher}, All Rights Reserved.

SetupIconFile={#SOURCE_ROOT}..\bin\icons\Setup.ico
//WizardImageFile={#SOURCE_ROOT}bin\icons\wizardimage.bmp
//WizardSmallImageFile={#SOURCE_ROOT}bin\icons\wizardsmallimage.bmp

[Languages]
Name: en; MessagesFile: compiler:Default.isl
Name: de; MessagesFile: compiler:languages\German.isl

[Types]
Name: "full"; Description: "Full installation"
Name: "serverstack"; Description: "Server Stack with Administration Tools"
Name: "debug"; Description: "Server Stack with Debugtools"
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "serverstack"; Description: "Base of the WPN-XM Server Stack (Nginx & PHP & MariaDb)"; ExtraDiskSpaceRequired: 155000000; Types: full serverstack debug custom; Flags: fixed
Name: "webinterface"; Description: "WPN-XM - Webinterface for Serveradministration"; ExtraDiskSpaceRequired: 500000; Types: full serverstack debug
Name: "consoleinterface"; Description: "WPN-XM - Tray App for Serveradministration"; ExtraDiskSpaceRequired: 500000; Types: full serverstack debug
Name: "xdebug"; Description: "Xdebug - PHP Extension for Debugging"; ExtraDiskSpaceRequired: 300000; Types: full debug
Name: "webgrind"; Description: "Webgrind - Xdebug profiling web frontend"; ExtraDiskSpaceRequired: 500000; Types: full debug
Name: "xhprof"; Description: "XhProfiler - Hierarchical Profiler for PHP"; ExtraDiskSpaceRequired: 800000; Types: full debug
// memcached install means the daemon and the php extension
Name: "memcached"; Description: "Memcached - distributed memory caching"; ExtraDiskSpaceRequired: 400000; Types: full
Name: "zeromq"; Description: "ZeroMQ - PHP Extension for concurrent socket magic"; ExtraDiskSpaceRequired: 300000; Types: full debug
Name: "phpmyadmin"; Description: "phpMyAdmin - MySQL database administration webinterface"; ExtraDiskSpaceRequired: 3300000; Types: full
Name: "junction"; Description: "junction - Mircosoft tool for creating junctions (symlinks)"; ExtraDiskSpaceRequired: 157000; Types: full
Name: "pear"; Description: "PEAR - PHP Extension and Application Repository"; ExtraDiskSpaceRequired: 10000000; Types: full;

[Files]
// tools
Source: "..\bin\UnxUtils\unzip.exe"; DestDir: "{tmp}"; Flags: dontcopy
Source: "..\bin\HideConsole\RunHiddenConsole.exe"; DestDir: "{app}\bin\tools\"
Source: "..\bin\killprocess\Process.exe"; DestDir: "{app}\bin\tools\"
Source: "..\bin\cleanup-mysql-5.5.15-win32.bat"; DestDir: "{tmp}"
// incorporate the whole "www" folder into the setup
Source: "..\www\*"; DestDir: "{app}\www";  Flags: recursesubdirs; Excludes: "*\nbproject*"
// incorporate several startfiles
Source: "..\startfiles\administration.url"; DestDir: "{app}"
Source: "..\startfiles\localhost.url"; DestDir: "{app}"
Source: "..\startfiles\start-wpnxm.exe"; DestDir: "{app}"
Source: "..\startfiles\stop-wpnxm.exe"; DestDir: "{app}"
Source: "..\startfiles\status-wpnxm.bat"; DestDir: "{app}"
// config files
Source: "..\configs\php.ini"; DestDir: "{app}\bin\php"
Source: "..\configs\nginx.conf"; DestDir: "{app}\bin\nginx\conf"
Source: "..\configs\vhosts.conf"; DestDir: "{app}\bin\nginx\conf"
Source: "..\configs\my.ini"; DestDir: "{app}\bin\mariadb"

[Icons]
Name: "{group}\Start WPN-XM"; Filename: "{app}\start-wpnxm.exe"
Name: "{group}\Stop WPN-XM"; Filename: "{app}\stop-wpnxm.exe"
Name: "{group}\Status of WPN-XM"; Filename: "{app}\status-wpnxm.bat"
Name: "{group}\Localhost"; Filename: "{app}\localhost.url"
Name: "{group}\Administration"; Filename: "{app}\administration.url"
Name: {group}\{cm:ProgramOnTheWeb,{#AppName}}; Filename: {#AppURL}
Name: {group}\{cm:ReportBug}; Filename: {#AppSupportURL}
Name: "{group}\{cm:RemoveApp}"; Filename: "{uninstallexe}"
//Name: "{userdesktop}\My Program"; Filename: "{app}\start-wpnxm.exe"; Tasks: desktopicon
//Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\WPN-XM"; Filename: "{app}\start-wpnxm.exe"; Tasks: quicklaunchicon

[Tasks]
//Name: "quicklaunchicon"; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: unchecked
//Name: "desktopicon"; Description: "Create a &Desktop icon"; GroupDescription: "Additional icons:"; Flags: unchecked

[Run]
// Automatically started...
Filename: "{tmp}\cleanup-mysql-5.5.15-win32.bat"; Parameters: "{app}\bin\mariadb";
//Filename: "{app}\SETUP.EXE"; Parameters: "/x"
// User selected... these files are shown for launch after everything is done
//Filename: "{app}\README.TXT"; Description: "View the README file"; Flags: postinstall shellexec skipifsilent
//Filename: "{app}\SETUP.EXE"; Description: "Configure Server Stack"; Flags: postinstall nowait skipifsilent unchecked

[INI]
;Filename: {app}\php\php.ini,Section: PHP; Key: extenson; String: php_pdo_mysql.dll; Components: ;

[Messages]
// define wizard title and tray status msg
// both are normally defined in /bin/innosetup/default.isl
SetupAppTitle = Setup WPN-XM {#AppVersion}
SetupWindowTitle = Setup - {#AppName} {#AppVersion}

[CustomMessages]
de.WebsiteLink={#AppURL}
en.WebsiteLink={#AppURL}
de.ReportBug=Fehler melden
en.ReportBug=Report Bug
de.RemoveApp=WPN-XM Server Stack deinstallieren
en.RemoveApp=Uninstall WPN-XM Server Stack

[Dirs]
Name: "{app}\www"

[Code]
// Constants and global variables
const
  // reassigning the preprocessor defined constant debug
  DEBUG = {#DEBUG};

  // Define download URLs for the software packages
  // Warning: Watch the protocol (Use http, not https!), if you add download links pointing to github.
  URL_nginx             = 'http://www.nginx.org/download/nginx-1.1.11.zip';
  URL_php               = 'http://windows.php.net/downloads/releases/php-5.3.10-nts-Win32-VC9-x86.zip';
  URL_mariadb           = 'http://mirror2.hs-esslingen.de/mariadb/mariadb-5.3.3-rc/win2008r2-vs2010-i386-packages/mariadb-5.3.3-win32.zip';
  URL_phpext_xdebug     = 'http://xdebug.org/files/php_xdebug-2.1.3-5.3-vc9-nts.dll';
  URL_webgrind          = 'http://webgrind.googlecode.com/files/webgrind-release-1.0.zip';
  // Leave the original url of xhprof in here ! we are fetching from paul reinheimers fork !
  //URL_xhprof          = 'http://nodeload.github.com/facebook/xhprof/zipball/master';
  URL_xhprof            = 'http://nodeload.github.com/preinheimer/xhprof/zipball/master';
  URL_memcached         = 'http://downloads.northscale.com/memcached-1.4.5-x86.zip';
  URL_phpext_memcached  = 'http://downloads.php.net/pierre/php_memcache-2.2.6-5.3-vc9-x86.zip';
  URL_phpext_zeromq     = 'http://snapshot.zero.mq/download/win32/php53-ext/php-zmq-20111011_12-39.zip';
  URL_phpmyadmin        = 'http://netcologne.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.9/phpMyAdmin-3.4.9-english.zip';
  URL_junction          = 'http://download.sysinternals.com/Files/Junction.zip';
  URL_pear              = 'http://pear.php.net/go-pear.phar';

  // Define file names for the downloads
  Filename_nginx            = 'nginx.zip';
  Filename_php              = 'php.zip';
  Filename_mariadb          = 'mariadb.zip';
  Filename_phpext_xdebug    = 'xdebug.dll';
  Filename_webgrind         = 'webgrind.zip';
  Filename_xhprof           = 'xhprof.zip';
  Filename_memcached        = 'memcached.zip';
  Filename_phpext_memcache  = 'phpext_memcache.zip'; // memcache without D
  Filename_phpext_zeromq    = 'zeromq.zip';
  Filename_phpmyadmin       = 'phpmyadmin.zip';
  Filename_junction         = 'junction.zip';
  Filename_pear             = 'go-pear.phar';

var
  unzipTool: String;    // path+filename of unzip helper for exec
  returnCode: Integer;  // errorcode
  targetPath: String;   // if debug true will download to app/downloads, else temp dir

procedure UrlLabelClick(Sender: TObject);
var
  errorCode : integer;
begin
  ShellExec('','http://wpn-xm.org/','','', SW_SHOWNORMAL, ewNoWait, errorCode);
end;

procedure InitializeWizard();
var
  UrlLabel  : TNewStaticText;
  CancelBtn : TButton;
begin

  // download target path depends on debug constant
  if DEBUG = false then
  begin
    // Initialize InnoTools Download Helper
    itd_init;
    // Change from a simple overall progress bar to the detailed download view
    itd_setoption('UI_DetailedMode', '1');
    // when download fails, do not allow continuing with the installation
    itd_setoption('UI_AllowContinue', '0');
    // Start the download after the "Ready to install" screen is shown
    itd_downloadafter(wpReady);
    // reset files to download
    itd_clearfiles();
  end;

  // when debug enabled, do a one-time download of all components to a local folder
  if (DEBUG = true) and (FileExists(expandconstant('c:\wpnxm-downloads\nginx.zip')) = false) then
  begin
    // re-create the server stack folder
    if not DirExists(ExpandConstant('c:\wpnxm-downloads')) then ForceDirectories(ExpandConstant('c:\wpnxm-downloads'));
    // Initialize InnoTools Download Helper
    itd_init;
    // Change from a simple overall progress bar to the detailed download view
    itd_setoption('UI_DetailedMode', '1');
    // when download fails, do not allow continuing with the installation
    itd_setoption('UI_AllowContinue', '0');
    // Start the download after the "Ready to install" screen is shown
    itd_downloadafter(wpReady);
    // reset files to download
    itd_clearfiles();
  end;

 // display website link in the bottom left corner of the install wizard
 CancelBtn := WizardForm.CancelButton;
 UrlLabel      := TNewStaticText.Create(WizardForm);
 UrlLabel.Top  := CancelBtn.Top + (CancelBtn.Height div 2) - (UrlLabel.Height div 2);
 UrlLabel.Left := WizardForm.ClientWidth - CancelBtn.Left - CancelBtn.Width;
 UrlLabel.Caption    := ExpandConstant('{cm:WebsiteLink}');
 UrlLabel.Font.Style := UrlLabel.Font.Style + [fsUnderline];
 UrlLabel.Cursor     := crHand;
 UrlLabel.Font.Color := clHighlight;
 UrlLabel.OnClick    := @UrlLabelClick;
 UrlLabel.Parent     := WizardForm;

 if DEBUG = true then  UrlLabel.Caption  := 'DEBUG ON    ' + UrlLabel.Caption;
end;

function NextButtonClick(CurPage: Integer): Boolean;
begin
  if CurPage = wpSelectComponents then
  begin

    if DEBUG = false then
    begin
      // using this path, the downloaded components are deleted after installation
      targetPath := expandconstant('{tmp}\');
    end else
    begin
      // using this path, the downloaded components are not deleted after installation
      targetPath := expandconstant('c:\wpnxm-downloads\');
    end;

    // add files to download handler

    if IsComponentSelected('serverstack') then
    begin
      itd_addfile(URL_nginx, expandconstant(targetPath + Filename_nginx));
      itd_addfile(URL_php, expandconstant(targetPath + Filename_php));
      itd_addfile(URL_mariadb, expandconstant(targetPath + Filename_mariadb));
    end;

    if IsComponentSelected('xdebug')    then itd_addfile(URL_phpext_xdebug, expandconstant(targetPath + Filename_phpext_xdebug));
    if IsComponentSelected('webgrind')  then itd_addfile(URL_webgrind,      expandconstant(targetPath + Filename_webgrind));
    if IsComponentSelected('xhprof')    then itd_addfile(URL_xhprof,        expandconstant(targetPath + Filename_xhprof));
    if IsComponentSelected('memcached') then
    begin
        itd_addfile(URL_memcached,          expandconstant(targetPath + Filename_memcached));
        itd_addfile(URL_phpext_memcached,   expandconstant(targetPath + Filename_phpext_memcache));
    end;

    if IsComponentSelected('zeromq')     then itd_addfile(URL_phpext_zeromq, expandconstant(targetPath + Filename_phpext_zeromq));
    if IsComponentSelected('phpmyadmin') then itd_addfile(URL_phpmyadmin,    expandconstant(targetPath + Filename_phpmyadmin));
    if IsComponentSelected('junction')   then itd_addfile(URL_junction,      expandconstant(targetPath + Filename_junction));
    if IsComponentSelected('pear')       then itd_addfile(URL_pear,          expandconstant(targetPath + Filename_pear));

  end;

  Result := True;
end;

procedure DoUnzip(source: String; targetdir: String);
begin
    // source contains tmp constant, so resolve it to path name
    source := ExpandConstant(source);

    unzipTool := ExpandConstant('{tmp}\unzip.exe');

    if not FileExists(unzipTool)
    then MsgBox('UnzipTool not found: ' + unzipTool, mbError, MB_OK)
    else if not FileExists(source)
    then MsgBox('File was not found while trying to unzip: ' + source, mbError, MB_OK)
    else begin
         if Exec(unzipTool, '-o -qq "' + source + '" -d "' + targetdir + '"',
                 '', SW_HIDE, ewWaitUntilTerminated, ReturnCode) = false
         then begin
             MsgBox('Unzip failed:' + source, mbError, MB_OK)
         end;
    end;
end;

procedure UnzipFiles();
var
  selectedComponents: String;
begin
  selectedComponents := WizardSelectedComponents(false);

  // lets fetch the unzip command from the compressed setup
  ExtractTemporaryFile('unzip.exe');

  if not DirExists(ExpandConstant('{app}\bin')) then ForceDirectories(ExpandConstant('{app}\bin'));
  if not DirExists(ExpandConstant('{app}\www')) then ForceDirectories(ExpandConstant('{app}\www'));

  // always unzip the serverstack base

  DoUnzip(targetPath + Filename_nginx, ExpandConstant('{app}\bin')); // no subfolder, because nginx brings own dir

  DoUnzip(targetPath + Filename_php, ExpandConstant('{app}\bin\php'));

  DoUnzip(targetPath + Filename_mariadb, ExpandConstant('{app}\bin')); // no subfolder, brings own dir

  // unzip selected components

  // xdebug is not a zipped, its just a dll file, so copy it to the target path
  if Pos('xdebug', selectedComponents) > 0 then FileCopy(ExpandConstant(targetPath + Filename_phpext_xdebug), ExpandConstant('{app}\bin\php\ext\php_xdebug.dll'), false);

  if Pos('webgrind', selectedComponents) > 0 then DoUnzip(targetPath + Filename_webgrind, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('xhprof', selectedComponents) > 0 then DoUnzip(targetPath + Filename_xhprof, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('memcached', selectedComponents) > 0 then
  begin
    DoUnzip(targetPath + Filename_memcached, ExpandConstant('{app}\bin')); // no subfolder, brings own dir
    DoUnzip(targetPath + Filename_phpext_memcache, ExpandConstant('{app}\bin\php\ext'));
  end;

  if Pos('zeromq', selectedComponents) > 0 then DoUnzip(targetPath + Filename_zeromq, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('phpmyadmin', selectedComponents) > 0 then DoUnzip(targetPath + Filename_phpmyadmin, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('junction', selectedComponents) > 0 then DoUnzip(targetPath + Filename_junction, ExpandConstant('{app}\bin\tools'));

  // pear is not a zipped, its just a php phar package, so copy it to the php path
  if Pos('pear', selectedComponents) > 0 then FileCopy(ExpandConstant(targetPath + Filename_pear), ExpandConstant('{app}\bin\php\go-pear.php'), false);

end;

procedure ApplyModifications();
var
  php_ini_file : String;
  selectedComponents: String;
begin
  selectedComponents := WizardSelectedComponents(false);

  // config files

  php_ini_file := ExpandConstant('{app}\bin\php\php.ini');

  // modifications to the config files

  // nginx - rename directory
  Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\nginx-*') + ' ' + ExpandConstant('{app}\bin\nginx') + '"',
  '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

  // mariadb - rename directory
  Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\mariadb-*') + '  ' + ExpandConstant('{app}\bin\mariadb') + '"',
   '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

  // php
  SetIniString('PHP', 'error_log',            ExpandConstant('{app}\logs') + '\php_error.log', php_ini_file );
  SetIniString('PHP', 'doc_root',             ExpandConstant('{app}\www'), php_ini_file );
  SetIniString('PHP', 'include_path',         ExpandConstant('{app}\bin\php\pear'), php_ini_file );
  SetIniString('PHP', 'upload_tmp_dir',       ExpandConstant('{app}\temp'), php_ini_file );
  SetIniString('PHP', 'upload_max_filesize',  '8M', php_ini_file );
  SetIniString('PHP', 'session.save_path',    ExpandConstant('{app}\temp'), php_ini_file );

  // xdebug
  if Pos('xdebug', selectedComponents) > 0 then
  begin
      // add loading of xdebug.dll to php.ini
      if not IniKeyExists('Zend', 'zend_extension', php_ini_file) then
      begin
          SetIniString('Zend', 'zend_extension', ExpandConstant('{app}\bin\php\ext\php_xdebug.dll'), php_ini_file );
      end;

      // activate remote debugging
      SetIniString('Xdebug', 'xdebug.remote_enable',  'on', php_ini_file );
      SetIniString('Xdebug', 'xdebug.remote_handler', 'dbgp', php_ini_file );
      SetIniString('Xdebug', 'xdebug.remote_host',    'localhost', php_ini_file );
      SetIniString('Xdebug', 'xdebug.remote_port',    '9000', php_ini_file );
  end;

  if Pos('xhprof', selectedComponents) > 0 then
  begin
    // deactivated, because we are fetching from preinheimer's fork, see below
    // xhprof - rename "facebook-xhprof-gitref" directory
    //Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\www\facebook-xhprof*') + '  ' + ExpandConstant('{app}\www\xhprof') + '"',
    //'', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

    // xhprof - rename "preinheimer-xhprof-gitref" directory
    Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\www\preinheimer-xhprof*') + '  ' + ExpandConstant('{app}\www\xhprof') + '"',
    '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);
  end;

  if Pos('memcached', selectedComponents) > 0 then
  begin
      // rename the existing directory
      Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\memcached-x86') + ' ' + ExpandConstant('{app}\bin\memcached') + '"',
      '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

      // php.ini entry for loading the the extension
      SetIniString('PHP', 'extension', 'php_memcache.dll', php_ini_file );
  end;

  if Pos('zeromq', selectedComponents) > 0 then
  begin
      // rename the existing directory
      //Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\memcached-x86') + ' ' + ExpandConstant('{app}\bin\memcached') + '"',
      //'', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

      // php.ini entry for loading the the extension
      SetIniString('PHP', 'extension', 'php_zmq.dll', php_ini_file );
  end;

  if Pos('phpmyadmin', selectedComponents) > 0 then
  begin
     // phpmyadmin - rename "phpMyAdmin-3.4.6-english" directory
    Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\www\phpMyAdmin-*') + '  ' + ExpandConstant('{app}\www\phpmyadmin') + '"',
    '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);
  end;

end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  logfilepathname : String;
  logfilename : String;
  newfilepathname : String;
begin
 if CurStep=ssInstall then
   begin
    UnzipFiles();
    ApplyModifications();
   end;

 if CurStep = ssDone then
   begin
     // copy logfile from tmp dir to the application dir, when the setup wizward is finished
     logfilepathname := ExpandConstant('{log}');
     logfilename := ExtractFileName(logfilepathname);
     newfilepathname := ExpandConstant('{app}\') +logfilename;
     filecopy(logfilepathname, newfilepathname, false);
   end;
end;

//
//          _\|/_
//          (o o)
// +-----oOO-{_}-OOo------------------------------------------------------+
// |                                                                      |
// |  WPN-XM Server Stack - Inno Setup Script File                        |
// |  --------------------------------------------                        |
// |                                                                      |
// |  WPN-XM is a free and open-source web server solution stack for      |
// |  professional PHP development on the Windows platform.               |
// |                                                                      |
// |  The groundation of this stack consists of NGINX, MariaDb and PHP.   |
// |                                                                      |
// |  The stack contains several additional tools you might install:      |
// |                                                                      |
// |   - Server Control Panel for controlling server daemons,             |
// |   - WPN-XM Webinterface for administration of the stack,             |
// |   - Xdebug, Xhprof, webgrind for php debugging purposes,             |
// |   - phpMyAdmin for MySQL database administration,                    |
// |   - memcached and APC for caching purposes,                          |
// |   - junctions for creating symlinks.                                 |
// |                                                                      |
// |  Author:   Jens-Andre Koch <jakoch@web.de>                           |
// |  Website:  http://wpn-xm.org                                         |
// |  License:  GNU/GPLv2+                                                |
// |                                                                      |
// |  Note for developers                                                 |
// |  -------------------                                                 |
// |  A good resource for developing and understanding                    |
// |  Inno Setup Script files is the official "Inno Setup Help".          |
// |  Website:  http://jrsoftware.org/ishelp/index.php                    |
// |                                                                      |
// +---------------------------------------------------------------------<3
//

// toggle for enabling/disabling the debug mode
# define DEBUG "@DEBUG@"

// defines the root folder
# define SOURCE_ROOT AddBackslash(SourcePath);

// defines for the setup section
#define AppName "WPN-XM Server Stack"
// the -APPVERSION- token is replaced during the nant build process
#define AppVersion "@APPVERSION@"
#define AppPublisher "Jens-Andr Koch"
#define AppURL "http://wpn-xm.org/"
#define AppSupportURL "https://github.com/jakoch/WPN-XM/issues/"

// we need to include the Sherlock Software\InnoTools\Downloader
# include SOURCE_ROOT + "..\bin\InnoToolsDownloader\it_download.iss"

[Setup]
AppId={{8E0B8E63-FF85-4B78-9C7F-109F905E1D3B}}
AppName={#AppName}
AppVerName={#AppName} {#AppVersion}
AppVersion={#AppVersion}
AppPublisher={#AppPublisher}
AppCopyright= {#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppSupportURL}
AppUpdatesURL={#AppURL}

// default installation folder is "c:\server". but user might change this via dialog.
DefaultDirName={sd}\server
DefaultGroupName="{#AppName}"
OutputBaseFilename="WPNXM-{#AppVersion}-Setup"
Compression=lzma/ultra
InternalCompressLevel=max
SolidCompression=true
CreateAppDir=true
ShowLanguageDialog=no
BackColor=clBlack
PrivilegesRequired=admin

// create a log file, see [code] procedure CurStepChanged
SetupLogging=yes

VersionInfoVersion={#AppVersion}
VersionInfoCompany={#AppPublisher}
VersionInfoDescription={#AppName} {#AppVersion}
VersionInfoTextVersion={#AppVersion}
VersionInfoCopyright=Copyright (C) 2011 - 2012 {#AppPublisher}, All Rights Reserved.

SetupIconFile={#SOURCE_ROOT}..\bin\icons\Setup.ico
//WizardImageFile={#SOURCE_ROOT}bin\icons\wizardimage.bmp
//WizardSmallImageFile={#SOURCE_ROOT}bin\icons\wizardsmallimage.bmp

[Languages]
Name: en; MessagesFile: compiler:Default.isl
Name: de; MessagesFile: compiler:languages\German.isl

[Types]
Name: "full"; Description: "Full installation"
Name: "serverstack"; Description: "Server Stack with Administration Tools"
Name: "debug"; Description: "Server Stack with Debugtools"
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "serverstack"; Description: "Base of the WPN-XM Server Stack (Nginx & PHP & MariaDb)"; ExtraDiskSpaceRequired: 155000000; Types: full serverstack debug custom; Flags: fixed
Name: "webinterface"; Description: "WPN-XM - Webinterface for Serveradministration"; ExtraDiskSpaceRequired: 500000; Types: full serverstack debug
Name: "consoleinterface"; Description: "WPN-XM - Tray App for Serveradministration"; ExtraDiskSpaceRequired: 500000; Types: full serverstack debug
Name: "xdebug"; Description: "Xdebug - PHP Extension for Debugging"; ExtraDiskSpaceRequired: 300000; Types: full debug
Name: "webgrind"; Description: "Webgrind - Xdebug profiling web frontend"; ExtraDiskSpaceRequired: 500000; Types: full debug
Name: "xhprof"; Description: "XhProfiler - Hierarchical Profiler for PHP"; ExtraDiskSpaceRequired: 800000; Types: full debug
// memcached install means the daemon and the php extension
Name: "memcached"; Description: "Memcached - distributed memory caching"; ExtraDiskSpaceRequired: 400000; Types: full
Name: "zeromq"; Description: "ZeroMQ - PHP Extension for concurrent socket magic"; ExtraDiskSpaceRequired: 300000; Types: full debug
Name: "phpmyadmin"; Description: "phpMyAdmin - MySQL database administration webinterface"; ExtraDiskSpaceRequired: 3300000; Types: full
Name: "junction"; Description: "junction - Mircosoft tool for creating junctions (symlinks)"; ExtraDiskSpaceRequired: 157000; Types: full

[Files]
// tools
Source: "..\bin\UnxUtils\unzip.exe"; DestDir: "{tmp}"; Flags: dontcopy
Source: "..\bin\HideConsole\RunHiddenConsole.exe"; DestDir: "{app}\bin\tools\"
Source: "..\bin\killprocess\Process.exe"; DestDir: "{app}\bin\tools\"
Source: "..\bin\cleanup-mysql-5.5.15-win32.bat"; DestDir: "{tmp}"
// incorporate the whole "www" folder into the setup
Source: "..\www\*"; DestDir: "{app}\www";  Flags: recursesubdirs; Excludes: "*\nbproject*"
// incorporate several startfiles
Source: "..\startfiles\administration.url"; DestDir: "{app}"
Source: "..\startfiles\localhost.url"; DestDir: "{app}"
Source: "..\startfiles\start-wpnxm.exe"; DestDir: "{app}"
Source: "..\startfiles\stop-wpnxm.exe"; DestDir: "{app}"
Source: "..\startfiles\status-wpnxm.bat"; DestDir: "{app}"
// config files
Source: "..\configs\php.ini"; DestDir: "{app}\bin\php"
Source: "..\configs\nginx.conf"; DestDir: "{app}\bin\nginx\conf"
Source: "..\configs\vhosts.conf"; DestDir: "{app}\bin\nginx\conf"
Source: "..\configs\my.ini"; DestDir: "{app}\bin\mariadb"

[Icons]
Name: "{group}\Start WPN-XM"; Filename: "{app}\start-wpnxm.exe"
Name: "{group}\Stop WPN-XM"; Filename: "{app}\stop-wpnxm.exe"
Name: "{group}\Status of WPN-XM"; Filename: "{app}\status-wpnxm.bat"
Name: "{group}\Localhost"; Filename: "{app}\localhost.url"
Name: "{group}\Administration"; Filename: "{app}\administration.url"
Name: {group}\{cm:ProgramOnTheWeb,{#AppName}}; Filename: {#AppURL}
Name: {group}\{cm:ReportBug}; Filename: {#AppSupportURL}
Name: "{group}\{cm:RemoveApp}"; Filename: "{uninstallexe}"
//Name: "{userdesktop}\My Program"; Filename: "{app}\start-wpnxm.exe"; Tasks: desktopicon
//Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\WPN-XM"; Filename: "{app}\start-wpnxm.exe"; Tasks: quicklaunchicon

[Tasks]
//Name: "quicklaunchicon"; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: unchecked
//Name: "desktopicon"; Description: "Create a &Desktop icon"; GroupDescription: "Additional icons:"; Flags: unchecked

[Run]
// Automatically started...
Filename: "{tmp}\cleanup-mysql-5.5.15-win32.bat"; Parameters: "{app}\bin\mariadb";
//Filename: "{app}\SETUP.EXE"; Parameters: "/x"
// User selected... these files are shown for launch after everything is done
//Filename: "{app}\README.TXT"; Description: "View the README file"; Flags: postinstall shellexec skipifsilent
//Filename: "{app}\SETUP.EXE"; Description: "Configure Server Stack"; Flags: postinstall nowait skipifsilent unchecked

[INI]
;Filename: {app}\php\php.ini,Section: PHP; Key: extenson; String: php_pdo_mysql.dll; Components: ;

[Messages]
// define wizard title and tray status msg
// both are normally defined in /bin/innosetup/default.isl
SetupAppTitle = Setup WPN-XM {#AppVersion}
SetupWindowTitle = Setup - {#AppName} {#AppVersion}

[CustomMessages]
de.WebsiteLink={#AppURL}
en.WebsiteLink={#AppURL}
de.ReportBug=Fehler melden
en.ReportBug=Report Bug
de.RemoveApp=WPN-XM Server Stack deinstallieren
en.RemoveApp=Uninstall WPN-XM Server Stack

[Dirs]
Name: "{app}\www"

[Code]
// Constants and global variables
const
  // reassigning the preprocessor defined constant debug
  DEBUG = {#DEBUG};

  // Define download URLs for the software packages
  // Warning: Watch the protocol (Use http, not https!), if you add download links pointing to github.
  URL_nginx             = 'http://www.nginx.org/download/nginx-1.1.11.zip';
  URL_php               = 'http://windows.php.net/downloads/releases/php-5.3.10-nts-Win32-VC9-x86.zip';
  URL_mariadb           = 'http://mirror2.hs-esslingen.de/mariadb/mariadb-5.3.3-rc/win2008r2-vs2010-i386-packages/mariadb-5.3.3-win32.zip';
  URL_phpext_xdebug     = 'http://xdebug.org/files/php_xdebug-2.1.3-5.3-vc9-nts.dll';
  URL_webgrind          = 'http://webgrind.googlecode.com/files/webgrind-release-1.0.zip';
  // Leave the original url of xhprof in here ! we are fetching from paul reinheimers fork !
  //URL_xhprof          = 'http://nodeload.github.com/facebook/xhprof/zipball/master';
  URL_xhprof            = 'http://nodeload.github.com/preinheimer/xhprof/zipball/master';
  URL_memcached         = 'http://downloads.northscale.com/memcached-1.4.5-x86.zip';
  URL_phpext_memcached  = 'http://downloads.php.net/pierre/php_memcache-2.2.6-5.3-vc9-x86.zip';
  URL_phpext_zeromq     = 'http://snapshot.zero.mq/download/win32/php53-ext/php-zmq-20111011_12-39.zip';
  URL_phpmyadmin        = 'http://netcologne.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.9/phpMyAdmin-3.4.9-english.zip';
  URL_junction          = 'http://download.sysinternals.com/Files/Junction.zip';

  // Define file names for the downloads
  Filename_nginx            = 'nginx.zip';
  Filename_php              = 'php.zip';
  Filename_mariadb          = 'mariadb.zip';
  Filename_phpext_xdebug    = 'xdebug.dll';
  Filename_webgrind         = 'webgrind.zip';
  Filename_xhprof           = 'xhprof.zip';
  Filename_memcached        = 'memcached.zip';
  Filename_phpext_memcache  = 'phpext_memcache.zip'; // memcache without D
  Filename_phpext_zeromq    = 'zeromq.zip';
  Filename_phpmyadmin       = 'phpmyadmin.zip';
  Filename_junction         = 'junction.zip';

var
  unzipTool: String;    // path+filename of unzip helper for exec
  returnCode: Integer;  // errorcode
  targetPath: String;   // if debug true will download to app/downloads, else temp dir

procedure UrlLabelClick(Sender: TObject);
var
  errorCode : integer;
begin
  ShellExec('','http://wpn-xm.org/','','', SW_SHOWNORMAL, ewNoWait, errorCode);
end;

procedure InitializeWizard();
var
  UrlLabel  : TNewStaticText;
  CancelBtn : TButton;
begin

  // download target path depends on debug constant
  if DEBUG = false then
  begin
    // Initialize InnoTools Download Helper
    itd_init;
    // Change from a simple overall progress bar to the detailed download view
    itd_setoption('UI_DetailedMode', '1');
    // when download fails, do not allow continuing with the installation
    itd_setoption('UI_AllowContinue', '0');
    // Start the download after the "Ready to install" screen is shown
    itd_downloadafter(wpReady);
    // reset files to download
    itd_clearfiles();
  end;

  // when debug enabled, do a one-time download of all components to a local folder
  if (DEBUG = true) and (FileExists(expandconstant('c:\wpnxm-downloads\nginx.zip')) = false) then
  begin
    // re-create the server stack folder
    if not DirExists(ExpandConstant('c:\wpnxm-downloads')) then ForceDirectories(ExpandConstant('c:\wpnxm-downloads'));
    // Initialize InnoTools Download Helper
    itd_init;
    // Change from a simple overall progress bar to the detailed download view
    itd_setoption('UI_DetailedMode', '1');
    // when download fails, do not allow continuing with the installation
    itd_setoption('UI_AllowContinue', '0');
    // Start the download after the "Ready to install" screen is shown
    itd_downloadafter(wpReady);
    // reset files to download
    itd_clearfiles();
  end;

 // display website link in the bottom left corner of the install wizard
 CancelBtn := WizardForm.CancelButton;
 UrlLabel      := TNewStaticText.Create(WizardForm);
 UrlLabel.Top  := CancelBtn.Top + (CancelBtn.Height div 2) - (UrlLabel.Height div 2);
 UrlLabel.Left := WizardForm.ClientWidth - CancelBtn.Left - CancelBtn.Width;
 UrlLabel.Caption    := ExpandConstant('{cm:WebsiteLink}');
 UrlLabel.Font.Style := UrlLabel.Font.Style + [fsUnderline];
 UrlLabel.Cursor     := crHand;
 UrlLabel.Font.Color := clHighlight;
 UrlLabel.OnClick    := @UrlLabelClick;
 UrlLabel.Parent     := WizardForm;

 if DEBUG = true then  UrlLabel.Caption  := 'DEBUG ON    ' + UrlLabel.Caption;
end;

function NextButtonClick(CurPage: Integer): Boolean;
begin
  if CurPage = wpSelectComponents then
  begin

    if DEBUG = false then
    begin
      // using this path, the downloaded components are deleted after installation
      targetPath := expandconstant('{tmp}\');
    end else
    begin
      // using this path, the downloaded components are not deleted after installation
      targetPath := expandconstant('c:\wpnxm-downloads\');
    end;

    // add files to download handler

    if IsComponentSelected('serverstack') then
    begin
      itd_addfile(URL_nginx, expandconstant(targetPath + Filename_nginx));
      itd_addfile(URL_php, expandconstant(targetPath + Filename_php));
      itd_addfile(URL_mariadb, expandconstant(targetPath + Filename_mariadb));
    end;

    if IsComponentSelected('xdebug')    then itd_addfile(URL_phpext_xdebug, expandconstant(targetPath + Filename_phpext_xdebug));
    if IsComponentSelected('webgrind')  then itd_addfile(URL_webgrind,      expandconstant(targetPath + Filename_webgrind));
    if IsComponentSelected('xhprof')    then itd_addfile(URL_xhprof,        expandconstant(targetPath + Filename_xhprof));
    if IsComponentSelected('memcached') then
    begin
        itd_addfile(URL_memcached,          expandconstant(targetPath + Filename_memcached));
        itd_addfile(URL_phpext_memcached,   expandconstant(targetPath + Filename_phpext_memcache));
    end;

    if IsComponentSelected('zeromq')     then itd_addfile(URL_phpext_zeromq, expandconstant(targetPath + Filename_phpext_zeromq));
    if IsComponentSelected('phpmyadmin') then itd_addfile(URL_phpmyadmin,    expandconstant(targetPath + Filename_phpmyadmin));
    if IsComponentSelected('junction')   then itd_addfile(URL_junction,      expandconstant(targetPath + Filename_junction));

  end;

  Result := True;
end;

procedure DoUnzip(source: String; targetdir: String);
begin
    // source contains tmp constant, so resolve it to path name
    source := ExpandConstant(source);

    unzipTool := ExpandConstant('{tmp}\unzip.exe');

    if not FileExists(unzipTool)
    then MsgBox('UnzipTool not found: ' + unzipTool, mbError, MB_OK)
    else if not FileExists(source)
    then MsgBox('File was not found while trying to unzip: ' + source, mbError, MB_OK)
    else begin
         if Exec(unzipTool, '-o -qq "' + source + '" -d "' + targetdir + '"',
                 '', SW_HIDE, ewWaitUntilTerminated, ReturnCode) = false
         then begin
             MsgBox('Unzip failed:' + source, mbError, MB_OK)
         end;
    end;
end;

procedure UnzipFiles();
var
  selectedComponents: String;
begin
  selectedComponents := WizardSelectedComponents(false);

  // lets fetch the unzip command from the compressed setup
  ExtractTemporaryFile('unzip.exe');

  if not DirExists(ExpandConstant('{app}\bin')) then ForceDirectories(ExpandConstant('{app}\bin'));
  if not DirExists(ExpandConstant('{app}\www')) then ForceDirectories(ExpandConstant('{app}\www'));

  // always unzip the serverstack base

  DoUnzip(targetPath + Filename_nginx, ExpandConstant('{app}\bin')); // no subfolder, because nginx brings own dir

  DoUnzip(targetPath + Filename_php, ExpandConstant('{app}\bin\php'));

  DoUnzip(targetPath + Filename_mariadb, ExpandConstant('{app}\bin')); // no subfolder, brings own dir

  // unzip selected components

  // xdebug is not a zipped, its just a dll file, so copy it to the target path
  if Pos('xdebug', selectedComponents) > 0 then FileCopy(ExpandConstant(targetPath + Filename_phpext_xdebug), ExpandConstant('{app}\bin\php\ext\php_xdebug.dll'), false);

  if Pos('webgrind', selectedComponents) > 0 then DoUnzip(targetPath + Filename_webgrind, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('xhprof', selectedComponents) > 0 then DoUnzip(targetPath + Filename_xhprof, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('memcached', selectedComponents) > 0 then
  begin
    DoUnzip(targetPath + Filename_memcached, ExpandConstant('{app}\bin')); // no subfolder, brings own dir
    DoUnzip(targetPath + Filename_phpext_memcache, ExpandConstant('{app}\bin\php\ext'));
  end;

  if Pos('zeromq', selectedComponents) > 0 then DoUnzip(targetPath + Filename_zeromq, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('phpmyadmin', selectedComponents) > 0 then DoUnzip(targetPath + Filename_phpmyadmin, ExpandConstant('{app}\www')); // no subfolder, brings own dir

  if Pos('junction', selectedComponents) > 0 then DoUnzip(targetPath + Filename_junction, ExpandConstant('{app}\bin\tools'));

end;

procedure ApplyModifications();
var
  php_ini_file : String;
  selectedComponents: String;
begin
  selectedComponents := WizardSelectedComponents(false);

  // config files

  php_ini_file := ExpandConstant('{app}\bin\php\php.ini');

  // modifications to the config files

  // nginx - rename directory
  Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\nginx-*') + ' ' + ExpandConstant('{app}\bin\nginx') + '"',
  '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

  // mariadb - rename directory
  Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\mariadb-*') + '  ' + ExpandConstant('{app}\bin\mariadb') + '"',
   '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

  // php
  SetIniString('PHP', 'error_log',            ExpandConstant('{app}\logs') + '\php_error.log', php_ini_file );
  SetIniString('PHP', 'doc_root',             ExpandConstant('{app}\www'), php_ini_file );
  SetIniString('PHP', 'include_path',         ExpandConstant('{app}\bin\php\pear'), php_ini_file );
  SetIniString('PHP', 'upload_tmp_dir',       ExpandConstant('{app}\temp'), php_ini_file );
  SetIniString('PHP', 'upload_max_filesize',  '8M', php_ini_file );
  SetIniString('PHP', 'session.save_path',    ExpandConstant('{app}\temp'), php_ini_file );

  // xdebug
  if Pos('xdebug', selectedComponents) > 0 then
  begin
      // add loading of xdebug.dll to php.ini
      if not IniKeyExists('Zend', 'zend_extension', php_ini_file) then
      begin
          SetIniString('Zend', 'zend_extension', ExpandConstant('{app}\bin\php\ext\php_xdebug.dll'), php_ini_file );
      end;

      // activate remote debugging
      SetIniString('Xdebug', 'xdebug.remote_enable',  'on', php_ini_file );
      SetIniString('Xdebug', 'xdebug.remote_handler', 'dbgp', php_ini_file );
      SetIniString('Xdebug', 'xdebug.remote_host',    'localhost', php_ini_file );
      SetIniString('Xdebug', 'xdebug.remote_port',    '9000', php_ini_file );
  end;

  if Pos('xhprof', selectedComponents) > 0 then
  begin
    // deactivated, because we are fetching from preinheimer's fork, see below
    // xhprof - rename "facebook-xhprof-gitref" directory
    //Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\www\facebook-xhprof*') + '  ' + ExpandConstant('{app}\www\xhprof') + '"',
    //'', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

    // xhprof - rename "preinheimer-xhprof-gitref" directory
    Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\www\preinheimer-xhprof*') + '  ' + ExpandConstant('{app}\www\xhprof') + '"',
    '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);
  end;

  if Pos('memcached', selectedComponents) > 0 then
  begin
      // rename the existing directory
      Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\memcached-x86') + ' ' + ExpandConstant('{app}\bin\memcached') + '"',
      '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

      // php.ini entry for loading the the extension
      SetIniString('PHP', 'extension', 'php_memcache.dll', php_ini_file );
  end;

  if Pos('zeromq', selectedComponents) > 0 then
  begin
      // rename the existing directory
      //Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\bin\memcached-x86') + ' ' + ExpandConstant('{app}\bin\memcached') + '"',
      //'', SW_SHOW, ewWaitUntilTerminated, ReturnCode);

      // php.ini entry for loading the the extension
      SetIniString('PHP', 'extension', 'php_zmq.dll', php_ini_file );
  end;

  if Pos('phpmyadmin', selectedComponents) > 0 then
  begin
     // phpmyadmin - rename "phpMyAdmin-3.4.6-english" directory
    Exec('cmd.exe', '/c "move ' + ExpandConstant('{app}\www\phpMyAdmin-*') + '  ' + ExpandConstant('{app}\www\phpmyadmin') + '"',
    '', SW_SHOW, ewWaitUntilTerminated, ReturnCode);
  end;

end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  logfilepathname : String;
  logfilename : String;
  newfilepathname : String;
begin
 if CurStep=ssInstall then
   begin
    UnzipFiles();
    ApplyModifications();
   end;

 if CurStep = ssDone then
   begin
     // copy logfile from tmp dir to the application dir, when the setup wizward is finished
     logfilepathname := ExpandConstant('{log}');
     logfilename := ExtractFileName(logfilepathname);
     newfilepathname := ExpandConstant('{app}\') +logfilename;
     filecopy(logfilepathname, newfilepathname, false);
   end;
end;


* packages/windows-innosetup/svn.iss
  (Components): Capitalize the "F" in the name of the "Flags" element
   so that it stands out better as an element name to avoid problems
   like those found in r21022.

  (InstallDelete): Improve the description of when to some "Type"
   elements.

git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@861098 13f79535-47bb-0310-9956-ffa450edef68

[Setup]
;# Version parameters #########################################################
#define svn_cpr "Copyright 2000-2005 CollabNet"

; Version and release info:
#include "svn_version.iss"

;# svn_dynamics.iss ###########################################################
; This file contains all the paths needed by inno for finding the sources to
; compile a Windows Setup for Subversion.
; A template of the file can be found in the Subversion repository:
;     packages\win32-innosetup\tools\templates
; Copy svn_dynamics.iss to the same folder as this file and read the
; documentation inside it.
#include "svn_dynamics.iss"

AppName=Subversion
AppVerName=Subversion-{#= svn_version}{#= svn_pretxtrevision}{#= svn_revision}
AppPublisher=CollabNet
AppPublisherURL=http://subversion.tigris.org/
AppSupportURL=http://subversion.tigris.org/project_faq.html
AppUpdatesURL=http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
DefaultDirName={pf}\Subversion
DefaultGroupName=Subversion
LicenseFile={#= path_setup_in}\subversion\SubversionLicense.txt
OutputDir={#= path_setup_out}
OutputBaseFilename=svn-{#= svn_version}-setup
Compression=lzma
InternalCompressLevel=max
SolidCompression=true
AppCopyright={#= svn_cpr}
UninstallDisplayIcon={app}\bin\svn.exe
UninstallDisplayName=Subversion {#= svn_version}{#= svn_pretxtrevision}{#= svn_revision}
AlwaysShowDirOnReadyPage=true
AlwaysShowGroupOnReadyPage=true
InfoAfterFile=Post.rtf
InfoBeforeFile=Pre.rtf
DisableStartupPrompt=false
UseSetupLdr=true
AppVersion={#= svn_version}{#= svn_pretxtrevision}{#= svn_revision}
VersionInfoVersion={#= svn_version}
VersionInfoDescription=Subversion-{#= svn_version} Windows Setup
WizardImageFile=images\wiz-164x314x24.bmp
WizardSmallImageFile=images\wiz-55x55x24.bmp
RestartIfNeededByRun=false
ShowTasksTreeLines=true
AllowNoIcons=true
ShowLanguageDialog=no
ChangesEnvironment=true

[Tasks]
Name: desktopicon; Description: Create &desktop icon for the Subversion documentation; GroupDescription: Desktop icons:
Name: quicklaunchicon; Description: Create &Quick Launch icon for the Subversion Documentation; GroupDescription: Quick Launch icons:; MinVersion: 4.01.1998,5.00.2195
Name: apachehandler; Description: Install and configure Subversion modules (the Setup will do a stop/uninstall/configure/install/start cycle of the Apache service); GroupDescription: Apache modules:; MinVersion: 0,4.0.1381; Check: ApacheTask

[Files]
; Subversion files --------------------------------------------------------------
Source: in\subversion\Readme.dist; DestDir: {app}; DestName: Readme.txt
Source: W32notes.txt; DestDir: {app}
Source: {#= path_setup_in}\subversion\svn-proxy-template.reg; DestDir: {app}; Flags: ignoreversion
Source: {#= path_svn}\README.txt; DestDir: {app}; DestName: Buildnotes.txt
Source: {#= path_svnclient}\svn.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnadmin}\svnadmin.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnlook}\svnlook.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnserve}\svnserve.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnversion}\svnversion.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svndumpfilter}\svndumpfilter.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_brkdb_dll}\{#= libdb_dll}; DestDir: {app}\bin
Source: {#= path_iconv}\*.so; DestDir: {app}\iconv; Flags: ignoreversion
#ifdef inc_locale
Source: {#= path_locale}\*.*; DestDir: {app}\share\locale; Flags: ignoreversion recursesubdirs
#endif
Source: {#= path_setup_in}\berkeley\BerkeleyLicense.txt; DestDir: {app}
Source: {#= path_setup_in}\doc\svn-book.chm; DestDir: {app}\doc

; APR DLLs
Source: {#= path_libapr_dll}\libapr.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_libaprutil_dll}\libaprutil.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_libapriconv_dll}\libapriconv.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_intl_dll}\intl3_svn.dll; DestDir: {app}\bin; Flags: ignoreversion

; VC7 Runtime
#ifdef VC7
Source: {#= path_msvcr70_dll}\msvcr70.dll; DestDir: {app}\bin
#endif

;SSL
Source: {#= path_ssl}\libeay32.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_ssl}\ssleay32.dll; DestDir: {app}\bin; Flags: ignoreversion

; Missing stuff
Source: missing_msvcp60dll.html; DestDir: {app}\doc; Check: VCRuntimeNotFound
Source: missing_shfolderdll.html; DestDir: {app}\doc; Check: ShFolderDllNotFound

; httpd modules
Source: {#= path_davsvn}\mod_dav_svn.so; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_authzsvn}\mod_authz_svn.so; DestDir: {app}\bin; Flags: ignoreversion

;Helpers ---------------------------------------------------------------------
Source: {#= path_svnpath}\svnpath.exe; DestDir: {app}\helpers; Flags: ignoreversion
Source: UninsHs.exe; DestDir: {app}; Flags: restartreplace

; Debug symbols;
#ifdef inc_dbgsyms
Source: {#= path_svnclient_pdb}\svn.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnadmin_pdb}\svnadmin.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnlook_pdb}\svnlook.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnserve_pdb}\svnserve.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnversion_pdb}\svnversion.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svndumpfilter_pdb}\svndumpfilter.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb

Source: {#= path_davsvn_pdb}\mod_dav_svn.pdb; DestDir: {app}\httpd; Flags: ignoreversion; Components: pdb
Source: {#= path_authzsvn_pdb}\mod_authz_svn.pdb; DestDir: {app}\httpd; Flags: ignoreversion; Components: pdb

Source: {#= path_iconv_pdb}\*.pdb; DestDir: {app}\iconv; Flags: ignoreversion; Components: pdb
#endif

; Internet Shortcuts ----------------------------------------------------------
Source: svn.url; DestDir: {app}

[INI]
Filename: {app}\svn.url; Section: InternetShortcut; Key: URL; String: http://subversion.tigris.org/

; Reinstall, repair and uninstall with UninsHS
FileName: {app}\UninsHs.dat; Section: Common; Key: Software; String: Subversion
FileName: {app}\UninsHs.dat; Section: Common; Key: Install; String: {srcexe}

FileName: {app}\UninsHs.dat; Section: Common; Key: Language; String: {language}
FileName: {app}\UninsHs.dat; Section: Common; Key: Remove; String: {uninstallexe}
FileName: {app}\UninsHs.dat; Section: Common; Key: Group; String: {groupname}
FileName: {app}\UninsHs.dat; Section: Common; Key: Components; String: {code:ComponentList|x}

[Icons]
Name: {group}\Subversion on the Web; Filename: {app}\svn.url
Name: {group}\Uninstall Subversion; Filename: {app}\UninsHs.exe
Name: {group}\Licenses\Subversion; Filename: {app}\SubversionLicense.txt
Name: {group}\Licenses\Berkeley DB Licence; Filename: {app}\BerkeleyLicense.txt
Name: {group}\Subversion Documentation; Filename: {app}\doc\svn-book.chm; IconFilename: {app}\bin\svn.exe; Comment: The standard Subversion documentation; IconIndex: 0
Name: {userdesktop}\Subversion Documentation; Filename: {app}\doc\svn-book.chm; IconFilename: {app}\bin\svn.exe; Comment: The standard Subversion documentation; IconIndex: 0; Tasks: desktopicon
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\Subversion Documentation; Filename: {app}\doc\svn-book.chm; Comment: The standard Subversion Documentation; IconFilename: {app}\bin\svn.exe; IconIndex: 0; MinVersion: 4.01.1998,5.00.2195; Tasks: quicklaunchicon
Name: {group}\Read Me; Filename: {app}\Readme.txt
Name: {group}\Download and install msvcp60.dll; Filename: {app}\doc\missing_msvcp60dll.html; Check: VCRuntimeNotFound
Name: {group}\Download and install shfolder.dll; Filename: {app}\doc\missing_shfolderdll.html; Check: ShFolderDllNotFound

[UninstallDelete]
Type: files; Name: {app}\svn.url
Type: filesandordirs; Name: {app}\UninsHs.dat

[Types]
#ifdef inc_dbgsyms
Name: standard; Description: Standard installation - Binaries only
Name: full; Description: Full installation - Binaries and debugging symbols
Name: custom; Description: Custom Installation; Flags: iscustom

[Components]
Name: main; Description: Subversion application files; Types: standard custom full; Flags: disablenouninstallwarning
;or
;Name: main; Description: Subversion application files; Types: standard custom full; flags: fixed

Name: pdb; Description: Debug Symbol Files; Types: full custom; Flags: disablenouninstallwarning

[InstallDelete]

;If the "disablenouninstallwarning" flag is present for the "main" entry in [Components], use these lines:
Type: files; Name: {app}\Readme.txt
Type: files; Name: {app}\W32notes.txt
Type: files; Name: {app}\svn-proxy-template.reg
Type: files; Name: {app}\Buildnotes.txt
Type: files; Name: {app}\Buildnotes.txt
Type: filesandordirs; Name: {app}\bin
Type: filesandordirs; Name: {app}\iconv
#ifdef inc_locale
Type: filesandordirs; Name: {app}\share\locale
#endif
Type: files; Name: {app}\BerkeleyLicense.txt
Type: filesandordirs; Name: {app}\doc
Type: filesandordirs; Name: {app}\helpers
Type: filesandordirs; Name: {app}\httpd

;If add "fixed" flag to "main" in [Components], use these lines:
;Type: files; Name: {app}\svn.pdb
;Type: files; Name: {app}\svnadmin.pdb
;Type: files; Name: {app}\svnserve.pdb
;Type: files; Name: {app}\svnlook.pdb
;Type: files; Name: {app}\svnversion.pdb
;Type: files; Name: {app}\svndumpfilter.pdb
;Type: filesandordirs; Name: {app}\httpd
;Type: files; Name: {app}\iconv\*.pdb
#endif

[Registry]
Root: HKCU; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueData: {app}\bin\svn.exe; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueName: Path; ValueData: {app}; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Version; ValueData: {#= svn_version}; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Revision; ValueData: {#= svn_revision}; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; Subkey: Environment; ValueType: string; ValueName: APR_ICONV_PATH; ValueData: {app}\iconv; Flags: uninsdeletevalue noerror

Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueData: {app}\bin\svn.exe; Flags: noerror uninsdeletekeyifempty uninsdeletevalue
Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueName: Path; ValueData: {app}; Flags: uninsdeletekeyifempty uninsdeletevalue noerror
Root: HKLM; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Version; ValueData: {#= svn_version}; Flags: noerror uninsdeletekey
Root: HKLM; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Revision; ValueData: {#= svn_revision}; Flags: uninsdeletevalue noerror uninsdeletekeyifempty
Root: HKLM; Subkey: SYSTEM\CurrentControlSet\Control\Session Manager\Environment; ValueType: string; ValueName: APR_ICONV_PATH; ValueData: {app}\iconv; Flags: uninsdeletevalue noerror

[Run]
Filename: {app}\helpers\svnpath.exe; Parameters: "add ""{app}\bin"""; StatusMsg: Editing the path...
Filename: {app}\UninsHs.exe; Parameters: /r; Flags: runminimized runhidden nowait

[UninstallRun]
Filename: {app}\helpers\svnpath.exe; Parameters: "remove ""{app}\bin"""

[Languages]
Name: en; MessagesFile: compiler:Default.isl

[Code]
#include "is_main.pas"

[Setup]
;# Version parameters #########################################################
#define svn_cpr "Copyright 2000-2005 CollabNet"

; Version and release info:
#include "svn_version.iss"

;# svn_dynamics.iss ###########################################################
; This file contains all the paths needed by inno for finding the sources to
; compile a Windows Setup for Subversion.
; A template of the file can be found in the Subversion repository:
;     packages\win32-innosetup\tools\templates
; Copy svn_dynamics.iss to the same folder as this file and read the
; documentation inside it.
#include "svn_dynamics.iss"

AppName=Subversion
AppVerName=Subversion-{#= svn_version}{#= svn_pretxtrevision}{#= svn_revision}
AppPublisher=CollabNet
AppPublisherURL=http://subversion.tigris.org/
AppSupportURL=http://subversion.tigris.org/project_faq.html
AppUpdatesURL=http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
DefaultDirName={pf}\Subversion
DefaultGroupName=Subversion
LicenseFile={#= path_setup_in}\subversion\SubversionLicense.txt
OutputDir={#= path_setup_out}
OutputBaseFilename=svn-{#= svn_version}-setup
Compression=lzma
InternalCompressLevel=max
SolidCompression=true
AppCopyright={#= svn_cpr}
UninstallDisplayIcon={app}\bin\svn.exe
UninstallDisplayName=Subversion {#= svn_version}{#= svn_pretxtrevision}{#= svn_revision}
AlwaysShowDirOnReadyPage=true
AlwaysShowGroupOnReadyPage=true
InfoAfterFile=Post.rtf
InfoBeforeFile=Pre.rtf
DisableStartupPrompt=false
UseSetupLdr=true
AppVersion={#= svn_version}{#= svn_pretxtrevision}{#= svn_revision}
VersionInfoVersion={#= svn_version}
VersionInfoDescription=Subversion-{#= svn_version} Windows Setup
WizardImageFile=images\wiz-164x314x24.bmp
WizardSmallImageFile=images\wiz-55x55x24.bmp
RestartIfNeededByRun=false
ShowTasksTreeLines=true
AllowNoIcons=true
ShowLanguageDialog=no
ChangesEnvironment=true

[Tasks]
Name: desktopicon; Description: Create &desktop icon for the Subversion documentation; GroupDescription: Desktop icons:
Name: quicklaunchicon; Description: Create &Quick Launch icon for the Subversion Documentation; GroupDescription: Quick Launch icons:; MinVersion: 4.01.1998,5.00.2195
Name: apachehandler; Description: Install and configure Subversion modules (the Setup will do a stop/uninstall/configure/install/start cycle of the Apache service); GroupDescription: Apache modules:; MinVersion: 0,4.0.1381; Check: ApacheTask

[Files]
; Subversion files --------------------------------------------------------------
Source: in\subversion\Readme.dist; DestDir: {app}; DestName: Readme.txt
Source: W32notes.txt; DestDir: {app}
Source: {#= path_setup_in}\subversion\svn-proxy-template.reg; DestDir: {app}; Flags: ignoreversion
Source: {#= path_svn}\README.txt; DestDir: {app}; DestName: Buildnotes.txt
Source: {#= path_svnclient}\svn.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnadmin}\svnadmin.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnlook}\svnlook.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnserve}\svnserve.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svnversion}\svnversion.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_svndumpfilter}\svndumpfilter.exe; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_brkdb_dll}\{#= libdb_dll}; DestDir: {app}\bin
Source: {#= path_iconv}\*.so; DestDir: {app}\iconv; Flags: ignoreversion
#ifdef inc_locale
Source: {#= path_locale}\*.*; DestDir: {app}\share\locale; Flags: ignoreversion recursesubdirs
#endif
Source: {#= path_setup_in}\berkeley\BerkeleyLicense.txt; DestDir: {app}
Source: {#= path_setup_in}\doc\svn-book.chm; DestDir: {app}\doc

; APR DLLs
Source: {#= path_libapr_dll}\libapr.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_libaprutil_dll}\libaprutil.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_libapriconv_dll}\libapriconv.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_intl_dll}\intl3_svn.dll; DestDir: {app}\bin; Flags: ignoreversion

; VC7 Runtime
#ifdef VC7
Source: {#= path_msvcr70_dll}\msvcr70.dll; DestDir: {app}\bin
#endif

;SSL
Source: {#= path_ssl}\libeay32.dll; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_ssl}\ssleay32.dll; DestDir: {app}\bin; Flags: ignoreversion

; Missing stuff
Source: missing_msvcp60dll.html; DestDir: {app}\doc; Check: VCRuntimeNotFound
Source: missing_shfolderdll.html; DestDir: {app}\doc; Check: ShFolderDllNotFound

; httpd modules
Source: {#= path_davsvn}\mod_dav_svn.so; DestDir: {app}\bin; Flags: ignoreversion
Source: {#= path_authzsvn}\mod_authz_svn.so; DestDir: {app}\bin; Flags: ignoreversion

;Helpers ---------------------------------------------------------------------
Source: {#= path_svnpath}\svnpath.exe; DestDir: {app}\helpers; Flags: ignoreversion
Source: UninsHs.exe; DestDir: {app}; Flags: restartreplace

; Debug symbols;
#ifdef inc_dbgsyms
Source: {#= path_svnclient_pdb}\svn.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnadmin_pdb}\svnadmin.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnlook_pdb}\svnlook.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnserve_pdb}\svnserve.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svnversion_pdb}\svnversion.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb
Source: {#= path_svndumpfilter_pdb}\svndumpfilter.pdb; DestDir: {app}\bin; Flags: ignoreversion; Components: pdb

Source: {#= path_davsvn_pdb}\mod_dav_svn.pdb; DestDir: {app}\httpd; Flags: ignoreversion; Components: pdb
Source: {#= path_authzsvn_pdb}\mod_authz_svn.pdb; DestDir: {app}\httpd; Flags: ignoreversion; Components: pdb

Source: {#= path_iconv_pdb}\*.pdb; DestDir: {app}\iconv; Flags: ignoreversion; Components: pdb
#endif

; Internet Shortcuts ----------------------------------------------------------
Source: svn.url; DestDir: {app}

[INI]
Filename: {app}\svn.url; Section: InternetShortcut; Key: URL; String: http://subversion.tigris.org/

; Reinstall, repair and uninstall with UninsHS
FileName: {app}\UninsHs.dat; Section: Common; Key: Software; String: Subversion
FileName: {app}\UninsHs.dat; Section: Common; Key: Install; String: {srcexe}

FileName: {app}\UninsHs.dat; Section: Common; Key: Language; String: {language}
FileName: {app}\UninsHs.dat; Section: Common; Key: Remove; String: {uninstallexe}
FileName: {app}\UninsHs.dat; Section: Common; Key: Group; String: {groupname}
FileName: {app}\UninsHs.dat; Section: Common; Key: Components; String: {code:ComponentList|x}

[Icons]
Name: {group}\Subversion on the Web; Filename: {app}\svn.url
Name: {group}\Uninstall Subversion; Filename: {app}\UninsHs.exe
Name: {group}\Licenses\Subversion; Filename: {app}\SubversionLicense.txt
Name: {group}\Licenses\Berkeley DB Licence; Filename: {app}\BerkeleyLicense.txt
Name: {group}\Subversion Documentation; Filename: {app}\doc\svn-book.chm; IconFilename: {app}\bin\svn.exe; Comment: The standard Subversion documentation; IconIndex: 0
Name: {userdesktop}\Subversion Documentation; Filename: {app}\doc\svn-book.chm; IconFilename: {app}\bin\svn.exe; Comment: The standard Subversion documentation; IconIndex: 0; Tasks: desktopicon
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\Subversion Documentation; Filename: {app}\doc\svn-book.chm; Comment: The standard Subversion Documentation; IconFilename: {app}\bin\svn.exe; IconIndex: 0; MinVersion: 4.01.1998,5.00.2195; Tasks: quicklaunchicon
Name: {group}\Read Me; Filename: {app}\Readme.txt
Name: {group}\Download and install msvcp60.dll; Filename: {app}\doc\missing_msvcp60dll.html; Check: VCRuntimeNotFound
Name: {group}\Download and install shfolder.dll; Filename: {app}\doc\missing_shfolderdll.html; Check: ShFolderDllNotFound

[UninstallDelete]
Type: files; Name: {app}\svn.url
Type: filesandordirs; Name: {app}\UninsHs.dat

[Types]
#ifdef inc_dbgsyms
Name: standard; Description: Standard installation - Binaries only
Name: full; Description: Full installation - Binaries and debugging symbols
Name: custom; Description: Custom Installation; Flags: iscustom

[Components]
Name: main; Description: Subversion application files; Types: standard custom full; flags: disablenouninstallwarning
;or
;Name: main; Description: Subversion application files; Types: standard custom full; flags: fixed

Name: pdb; Description: Debug Symbol Files; Types: full custom; flags: disablenouninstallwarning

[InstallDelete]

;If add "disablenouninstallwarning" flag to "main" in [Components], use these lines:
Type: files; Name: {app}\Readme.txt
Type: files; Name: {app}\W32notes.txt
Type: files; Name: {app}\svn-proxy-template.reg
Type: files; Name: {app}\Buildnotes.txt
Type: files; Name: {app}\Buildnotes.txt
Type: filesandordirs; Name: {app}\bin
Type: filesandordirs; Name: {app}\iconv
#ifdef inc_locale
Type: filesandordirs; Name: {app}\share\locale
#endif
Type: files; Name: {app}\BerkeleyLicense.txt
Type: filesandordirs; Name: {app}\doc
Type: filesandordirs; Name: {app}\helpers
Type: filesandordirs; Name: {app}\httpd

;If add "fixed" flag to "main" in [Components], use these lines:
;Type: files; Name: {app}\svn.pdb
;Type: files; Name: {app}\svnadmin.pdb
;Type: files; Name: {app}\svnserve.pdb
;Type: files; Name: {app}\svnlook.pdb
;Type: files; Name: {app}\svnversion.pdb
;Type: files; Name: {app}\svndumpfilter.pdb
;Type: filesandordirs; Name: {app}\httpd
;Type: files; Name: {app}\iconv\*.pdb
#endif

[Registry]
Root: HKCU; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueData: {app}\bin\svn.exe; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueName: Path; ValueData: {app}; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Version; ValueData: {#= svn_version}; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Revision; ValueData: {#= svn_revision}; Flags: uninsdeletekeyifempty uninsdeletevalue
Root: HKCU; Subkey: Environment; ValueType: string; ValueName: APR_ICONV_PATH; ValueData: {app}\iconv; Flags: uninsdeletevalue noerror

Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueData: {app}\bin\svn.exe; Flags: noerror uninsdeletekeyifempty uninsdeletevalue
Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\svn.exe; ValueType: string; ValueName: Path; ValueData: {app}; Flags: uninsdeletekeyifempty uninsdeletevalue noerror
Root: HKLM; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Version; ValueData: {#= svn_version}; Flags: noerror uninsdeletekey
Root: HKLM; SubKey: SOFTWARE\Tigris.org\Subversion; ValueType: string; ValueName: Revision; ValueData: {#= svn_revision}; Flags: uninsdeletevalue noerror uninsdeletekeyifempty
Root: HKLM; Subkey: SYSTEM\CurrentControlSet\Control\Session Manager\Environment; ValueType: string; ValueName: APR_ICONV_PATH; ValueData: {app}\iconv; Flags: uninsdeletevalue noerror

[Run]
Filename: {app}\helpers\svnpath.exe; Parameters: "add ""{app}\bin"""; StatusMsg: Editing the path...
Filename: {app}\UninsHs.exe; Parameters: /r; Flags: runminimized runhidden nowait

[UninstallRun]
Filename: {app}\helpers\svnpath.exe; Parameters: "remove ""{app}\bin"""

[Languages]
Name: en; MessagesFile: compiler:Default.isl

[Code]
#include "is_main.pas"


Fix installer file version number

Fix installer file version number

; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "InjuredPixels"
#define MyAppVersion "4.0"
#define MyAppFileVersion "4.0.0.125"
#define MyAppPublisher "Aurelitec"
#define MyAppURL "http://www.aurelitec.com/injuredpixels/"
#define MyAppExeName "InjuredPixels.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{7AE8ACDB-C766-4639-9FEE-7062221B22F0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppPublisher}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=Files\License.txt
OutputBaseFilename=injuredpixels-install
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64 ia64
InternalCompressLevel=max
AppCopyright=Copyright (c) 2009-2017 Aurelitec
SetupIconFile=Assets\InjuredPixelsIcon.ico
UninstallDisplayIcon={app}\InjuredPixels.exe
VersionInfoVersion={#MyAppFileVersion}
UninstallDisplayName={#MyAppName}

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "Files\InjuredPixels.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "Files\HomePage.link.html"; DestDir: "{app}"; Flags: ignoreversion
Source: "Files\InjuredPixels.exe.config"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: UpdateLogPath
Source: "Files\InjuredPixels.ini"; DestDir: "{userappdata}\Aurelitec\InjuredPixels"; Flags: ignoreversion onlyifdoesntexist
Source: "Files\License.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "Files\SharpConfig.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Dirs]
Name: "{commonappdata}\Aurelitec\InjuredPixels"

[Code]
procedure UpdateLogPath;
var
    AnsiFileData: AnsiString;
    UnicodeFileData: string;
begin
    LoadStringFromFile(ExpandConstant('{app}\InjuredPixels.exe.config'), AnsiFileData);
    UnicodeFileData := String(AnsiFileData);
    StringChange(UnicodeFileData, 'InjuredPixels.log', ExpandConstant('{commonappdata}\Aurelitec\InjuredPixels\InjuredPixels.log'));
    SaveStringToFile(ExpandConstant('{app}\InjuredPixels.exe.config'), AnsiString(UnicodeFileData), False);
end;

; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "InjuredPixels"
#define MyAppVersion "4.0"
#define MyAppFileVersion "4.0.0.200"
#define MyAppPublisher "Aurelitec"
#define MyAppURL "http://www.aurelitec.com/injuredpixels/"
#define MyAppExeName "InjuredPixels.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{7AE8ACDB-C766-4639-9FEE-7062221B22F0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppPublisher}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=Files\License.txt
OutputBaseFilename=injuredpixels-install
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64 ia64
InternalCompressLevel=max
AppCopyright=Copyright (c) 2009-2017 Aurelitec
SetupIconFile=Assets\InjuredPixelsIcon.ico
UninstallDisplayIcon={app}\InjuredPixels.exe
VersionInfoVersion={#MyAppFileVersion}
UninstallDisplayName={#MyAppName}

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "Files\InjuredPixels.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "Files\HomePage.link.html"; DestDir: "{app}"; Flags: ignoreversion
Source: "Files\InjuredPixels.exe.config"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: UpdateLogPath
Source: "Files\InjuredPixels.ini"; DestDir: "{userappdata}\Aurelitec\InjuredPixels"; Flags: ignoreversion onlyifdoesntexist
Source: "Files\License.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "Files\SharpConfig.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Dirs]
Name: "{commonappdata}\Aurelitec\InjuredPixels"

[Code]
procedure UpdateLogPath;
var
    AnsiFileData: AnsiString;
    UnicodeFileData: string;
begin
    LoadStringFromFile(ExpandConstant('{app}\InjuredPixels.exe.config'), AnsiFileData);
    UnicodeFileData := String(AnsiFileData);
    StringChange(UnicodeFileData, 'InjuredPixels.log', ExpandConstant('{commonappdata}\Aurelitec\InjuredPixels\InjuredPixels.log'));
    SaveStringToFile(ExpandConstant('{app}\InjuredPixels.exe.config'), AnsiString(UnicodeFileData), False);
end;


Changed a comment to a HACKALERT.

Changed a comment to a HACKALERT.

; You will need to adjust the source paths (i.e. those currently beginning
; 'd:\program files\topographica') to wherever is the copy of Topographica
; that's being used to create the setup file.

[Setup]
AppName=Topographica
AppVerName=Topographica 0.8
AppPublisher=Topographica development team
AppPublisherURL=http://www.topographica.org
AppSupportURL=http://www.topographica.org
AppUpdatesURL=http://www.topographica.org
DefaultDirName={pf}\Topographica
DefaultGroupName=Topographica
LicenseFile=D:\Program Files\topographica\COPYING.txt
InfoBeforeFile=D:\Program Files\topographica\README.txt
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "D:\Program Files\topographica\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

; [Icons]
; Name: "{group}\Topographica"; Filename: "{app}\topographica.bat"
; Name: "{userdesktop}\Topographica"; Filename: "{app}\topographica.bat"; Tasks: desktopicon

[Run]
Filename: "{app}\setup\setup.bat"; WorkingDir: "{app}\setup"; Flags: runhidden
Filename: "{app}\topographica.bat"; Description: "{cm:LaunchProgram,Topographica}"; Flags: shellexec postinstall skipifsilent

; CEBHACKALERT: should have [UninstallRun] section to remove desktop shortcut and .ty association.

; You will need to adjust the source paths (i.e. those currently beginning
; 'd:\program files\topographica') to wherever is the copy of Topographica
; that's being used to create the setup file.

[Setup]
AppName=Topographica
AppVerName=Topographica 0.8
AppPublisher=Topographica development team
AppPublisherURL=http://www.topographica.org
AppSupportURL=http://www.topographica.org
AppUpdatesURL=http://www.topographica.org
DefaultDirName={pf}\Topographica
DefaultGroupName=Topographica
LicenseFile=D:\Program Files\topographica\COPYING.txt
InfoBeforeFile=D:\Program Files\topographica\README.txt
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "D:\Program Files\topographica\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

; [Icons]
; Name: "{group}\Topographica"; Filename: "{app}\topographica.bat"
; Name: "{userdesktop}\Topographica"; Filename: "{app}\topographica.bat"; Tasks: desktopicon

[Run]
Filename: "{app}\setup\setup.bat"; WorkingDir: "{app}\setup"; Flags: runhidden
Filename: "{app}\topographica.bat"; Description: "{cm:LaunchProgram,Topographica}"; Flags: shellexec postinstall skipifsilent

; should have [UninstallRun] section to remove desktop shortcut and .ty association.


Remove 'quick launch' task from Windows installer

Ticking the box doesn't actually do anything.

;###############################################################################
;##
;## Copyright (C) 2014-2016, New York University.
;## Copyright (C) 2011-2014, NYU-Poly.
;## Copyright (C) 2006-2011, University of Utah.
;## All rights reserved.
;## Contact: vistrails@sci.utah.edu
;##
;## This file is part of VisTrails.
;##
;## "Redistribution and use in source and binary forms, with or without
;## modification, are permitted provided that the following conditions are met:
;##
;##  - Redistributions of source code must retain the above copyright notice,
;##    this list of conditions and the following disclaimer.
;##  - Redistributions in binary form must reproduce the above copyright
;##    notice, this list of conditions and the following disclaimer in the
;##    documentation and/or other materials provided with the distribution.
;##  - Neither the name of the New York University nor the names of its
;##    contributors may be used to endorse or promote products derived from
;##    this software without specific prior written permission.
;##
;## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
;## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
;## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
;## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
;## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
;## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
;## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
;## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
;## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
;##
;###############################################################################

[Dirs]
Name: {app}\vistrails
Name: {app}\examples; Components: examples; Tasks:
Name: {app}\extensions; Components: extensions; Tasks:
Name: {app}\doc; Components: usersguide; Tasks:
Name: {app}\scripts
Name: {app}\scripts\gen_vtk_examples
Name: {app}\libsrc
Name: {app}\{#python}
Name: {app}\{#python}\DLLs
Name: {app}\{#python}\include
Name: {app}\{#python}\Lib
Name: {app}\{#python}\libs
Name: {app}\{#python}\Scripts
Name: {app}\{#python}\sip
Name: {app}\{#python}\tcl
Name: {app}\{#python}\Tools
[Components]
Name: main; Description: Main Files; Types: full compact custom; Flags: fixed
Name: examples; Description: Example Files; Types: full
Name: extensions; Description: Extension Files; Types: full
Name: usersguide; Description: User's Guide PDF document; Types: full

[Icons]
Name: {group}\VisTrails; Filename: {app}\{#python}\python.exe; WorkingDir: {app}; IconFilename: {app}\vistrails\gui\resources\images\vistrails_icon_small.ico; IconIndex: 0; Components: ; Parameters: """{app}\runvistrails.py"""
Name: {commondesktop}\VisTrails; Filename: {app}\{#python}\python.exe; WorkingDir: {app}; IconFilename: {app}\vistrails\gui\resources\images\vistrails_icon_small.ico; IconIndex: 0; Parameters: """{app}\runvistrails.py"""; Components: main; Tasks: desktopicon
Name: {group}\Uninstall VisTrails; Filename: {uninstallexe}
Name: {group}\VisTrails.pdf; Filename: {app}\doc\VisTrails.pdf; Components: usersguide
[Tasks]
Name: desktopicon; Description: Create a &desktop icon; GroupDescription: Additional icons:; Components: main
Name: desktopicon\common; Description: For all users; GroupDescription: Additional icons:; Components: main; Flags: exclusive
Name: desktopicon\user; Description: For the current user only; GroupDescription: Additional icons:; Components: main; Flags: exclusive unchecked
Name: associatefiles; Description: Associate *.vt files with VisTrails; GroupDescription: File Association:; Components: main
[_ISTool]
LogFile=Output\build.log
LogFileAppend=false
[Registry]
Root: HKCR; Subkey: .vt; ValueType: string; ValueData: VisTrailsFile; Flags: uninsdeletevalue; Tasks: associatefiles
Root: HKCR; Subkey: VisTrailsFile; ValueType: string; ValueData: VisTrails File; Flags: uninsdeletekey; Tasks: associatefiles
Root: HKCR; Subkey: VisTrailsFile\DefaultIcon; ValueType: string; ValueData: {app}\vistrails\gui\resources\images\vistrails_icon_small.ico; Tasks: associatefiles; Flags: uninsdeletekey
Root: HKCR; Subkey: VisTrailsFile\shell\open\command; ValueType: string; ValueData: """{app}\{#python}\python.exe"" ""{app}\runvistrails.py"" ""%1"""; Tasks: associatefiles; Flags: uninsdeletekey
Root: HKCR; Subkey: .vtl; ValueType: string; ValueData: VisTrailsFile; Flags: uninsdeletevalue; Tasks: associatefiles
[InstallDelete]
Name: {app}\dot.exe; Type: files
Name: {app}\freetype6.dll; Type: files
Name: {app}\jpeg.dll; Type: files
Name: {app}\libexpat.dll; Type: files
Name: {app}\libexpatw.dll; Type: files
Name: {app}\png.dll; Type: files
Name: {app}\z.dll; Type: files
Name: {app}\zlib1.dll; Type: files
Name: {app}\{#python}; Type: filesandordirs
Name: {app}\*.pyd; Type: files
Name: {app}\dgnlib.dll; Type: files
Name: {app}\_Xdmf.dll; Type: files
Name: {app}\geotiff.dll; Type: files
Name: {app}\libmysql.dll; Type: files
Name: {app}\vistrails; Type: filesandordirs
Name: {app}\vistrails\packages\gridfield; Type: filesandordirs
Name: {app}\lib\site-packages; Type: filesandordirs
[Run]
Filename: {tmp}\vcredist_{#bits}.exe; Parameters: /Q; Components: ; Tasks:

[ThirdPartySettings]
CompileLogFile=Output\build.log
CompileLogMethod=append

[PreCompile]
Name: "C:\{#python_src}\python.exe"; Parameters: "C:\Users\vistrails\code\vistrails\scripts\dist\windows\Input\download_usersguide.py"; Flags: abortonerror cmdprompt

[PreCompile]
Name: "C:\{#python_src}\python.exe"; Parameters: "-m compileall C:\Users\vistrails\code"; Flags: abortonerror cmdprompt

[Code]
var
  FinishedInstall: Boolean;
function CustomAppDir(Param: String): String;
begin
  if IsAdminLoggedOn then
    Result := ExpandConstant('{pf}')
  else
    Result := ExpandConstant('{userappdata}')
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
    FinishedInstall := True;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
end;

procedure DeleteVCRedistRuntimeTemporaryFiles();
var
   i : Integer;
   byCounter : Byte;
   byDrive : Byte;
   strFile1, strFile2, strFile3 : String;
   strRootDrivePath : String;
   //totally there are 24 files to be deleted
   arrFiles : Array [1..24] Of String;
begin

   //We will check the following root drives
   //C, D, E, F, G, H, I, J, K, L, M
   For byCounter := 67 to 77 do
   Begin
      strRootDrivePath := Chr(byCounter) + ':\';
      arrFiles[1] := strRootDrivePath + 'vcredist.bmp';
      arrFiles[2] := strRootDrivePath + 'VC_RED.cab';
      arrFiles[3] := strRootDrivePath + 'VC_RED.MSI';

      //If these 3 files then we have found the right
      //drive in which the VC runtime files are extracted
      If (FileExists(arrFiles[1]) And
          FileExists(arrFiles[2]) And
          FileExists(arrFiles[3])) Then
      Begin

          arrFiles[4] := strRootDrivePath + 'eula.1028.txt';
          arrFiles[5] := strRootDrivePath + 'eula.1031.txt';
          arrFiles[6] := strRootDrivePath + 'eula.1033.txt';
          arrFiles[7] := strRootDrivePath + 'eula.1036.txt';
          arrFiles[8] := strRootDrivePath + 'eula.1040.txt';
          arrFiles[9] := strRootDrivePath + 'eula.1041.txt';
          arrFiles[10] := strRootDrivePath + 'eula.1042.txt';
          arrFiles[11] := strRootDrivePath + 'eula.2052.txt';
          arrFiles[12] := strRootDrivePath + 'eula.3082.txt';
          arrFiles[13] := strRootDrivePath + 'globdata.ini';
          arrFiles[14] := strRootDrivePath + 'install.exe';
          arrFiles[15] := strRootDrivePath + 'install.ini';
          arrFiles[16] := strRootDrivePath + 'install.res.1028.dll';
          arrFiles[17] := strRootDrivePath + 'install.res.1031.dll';
          arrFiles[18] := strRootDrivePath + 'install.res.1033.dll';
          arrFiles[19] := strRootDrivePath + 'install.res.1036.dll';
          arrFiles[20] := strRootDrivePath + 'install.res.1040.dll';
          arrFiles[21] := strRootDrivePath + 'install.res.1041.dll';
          arrFiles[22] := strRootDrivePath + 'install.res.1042.dll';
          arrFiles[23] := strRootDrivePath + 'install.res.2052.dll';
          arrFiles[24] := strRootDrivePath + 'install.res.3082.dll';

          For i := 1 to 24 Do
          Begin
            DeleteFile(arrFiles[i]);
          End;

          //Now that we have found and deleted all the files
          //we will break
          Break;
      End;
   End;
End;

procedure DeinitializeSetup();
var
  qvtk: String;
begin
  if FinishedInstall then begin
      qvtk := ExpandConstant('{app}') + '\vistrails\packages\spreadsheet\widgets\QVTKWidget';
    if DirExists(qvtk) then
    DelTree(qvtk, True, True, True);
  end;
  DeleteVCRedistRuntimeTemporaryFiles();
end;

[InnoIDE_Settings]
LogFile=Output\build.log
LogFileOverwrite=false

;###############################################################################
;##
;## Copyright (C) 2014-2016, New York University.
;## Copyright (C) 2011-2014, NYU-Poly.
;## Copyright (C) 2006-2011, University of Utah.
;## All rights reserved.
;## Contact: vistrails@sci.utah.edu
;##
;## This file is part of VisTrails.
;##
;## "Redistribution and use in source and binary forms, with or without
;## modification, are permitted provided that the following conditions are met:
;##
;##  - Redistributions of source code must retain the above copyright notice,
;##    this list of conditions and the following disclaimer.
;##  - Redistributions in binary form must reproduce the above copyright
;##    notice, this list of conditions and the following disclaimer in the
;##    documentation and/or other materials provided with the distribution.
;##  - Neither the name of the New York University nor the names of its
;##    contributors may be used to endorse or promote products derived from
;##    this software without specific prior written permission.
;##
;## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
;## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
;## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
;## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
;## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
;## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
;## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
;## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
;## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
;##
;###############################################################################

[Dirs]
Name: {app}\vistrails
Name: {app}\examples; Components: examples; Tasks:
Name: {app}\extensions; Components: extensions; Tasks:
Name: {app}\doc; Components: usersguide; Tasks:
Name: {app}\scripts
Name: {app}\scripts\gen_vtk_examples
Name: {app}\libsrc
Name: {app}\{#python}
Name: {app}\{#python}\DLLs
Name: {app}\{#python}\include
Name: {app}\{#python}\Lib
Name: {app}\{#python}\libs
Name: {app}\{#python}\Scripts
Name: {app}\{#python}\sip
Name: {app}\{#python}\tcl
Name: {app}\{#python}\Tools
[Components]
Name: main; Description: Main Files; Types: full compact custom; Flags: fixed
Name: examples; Description: Example Files; Types: full
Name: extensions; Description: Extension Files; Types: full
Name: usersguide; Description: User's Guide PDF document; Types: full

[Icons]
Name: {group}\VisTrails; Filename: {app}\{#python}\python.exe; WorkingDir: {app}; IconFilename: {app}\vistrails\gui\resources\images\vistrails_icon_small.ico; IconIndex: 0; Components: ; Parameters: """{app}\runvistrails.py"""
Name: {commondesktop}\VisTrails; Filename: {app}\{#python}\python.exe; WorkingDir: {app}; IconFilename: {app}\vistrails\gui\resources\images\vistrails_icon_small.ico; IconIndex: 0; Parameters: """{app}\runvistrails.py"""; Components: main; Tasks: desktopicon
Name: {group}\Uninstall VisTrails; Filename: {uninstallexe}
Name: {group}\VisTrails.pdf; Filename: {app}\doc\VisTrails.pdf; Components: usersguide
[Tasks]
Name: desktopicon; Description: Create a &desktop icon; GroupDescription: Additional icons:; Components: main
Name: desktopicon\common; Description: For all users; GroupDescription: Additional icons:; Components: main; Flags: exclusive
Name: desktopicon\user; Description: For the current user only; GroupDescription: Additional icons:; Components: main; Flags: exclusive unchecked
Name: quicklaunchicon; Description: Create a &Quick Launch icon; GroupDescription: Additional icons:; Components: main; Flags: unchecked
Name: associatefiles; Description: Associate *.vt files with VisTrails; GroupDescription: File Association:; Components: main
[_ISTool]
LogFile=Output\build.log
LogFileAppend=false
[Registry]
Root: HKCR; Subkey: .vt; ValueType: string; ValueData: VisTrailsFile; Flags: uninsdeletevalue; Tasks: associatefiles
Root: HKCR; Subkey: VisTrailsFile; ValueType: string; ValueData: VisTrails File; Flags: uninsdeletekey; Tasks: associatefiles
Root: HKCR; Subkey: VisTrailsFile\DefaultIcon; ValueType: string; ValueData: {app}\vistrails\gui\resources\images\vistrails_icon_small.ico; Tasks: associatefiles; Flags: uninsdeletekey
Root: HKCR; Subkey: VisTrailsFile\shell\open\command; ValueType: string; ValueData: """{app}\{#python}\python.exe"" ""{app}\runvistrails.py"" ""%1"""; Tasks: associatefiles; Flags: uninsdeletekey
Root: HKCR; Subkey: .vtl; ValueType: string; ValueData: VisTrailsFile; Flags: uninsdeletevalue; Tasks: associatefiles
[InstallDelete]
Name: {app}\dot.exe; Type: files
Name: {app}\freetype6.dll; Type: files
Name: {app}\jpeg.dll; Type: files
Name: {app}\libexpat.dll; Type: files
Name: {app}\libexpatw.dll; Type: files
Name: {app}\png.dll; Type: files
Name: {app}\z.dll; Type: files
Name: {app}\zlib1.dll; Type: files
Name: {app}\{#python}; Type: filesandordirs
Name: {app}\*.pyd; Type: files
Name: {app}\dgnlib.dll; Type: files
Name: {app}\_Xdmf.dll; Type: files
Name: {app}\geotiff.dll; Type: files
Name: {app}\libmysql.dll; Type: files
Name: {app}\vistrails; Type: filesandordirs
Name: {app}\vistrails\packages\gridfield; Type: filesandordirs
Name: {app}\lib\site-packages; Type: filesandordirs
[Run]
Filename: {tmp}\vcredist_{#bits}.exe; Parameters: /Q; Components: ; Tasks:

[ThirdPartySettings]
CompileLogFile=Output\build.log
CompileLogMethod=append

[PreCompile]
Name: "C:\{#python_src}\python.exe"; Parameters: "C:\Users\vistrails\code\vistrails\scripts\dist\windows\Input\download_usersguide.py"; Flags: abortonerror cmdprompt

[PreCompile]
Name: "C:\{#python_src}\python.exe"; Parameters: "-m compileall C:\Users\vistrails\code"; Flags: abortonerror cmdprompt

[Code]
var
  FinishedInstall: Boolean;
function CustomAppDir(Param: String): String;
begin
  if IsAdminLoggedOn then
    Result := ExpandConstant('{pf}')
  else
    Result := ExpandConstant('{userappdata}')
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
    FinishedInstall := True;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
end;

procedure DeleteVCRedistRuntimeTemporaryFiles();
var
   i : Integer;
   byCounter : Byte;
   byDrive : Byte;
   strFile1, strFile2, strFile3 : String;
   strRootDrivePath : String;
   //totally there are 24 files to be deleted
   arrFiles : Array [1..24] Of String;
begin

   //We will check the following root drives
   //C, D, E, F, G, H, I, J, K, L, M
   For byCounter := 67 to 77 do
   Begin
      strRootDrivePath := Chr(byCounter) + ':\';
      arrFiles[1] := strRootDrivePath + 'vcredist.bmp';
      arrFiles[2] := strRootDrivePath + 'VC_RED.cab';
      arrFiles[3] := strRootDrivePath + 'VC_RED.MSI';

      //If these 3 files then we have found the right
      //drive in which the VC runtime files are extracted
      If (FileExists(arrFiles[1]) And
          FileExists(arrFiles[2]) And
          FileExists(arrFiles[3])) Then
      Begin

          arrFiles[4] := strRootDrivePath + 'eula.1028.txt';
          arrFiles[5] := strRootDrivePath + 'eula.1031.txt';
          arrFiles[6] := strRootDrivePath + 'eula.1033.txt';
          arrFiles[7] := strRootDrivePath + 'eula.1036.txt';
          arrFiles[8] := strRootDrivePath + 'eula.1040.txt';
          arrFiles[9] := strRootDrivePath + 'eula.1041.txt';
          arrFiles[10] := strRootDrivePath + 'eula.1042.txt';
          arrFiles[11] := strRootDrivePath + 'eula.2052.txt';
          arrFiles[12] := strRootDrivePath + 'eula.3082.txt';
          arrFiles[13] := strRootDrivePath + 'globdata.ini';
          arrFiles[14] := strRootDrivePath + 'install.exe';
          arrFiles[15] := strRootDrivePath + 'install.ini';
          arrFiles[16] := strRootDrivePath + 'install.res.1028.dll';
          arrFiles[17] := strRootDrivePath + 'install.res.1031.dll';
          arrFiles[18] := strRootDrivePath + 'install.res.1033.dll';
          arrFiles[19] := strRootDrivePath + 'install.res.1036.dll';
          arrFiles[20] := strRootDrivePath + 'install.res.1040.dll';
          arrFiles[21] := strRootDrivePath + 'install.res.1041.dll';
          arrFiles[22] := strRootDrivePath + 'install.res.1042.dll';
          arrFiles[23] := strRootDrivePath + 'install.res.2052.dll';
          arrFiles[24] := strRootDrivePath + 'install.res.3082.dll';

          For i := 1 to 24 Do
          Begin
            DeleteFile(arrFiles[i]);
          End;

          //Now that we have found and deleted all the files
          //we will break
          Break;
      End;
   End;
End;

procedure DeinitializeSetup();
var
  qvtk: String;
begin
  if FinishedInstall then begin
      qvtk := ExpandConstant('{app}') + '\vistrails\packages\spreadsheet\widgets\QVTKWidget';
    if DirExists(qvtk) then
    DelTree(qvtk, True, True, True);
  end;
  DeleteVCRedistRuntimeTemporaryFiles();
end;

[InnoIDE_Settings]
LogFile=Output\build.log
LogFileOverwrite=false