rubygems-requirements-system 0.0.1 → 0.0.2
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/README.md +95 -3
- data/doc/text/news.md +10 -0
- data/lib/rubygems-requirements-system/os-release.rb +8 -0
- data/lib/rubygems-requirements-system/platform/base.rb +26 -9
- data/lib/rubygems-requirements-system/platform/debian.rb +28 -2
- data/lib/rubygems-requirements-system/platform/fedora.rb +24 -3
- data/lib/rubygems-requirements-system/platform/red-hat-enterprise-linux.rb +6 -13
- data/lib/rubygems-requirements-system/platform/ubuntu.rb +24 -0
- data/lib/rubygems-requirements-system/version.rb +1 -1
- metadata +2 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 598b91ef023d6606d97e7bfc74168cef0316de0897c63266c7371ef844322d6a
|
4
|
+
data.tar.gz: 99fe81ea125044711118147950372853e17377a25306b09e20f9ca0f3369e43e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0dbff35b8e7ccfd004b78bfcf26efe011afd87106c646ba02093c4c7e076f568ebc8d65b96dc3ce15d2ed739780de8504557a412f5e4a1e21a2a38c15e6f735
|
7
|
+
data.tar.gz: 89933a20c0aa2129b871df4a70d445bb856258959889a225849f25030d55de60252470db5e540e3a3fd12cedc4773ca5c78712d170183aa393948267419ea2b2
|
data/README.md
CHANGED
@@ -52,6 +52,8 @@ Gem::Specification.new do |spec|
|
|
52
52
|
end
|
53
53
|
```
|
54
54
|
|
55
|
+
### Basic usage
|
56
|
+
|
55
57
|
Add dependency information to `Gem::Specification#requirements`:
|
56
58
|
|
57
59
|
```ruby
|
@@ -77,6 +79,8 @@ Gem::Specification.new do |spec|
|
|
77
79
|
end
|
78
80
|
```
|
79
81
|
|
82
|
+
### OR dependency
|
83
|
+
|
80
84
|
You can require dependency A or B. For example, you can require
|
81
85
|
`mysqlclient` or `libmariadb`.
|
82
86
|
|
@@ -85,14 +89,23 @@ Gem::Specification.new do |spec|
|
|
85
89
|
# ...
|
86
90
|
|
87
91
|
# We need mysqliclient or libmariadb for this gem.
|
88
|
-
|
89
|
-
|
92
|
+
|
93
|
+
# Try libmysqlclient-dev and then libmariadb-dev on Ubuntu. Because
|
94
|
+
# "debian: libmariadb-dev" is also used on Ubuntu.
|
95
|
+
#
|
96
|
+
# mysqlclient or libmariadb will be satsfied by a system package.
|
97
|
+
spec.requirements << "system: mysqlclient|libmariadb: ubuntu: libmysqlclient-dev"
|
98
|
+
# Try only libmariadb-dev on Debian.
|
99
|
+
#
|
100
|
+
# libmariadb will be satsfied by a system package.
|
90
101
|
spec.requirements << "system: mysqlclient|libmariadb: debian: libmariadb-dev"
|
91
102
|
|
92
103
|
# ...
|
93
104
|
end
|
94
105
|
```
|
95
106
|
|
107
|
+
### Multiple packages per dependency
|
108
|
+
|
96
109
|
You can install multiple packages for a dependency.
|
97
110
|
|
98
111
|
```ruby
|
@@ -115,6 +128,85 @@ Gem::Specification.new do |spec|
|
|
115
128
|
end
|
116
129
|
```
|
117
130
|
|
131
|
+
### Install packages via HTTPS
|
132
|
+
|
133
|
+
You can install `.deb`/`.rpm` via HTTPS. If a product provides its
|
134
|
+
APT/Yum repository configurations by `.deb`/`.rpm`, you can use this
|
135
|
+
feature to register additional APT/Yum repositories.
|
136
|
+
|
137
|
+
You can use placeholder for URL with `%{KEY}` format.
|
138
|
+
|
139
|
+
Here are available placeholders:
|
140
|
+
|
141
|
+
`debian` family platforms:
|
142
|
+
|
143
|
+
* `distribution`: The `ID` value in `/etc/os-release`. It's `debian`,
|
144
|
+
`ubuntu` and so on.
|
145
|
+
* `code_name`: The `VERSION_CODENAME` value in `/etc/os-release`. It's
|
146
|
+
`bookworm`, `noble` and so on.
|
147
|
+
* `version`: The `VERSION_ID` value in `/etc/os-release`. It's `12`,
|
148
|
+
`24.04` and so on.
|
149
|
+
|
150
|
+
`fedora` family platforms:
|
151
|
+
|
152
|
+
* `distribution`: The `ID` value in `/etc/os-release`. It's `fedora`,
|
153
|
+
`rhel`, `almalinux` and so on.
|
154
|
+
* `major_version`: The major part of `VERSION_ID` value in
|
155
|
+
`/etc/os-release`. It's `41`, `9` and so on.
|
156
|
+
* `version`: The `VERSION_ID` value in `/etc/os-release`. It's `41`,
|
157
|
+
`9.5` and so on.
|
158
|
+
|
159
|
+
Here is an example that uses this feature for adding new repositories:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
Gem::Specification.new do |spec|
|
163
|
+
# ...
|
164
|
+
|
165
|
+
# Install Groonga's APT repository for libgroonga-dev on Debian
|
166
|
+
# family platforms.
|
167
|
+
#
|
168
|
+
# %{distribution} and %{code_name} are placeholders.
|
169
|
+
#
|
170
|
+
# On Debian GNU/Linux bookworm:
|
171
|
+
# https://packages.groonga.org/%{distribution}/groonga-apt-source-latest-%{code_name}.deb ->
|
172
|
+
# https://packages.groonga.org/debian/groonga-apt-source-latest-bookworm.deb
|
173
|
+
#
|
174
|
+
# On Ubuntu 24.04:
|
175
|
+
# https://packages.groonga.org/%{distribution}/groonga-apt-source-latest-%{code_name}.deb ->
|
176
|
+
# https://packages.groonga.org/ubuntu/groonga-apt-source-latest-nobole.deb
|
177
|
+
spec.requirements << "system: groonga: debian: https://packages.groonga.org/%{distribution}/groonga-apt-source-latest-%{code_name}.deb"
|
178
|
+
# Install libgroonga-dev from the registered repository.
|
179
|
+
spec.requirements << "system: groonga: debian: libgroonga-dev"
|
180
|
+
|
181
|
+
# Install 2 repositories for pkgconfig(groonga) package on RHEL
|
182
|
+
# family plaforms:
|
183
|
+
# 1. Apache Arrow: https://apache.jfrog.io/artifactory/arrow/almalinux/%{major_version}/apache-arrow-release-latest.rpm
|
184
|
+
# 2. Groonga: https://packages.groonga.org/almalinux/%{major_version}/groonga-release-latest.noarch.rpm
|
185
|
+
#
|
186
|
+
# %{major_version} is placeholder.
|
187
|
+
#
|
188
|
+
# On AlmaLinux 8:
|
189
|
+
# https://apache.jfrog.io/artifactory/arrow/almalinux/%{major_version}/apache-arrow-release-latest.rpm ->
|
190
|
+
# https://apache.jfrog.io/artifactory/arrow/almalinux/8/apache-arrow-release-latest.rpm
|
191
|
+
#
|
192
|
+
# https://packages.groonga.org/almalinux/%{major_version}/groonga-release-latest.noarch.rpm ->
|
193
|
+
# https://packages.groonga.org/almalinux/8/groonga-release-latest.noarch.rpm
|
194
|
+
#
|
195
|
+
# On AlmaLinux 9:
|
196
|
+
# https://apache.jfrog.io/artifactory/arrow/almalinux/%{major_version}/apache-arrow-release-latest.rpm ->
|
197
|
+
# https://apache.jfrog.io/artifactory/arrow/almalinux/9/apache-arrow-release-latest.rpm
|
198
|
+
#
|
199
|
+
# https://packages.groonga.org/almalinux/%{major_version}/groonga-release-latest.noarch.rpm ->
|
200
|
+
# https://packages.groonga.org/almalinux/9/groonga-release-latest.noarch.rpm
|
201
|
+
spec.requirements << "system: groonga: rhel: https://apache.jfrog.io/artifactory/arrow/almalinux/%{major_version}/apache-arrow-release-latest.rpm"
|
202
|
+
spec.requirements << "system: groonga: rhel: https://packages.groonga.org/almalinux/%{major_version}/groonga-release-latest.noarch.rpm"
|
203
|
+
# Install pkgconfig(groonga) from the registered repositories.
|
204
|
+
spec.requirements << "system: groonga: rhel: pkgconfig(groonga)"
|
205
|
+
|
206
|
+
# ...
|
207
|
+
end
|
208
|
+
```
|
209
|
+
|
118
210
|
## Requirements
|
119
211
|
|
120
212
|
RubyGems 3.5.0 or later is required. RubyGems can load installed
|
@@ -136,6 +228,6 @@ other word than "native". So we create a new gem.
|
|
136
228
|
|
137
229
|
## License
|
138
230
|
|
139
|
-
Copyright (C)
|
231
|
+
Copyright (C) 2025 Ruby-GNOME Project Team
|
140
232
|
|
141
233
|
LGPL-3 or later. See doc/text/lgpl-3.txt for details.
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 0.0.2 - 2025-01-08
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* debian: Added support for installing `.deb` via HTTPS.
|
8
|
+
|
9
|
+
* ubuntu: Added support for PPA repository.
|
10
|
+
|
11
|
+
* fedora: Added support for installing `.rpm` via HTTPS.
|
12
|
+
|
3
13
|
## 0.0.1 - 2025-01-08
|
4
14
|
|
5
15
|
Initial release!!!
|
@@ -14,6 +14,8 @@
|
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
16
|
require "fileutils"
|
17
|
+
require "open-uri"
|
18
|
+
require "tempfile"
|
17
19
|
|
18
20
|
require_relative "../executable-finder"
|
19
21
|
require_relative "../os-release"
|
@@ -79,19 +81,34 @@ module RubyGemsRequirementsSystem
|
|
79
81
|
super_user?
|
80
82
|
end
|
81
83
|
|
84
|
+
def temporary_file_scope
|
85
|
+
@temporary_files = []
|
86
|
+
begin
|
87
|
+
yield
|
88
|
+
ensure
|
89
|
+
@temporary_files.each(&:close!)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def create_temporary_file(basename)
|
94
|
+
file = Tempfile.new(basename)
|
95
|
+
@temporary_files << file
|
96
|
+
file
|
97
|
+
end
|
98
|
+
|
82
99
|
def install_package(package)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
100
|
+
temporary_file_scope do
|
101
|
+
prepare_command_lines(package).each do |command_line|
|
102
|
+
unless run_command_line(package, "prepare", command_line)
|
103
|
+
return false
|
104
|
+
end
|
87
105
|
end
|
106
|
+
run_command_line(package, "install", install_command_line(package))
|
88
107
|
end
|
89
|
-
run_command_line(package, "install", install_command_line(package))
|
90
108
|
end
|
91
109
|
|
92
110
|
def run_command_line(package, action, command_line)
|
93
111
|
failed_to_get_super_user_priviledge = false
|
94
|
-
command_line = install_command_line(package)
|
95
112
|
if have_priviledge?
|
96
113
|
succeeded = system(*command_line)
|
97
114
|
else
|
@@ -118,13 +135,13 @@ module RubyGemsRequirementsSystem
|
|
118
135
|
alert_warning("'#{package}' system package is required.")
|
119
136
|
alert_warning("Run the following command " +
|
120
137
|
"to #{action} required system package: " +
|
121
|
-
|
138
|
+
escaped_command_line.join(" "))
|
122
139
|
end
|
123
140
|
succeeded
|
124
141
|
end
|
125
142
|
|
126
|
-
def
|
127
|
-
|
143
|
+
def prepare_command_lines(package)
|
144
|
+
[]
|
128
145
|
end
|
129
146
|
|
130
147
|
def install_command_line(package)
|
@@ -43,11 +43,28 @@ module RubyGemsRequirementsSystem
|
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
46
|
-
def
|
47
|
-
[
|
46
|
+
def prepare_command_lines(package)
|
47
|
+
[
|
48
|
+
["apt-get", "update"],
|
49
|
+
]
|
48
50
|
end
|
49
51
|
|
50
52
|
def install_command_line(package)
|
53
|
+
if package.start_with?("https://")
|
54
|
+
package_url = resolve_package_url_template(package)
|
55
|
+
temporary_file_base_name = [
|
56
|
+
"rubygems-requirements-system-debian",
|
57
|
+
File.extname(package),
|
58
|
+
]
|
59
|
+
local_package = create_temporary_file(temporary_file_base_name)
|
60
|
+
URI.open(package_url) do |response|
|
61
|
+
IO.copy_stream(response, local_package)
|
62
|
+
end
|
63
|
+
local_package.close
|
64
|
+
@temporary_files << local_package
|
65
|
+
FileUtils.chmod("go+r", local_package.path)
|
66
|
+
package = local_package.path
|
67
|
+
end
|
51
68
|
[
|
52
69
|
"env",
|
53
70
|
"DEBIAN_FRONTEND=noninteractive",
|
@@ -62,6 +79,15 @@ module RubyGemsRequirementsSystem
|
|
62
79
|
def need_super_user_priviledge?
|
63
80
|
true
|
64
81
|
end
|
82
|
+
|
83
|
+
def resolve_package_url_template(package_url_template)
|
84
|
+
os_release = OSRelease.new
|
85
|
+
package_url_template % {
|
86
|
+
distribution: os_release.id,
|
87
|
+
code_name: os_release.version_codename,
|
88
|
+
version: os_release.version_id,
|
89
|
+
}
|
90
|
+
end
|
65
91
|
end
|
66
92
|
end
|
67
93
|
end
|
@@ -13,11 +13,11 @@
|
|
13
13
|
# You should have received a copy of the GNU Lesser General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
-
require_relative "
|
16
|
+
require_relative "base"
|
17
17
|
|
18
18
|
module RubyGemsRequirementsSystem
|
19
19
|
module Platform
|
20
|
-
class Fedora <
|
20
|
+
class Fedora < Base
|
21
21
|
Platform.register(self)
|
22
22
|
|
23
23
|
class << self
|
@@ -28,17 +28,38 @@ module RubyGemsRequirementsSystem
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def target?(platform)
|
31
|
-
platform == "fedora"
|
31
|
+
platform == "fedora"
|
32
|
+
end
|
33
|
+
|
34
|
+
def default_system_packages(packages)
|
35
|
+
packages.collect {|package| "pkgconfig(#{package.id})"}
|
32
36
|
end
|
33
37
|
|
34
38
|
private
|
35
39
|
def install_command_line(package)
|
40
|
+
if package.start_with?("https://")
|
41
|
+
package = resolve_package_url_template(package)
|
42
|
+
end
|
36
43
|
["dnf", "install", "-y", package]
|
37
44
|
end
|
38
45
|
|
39
46
|
def need_super_user_priviledge?
|
40
47
|
true
|
41
48
|
end
|
49
|
+
|
50
|
+
def resolve_package_url_template(package_url_template)
|
51
|
+
os_release = OSRelease.new
|
52
|
+
package_url_template % {
|
53
|
+
distribution: os_release.id,
|
54
|
+
major_version: major_version.to_s,
|
55
|
+
version: os_release.version_id,
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def major_version
|
60
|
+
major_version_string = OSRelease.new.version_id.split(".")[0]
|
61
|
+
Integer(major_version_string, 10)
|
62
|
+
end
|
42
63
|
end
|
43
64
|
end
|
44
65
|
end
|
@@ -13,11 +13,11 @@
|
|
13
13
|
# You should have received a copy of the GNU Lesser General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
-
require_relative "
|
16
|
+
require_relative "fedora"
|
17
17
|
|
18
18
|
module RubyGemsRequirementsSystem
|
19
19
|
module Platform
|
20
|
-
class RedHatEnterpriseLinux <
|
20
|
+
class RedHatEnterpriseLinux < Fedora
|
21
21
|
Platform.register(self)
|
22
22
|
|
23
23
|
class << self
|
@@ -34,17 +34,15 @@ module RubyGemsRequirementsSystem
|
|
34
34
|
when "redhat" # For backward compatibility
|
35
35
|
true
|
36
36
|
else
|
37
|
-
|
37
|
+
super
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def default_system_packages(packages)
|
42
|
-
packages.collect {|package| "pkgconfig(#{package.id})"}
|
43
|
-
end
|
44
|
-
|
45
41
|
private
|
46
|
-
|
47
42
|
def install_command_line(package)
|
43
|
+
if package.start_with?("https://")
|
44
|
+
package = resolve_package_url_template(package)
|
45
|
+
end
|
48
46
|
if major_version >= 9
|
49
47
|
["dnf", "install", "--enablerepo=crb", "-y", package]
|
50
48
|
elsif major_version >= 8
|
@@ -57,11 +55,6 @@ module RubyGemsRequirementsSystem
|
|
57
55
|
def need_super_user_priviledge?
|
58
56
|
true
|
59
57
|
end
|
60
|
-
|
61
|
-
def major_version
|
62
|
-
major_version_string = File.read("/etc/redhat-release")[/(\d+)/, 0]
|
63
|
-
Integer(major_version_string, 10)
|
64
|
-
end
|
65
58
|
end
|
66
59
|
end
|
67
60
|
end
|
@@ -36,6 +36,30 @@ module RubyGemsRequirementsSystem
|
|
36
36
|
def target?(platform)
|
37
37
|
platform == "ubuntu" || super
|
38
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def prepare_command_lines(package)
|
42
|
+
if package.start_with?("ppa:")
|
43
|
+
[
|
44
|
+
["apt-get", "update"],
|
45
|
+
install_command_line("software-properties-common"),
|
46
|
+
]
|
47
|
+
else
|
48
|
+
super
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def install_command_line(package)
|
53
|
+
if package.start_with?("ppa:")
|
54
|
+
[
|
55
|
+
"add-apt-repository",
|
56
|
+
"-y",
|
57
|
+
package,
|
58
|
+
]
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
39
63
|
end
|
40
64
|
end
|
41
65
|
end
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems-requirements-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sutou Kouhei
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
10
|
date: 2025-01-08 00:00:00.000000000 Z
|
@@ -72,7 +71,6 @@ homepage: https://github.com/ruby-gnome/rubygems-requirements-system
|
|
72
71
|
licenses:
|
73
72
|
- LGPL-3.0-or-later
|
74
73
|
metadata: {}
|
75
|
-
post_install_message:
|
76
74
|
rdoc_options: []
|
77
75
|
require_paths:
|
78
76
|
- lib
|
@@ -87,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
85
|
- !ruby/object:Gem::Version
|
88
86
|
version: '0'
|
89
87
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
91
|
-
signing_key:
|
88
|
+
rubygems_version: 3.6.2
|
92
89
|
specification_version: 4
|
93
90
|
summary: Users can install system packages automatically on "gem install"
|
94
91
|
test_files: []
|