wxruby3 0.9.4 → 0.9.7
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.
- checksums.yaml +4 -4
- data/INSTALL.md +315 -78
- data/README.md +32 -21
- data/ext/wxruby3/include/wxruby-ComboPopup.h +777 -0
- data/lib/wx/core/combo_ctrl.rb +171 -0
- data/lib/wx/core/ext.rb +22 -3
- data/lib/wx/doc/comboctrl.rb +128 -3
- data/lib/wx/doc/owner_drawn_combobox.rb +5 -1
- data/lib/wx/version.rb +1 -1
- data/lib/wx/wxruby/base.rb +6 -4
- data/lib/wx/wxruby/cmd/sampler.rb +39 -29
- data/lib/wx/wxruby/cmd/setup.rb +122 -0
- data/lib/wx/wxruby/cmd/test.rb +56 -6
- data/rakefile +14 -0
- data/rakelib/bin.rake +48 -0
- data/rakelib/bin.rb +62 -0
- data/rakelib/build.rb +11 -7
- data/rakelib/config.rake +3 -1
- data/rakelib/configure.rb +28 -8
- data/rakelib/doc.rake +3 -1
- data/rakelib/gem.rake +169 -0
- data/rakelib/gem.rb +82 -0
- data/rakelib/install.rb +2 -0
- data/rakelib/lib/config/linux.rb +24 -2
- data/rakelib/lib/config/macosx.rb +16 -0
- data/rakelib/lib/config/mingw.rb +133 -9
- data/rakelib/lib/config/pkgman/arch.rb +53 -0
- data/rakelib/lib/config/pkgman/base.rb +169 -0
- data/rakelib/lib/config/pkgman/debian.rb +66 -0
- data/rakelib/lib/config/pkgman/macosx.rb +183 -0
- data/rakelib/lib/config/pkgman/rhel.rb +54 -0
- data/rakelib/lib/config/pkgman/suse.rb +54 -0
- data/rakelib/lib/config/unixish.rb +36 -19
- data/rakelib/lib/config.rb +254 -61
- data/rakelib/lib/core/include/funcall.inc +2 -1
- data/rakelib/lib/core/package.rb +47 -49
- data/rakelib/lib/director/comboctrl.rb +104 -3
- data/rakelib/lib/director/defs.rb +1 -3
- data/rakelib/lib/director/gdicommon.rb +5 -0
- data/rakelib/lib/director/menu_item.rb +1 -1
- data/rakelib/lib/director/num_validator.rb +5 -7
- data/rakelib/lib/director/owner_drawn_combobox.rb +1 -0
- data/rakelib/lib/director/persistent_window.rb +2 -2
- data/rakelib/lib/director/pgeditor.rb +1 -1
- data/rakelib/lib/director/pgproperties.rb +3 -3
- data/rakelib/lib/director/pgproperty.rb +5 -1
- data/rakelib/lib/director/richtext_style_listbox.rb +5 -0
- data/rakelib/lib/director/sizer.rb +1 -1
- data/rakelib/lib/director/window.rb +4 -0
- data/rakelib/lib/extractor/module.rb +15 -0
- data/rakelib/lib/generate/doc/combo_ctrl.yaml +135 -0
- data/rakelib/lib/generate/doc/file_dialog_customize_hook.yaml +62 -0
- data/rakelib/lib/generate/doc/file_system.yaml +28 -0
- data/rakelib/lib/generate/doc.rb +29 -14
- data/rakelib/lib/generate/interface.rb +16 -6
- data/rakelib/lib/swig_runner.rb +18 -15
- data/rakelib/lib/typemap/combo_popup.rb +42 -0
- data/rakelib/prepost.rake +9 -4
- data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +14 -0
- data/rakelib/yard/templates/default/fulldoc/html/setup.rb +5 -5
- data/rakelib/yard/yard/relative_markdown_links.rb +7 -1
- data/tests/test_combo_ctrl.rb +196 -0
- metadata +28 -17
- data/ext/mkrf_conf_srcgem.rb +0 -67
- data/rakelib/run.rake +0 -52
data/rakelib/lib/config/mingw.rb
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
|
9
9
|
require_relative './unixish'
|
10
10
|
|
11
|
+
require 'uri'
|
12
|
+
|
13
|
+
|
11
14
|
if ENV['RI_DEVKIT'].nil?
|
12
15
|
begin
|
13
16
|
require 'devkit'
|
@@ -23,6 +26,13 @@ module WXRuby3
|
|
23
26
|
|
24
27
|
module Platform
|
25
28
|
|
29
|
+
SWIG_URL = 'https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.2.0/swigwin-4.2.0.zip/download'
|
30
|
+
SWIG_ZIP = 'swigwin-4.2.0.zip'
|
31
|
+
|
32
|
+
DOXYGEN_URL = 'https://www.doxygen.nl/files/doxygen-1.10.0.windows.x64.bin.zip'
|
33
|
+
|
34
|
+
GIT_URL = 'https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/MinGit-2.43.0-64-bit.zip'
|
35
|
+
|
26
36
|
def self.included(base)
|
27
37
|
base.class_eval do
|
28
38
|
include Config::UnixLike
|
@@ -65,20 +75,79 @@ module WXRuby3
|
|
65
75
|
ftmp.unlink # cleanup
|
66
76
|
end
|
67
77
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
78
|
+
def check_tool_pkgs
|
79
|
+
pkg_deps = []
|
80
|
+
pkg_deps << 'doxygen' if expand("which #{get_cfg_string('doxygen')} 2>/dev/null").strip.empty?
|
81
|
+
pkg_deps << 'swig' if expand("which #{get_cfg_string('swig')} 2>/dev/null").strip.empty?
|
82
|
+
pkg_deps << 'git' if expand("which #{get_cfg_string('git')} 2>/dev/null").strip.empty?
|
83
|
+
pkg_deps
|
72
84
|
end
|
73
85
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
86
|
+
def install_prerequisites
|
87
|
+
pkg_deps = super
|
88
|
+
unless pkg_deps.empty?
|
89
|
+
# autoinstall or not?
|
90
|
+
unless wants_autoinstall?
|
91
|
+
STDERR.puts <<~__ERROR_TXT
|
92
|
+
ERROR: This system lacks installed versions of the following required software packages:
|
93
|
+
#{pkg_deps.join(', ')}
|
94
|
+
|
95
|
+
Install these packages and try again.
|
96
|
+
__ERROR_TXT
|
97
|
+
exit(1)
|
98
|
+
end
|
99
|
+
# if SWIG was not found in the PATH
|
100
|
+
if pkg_deps.include?('swig')
|
101
|
+
$stdout.print 'Installing SWIG...' if run_silent?
|
102
|
+
# download and install SWIG
|
103
|
+
fname = download_and_install(SWIG_URL, SWIG_ZIP, 'swig.exe')
|
104
|
+
$stdout.puts 'done!' if run_silent?
|
105
|
+
Config.instance.log_progress("Installed #{fname}")
|
106
|
+
set_config('swig', fname)
|
107
|
+
Config.save
|
108
|
+
end
|
109
|
+
# if doxygen was not found in the PATH
|
110
|
+
if pkg_deps.include?('doxygen')
|
111
|
+
$stdout.print 'Installing Doxygen...' if run_silent?
|
112
|
+
# download and install doxygen
|
113
|
+
fname = download_and_install(DOXYGEN_URL, File.basename(URI(DOXYGEN_URL).path), 'doxygen.exe', 'doxygen')
|
114
|
+
$stdout.puts 'done!' if run_silent?
|
115
|
+
Config.instance.log_progress("Installed #{fname}")
|
116
|
+
set_config('doxygen', fname)
|
117
|
+
Config.save
|
118
|
+
end
|
119
|
+
# if git was not found in the PATH
|
120
|
+
if pkg_deps.include?('git')
|
121
|
+
$stdout.print 'Installing Git...' if run_silent?
|
122
|
+
# download and install doxygen
|
123
|
+
fname = download_and_install(GIT_URL, File.basename(URI(GIT_URL).path), 'git.exe', 'git')
|
124
|
+
$stdout.puts 'done!' if run_silent?
|
125
|
+
Config.instance.log_progress("Installed #{fname}")
|
126
|
+
set_config('git', fname)
|
127
|
+
Config.save
|
128
|
+
end
|
77
129
|
end
|
130
|
+
[]
|
78
131
|
end
|
79
132
|
|
80
|
-
|
81
|
-
|
133
|
+
# only called after src gem build
|
134
|
+
def cleanup_prerequisites
|
135
|
+
tmp_tool_root = File.join(ENV['HOME'].gsub("\\", '/'), '.wxruby3')
|
136
|
+
path = get_cfg_string('swig')
|
137
|
+
unless path.empty? || !path.start_with?(tmp_tool_root)
|
138
|
+
path = File.dirname(path) while File.dirname(path) != tmp_tool_root
|
139
|
+
rm_rf(path)
|
140
|
+
end
|
141
|
+
path = get_cfg_string('doxygen')
|
142
|
+
unless path.empty? || !path.start_with?(tmp_tool_root)
|
143
|
+
path = File.dirname(path) while File.dirname(path) != tmp_tool_root
|
144
|
+
rm_rf(path)
|
145
|
+
end
|
146
|
+
path = get_cfg_string('git')
|
147
|
+
unless path.empty? || !path.start_with?(tmp_tool_root)
|
148
|
+
path = File.dirname(path) while File.dirname(path) != tmp_tool_root
|
149
|
+
rm_rf(path)
|
150
|
+
end
|
82
151
|
end
|
83
152
|
|
84
153
|
def expand(cmd)
|
@@ -93,6 +162,61 @@ module WXRuby3
|
|
93
162
|
super(*cmd, **kwargs)
|
94
163
|
end
|
95
164
|
|
165
|
+
private
|
166
|
+
|
167
|
+
def download_and_install(url, zip, exe, unpack_to=nil)
|
168
|
+
# make sure the download destination exists
|
169
|
+
tmp_tool_root = File.join(ENV['HOME'].gsub("\\", '/'), '.wxruby3')
|
170
|
+
dest = unpack_to ? File.join(tmp_tool_root, unpack_to) : File.join(tmp_tool_root, File.basename(zip, '.*'))
|
171
|
+
mkdir(tmp_tool_root) unless File.directory?(tmp_tool_root)
|
172
|
+
# download
|
173
|
+
chdir(tmp_tool_root) do
|
174
|
+
unless sh("curl -L #{url} --output #{zip}")
|
175
|
+
STDERR.puts "ERROR: Failed to download installation package for #{exe}"
|
176
|
+
exit(1)
|
177
|
+
end
|
178
|
+
# unpack
|
179
|
+
unless sh("powershell Expand-Archive -LiteralPath '#{zip}' -DestinationPath #{dest} -Force")
|
180
|
+
STDERR.puts "ERROR: Failed to unpack installation package for #{exe}"
|
181
|
+
exit(1)
|
182
|
+
end
|
183
|
+
# cleanup
|
184
|
+
rm_f(zip)
|
185
|
+
end
|
186
|
+
# find executable
|
187
|
+
find_exe(dest, exe)
|
188
|
+
end
|
189
|
+
|
190
|
+
def find_exe(path, exe)
|
191
|
+
fp = Dir.glob(File.join(path, '*')).find { |p| File.file?(p) && File.basename(p) == exe }
|
192
|
+
unless fp
|
193
|
+
Dir.glob(File.join(path, '*')).each do |p|
|
194
|
+
fp = find_exe(p, exe) if File.directory?(p)
|
195
|
+
return fp if fp
|
196
|
+
end
|
197
|
+
end
|
198
|
+
fp
|
199
|
+
end
|
200
|
+
|
201
|
+
def wx_make
|
202
|
+
bash('make && make install')
|
203
|
+
end
|
204
|
+
|
205
|
+
def wx_generate_xml
|
206
|
+
doxygen = get_cfg_string("doxygen")
|
207
|
+
doxygen = nix_path(doxygen) unless doxygen == 'doxygen'
|
208
|
+
chdir(File.join(ext_path, 'wxWidgets', 'docs', 'doxygen')) do
|
209
|
+
unless bash({ 'DOXYGEN' => doxygen, 'WX_SKIP_DOXYGEN_VERSION_CHECK' => '1' }, './regen.sh', 'xml')
|
210
|
+
$stderr.puts 'ERROR: Failed to generate wxWidgets XML API specifications for parsing by wxRuby3.'
|
211
|
+
exit(1)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def respawn_rake(argv = ARGV)
|
217
|
+
Kernel.exec('rake', *argv)
|
218
|
+
end
|
219
|
+
|
96
220
|
def nix_path(winpath)
|
97
221
|
(winpath.nil? || winpath.empty?) ? '' : `cygpath -a -u #{winpath}`.strip
|
98
222
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
###
|
6
|
+
# wxRuby3 buildtools platform pkg manager for Arch Linux type systems
|
7
|
+
###
|
8
|
+
|
9
|
+
module WXRuby3
|
10
|
+
|
11
|
+
module Config
|
12
|
+
|
13
|
+
module Platform
|
14
|
+
|
15
|
+
module PkgManager
|
16
|
+
|
17
|
+
PLATFORM_DEPS = %w[pkg-config gtk3 webkit2gtk gspell libunwind gstreamer curl libsecret libnotify libpng12]
|
18
|
+
|
19
|
+
class << self
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def do_install(distro, pkgs)
|
24
|
+
run_pacman(make_install_cmd(pkgs))
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_platform_pkgs(pkgs)
|
28
|
+
if pkgs.include?('g++')
|
29
|
+
pkgs.delete('g++')
|
30
|
+
pkgs << 'gcc'
|
31
|
+
end
|
32
|
+
# find pkgs we need
|
33
|
+
PLATFORM_DEPS.inject(pkgs) { |list, pkg| list << pkg unless system("pacman -Qq #{pkg} >/dev/null 2>&1"); list }
|
34
|
+
end
|
35
|
+
|
36
|
+
def run_pacman(cmd)
|
37
|
+
run("pacman -q --noconfirm #{cmd}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def make_install_cmd(pkgs)
|
41
|
+
# create install command
|
42
|
+
"-S --needed #{ pkgs.join(' ') }"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
###
|
6
|
+
# wxRuby3 buildtools platform pkg manager base
|
7
|
+
###
|
8
|
+
|
9
|
+
module WXRuby3
|
10
|
+
|
11
|
+
module Config
|
12
|
+
|
13
|
+
module Platform
|
14
|
+
|
15
|
+
module PkgManager
|
16
|
+
|
17
|
+
MIN_GENERIC_PKGS = %w[gtk3-devel patchelf g++ make git webkit2gtk3-devel gspell-devel gstreamer-devel gstreamer-plugins-base-devel libcurl-devel libsecret-devel libnotify-devel libSDL-devel zlib-devel]
|
18
|
+
|
19
|
+
class << self
|
20
|
+
|
21
|
+
def install(pkgs)
|
22
|
+
# do we need to install anything?
|
23
|
+
if !pkgs.empty? || builds_wxwidgets?
|
24
|
+
# determine the linux distro specs
|
25
|
+
distro = get_distro
|
26
|
+
begin
|
27
|
+
# load distro installation support
|
28
|
+
require_relative "./#{distro[:type]}"
|
29
|
+
rescue LoadError
|
30
|
+
# do we need to build wxWidgets?
|
31
|
+
pkgs.concat(MIN_GENERIC_PKGS) if builds_wxwidgets?
|
32
|
+
$stderr.puts <<~__ERROR_TXT
|
33
|
+
ERROR: Do not know how to install required packages for distro type '#{distro[:type]}'.
|
34
|
+
|
35
|
+
Make sure the following packages (or equivalent) are installed and than try again with `WXRUBY_NO_AUTOINSTALL=1`:
|
36
|
+
#{pkgs.join(', ')}
|
37
|
+
__ERROR_TXT
|
38
|
+
exit(1)
|
39
|
+
end
|
40
|
+
# can we install?
|
41
|
+
unless no_autoinstall? || has_sudo? || is_root?
|
42
|
+
$stderr.puts 'ERROR: Cannot check for or install required packages. Please install sudo or run as root and try again.'
|
43
|
+
exit(1)
|
44
|
+
end
|
45
|
+
# do we need to build wxWidgets?
|
46
|
+
if builds_wxwidgets?
|
47
|
+
# add platform specific packages for wxWidgets
|
48
|
+
add_platform_pkgs(pkgs)
|
49
|
+
end
|
50
|
+
# do we actually have any packages to install?
|
51
|
+
unless pkgs.empty?
|
52
|
+
# autoinstall or not?
|
53
|
+
unless wants_autoinstall?
|
54
|
+
$stderr.puts <<~__ERROR_TXT
|
55
|
+
ERROR: This system may lack installed versions of the following required software packages:
|
56
|
+
#{pkgs.join(', ')}
|
57
|
+
|
58
|
+
Install these packages and try again.
|
59
|
+
__ERROR_TXT
|
60
|
+
exit(1)
|
61
|
+
end
|
62
|
+
# do the actual install
|
63
|
+
unless do_install(distro, pkgs)
|
64
|
+
$stderr.puts <<~__ERROR_TXT
|
65
|
+
ERROR: Failed to install all or some of the following required software packages:
|
66
|
+
#{pkgs.join(', ')}
|
67
|
+
|
68
|
+
Fix any problems or install these packages yourself and try again.
|
69
|
+
__ERROR_TXT
|
70
|
+
if WXRuby3.config.run_silent?
|
71
|
+
$stderr.puts "For error details check #{WXRuby3.config.silent_log_name}"
|
72
|
+
end
|
73
|
+
exit(1)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def builds_wxwidgets?
|
82
|
+
Config.get_config('with-wxwin') && Config.get_cfg_string('wxwin').empty?
|
83
|
+
end
|
84
|
+
|
85
|
+
def no_autoinstall?
|
86
|
+
Config.get_config('autoinstall') == false
|
87
|
+
end
|
88
|
+
|
89
|
+
def wants_autoinstall?
|
90
|
+
WXRuby3.config.wants_autoinstall?
|
91
|
+
end
|
92
|
+
|
93
|
+
def has_sudo?
|
94
|
+
system('command -v sudo > /dev/null')
|
95
|
+
end
|
96
|
+
|
97
|
+
def is_root?
|
98
|
+
`id -u 2>/dev/null`.chomp == '0'
|
99
|
+
end
|
100
|
+
|
101
|
+
def run(cmd)
|
102
|
+
$stdout.print "Running #{cmd}..."
|
103
|
+
rc = WXRuby3.config.sh("#{is_root? ? '' : 'sudo '}#{cmd}")
|
104
|
+
$stderr.puts (rc ? 'done!' : 'FAILED!')
|
105
|
+
rc
|
106
|
+
end
|
107
|
+
|
108
|
+
def expand(cmd)
|
109
|
+
`#{is_root? ? '' : 'sudo '}#{cmd}`
|
110
|
+
end
|
111
|
+
|
112
|
+
def get_distro
|
113
|
+
if File.file?('/etc/os-release') # works with most (if not all) recent distro releases
|
114
|
+
data = File.readlines('/etc/os-release').reduce({}) do |hash, line|
|
115
|
+
val, var = line.split('=')
|
116
|
+
hash[val] = var.strip.gsub(/(\A")|("\Z)/, '')
|
117
|
+
hash
|
118
|
+
end
|
119
|
+
{
|
120
|
+
type: if data['ID_LIKE']
|
121
|
+
data['ID_LIKE'].split.first.to_sym
|
122
|
+
elsif File.file?('/etc/redhat-release')
|
123
|
+
:rhel
|
124
|
+
elsif File.file?('/etc/SUSE-brand') || File.file?('/etc/SuSE-release')
|
125
|
+
:suse
|
126
|
+
elsif File.file?('/etc/debian_version')
|
127
|
+
:debian
|
128
|
+
else
|
129
|
+
data['ID'].to_sym
|
130
|
+
end,
|
131
|
+
distro: data['ID'].downcase,
|
132
|
+
release: data['VERSION_ID']
|
133
|
+
}
|
134
|
+
elsif File.file?('/etc/redhat-release')
|
135
|
+
data = File.read('/etc/redhat-release').strip
|
136
|
+
{
|
137
|
+
type: :rhel,
|
138
|
+
distro: data.split.shift.downcase,
|
139
|
+
release: data =~ /\d+(\.\d+)*/ ? $~[0] : ''
|
140
|
+
}
|
141
|
+
elsif File.file?('/etc/SUSE-brand') || File.file?('/etc/SuSE-release')
|
142
|
+
data = File.readlines(File.file?('/etc/SUSE-brand') ? '/etc/SUSE-brand' : '/etc/SuSE-release')
|
143
|
+
{
|
144
|
+
type: :suse,
|
145
|
+
distro: data.shift.split.shift.downcase,
|
146
|
+
release: (data.find { |s| s.strip =~ /\AVERSION\s*=/ } || '').split('=').last || ''
|
147
|
+
}
|
148
|
+
elsif File.file?('/etc/debian_version')
|
149
|
+
{
|
150
|
+
type: :debian,
|
151
|
+
distro: 'generic',
|
152
|
+
release: File.read('/etc/debian_version').strip
|
153
|
+
}
|
154
|
+
else
|
155
|
+
{
|
156
|
+
type: :unknown
|
157
|
+
}
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
###
|
6
|
+
# wxRuby3 buildtools platform pkg manager for Debian type systems
|
7
|
+
###
|
8
|
+
|
9
|
+
module WXRuby3
|
10
|
+
|
11
|
+
module Config
|
12
|
+
|
13
|
+
module Platform
|
14
|
+
|
15
|
+
module PkgManager
|
16
|
+
|
17
|
+
PLATFORM_DEPS = %w[libgtk-3-dev libwebkit2gtk-4.0-dev libgspell-1-dev libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libcurl4-openssl-dev libsecret-1-dev libnotify-dev]
|
18
|
+
|
19
|
+
class << self
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def do_install(distro, pkgs)
|
24
|
+
run_apt(make_install_cmd(pkgs))
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_platform_pkgs(pkgs)
|
28
|
+
# get architecture
|
29
|
+
arch = expand('dpkg --print-architecture').strip
|
30
|
+
# find pkgs we need
|
31
|
+
PLATFORM_DEPS.inject(pkgs) do |list, pkg|
|
32
|
+
list << pkg unless (system("dpkg-query -s \"#{pkg}:#{arch}\" >/dev/null 2>&1") ||
|
33
|
+
system("dpkg-query -s \"#{pkg}:all\" >/dev/null 2>&1") ||
|
34
|
+
(expand("dpkg-query -s \"#{pkg}\" 2>/dev/null").strip =~ /Architecture: (#{arch}|all)/))
|
35
|
+
list
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def run_apt(cmd)
|
40
|
+
run("DEBIAN_FRONTEND=noninteractive apt-get -q -o=Dpkg::Use-Pty=0 #{cmd}")
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_pkgs
|
44
|
+
run_apt('update')
|
45
|
+
end
|
46
|
+
|
47
|
+
def make_install_cmd(pkgs)
|
48
|
+
# update cache
|
49
|
+
update_pkgs
|
50
|
+
# get list of available packages
|
51
|
+
apt_cache = `apt-cache pkgnames`.chomp.split("\n").collect { |s| s.strip }
|
52
|
+
# remove un-installables
|
53
|
+
pkgs = pkgs.select { |pkg| apt_cache.include?(pkg) }
|
54
|
+
# create install command
|
55
|
+
"install -y #{ pkgs.join(' ') }"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
###
|
6
|
+
# wxRuby3 buildtools MacOSX pkg manager
|
7
|
+
###
|
8
|
+
|
9
|
+
module WXRuby3
|
10
|
+
|
11
|
+
module Config
|
12
|
+
|
13
|
+
module Platform
|
14
|
+
|
15
|
+
module PkgManager
|
16
|
+
|
17
|
+
class << self
|
18
|
+
|
19
|
+
def install(pkgs)
|
20
|
+
# do we need to install anything?
|
21
|
+
if !pkgs.empty?
|
22
|
+
# can we install XCode commandline tools?
|
23
|
+
unless no_autoinstall? || !pkgs.include?('xcode') || has_sudo? || is_root?
|
24
|
+
STDERR.puts 'ERROR: Cannot check for or install required packages. Please install sudo or run as root and try again.'
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
|
28
|
+
# autoinstall or not?
|
29
|
+
unless pkgs.empty? || wants_autoinstall?
|
30
|
+
$stderr.puts <<~__ERROR_TXT
|
31
|
+
ERROR: This system may lack installed versions of the following required software packages:
|
32
|
+
#{pkgs.join(', ')}
|
33
|
+
|
34
|
+
Install these packages and try again.
|
35
|
+
__ERROR_TXT
|
36
|
+
exit(1)
|
37
|
+
end
|
38
|
+
# do the actual install (or nothing)
|
39
|
+
unless do_install(pkgs)
|
40
|
+
$stderr.puts <<~__ERROR_TXT
|
41
|
+
ERROR: Failed to install all or some of the following required software packages:
|
42
|
+
#{pkgs.join(', ')}
|
43
|
+
|
44
|
+
Fix any problems or install these packages yourself and try again.
|
45
|
+
__ERROR_TXT
|
46
|
+
exit(1)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def do_install(pkgs)
|
54
|
+
rc = true
|
55
|
+
# first see if we need to install XCode commandline tools
|
56
|
+
if pkgs.include?('xcode')
|
57
|
+
pkgs.delete('xcode')
|
58
|
+
rc = run('xcode-select --install')
|
59
|
+
end
|
60
|
+
# now check if we need any other packages (which need Homebrew or MacPorts)
|
61
|
+
if rc && !pkgs.empty?
|
62
|
+
# Has Ruby been installed through MacPorts?
|
63
|
+
if has_macports? &&
|
64
|
+
(ruby_info = expand('port -q installed installed').strip.split("\n").find { |ln| ln.strip =~ /\Aruby\d+\s/ })
|
65
|
+
|
66
|
+
# this is really crap; with MacPorts we need to install swig-ruby instead of simply swig
|
67
|
+
# which for whatever nonsensical reason will pull in another (older) Ruby version (probably 2.3 or such)
|
68
|
+
# although SWIG's Ruby support is version agnostic and has no binary bindings
|
69
|
+
if pkgs.include?('swig')
|
70
|
+
pkgs.delete('swig')
|
71
|
+
pkgs << 'swig-ruby'
|
72
|
+
end
|
73
|
+
# in case MacPorts was installed with root privileges this install would also have to be run
|
74
|
+
# with root privileges (otherwise it would fail early on with access problems) so we can
|
75
|
+
# just run without sudo as we either have root privileges for root-installed MacPorts or
|
76
|
+
# we're running without root privileges for user-installed MacPorts
|
77
|
+
pkgs.each { |pkg| rc &&= sh("port install #{pkg}") }
|
78
|
+
|
79
|
+
# or are we running without root privileges and have Homebrew installed?
|
80
|
+
# (Ruby may be installed using Homebrew itself or using a Ruby version manager like RVM)
|
81
|
+
elsif !is_root? && has_homebrew?
|
82
|
+
|
83
|
+
pkgs.each { |pkg| rc &&= sh("brew install #{pkg}") }
|
84
|
+
|
85
|
+
# or do we have MacPorts (running either privileged or not) and
|
86
|
+
# a Ruby installed using a Ruby version manager.
|
87
|
+
elsif has_macports?
|
88
|
+
|
89
|
+
# same crap as above
|
90
|
+
if pkgs.include?('swig')
|
91
|
+
pkgs.delete('swig')
|
92
|
+
pkgs << 'swig-ruby'
|
93
|
+
end
|
94
|
+
# in case MacPorts was installed with root privileges this install would also have to be run
|
95
|
+
# with root privileges (otherwise it would fail early on with access problems) so we can
|
96
|
+
# just run without sudo as we either have root privileges for root-installed MacPorts or
|
97
|
+
# we're running without root privileges for user-installed MacPorts
|
98
|
+
pkgs.each { |pkg| rc &&= sh("port install #{pkg}") }
|
99
|
+
|
100
|
+
else
|
101
|
+
if has_homebrew? || is_root?
|
102
|
+
$stderr.puts <<~__ERROR_TXT
|
103
|
+
ERROR: Unsupported Ruby installation. wxRuby3 can only be installed for Ruby with root privileges
|
104
|
+
in case Ruby was installed with MacPorts. Homebrew should not be run with root privileges.
|
105
|
+
|
106
|
+
Re-install a supported Ruby setup and try again.
|
107
|
+
__ERROR_TXT
|
108
|
+
else
|
109
|
+
$stderr.puts <<~__ERROR_TXT
|
110
|
+
ERROR: Unsupported Ruby installation. wxRuby3 requires either a MacPorts installed Ruby version
|
111
|
+
or a non-privileged Ruby installation and have Homebrew installed.
|
112
|
+
|
113
|
+
Install either Homebrew or MacPorts and try again.
|
114
|
+
__ERROR_TXT
|
115
|
+
end
|
116
|
+
exit(1)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
rc
|
120
|
+
end
|
121
|
+
|
122
|
+
def builds_wxwidgets?
|
123
|
+
Config.get_config('with-wxwin') && Config.get_cfg_string('wxwin').empty?
|
124
|
+
end
|
125
|
+
|
126
|
+
def no_autoinstall?
|
127
|
+
Config.get_config('autoinstall') == false
|
128
|
+
end
|
129
|
+
|
130
|
+
def wants_autoinstall?
|
131
|
+
WXRuby3.config.wants_autoinstall?
|
132
|
+
end
|
133
|
+
|
134
|
+
def has_sudo?
|
135
|
+
system('command -v sudo > /dev/null')
|
136
|
+
end
|
137
|
+
|
138
|
+
def is_root?
|
139
|
+
if @is_root.nil?
|
140
|
+
@is_root = (`id -u 2>/dev/null`.chomp == '0')
|
141
|
+
end
|
142
|
+
@is_root
|
143
|
+
end
|
144
|
+
|
145
|
+
def has_macports?
|
146
|
+
if @has_macports.nil?
|
147
|
+
@has_macports = system('command -v port>/dev/null')
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def has_homebrew?
|
152
|
+
if @has_homebrew.nil?
|
153
|
+
@has_homebrew = system('command -v brew>/dev/null')
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def run(cmd)
|
158
|
+
$stdout.print "Running #{cmd}..."
|
159
|
+
rc = WXRuby3.config.sh("#{is_root? ? '' : 'sudo '}#{cmd}")
|
160
|
+
$stderr.puts (rc ? 'done!' : 'FAILED!')
|
161
|
+
rc
|
162
|
+
end
|
163
|
+
|
164
|
+
def sh(*cmd, title: nil)
|
165
|
+
$stdout.print(title ? title : "Running #{cmd}...")
|
166
|
+
rc = WXRuby3.config.sh(*cmd)
|
167
|
+
$stderr.puts (rc ? 'done!' : 'FAILED!')
|
168
|
+
rc
|
169
|
+
end
|
170
|
+
|
171
|
+
def expand(cmd)
|
172
|
+
WXRuby3.config.expand(cmd)
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|