-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
181 lines (157 loc) · 4.26 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# -*- ruby -*-
#
# Copyright(C) 2023 Sutou Kouhei <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
require "json"
require "pathname"
require_relative "../version"
groonga_repository = ENV["GROONGA_REPOSITORY"]
if groonga_repository.nil?
raise "Specify GROONGA_REPOSITORY environment variable"
end
require "#{groonga_repository}/packages/packages-groonga-org-package-task"
class GroongaNginxPackageTask < PackagesGroongaOrgPackageTask
def initialize
super("groonga-nginx",
ENV["VERSION"] || GroongaNginx::VERSION,
detect_release_time)
end
private
def detect_release_time
release_time_env = ENV["RELEASE_TIME"] || ENV["NEW_RELEASE_DATE"]
if release_time_env
Time.parse(release_time_env).utc
else
Time.now.utc
end
end
def top_directory
packages_directory.parent
end
def packages_directory
Pathname(__dir__)
end
def original_archive_path
top_directory + @archive_name
end
def define_archive_task
unless original_archive_path.exist?
downloaded_original_archive_path =
top_directory +
"packages" +
"source" +
"tmp" +
"downloads" +
@version +
original_archive_path.basename
file original_archive_path.to_s => downloaded_original_archive_path.to_s do
ln_s(downloaded_original_archive_path,
original_archive_path)
end
end
[@archive_name, deb_archive_name, rpm_archive_name].each do |archive_name|
file archive_name => original_archive_path.to_s do
sh("tar", "xf", original_archive_path.to_s)
archive_base_name = File.basename(archive_name, ".tar.gz")
if @archive_base_name != archive_base_name
mv(@archive_base_name, archive_base_name)
end
sh("tar", "czf", archive_name, archive_base_name)
rm_r(archive_base_name)
end
end
end
def github_repository
"groonga/groonga-nginx"
end
def apt_targets_default
[
"debian-bookworm",
"debian-bookworm-arm64",
]
end
def latest_groonga_version
@latest_groonga_version ||= detect_latest_groonga_version
end
def detect_latest_groonga_version
releases_uri = URI("https://api.github.com/repos/groonga/groonga/releases")
releases_uri.open do |releases_output|
releases = JSON.parse(releases_output.read)
releases[0]["tag_name"].delete_prefix("v")
end
end
def apt_prepare_debian_control(control_in, target)
substitute_content(control_in) do |key, matched|
apt_expand_variable(key) || matched
end
end
def apt_expand_variable(key)
case key
when "GROONGA_VERSION"
latest_groonga_version
else
nil
end
end
def ubuntu_targets_default
[
["noble", "24.04"],
]
end
def enable_yum?
false
end
def source_targets_default
[
@archive_name,
]
end
def use_built_package?
true
end
def use_packages_groonga_org?(target_namespace)
case target_namespace
when :source
false
else
true
end
end
def built_package_url(target_namespace, target)
case target_namespace
when :apt
if target.end_with?("-arm64")
base_name = "#{target}.tar.gz"
else
base_name = "#{target}-amd64.tar.gz"
end
when :yum
if target.end_with?("-aarch64")
base_name = "#{target}.tar.gz"
else
base_name = "#{target}-x86_64.tar.gz"
end
else
base_name = target
end
github_download_url(base_name)
end
def built_package_n_split_components
3
end
end
task = GroongaNginxPackageTask.new
task.define