Advertisement
Guest User

Untitled

a guest
Sep 19th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 16.43 KB | None | 0 0
  1. ; This is the install script for the Sample Program build for Inno Setup.
  2.  
  3. #define MyAppName "Sample Program"
  4. #define MyAppPublisher "company"
  5. #define MyAppURL "http://www.company.com/"
  6. #define MyAppContact "email@email.com"
  7.  
  8. ; Read previous build number from INI config. If no build number exists, set to 0
  9. #define MyAppVersion Int(ReadIni(SourcePath+"\\version.ini", "Info", "Build", "0"))
  10.  
  11. ; Increment build number and write to INI
  12. #expr MyAppVersion = MyAppVersion + 1
  13. #expr WriteIni(SourcePath+"\\version.ini", "Info", "Build", MyAppVersion)
  14.  
  15. [Setup]
  16. ; NOTE: The value of AppId uniquely identifies this application.
  17. ; Do not use the same AppId value in installers for other applications.
  18. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
  19.  
  20. AppId={{6525583A-1BF8-43C9-AF77-59A4813D207E}
  21. AppName={#MyAppName}
  22. AppVersion={#MyAppVersion}
  23. AppVerName={#MyAppName} {#MyAppVersion}
  24. AppPublisher={#MyAppPublisher}
  25. AppPublisherURL={#MyAppURL}
  26. AppSupportURL={#MyAppURL}
  27. AppUpdatesURL={#MyAppURL}
  28. AppContact={#MyAppContact}
  29. AppCopyright={#MyAppPublisher}
  30.  
  31. VersionInfoTextVersion=Build {#MyAppVersion}
  32.  
  33. DefaultDirName={pf}\{#MyAppPublisher}\Sample Program
  34. DefaultGroupName={#MyAppPublisher}
  35. AllowNoIcons=yes
  36. OutputBaseFilename=setup_r{#MyAppVersion}
  37. Compression=lzma/ultra64
  38. SolidCompression=yes
  39. ShowTasksTreeLines=True
  40. SetupLogging=yes
  41. EnableDirDoesntExistWarning=True
  42. MinVersion=0,5.01sp3
  43. UsePreviousAppDir=False
  44. AppendDefaultDirName=False
  45. OutputDir="..\bin\"
  46. ChangesEnvironment=True
  47. CloseApplications=yes
  48. DisableProgramGroupPage=auto
  49. PrivilegesRequired=admin
  50. SetupIconFile="..\resource\logo_fb.ico"
  51. WizardImageFile="..\resource\wizard.bmp"
  52. WizardSmallImageFile="..\resource\wizardSmall.bmp"
  53. InfoBeforeFile="info.txt"
  54. LicenseFile="license.txt"
  55. Uninstallable=True
  56. ArchitecturesInstallIn64BitMode="x64 ia64"
  57. ArchitecturesAllowed="x64 ia64"
  58. VersionInfoVersion={#MyAppVersion}
  59. VersionInfoCompany=company
  60. VersionInfoDescription=Sample Program
  61. VersionInfoCopyright=company
  62. VersionInfoProductName=Sample Program
  63. VersionInfoProductVersion={#MyAppVersion}
  64. VersionInfoProductTextVersion=Build {#MyAppVersion}
  65. InternalCompressLevel=ultra64
  66.  
  67. [Registry]
  68. ; Set environment variable to point to company installation
  69. Root: "HKLM64"; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "MY_ENV_VARIABLE"; ValueData: "{app}"; Flags: uninsdeletevalue; Components: connect
  70.  
  71. ; Append python to PATH if does not already exist
  72. Root: "HKLM64"; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "PATH"; ValueData: "{olddata};{sd}\Python27\;{sd}\Python27\Scripts\"; Components: connect; Check: NeedsAddPath('{sd}\Python27')
  73.  
  74. ; Set environment variable to point to graphviz installation
  75. Root: "HKLM64"; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GRAPHVIZ"; ValueData: "{pf32}\GraphViz2.38\bin\"; Flags: uninsdeletevalue; Components: developerResources
  76.  
  77. [Languages]
  78. Name: "english"; MessagesFile: "compiler:Default.isl"
  79. Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
  80. Name: "chinese_simplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
  81. Name: "korean"; MessagesFile: "compiler:Languages\Korean.isl"
  82.  
  83. [Files]
  84. ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
  85. Source: "..\dependencies\ez_setup.py"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: connect
  86. Source: "..\dependencies\get-pip.py"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: connect
  87.  
  88. Source: "..\dependencies\python-2.7.6.amd64.msi"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: connect
  89. Source: "..\dependencies\graphviz-2.38.msi"; DestDir: "{app}\dependencies"; Flags: ignoreversion; Components: developerResources
  90. Source: "..\dependencies\lowdown\*"; DestDir: "{app}\dependencies\lowdown\"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "*.pyc"
  91. Source: "..\..\.eggs\*"; DestDir: "{app}\eggs"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
  92. Source: "..\..\build\*"; DestDir: "{app}\build"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
  93. Source: "..\..\doc\*"; DestDir: "{app}\doc"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
  94. Source: "..\..\event\*"; DestDir: "{app}\event"; Flags: ignoreversion createallsubdirs recursesubdirs; Excludes: "*.pyc"
  95. Source: "..\..\resource\*"; DestDir: "{app}\resource"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: connect; Excludes: "*.pyc"
  96.  
  97. Source: "..\..\installer\*"; DestDir: "{app}\installer"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "bin, *.pyc"
  98. Source: "..\..\source\*"; DestDir: "{app}\source"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "*.pyc"
  99. Source: "..\..\test\*"; DestDir: "{app}\test"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: developerResources; Excludes: "*.pyc"
  100. Source: "..\..\.gitignore"; DestDir: "{app}"; Flags: ignoreversion; Components: developerResources
  101. Source: "..\..\company_build.bat"; DestDir: "{app}"; Flags: ignoreversion; Components: developerResources
  102. Source: "..\..\company_launch.bat"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  103. Source: "..\..\company_launch.sh"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  104. Source: "..\..\company_launch_standalone.bat"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  105. Source: "..\..\LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  106. Source: "..\..\logo.icns"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  107. Source: "..\..\logo.ico"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  108. Source: "..\..\logo_fb.ico"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  109. Source: "..\..\MANIFEST.in"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  110. Source: "..\..\README.rst"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  111. Source: "..\..\setup.cfg"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  112. Source: "..\..\setup.py"; DestDir: "{app}"; Flags: ignoreversion; Components: connect
  113.  
  114. [Icons]
  115. Name: "{group}\{#MyAppName}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
  116. Name: "{group}\{#MyAppName}\{cm:LaunchProgram, {#MyAppName}}"; Filename: "{app}\company_launch_standalone.bat"; IconFilename: "{app}\logo_fb.ico"; Comment: "Launch Sample Program"
  117.  
  118. [ThirdParty]
  119. UseRelativePaths=True
  120.  
  121. [Run]
  122. ; Install Python 2.7.6
  123. Filename: "msiexec"; Parameters: "/i ""{app}\dependencies\python-2.7.6.amd64.msi"" /qb! ALLUSERS=1 ADDLOCAL=ALL"; Flags: 64bit; Description: "Install Python 2.7.6 AMD64"; MinVersion: 0,6.0; Components: connect; Check: PythonSetup
  124.  
  125. ; Install pip and setuptools
  126. Filename: "{sd}\Python27\python.exe"; Parameters: """{app}\dependencies\get-pip.py"""; Description: "Install pip"; Components: connect; Check: DependenciesSetup('pip')
  127. Filename: "{sd}\Python27\python.exe"; Parameters: """{app}\dependencies\ez_setup.py"""; Description: "Install setuptools"; Components: connect; Check: DependenciesSetup('setuptools')
  128.  
  129. ; Install Python dependencies
  130. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install boto==2.28.0"""; Description: "Install boto 2.28.0"; Components: connect; Check: DependenciesSetup('boto')
  131. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install PySide==1.2.2"""; Description: "Install PySide"; Components: connect; Check: DependenciesSetup('PySide')
  132. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install riffle"""; Description: "Install Riffle"; Components: connect; Check: DependenciesSetup('riffle')
  133. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\easy_install http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win-amd64-py2.7.exe"""; Description: "Install Crypto"; Components: connect; Check: DependenciesSetup('pycrypto')
  134.  
  135. ; Install Developer Python dependencies
  136. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install Sphinx"""; Description: "Install Sphinx"; Components: developerResources; Check: DependenciesSetup('Sphinx')
  137. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install sphinx_rtd_theme"""; Description: "Install sphinx_rtd_theme"; Components: developerResources; Check: DependenciesSetup('sphinx_rtd_theme')
  138. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install virtualenv"""; Description: "Install virtualenv"; Components: developerResources; Check: DependenciesSetup('virtualenv')
  139. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install virtualenv-clone"""; Description: "Install virtualenv-clone"; Components: developerResources; Check: DependenciesSetup('virtualenv-clone')
  140. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install virtualenvwrapper"""; Description: "Install virtualenvwrapper"; Components: developerResources; Check: DependenciesSetup('virtualenvwrapper')
  141. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install mock"""; Description: "Install mock"; Components: developerResources; Check: DependenciesSetup('mock')
  142. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install Pillow"""; Description: "Install Pillow"; Components: developerResources; Check: DependenciesSetup('Pillow')
  143. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install pyScss"""; Description: "Install pyScss"; Components: developerResources; Check: DependenciesSetup('pyScss')
  144. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install Pytest"""; Description: "Install Pytest"; Components: developerResources; Check: DependenciesSetup('Pytest')
  145. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\Scripts\pip.exe install arrow"""; Description: "Install arrow"; Components: developerResources; Check: DependenciesSetup('arrow')
  146.  
  147. ; Install Lowdown package for building release notes
  148. Filename: "cmd.exe"; Parameters: "/C ""{sd}\Python27\python.exe {app}\lowdown\setup.py install"""; Description: "Install lowdown (company)"; Components: developerResources; Check: DependenciesSetup('lowdown')
  149.  
  150. ; Install graphviz for documentation graph generation
  151. Filename: "msiexec"; Parameters: "/i ""{app}\dependencies\graphviz-2.38.msi"" /qb! ALLUSERS=1 ADDLOCAL=ALL"; Description: "Install graphviz 2.38"; MinVersion: 0,6.0; Components: developerResources;
  152.  
  153. ; Open Documentation after installation
  154. Filename: "{app}\build\doc\html\index.html"; Flags: postinstall shellexec; Description: "Open Sample Program documentation"; Components: connect
  155.  
  156.  
  157. [Components]
  158. Name: "connect"; Description: "Sample Program"; Types: full compact; Flags: fixed; MinVersion: 0,6.0; Languages: chinese_simplified english japanese korean
  159. Name: "developerResources"; Description: "Developer Resources"; Types: full; MinVersion: 0,6.0; Languages: chinese_simplified english japanese korean
  160.  
  161. [Code]
  162. // Global variables
  163.  
  164. // This function checks the registry for an existing Python 2.7.x installation
  165. function IsPythonInstalled: boolean;
  166. begin
  167.    Result := RegKeyExists(HKLM64, 'SOFTWARE\Python\PythonCore\2.7' );
  168. end;
  169.  
  170.  
  171. // This function checks if Python is installed and brings up user confirmation to automatically install it
  172. function PythonSetup(): boolean;
  173.  
  174. var
  175.  installPythonResult : Boolean;
  176.  check : Boolean;
  177.  
  178. begin
  179.    // Check if installer is being run in silent mode and skip all dialogs
  180.    if WizardSilent() then
  181.    begin
  182.      Result := True;
  183.      Exit;
  184.    
  185.    end;
  186.  
  187.    check := IsPythonInstalled;
  188.    if not check then
  189.        begin
  190.          installPythonResult := MsgBox('The toolkit requires Python 2.7.6 to be installed! Do you want to have it automatically installed for you?', mbConfirmation, MB_YESNO) = IDYES;
  191.  
  192.          if not installPythonResult then
  193.            begin
  194.              MsgBox('Python 2.7.6 will not be installed! Remember to install it later manually on your own!', mbInformation, MB_OK);
  195.              Result := False;
  196.            end;
  197.        end;
  198.  
  199.    Result := True;
  200.  
  201. end;
  202.  
  203.  
  204. // This function returns True if Python 2.7 registry key is detected on the system
  205. function DependenciesSetup(Param: String): Boolean;
  206.  
  207. var
  208.  check : Boolean;
  209.  
  210. begin
  211.  
  212.    if WizardSilent() then
  213.    begin
  214.      Result := True;
  215.      Exit;
  216.    end;
  217.  
  218.    check := IsPythonInstalled;
  219.    if not check then
  220.    begin
  221.        MsgBox('Could not install' + Param + 'because Python 2.7.x was not detected on the system!', mbInformation, MB_OK);
  222.        Result := False;
  223.    end;
  224.  
  225.    Result := True;
  226. end;
  227.  
  228.  
  229. // This function will return True if the Param already exists in the system PATH
  230. function NeedsAddPath(Param: String): Boolean;
  231. var
  232.  OrigPath: String;
  233.  
  234. begin
  235.    if not RegQueryStringValue(HKLM64, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'PATH', OrigPath) then
  236.    begin
  237.        Result := True;
  238.        exit;
  239.    end;
  240.  
  241.    // look for the path with leading and trailing semicolon; Pos() returns 0 if not found
  242.    Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
  243.  
  244. end;
  245.  
  246.  
  247. // Check for working internet connection
  248. function CheckInternetConnection(Param: String) : Boolean;
  249.  
  250. var
  251.  WinHttpReq : Variant;
  252.  
  253. begin
  254.  
  255.  try
  256.    // Create COM object to handle net connection attempt
  257.    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
  258.    WinHttpReq.Open('GET', Param, false);
  259.    WinHttpReq.Send();
  260.  
  261.  except
  262.    MsgBox('Could not connect to: ' + Param + '!' + #13#10 + 'Ensure that this computer has a working internet connection!', mbError, MB_OK);
  263.  
  264.  end;
  265.  
  266.  // Check for timeout
  267.  if WinHttpReq.Status <> 200 then begin
  268.    MsgBox('Could not connect to' + Param + '! Connection timed out!', mbError, MB_OK);
  269.    Result := False;
  270.  end;
  271.  
  272.  if Length(WinHttpReq.ResponseText) > 0 then begin
  273.    Result := True;
  274.  end;
  275.  
  276. end;
  277.  
  278.  
  279. // This method checks for presence of uninstaller entries in the registry and returns the path to the uninstaller executable.
  280. function GetUninstallString: String;
  281.  
  282. var
  283.  uninstallerPath: String;
  284.  uninstallerString: String;
  285.  
  286. begin
  287.  Result := '';
  288.  
  289.  // Get the uninstallerPath from the registry
  290.  uninstallerPath := ExpandConstant('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{6525583A-1BF8-43C9-AF77-59A4813D207E}_is1');
  291.  
  292.  uninstallerString := '';
  293.  
  294.  // Check if uninstaller entries in registry have values in them
  295.  if not RegQueryStringValue(HKLM64, uninstallerPath, 'UninstallString', uninstallerString) then
  296.    RegQueryStringValue(HKCU, uninstallerPath, 'UninstallString', uninstallerString);
  297.  
  298.  // Return path of uninstaller to run  
  299.  Result := uninstallerString;
  300.  
  301. end;
  302.  
  303.  
  304. // This method checks if a previous version has been installed
  305. function PreviousInstallationExists : Boolean;
  306. begin
  307.  // Check if not equal '<>' to empty string and return result
  308.  Result := (GetUninstallString() <> '');
  309. end;
  310.  
  311.  
  312. // This Event function runs before setup is initialized
  313. function InitializeSetup(): Boolean;
  314.  
  315. var
  316.  checkNetCxn : Boolean;
  317.  uninstallChoiceResult: Boolean;
  318.  uninstallPath : String;
  319.  iResultCode : Integer;
  320.  previouslyInstalledCheck : Boolean;
  321.  
  322. begin
  323.  // Connect to Python package dist server
  324.  checkNetCxn := CheckInternetConnection('https://pypi.python.org/pypi');
  325.   if not checkNetCxn then
  326.   begin
  327.     MsgBox('Please ensure that this computer has a working internet connection and try again!', mbError, MB_OK)
  328.     Result := False;
  329.     Exit;
  330.   end;
  331.  
  332.   // Now check if previous version was installed
  333.   previouslyInstalledCheck := PreviousInstallationExists;
  334.   if previouslyInstalledCheck then
  335.   begin
  336.     uninstallChoiceResult := MsgBox('A previous installation was detected. Do you want to uninstall the previous version first? (Recommended)', mbInformation, MB_YESNO) = IDYES;
  337.    
  338.     // If user chooses, uninstall the previous version and wait until it has finished before allowing installation to proceed
  339.     if uninstallChoiceResult then
  340.     begin
  341.       uninstallPath := RemoveQuotes(GetUninstallString());
  342.       Exec(ExpandConstant(uninstallPath), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
  343.  
  344.       Result := True;
  345.     end
  346.  
  347.     else
  348.     begin
  349.       Result := True;
  350.       Exit;
  351.     end;
  352.   end
  353.  
  354.   else
  355.     Result := True;
  356.  
  357. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement