rubyinstaller-build 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +8 -0
  3. data/.gitignore +12 -0
  4. data/.yardopts +7 -0
  5. data/CHANGELOG-2.4.md +166 -0
  6. data/CHANGELOG-2.5.md +87 -0
  7. data/CHANGELOG-2.6.md +62 -0
  8. data/CHANGELOG-2.7.md +22 -0
  9. data/Gemfile +6 -0
  10. data/LICENSE.txt +25 -0
  11. data/README.md +114 -0
  12. data/Rakefile +164 -0
  13. data/appveyor-key.asc.asc +61 -0
  14. data/appveyor.yml +141 -0
  15. data/docker/Dockerfile +50 -0
  16. data/docker/Rakefile +22 -0
  17. data/gems/rubyinstaller-build.yaml +2 -0
  18. data/lib/devkit.rb +3 -0
  19. data/lib/ruby_installer.rb +3 -0
  20. data/lib/ruby_installer/build.rb +23 -0
  21. data/lib/ruby_installer/build/ca_cert_file.rb +66 -0
  22. data/lib/ruby_installer/build/colors.rb +45 -0
  23. data/lib/ruby_installer/build/components/01_msys2.rb +97 -0
  24. data/lib/ruby_installer/build/components/02_pacman_update.rb +35 -0
  25. data/lib/ruby_installer/build/components/03_dev_tools.rb +68 -0
  26. data/lib/ruby_installer/build/components/base.rb +58 -0
  27. data/lib/ruby_installer/build/components_installer.rb +53 -0
  28. data/lib/ruby_installer/build/dll_directory.rb +97 -0
  29. data/lib/ruby_installer/build/erb_compiler.rb +61 -0
  30. data/lib/ruby_installer/build/gem_version.rb +5 -0
  31. data/lib/ruby_installer/build/gems.rb +74 -0
  32. data/lib/ruby_installer/build/msys2_installation.rb +280 -0
  33. data/lib/ruby_installer/build/openstruct.rb +29 -0
  34. data/lib/ruby_installer/build/release.rb +120 -0
  35. data/lib/ruby_installer/build/singleton.rb +45 -0
  36. data/lib/ruby_installer/build/task.rb +20 -0
  37. data/lib/ruby_installer/build/utils.rb +110 -0
  38. data/lib/ruby_installer/runtime.rb +18 -0
  39. data/lib/ruby_installer/runtime/ridk.rb +195 -0
  40. data/packages/ri-msys/Rakefile +72 -0
  41. data/packages/ri-msys/recipes/sandbox/70-add-msys2-installation.rake +18 -0
  42. data/packages/ri/Rakefile +60 -0
  43. data/recipes/archive-7z/10-define-variables.rake +2 -0
  44. data/recipes/archive-7z/70-create-archive.rake +10 -0
  45. data/recipes/archive-7z/90-define-main-task.rake +2 -0
  46. data/recipes/installer-inno/10-define-variables.rake +2 -0
  47. data/recipes/installer-inno/50-generate-filelist.rake +28 -0
  48. data/recipes/installer-inno/60-generate-iss-file.rake +8 -0
  49. data/recipes/installer-inno/70-run-iscc.rake +19 -0
  50. data/recipes/installer-inno/90-define-main-task.rake +2 -0
  51. data/recipes/installer-inno/events.iss +88 -0
  52. data/recipes/installer-inno/images/fake.bmp +0 -0
  53. data/recipes/installer-inno/images/wizard-large.bmp +0 -0
  54. data/recipes/installer-inno/images/wizard-logo.bmp +0 -0
  55. data/recipes/installer-inno/ri_gui.iss +286 -0
  56. data/recipes/installer-inno/rubyinstaller.iss.erb +157 -0
  57. data/recipes/installer-inno/util.iss +271 -0
  58. data/recipes/msys2/10-define-variables.rake +6 -0
  59. data/recipes/msys2/30-download-msys2-base.rake +4 -0
  60. data/recipes/msys2/40-extract-msys2-base.rake +9 -0
  61. data/recipes/msys2/50-init-msys.rake +8 -0
  62. data/recipes/msys2/50-install-components.rake +19 -0
  63. data/recipes/msys2/90-define-main-task.rake +2 -0
  64. data/recipes/sandbox/10-define-variables.rake +6 -0
  65. data/recipes/sandbox/20-add-runtime-files.rake +15 -0
  66. data/recipes/sandbox/20-define-import-files.rake +16 -0
  67. data/recipes/sandbox/20-define-import-readline.rake +28 -0
  68. data/recipes/sandbox/20-extend-irb.rake +13 -0
  69. data/recipes/sandbox/40-fix-rake-shebang.rake +6 -0
  70. data/recipes/sandbox/40-generate-rake-cmd.rake +7 -0
  71. data/recipes/sandbox/40-generate-version-file.rake +20 -0
  72. data/recipes/sandbox/50-do-import-files.rake +17 -0
  73. data/recipes/sandbox/50-gather-sandbox-files.rake +6 -0
  74. data/recipes/sandbox/60-define-gem-wrappers.rake +5 -0
  75. data/recipes/sandbox/60-side-by-side-assembly.rake +81 -0
  76. data/recipes/sandbox/70-add-gem-bin-wrappers.rake +10 -0
  77. data/recipes/sandbox/70-install-gems.rake +11 -0
  78. data/recipes/sandbox/80-copy-msys-files.rake +8 -0
  79. data/recipes/sandbox/90-define-main-task.rake +2 -0
  80. data/recipes/sandbox/LICENSE.txt +24 -0
  81. data/recipes/sandbox/rubyinstaller-2.3.4-x64.files +4 -0
  82. data/recipes/sandbox/rubyinstaller-2.3.4-x86.files +4 -0
  83. data/recipes/sandbox/rubyinstaller-2.3.4.files +43 -0
  84. data/recipes/sandbox/rubyinstaller-2.4.10-x64.files +4 -0
  85. data/recipes/sandbox/rubyinstaller-2.4.10-x86.files +4 -0
  86. data/recipes/sandbox/rubyinstaller-2.4.10.files +44 -0
  87. data/recipes/sandbox/rubyinstaller-2.5.8-x64.files +6 -0
  88. data/recipes/sandbox/rubyinstaller-2.5.8-x86.files +6 -0
  89. data/recipes/sandbox/rubyinstaller-2.5.8.files +33 -0
  90. data/recipes/sandbox/rubyinstaller-2.6.6-x64.files +6 -0
  91. data/recipes/sandbox/rubyinstaller-2.6.6-x86.files +6 -0
  92. data/recipes/sandbox/rubyinstaller-2.6.6.files +35 -0
  93. data/recipes/sandbox/rubyinstaller-2.7.1-x64.files +6 -0
  94. data/recipes/sandbox/rubyinstaller-2.7.1-x86.files +6 -0
  95. data/recipes/sandbox/rubyinstaller-2.7.1.files +35 -0
  96. data/recipes/sandbox/rubyinstaller-head-x64.files +6 -0
  97. data/recipes/sandbox/rubyinstaller-head-x86.files +6 -0
  98. data/recipes/sandbox/rubyinstaller-head.files +35 -0
  99. data/recipes/unpack/10-define-variables.rake +5 -0
  100. data/recipes/unpack/20-define-msys-packages.rake +1 -0
  101. data/recipes/unpack/30-add-ri2-repo-to-msys.rake +41 -0
  102. data/recipes/unpack/50-install-msys-packages.rake +28 -0
  103. data/recipes/unpack/90-define-main-task.rake +2 -0
  104. data/recipes/unpack/appveyor-repo-key.asc +29 -0
  105. data/resources/files/irbrc_predefiner.rb +21 -0
  106. data/resources/files/operating_system.rb +21 -0
  107. data/resources/files/readline.rb +17 -0
  108. data/resources/files/reline.rb +437 -0
  109. data/resources/files/reline/ansi.rb +177 -0
  110. data/resources/files/reline/config.rb +297 -0
  111. data/resources/files/reline/general_io.rb +75 -0
  112. data/resources/files/reline/history.rb +56 -0
  113. data/resources/files/reline/key_actor.rb +7 -0
  114. data/resources/files/reline/key_actor/base.rb +7 -0
  115. data/resources/files/reline/key_actor/emacs.rb +517 -0
  116. data/resources/files/reline/key_actor/vi_command.rb +518 -0
  117. data/resources/files/reline/key_actor/vi_insert.rb +517 -0
  118. data/resources/files/reline/key_stroke.rb +53 -0
  119. data/resources/files/reline/kill_ring.rb +113 -0
  120. data/resources/files/reline/line_editor.rb +2231 -0
  121. data/resources/files/reline/unicode.rb +527 -0
  122. data/resources/files/reline/unicode/east_asian_width.rb +1145 -0
  123. data/resources/files/reline/version.rb +3 -0
  124. data/resources/files/reline/windows.rb +273 -0
  125. data/resources/files/ridk.cmd +39 -0
  126. data/resources/files/ridk.ps1 +26 -0
  127. data/resources/files/ridk_use/ridk.cmd +13 -0
  128. data/resources/files/ridk_use/ridk.ps1 +17 -0
  129. data/resources/files/ridk_use/ridk_use.rb +221 -0
  130. data/resources/files/setrbvars.cmd +14 -0
  131. data/resources/icons/ruby-doc.ico +0 -0
  132. data/resources/ssl/README-SSL.md +37 -0
  133. data/resources/ssl/c_rehash.rb +167 -0
  134. data/resources/ssl/cacert.pem +4105 -0
  135. data/rubyinstaller-build.gemspec +28 -0
  136. metadata +226 -0
@@ -0,0 +1,157 @@
1
+ ; RubyInstaller - InnoSetup Script (base)
2
+ ; This script is used to build Ruby Installers for Windows
3
+ ; Copyright (c) 2009-2012 Jon Maken
4
+ ; Copyright (c) 2009-2012 Gordon Thiesfeld
5
+ ; Copyright (c) 2009-2012 Luis Lavena
6
+ ; Copyright (c) 2012 Yusuke Endoh
7
+ ; Revision: 2012-05-28 13:57:37 -0600
8
+ ; License: Modified BSD License
9
+
10
+ <% require "etc" %>
11
+ <% with_msys = package.respond_to?(:msysdir) %>
12
+
13
+ #define RubyVersion <%=q package.rubyver %>
14
+ #define PackageRelease <%=q package.pkgrel %>
15
+ #define RubyBuildPlatform <%=q package.ruby_arch %>
16
+
17
+ ; Build Installer details using above values
18
+ #define InstallerName "Ruby " + <%=q package.packagever %> + "-" + <%=q package.arch %> + "<%= " with MSYS2" if with_msys %>"
19
+ #define InstallerPublisher "RubyInstaller Team"
20
+ #define InstallerHomepage "http://rubyinstaller.org"
21
+
22
+ #define CurrentYear GetDateTimeString('yyyy', '', '')
23
+ #define PackageBaseId "MRI"
24
+
25
+ #define MsysDir <%=q( with_msys ? package.msysdir : '' )%>
26
+
27
+ [Setup]
28
+ DefaultDirName=<%=q package.default_instdir %>
29
+
30
+ ; NOTE: The value of AppId uniquely identifies this application.
31
+ ; Do not use the same AppId value in installers for other applications!
32
+ AppId=<%=q "RubyInstaller-#{package.rubyver2}-#{package.ruby_arch}" %>
33
+ AppName={#InstallerName}
34
+ AppVerName={#InstallerName}
35
+ AppPublisher={#InstallerPublisher}
36
+ AppPublisherURL={#InstallerHomepage}
37
+ AppVersion=<%=q package.packagever %>
38
+ DefaultGroupName={#InstallerName}
39
+ DisableWelcomePage=true
40
+ DisableProgramGroupPage=true
41
+ LicenseFile=<%= ovl_expand_file("recipes/sandbox/LICENSE.txt") %>
42
+ Compression=lzma2/ultra64
43
+ SolidCompression=true
44
+ CompressionThreads=<%= Etc.nprocessors %>
45
+ LZMANumBlockThreads=<%= Etc.nprocessors %>
46
+ LZMAUseSeparateProcess=yes
47
+ AlwaysShowComponentsList=false
48
+ DisableReadyPage=true
49
+ InternalCompressLevel=ultra64
50
+ VersionInfoCompany={#InstallerPublisher}
51
+ VersionInfoCopyright=(c) {#CurrentYear} {#InstallerPublisher}
52
+ VersionInfoDescription=Ruby Programming Language for Windows
53
+ VersionInfoTextVersion=<%=q package.packagever %>
54
+ VersionInfoVersion=<%=q(package.rubyver[/^\d+\.\d+\.\d+/] || package.rubyver2)%>
55
+ UninstallDisplayIcon={app}\bin\ruby.exe
56
+ WizardStyle=modern
57
+ WizardImageFile=<%=q ovl_expand_file("recipes/installer-inno/images/wizard-large.bmp") %>
58
+ WizardSmallImageFile=<%=q ovl_expand_file("recipes/installer-inno/images/wizard-logo.bmp") %>
59
+ PrivilegesRequired=lowest
60
+ ChangesAssociations=yes
61
+ ChangesEnvironment=yes
62
+ MinVersion=6.0
63
+ #if Defined(SignPackage) == 1
64
+ SignTool=risigntool sign /a /d $q{#InstallerName}$q /du $q{#InstallerHomepage}$q /t $qhttp://timestamp.comodoca.com/authenticode$q $f
65
+ #endif
66
+
67
+ [Languages]
68
+ Name: en; MessagesFile: compiler:Default.isl
69
+
70
+ [Messages]
71
+ en.WelcomeLabel1=Welcome to the [name] Installer
72
+ en.WelcomeLabel2=This will install [name/ver] on your computer. Please close all other applications before continuing.
73
+ en.WizardLicense={#InstallerName} License Agreement
74
+ en.LicenseLabel=
75
+ en.LicenseLabel3=Please read the following License Agreement and accept the terms before continuing the installation.
76
+ en.LicenseAccepted=I &accept the License
77
+ en.LicenseNotAccepted=I &decline the License
78
+ en.WizardSelectDir=Installation Destination and Optional Tasks
79
+ en.SelectDirDesc=
80
+ en.SelectDirLabel3=Setup will install [name] into the following folder. Click Install to continue or click Browse to use a different one.
81
+ en.SelectDirBrowseLabel=Please avoid any folder name that contains spaces (e.g. Program Files).
82
+ en.DiskSpaceMBLabel=Required free disk space: ~[mb] MB
83
+ en.DirExists=The folder:%n%n%1%n%nalready exists. Would you like to install to that folder anyway?%n%nOverwriting a Ruby version with the same major and minor version usually works, but for example Ruby-2.5.0 over 2.4.0 doesn't.
84
+
85
+ [CustomMessages]
86
+ AddPath=Add Ruby executables to your PATH
87
+ AddPathHint=Select to make this Ruby installation available from everywhere.%nThis may affect existing Ruby installations.
88
+ AssociateExt=Associate .rb and .rbw files with this Ruby installation
89
+ AssociateExtHint=Select to enable running your Ruby scripts by double clicking%nor simply typing the script name at your shell prompt. This may%naffect existing Ruby installations.
90
+ DevkitInstall=Run 'ridk install' to setup MSYS2 and development toolchain.
91
+ DevkitInstall2=MSYS2 is required to install gems with C extensions.
92
+ DevkitInstallHint=The MSYS2 development tools consists of the GCC compiler suite and%nmany common UNIX tools required to build OpenSource software.%nIt is safe to run `ridk install` even if MSYS2 is already installed.
93
+ DefaultUtf8=Use UTF-8 as default external encoding.
94
+ DefaultUtf8Hint=This sets the environment variable 'RUBYOPT=-Eutf-8'.%nRubyInstaller-2.6 will probably set this as default.%nSee the wiki for more information.
95
+ MouseoverHint=TIP: Mouse over the above options for more detailed information.
96
+ WebSiteLabel=Web Site:
97
+ SupportGroupLabel=Support group:
98
+ WikiLabel=Wiki:
99
+ InteractiveRubyTitle=Interactive Ruby
100
+ RubyGemsDocumentationServerTitle=RubyGems Documentation Server
101
+ StartCmdPromptWithRubyTitle=Start Command Prompt with Ruby
102
+ DocumentationTitle=Documentation
103
+ APIReferenceTitle=Ruby %1 API Reference
104
+ TheBookofRubyTitle=The Book of Ruby
105
+
106
+ [Files]
107
+ #define InstallerFileList "filelist-ruby-" + RubyVersion + "-" + RubyBuildPlatform + ".iss"
108
+ #include InstallerFileList
109
+
110
+ [Registry]
111
+ <% [["HKLM", "IsAdmin"],
112
+ ["HKCU", "IsNotAdmin"]].each do |regroot, chkadmin| %>
113
+
114
+ <% [[".rb", "Ruby", "ruby.exe"],
115
+ [".rbw", "RubyW", "rubyw.exe"]].each do |extension, rubyname, rubyexe| %>
116
+
117
+ ; .rb, *.rbw file for admin+nonadmin
118
+ Root: <%= regroot %>; Subkey: Software\Classes\<%= extension %>; ValueType: string; ValueName: ; ValueData: <%= rubyname %>File; Flags: uninsdeletevalue uninsdeletekeyifempty; Check: <%= chkadmin %> and IsAssociated
119
+ Root: <%= regroot %>; Subkey: Software\Classes\<%= rubyname %>File; ValueType: string; ValueName: ; ValueData: <%= rubyname %> File; Flags: uninsdeletekey; Check: <%= chkadmin %> and IsAssociated
120
+ Root: <%= regroot %>; Subkey: Software\Classes\<%= rubyname %>File\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\bin\<%= rubyexe %>,0; Check: <%= chkadmin %> and IsAssociated
121
+ Root: <%= regroot %>; Subkey: Software\Classes\<%= rubyname %>File\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\bin\<%= rubyexe %>"" ""%1"" %*"; Check: <%= chkadmin %> and IsAssociated
122
+
123
+ <% end %>
124
+
125
+ ; RubyInstaller identification for admin+nonadmin
126
+ Root: <%= regroot %>; Subkey: Software\RubyInstaller; ValueType: string; ValueName: ; ValueData: ; Flags: uninsdeletevalue uninsdeletekeyifempty; Check: <%= chkadmin %>
127
+ Root: <%= regroot %>; Subkey: Software\RubyInstaller\{#PackageBaseId}; ValueType: string; ValueName: ; ValueData: ; Flags: uninsdeletevalue uninsdeletekeyifempty; Check: <%= chkadmin %>
128
+ Root: <%= regroot %>; Subkey: Software\RubyInstaller\{#PackageBaseId}\{#RubyVersion}; ValueType: string; ValueName: ; ValueData: ; Flags: uninsdeletekey; Check: <%= chkadmin %>
129
+ Root: <%= regroot %>; Subkey: Software\RubyInstaller\{#PackageBaseId}\{#RubyVersion}; ValueType: string; ValueName: InstallLocation ; ValueData: {app}; Check: <%= chkadmin %>
130
+ Root: <%= regroot %>; Subkey: Software\RubyInstaller\{#PackageBaseId}\{#RubyVersion}; ValueType: string; ValueName: InstallDate ; ValueData: {code:GetInstallDate}; Check: <%= chkadmin %>
131
+ Root: <%= regroot %>; Subkey: Software\RubyInstaller\{#PackageBaseId}\{#RubyVersion}; ValueType: string; ValueName: PackageRelease ; ValueData: {#PackageRelease}; Check: <%= chkadmin %>
132
+ Root: <%= regroot %>; Subkey: Software\RubyInstaller\{#PackageBaseId}\{#RubyVersion}; ValueType: string; ValueName: BuildPlatform ; ValueData: {#RubyBuildPlatform}; Check: <%= chkadmin %>
133
+
134
+ <% end %>
135
+
136
+ [Icons]
137
+ Name: {group}\{cm:InteractiveRubyTitle}; Filename: {app}\bin\irb.cmd; Parameters: -rirb/completion; IconFilename: {app}\bin\ruby.exe
138
+ Name: {group}\{cm:DocumentationTitle}\{cm:APIReferenceTitle,{#RubyVersion}}; Filename: {app}\share\doc\ruby\html\index.html; IconFilename: {app}\share\doc\ruby\html\images\ruby-doc.ico; Components: rdoc
139
+ Name: {group}\{cm:RubyGemsDocumentationServerTitle}; Filename: {app}\bin\gem.cmd; Parameters: server --launch; IconFilename: {app}\share\doc\ruby\html\images\ruby-doc.ico; Flags: runminimized
140
+ Name: {group}\{cm:StartCmdPromptWithRubyTitle}; Filename: {sys}\cmd.exe; Parameters: /E:ON /K {app}\bin\setrbvars.cmd; WorkingDir: {%HOMEDRIVE}{%HOMEPATH}; IconFilename: {sys}\cmd.exe
141
+ Name: {group}\{cm:UninstallProgram,{#InstallerName}}; Filename: {uninstallexe}
142
+
143
+ [Components]
144
+ Name: "ruby"; Description: "Ruby-<%= package.rubyver %> base files"; Types: custom; Flags: fixed
145
+ Name: "rdoc"; Description: "Ruby RI and HTML documentation"; Types: custom; Flags: disablenouninstallwarning
146
+ <% if with_msys %>
147
+ Name: "msys2"; Description: "MSYS2 development toolchain <%= Time.now.strftime("%Y-%m-%d") %>"; Types: custom; Flags: disablenouninstallwarning
148
+ <% end %>
149
+
150
+ [Types]
151
+ Name: "custom"; Description: "Default installation"; Flags: iscustom
152
+
153
+
154
+ [Code]
155
+ <%= ovl_read_file "recipes/installer-inno/util.iss" %>
156
+ <%= ovl_read_file "recipes/installer-inno/ri_gui.iss" %>
157
+ <%= ovl_read_file "recipes/installer-inno/events.iss" %>
@@ -0,0 +1,271 @@
1
+ // Inno Setup utilities
2
+ //
3
+ // Copyright (c) 2009-2012 Jon Maken
4
+ // Revision: 2012-05-28 14:06:56 -0600
5
+ // License: Modified BSD License
6
+
7
+ // forward declarations
8
+ function MungePathish(const SrcList: TStringList; NewData: Array of String; RegValue: String; IsUninstalling: Boolean): Boolean; forward;
9
+ procedure ModifyPathish(NewData: Array of String; RegValue, Delim: String); forward;
10
+ function StrToList(const SrcString: String; Delim: String): TStringList; forward;
11
+ function ListToStr(const SrcList: TStringList; Delim: String): String; forward;
12
+
13
+ function IsAdmin(): Boolean;
14
+ begin
15
+ Result := IsAdminLoggedOn or IsPowerUserLoggedOn;
16
+ end;
17
+
18
+ function IsNotAdmin(): Boolean;
19
+ begin
20
+ Result := not (IsAdminLoggedOn or IsPowerUserLoggedOn);
21
+ end;
22
+
23
+ function GetUserHive(): Integer;
24
+ begin
25
+ if IsAdminLoggedOn or IsPowerUserLoggedOn then
26
+ Result := HKLM
27
+ else
28
+ Result := HKCU;
29
+ end;
30
+
31
+ function GetEnvironmentKey(): String;
32
+ begin
33
+ if IsAdmin then
34
+ Result := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
35
+ else
36
+ Result := 'Environment';
37
+ end;
38
+
39
+ function GetInstallDate(Param: String): String;
40
+ begin
41
+ Result := GetDateTimeString('yyyymmdd', #0 , #0);
42
+ end;
43
+
44
+ procedure ModifyFileExts(Exts: Array of String);
45
+ begin
46
+ ModifyPathish(Exts, 'PATHEXT', ';');
47
+ end;
48
+
49
+ procedure ModifyPath(Exts: Array of String);
50
+ begin
51
+ ModifyPathish(Exts, 'PATH', ';');
52
+ end;
53
+
54
+ procedure ModifyRubyopt(Exts: Array of String);
55
+ begin
56
+ ModifyPathish(Exts, 'RUBYOPT', ' ');
57
+ end;
58
+
59
+ // Modifies path-like registry keys such as PATH, PATHEXT
60
+ procedure ModifyPathish(NewData: Array of String; RegValue, Delim: String);
61
+ var
62
+ NeedRegChange: Boolean;
63
+ RootKey: Integer;
64
+ SubKey, OrigData, NewPathish, Tmp, TmpExpandable: String;
65
+ PathishList: TStringList;
66
+ begin
67
+ RootKey := GetUserHive;
68
+ SubKey := GetEnvironmentKey;
69
+
70
+ try
71
+ RegQueryStringValue(RootKey, SubKey, RegValue, OrigData);
72
+ Log('Original ' + AnsiUppercase(RegValue) + ': ' + OrigData);
73
+
74
+ // ensure originally empty users PATHEXT also contains system values
75
+ if (RootKey = HKCU) and (AnsiUppercase(RegValue) = 'PATHEXT') and (OrigData = '') then
76
+ begin
77
+ Log('Empty HKCU ' + AnsiUppercase(RegValue) + ', prepending %PATHEXT% to new value');
78
+ OrigData := ('%' + RegValue + '%');
79
+ end;
80
+
81
+ PathishList := StrToList(OrigData, Delim);
82
+
83
+ NeedRegChange := MungePathish(PathishList, NewData, RegValue, IsUninstaller);
84
+
85
+ if NeedRegChange then
86
+ begin
87
+ NewPathish := ListToStr(PathishList, ';');
88
+
89
+ case AnsiUppercase(RegValue) of
90
+ 'PATH': RegWriteExpandStringValue(RootKey, SubKey, 'Path', NewPathish);
91
+ ELSE RegWriteExpandStringValue(RootKey, SubKey, AnsiUppercase(RegValue), NewPathish);
92
+ end;
93
+ Log(AnsiUppercase(RegValue) + ' updated to: ' + NewPathish);
94
+
95
+ // remove values if empty after uninstaller reverts its mods
96
+ if IsUninstaller then
97
+ begin
98
+ if RegQueryStringValue(RootKey, SubKey, RegValue, Tmp) then
99
+ begin
100
+ // If the key is empty or expandable version (%RegValue%), remove it.
101
+ TmpExpandable := '%' + RegValue + '%';
102
+ if (Tmp = '') or (Tmp = TmpExpandable) then
103
+ begin
104
+ RegDeleteValue(RootKey, SubKey, RegValue);
105
+ Log('uninstaller deleted empty ' + AnsiUppercase(RegValue) +
106
+ ' to match original config');
107
+ end;
108
+ end;
109
+ end;
110
+ end else // no reg change needed
111
+ Log('no changes need for ' + AnsiUppercase(RegValue));
112
+ finally
113
+ PathishList.Free;
114
+ end;
115
+ end;
116
+
117
+ function StrToList(const SrcString: String; Delim: String): TStringList;
118
+ var
119
+ PathList: TStringList;
120
+ TmpPath: String;
121
+ begin
122
+ PathList := TStringList.Create;
123
+
124
+ // empty PATH
125
+ if Length(SrcString) = 0 then Result := PathList;
126
+
127
+ if (Length(SrcString) > 0) then
128
+ begin
129
+ // single entry with no trailing ';'
130
+ if Pos(Delim, SrcString) = 0 then
131
+ begin
132
+ PathList.Append(SrcString);
133
+
134
+ Result := PathList;
135
+ // single entry with trailing ';'
136
+ // TODO address pathological case of multiple trailing ';' chars?
137
+ end else if Pos(Delim, SrcString) = Length(SrcString) then
138
+ begin
139
+ TmpPath := SrcString;
140
+ StringChangeEx(TmpPath, Delim, '', True);
141
+ PathList.Append(TmpPath);
142
+
143
+ Result := PathList;
144
+ end else
145
+ // multiple entries
146
+ begin
147
+ TmpPath := SrcString;
148
+ // clean up a leading ';' pathological case if it exists
149
+ if Pos(Delim, TmpPath) = 1 then TmpPath := Copy(TmpPath, 2, Length(TmpPath));
150
+ while (Pos(Delim, TmpPath) > 0) do
151
+ begin
152
+ PathList.Append(Copy(TmpPath, 1, Pos(Delim, TmpPath) - 1));
153
+ TmpPath := Copy(TmpPath, Pos(Delim, TmpPath) + 1, Length(TmpPath));
154
+ end;
155
+ // add final remaining dir if not empty due to trailing ';'
156
+ if Length(TmpPath) > 0 then PathList.Append(TmpPath);
157
+
158
+ Result := PathList;
159
+ end;
160
+ end;
161
+ end;
162
+
163
+ function ListToStr(const SrcList: TStringList; Delim: String): String;
164
+ var
165
+ Path: String;
166
+ I: Integer;
167
+ begin
168
+ for I := 0 to SrcList.Count - 1 do begin
169
+ if Length(Path) = 0 then
170
+ begin
171
+ Path := SrcList[I];
172
+ Continue;
173
+ end;
174
+ Path := Path + Delim + SrcList[I];
175
+ end;
176
+
177
+ Result := Path;
178
+ end;
179
+
180
+ function MungePathish(const SrcList: TStringList; NewData: Array of String;
181
+ RegValue: String; IsUninstalling: Boolean): Boolean;
182
+ var
183
+ RootKey, I, N: Integer;
184
+ Item: String;
185
+ RegChangeFlag: Boolean;
186
+ begin
187
+ RegChangeFlag := False;
188
+ RootKey := GetUserHive;
189
+
190
+ for N := 0 to GetArrayLength(NewData) - 1 do
191
+ begin
192
+ Item := NewData[N];
193
+ if not IsUninstalling then // installing...
194
+ begin
195
+ // update PathishList ONLY if new item isn't already in the list
196
+ // DO NOT ASSUME that the installer should duplicate entry or change order!
197
+ if SrcList.IndexOf(Item) = -1 then
198
+ begin
199
+ case AnsiUppercase(RegValue) of
200
+ 'PATH', 'RUBYOPT': SrcList.Insert(0, Item);
201
+ 'PATHEXT': SrcList.Add(AnsiUppercase(Item));
202
+ end;
203
+ RegChangeFlag := True;
204
+ end else // already in existing config, no need for update; log it
205
+ Log(Item + ' already on ' + AnsiUppercase(RegValue) +
206
+ ' in original config; not modifying ' + AnsiUppercase(RegValue));
207
+ end else // uninstalling...
208
+ begin
209
+ I := SrcList.IndexOf(Item);
210
+ if I <> -1 then // found on PathishList, delete it
211
+ begin
212
+ SrcList.Delete(I);
213
+ RegChangeFlag := True;
214
+ end; // not found on PathishList, no need for registry mod
215
+ end;
216
+ end;
217
+
218
+ Result := RegChangeFlag;
219
+ end;
220
+
221
+ function GetUninstallString(): String;
222
+ var
223
+ sUnInstPath: String;
224
+ sUnInstallString: String;
225
+ appId: String;
226
+ begin
227
+ appId := RemoveQuotes('{#emit SetupSetting("AppId")}');
228
+ sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\' + appId + '_is1');
229
+ sUnInstallString := '';
230
+ Log('Check registry for previous RubyInstaller: ' + sUnInstPath);
231
+ if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
232
+ RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
233
+ Result := sUnInstallString;
234
+ end;
235
+
236
+ procedure UnInstallOldVersion();
237
+ var
238
+ sUnInstallString: String;
239
+ iResultCode: Integer;
240
+ sUninstParams: String;
241
+ begin
242
+ sUnInstallString := GetUninstallString();
243
+ if sUnInstallString <> '' then begin
244
+ // Previous RubyInstaller detected
245
+
246
+ sUnInstallString := RemoveQuotes(sUnInstallString);
247
+ sUninstParams := '/NORESTART /SUPPRESSMSGBOXES';
248
+ if WizardSilent then sUninstParams := sUninstParams + ' /VERYSILENT'
249
+ else sUninstParams := sUninstParams + ' /SILENT';
250
+
251
+ Log('Update installation detected - doing uninstall first: ' + sUnInstallString + ' ' + sUninstParams);
252
+ if Exec(sUnInstallString, sUninstParams, '', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
253
+ Log('Successfully uninstalled previous ruby version')
254
+ else
255
+ Log('Failed to uninstalled previous ruby version');
256
+ end else
257
+ Log('No previous ruby version found');
258
+ end;
259
+
260
+ function Msys2AlreadyInstalled(): String;
261
+ begin
262
+ if DirExists(ExpandConstant('{app}\msys32')) then Result := ExpandConstant('{app}\msys32')
263
+ else if DirExists(ExpandConstant('{app}\msys64')) then Result := ExpandConstant('{app}\msys64')
264
+ else Result := '';
265
+ end;
266
+
267
+ procedure DeleteRubyMsys2Directory();
268
+ begin
269
+ DelTree(ExpandConstant('{app}/msys32'), True, True, True);
270
+ DelTree(ExpandConstant('{app}/msys64'), True, True, True);
271
+ end;
@@ -0,0 +1,6 @@
1
+ self.msys2_base_tar_url = "http://repo.msys2.org/distrib/msys2-#{package.msys_arch}-latest.tar.xz"
2
+ self.msys2_base_tar_file = File.join(thisdir, File.basename(self.msys2_base_tar_url))
3
+ self.sandboxdir = "#{thisdir}/#{package.msysdir}"
4
+ self.devtools = File.join(sandboxdir, "devtools_installed")
5
+ self.before_init_filelist = File.join(sandboxdir, "before_init_filelist")
6
+ self.after_init_filelist = File.join(sandboxdir, "after_init_filelist")
@@ -0,0 +1,4 @@
1
+ directory File.dirname(self.msys2_base_tar_file)
2
+ file self.msys2_base_tar_file => File.dirname(self.msys2_base_tar_file) do |t|
3
+ sh "wget #{self.msys2_base_tar_url.inspect} -O #{t.name.inspect}"
4
+ end
@@ -0,0 +1,9 @@
1
+ untardir = File.dirname(self.sandboxdir)
2
+ directory untardir
3
+ file self.before_init_filelist => [self.msys2_base_tar_file, untardir] do |t|
4
+ sh "tar xf #{self.msys2_base_tar_file.inspect} -C #{untardir.inspect}"
5
+
6
+ chdir self.sandboxdir do
7
+ sh "find -type f > #{File.basename self.before_init_filelist}"
8
+ end
9
+ end