Skip to content

Commit 1c8c959

Browse files
authored
Create ucrt64-3.0 package with OpenSSL 3, Actions only push & cron (#2)
1 parent 234f8d7 commit 1c8c959

File tree

4 files changed

+104
-31
lines changed

4 files changed

+104
-31
lines changed

.github/workflows/mswin.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Windows MSWin Build Tools
22

33
on:
4-
pull_request:
5-
branches:
6-
- '*'
74
push:
85
branches:
96
- '*'

.github/workflows/windows-build-tools.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Windows MSYS2 Build Tools
22

33
on:
4-
pull_request:
5-
branches:
6-
- '*'
74
push:
85
branches:
96
- '*'
@@ -51,8 +48,9 @@ jobs:
5148
fail-fast: false
5249
matrix:
5350
include:
54-
- { gcc: mingw64, ruby: mingw }
55-
- { gcc: ucrt64 , ruby: ucrt }
51+
- { gcc: mingw64 , ruby: mingw }
52+
- { gcc: ucrt64 , ruby: ucrt }
53+
- { gcc: ucrt64-3.0 , ruby: head }
5654
steps:
5755
- name: Checkout
5856
uses: actions/checkout@v3

common.rb

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,49 @@ def response_ok(response_obj, msg, actions_group: false)
128128
end
129129
end
130130

131+
def download(uri_s, file)
132+
retry_max = 3
133+
retries = 0
134+
uri = URI uri_s
135+
redirect = nil
136+
begin
137+
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
138+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
139+
req = Net::HTTP::Get.new uri.request_uri
140+
http.request req do |resp|
141+
req['Connection'] = 'close'
142+
case resp
143+
when Net::HTTPSuccess then
144+
File.open file, 'wb' do |io|
145+
resp.read_body do |chunk|
146+
io.write chunk
147+
end
148+
end
149+
when Net::HTTPRedirection then
150+
redirect = resp['location']
151+
warn "redirected to #{URI(redirect).host}"
152+
else
153+
puts "Unknown issue connecting to:\n#{uri}\nCode: #{resp.code} Class: #{resp.class}"
154+
resp.value
155+
end
156+
end
157+
end
158+
rescue Errno::ECONNRESET => e
159+
if retries > retry_max
160+
raise e
161+
else
162+
puts "Retry"
163+
retries += 1
164+
sleep 2
165+
retry
166+
end
167+
end
168+
download(redirect, file) if redirect
169+
rescue => e
170+
STDOUT.syswrite "\nCannot connect to:\n#{uri.host}\n#{uri.request_uri}\n#{File.basename file}\n\n"
171+
raise e
172+
end
173+
131174
def upload_7z_update(pkg_name, time)
132175
resp_obj = nil
133176
body = nil
@@ -158,11 +201,6 @@ def upload_7z_update(pkg_name, time)
158201

159202
exit 1 if resp_obj.is_a? Net::HTTPResponse
160203

161-
unless current_asset_id
162-
STDOUT.syswrite "#{END_GROUP}#{RED}current asset #{pkg_name}.7z not found#{RST}\n"
163-
exit 1
164-
end
165-
166204
if old_asset_exists
167205
STDOUT.syswrite "#{END_GROUP}#{RED}old asset #{pkg_name}_old.7z exists#{RST}\n"
168206
exit 1
@@ -202,17 +240,21 @@ def upload_7z_update(pkg_name, time)
202240
gh_api_http do |http|
203241
time_start = Process.clock_gettime Process::CLOCK_MONOTONIC
204242

205-
resp_obj = gh_api_v3_patch http, USER_REPO, "releases/assets/#{current_asset_id}", {'name' => "#{pkg_name}_old.7z"}
206-
break unless response_ok resp_obj, 'PATCH - rename current asset to old', actions_group: true
243+
if current_asset_id
244+
resp_obj = gh_api_v3_patch http, USER_REPO, "releases/assets/#{current_asset_id}", {'name' => "#{pkg_name}_old.7z"}
245+
break unless response_ok resp_obj, 'PATCH - rename current asset to old', actions_group: true
246+
end
207247

208248
resp_obj = gh_api_v3_patch http, USER_REPO, "releases/assets/#{updated_asset_id}", {'name' => "#{pkg_name}.7z"}
209249
break unless response_ok resp_obj, 'PATCH - rename updated asset to current', actions_group: true
210250

211251
ttl_time = format '%5.2f', (Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start).round(2)
212252
STDOUT.syswrite "Rename time: #{ttl_time} secs\n"
213253

214-
resp_obj = gh_api_v3_delete http, USER_REPO, "releases/assets/#{current_asset_id}"
215-
break unless response_ok resp_obj, 'DELETE - remove old asset', actions_group: true
254+
if current_asset_id
255+
resp_obj = gh_api_v3_delete http, USER_REPO, "releases/assets/#{current_asset_id}"
256+
break unless response_ok resp_obj, 'DELETE - remove old asset', actions_group: true
257+
end
216258

217259
resp_obj = gh_api_v3_get http, USER_REPO, "releases/#{release_id}"
218260
break unless response_ok resp_obj, 'GET - release notes response', actions_group: true

create_gcc_pkg.rb

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,50 @@ class << self
1919
SYNC = 'var/lib/pacman/sync'
2020
LOCAL = 'var/lib/pacman/local'
2121

22-
PKG_NAME, PKG_PRE =
23-
case ARGV[0].downcase
24-
when 'ucrt64'
22+
PKG_DIR, PKG_PRE =
23+
case ARGV[0].downcase[/[^-]+/]
24+
when 'ucrt64', 'ucrt64-3.0'
2525
['ucrt64', 'mingw-w64-ucrt-x86_64-']
26-
when 'mingw64'
26+
when 'mingw64', 'mingw64-3.0'
2727
['mingw64', 'mingw-w64-x86_64-']
28-
when 'mingw32'
28+
when 'mingw32', 'mingw32-3.0'
2929
['mingw32', 'mingw-w64-i686-']
3030
else
3131
STDOUT.syswrite "Invalid package type, must be ucrt64, mingw64, or mingw32\n"
3232
exit 1
3333
end
34+
35+
PKG_NAME = ARGV[0].downcase
36+
37+
def add_ri2_key
38+
# appveyor ri2 package signing key
39+
key = 'F98B8484BE8BF1C5'
40+
exec_check "pacman-key --init", "bash.exe -c \"pacman-key --init\""
41+
exec_check "Get RI2 Key" , "bash.exe -c \"pacman-key --recv-keys #{key}\""
42+
exec_check "Sign RI2 Key", "bash.exe -c \"pacman-key --lsign-key #{key}\""
43+
end
44+
45+
def openssl_upgrade
46+
add_ri2_key
47+
48+
pkg_name = "openssl-3.0.5-1-any.pkg.tar.zst"
49+
pkg = "https://github.com/oneclick/rubyinstaller2-packages/releases/download/ci.ri2/#{PKG_PRE}#{pkg_name}"
50+
pkg_sig = "#{pkg}.sig"
51+
old_dlls = %w[libcrypto-1_1-x64.dll libssl-1_1-x64.dll]
52+
dll_root = "#{MSYS2_ROOT}/#{PKG_DIR}/bin"
53+
54+
# save previous dll files so we can copy back into folder
55+
old_dlls.each { |fn| FileUtils.cp "#{dll_root}/#{fn}", "." }
56+
57+
download pkg , "./#{PKG_PRE}#{pkg_name}"
58+
download pkg_sig, "./#{PKG_PRE}#{pkg_name}.sig"
59+
60+
# install package
61+
exec_check "Install OpenSSL Upgrade", "pacman.exe -Udd --noconfirm --noprogressbar #{PKG_PRE}#{pkg_name}"
62+
63+
# copy previous dlls back into MSYS2 folder
64+
old_dlls.each { |fn| FileUtils.cp fn , "#{dll_root}/#{fn}" }
65+
end
3466

3567
def install_gcc
3668
args = '--noconfirm --noprogressbar --needed'
@@ -46,6 +78,10 @@ def install_gcc
4678
exec_check "Updating the following #{PKG_PRE[0..-2]} packages:#{RST}\n" \
4779
"#{YEL}#{(base_gcc + base_ruby).join ' '}",
4880
"#{PACMAN} -S #{args} #{pkgs}"
81+
82+
if PKG_NAME.end_with? '-3.0'
83+
openssl_upgrade
84+
end
4985
end
5086

5187
# copies needed files from C:/msys64 to TEMP
@@ -56,8 +92,8 @@ def copy_to_temp
5692
end
5793

5894
Dir.chdir "#{MSYS2_ROOT}/#{SYNC}" do
59-
FileUtils.cp "#{PKG_NAME}.db", "#{TAR_DIR}/#{SYNC}"
60-
FileUtils.cp "#{PKG_NAME}.db.sig", "#{TAR_DIR}/#{SYNC}"
95+
FileUtils.cp "#{PKG_DIR}.db", "#{TAR_DIR}/#{SYNC}"
96+
FileUtils.cp "#{PKG_DIR}.db.sig", "#{TAR_DIR}/#{SYNC}"
6197
end
6298

6399
ary = Dir.glob "#{PKG_PRE}*", base: "#{MSYS2_ROOT}/#{LOCAL}"
@@ -68,12 +104,12 @@ def copy_to_temp
68104
ary.each { |dir| FileUtils.copy_entry dir, "#{local}/#{dir}" }
69105
end
70106

71-
FileUtils.copy_entry "#{MSYS2_ROOT}/#{PKG_NAME}", "#{TAR_DIR}/#{PKG_NAME}"
107+
FileUtils.copy_entry "#{MSYS2_ROOT}/#{PKG_DIR}", "#{TAR_DIR}/#{PKG_DIR}"
72108
end
73109

74110
# removes files contained in 'share' folder to reduce 7z file size
75111
def clean_package
76-
share = "#{TAR_DIR}/#{PKG_NAME}/share"
112+
share = "#{TAR_DIR}/#{PKG_DIR}/share"
77113

78114
Dir.chdir "#{share}/doc" do
79115
ary = Dir.glob "*"
@@ -98,9 +134,9 @@ def clean_package
98134
str = f.read
99135
f.truncate 0
100136
f.rewind
101-
str.gsub!(/^#{PKG_NAME}\/share\/doc\/\S+\s*/m , '')
102-
str.gsub!(/^#{PKG_NAME}\/share\/info\/\S+\s*/m, '')
103-
str.gsub!(/^#{PKG_NAME}\/share\/man\/\S+\s*/m , '')
137+
str.gsub!(/^#{PKG_DIR}\/share\/doc\/\S+\s*/m , '')
138+
str.gsub!(/^#{PKG_DIR}\/share\/info\/\S+\s*/m, '')
139+
str.gsub!(/^#{PKG_DIR}\/share\/man\/\S+\s*/m , '')
104140
f.write "#{str.strip}\n\n"
105141
}
106142
end
@@ -124,10 +160,10 @@ def run
124160
"Installed #{PKG_PRE[0..-2]} Packages"
125161

126162
if current_pkgs == updated_pkgs
127-
STDOUT.syswrite "\n** No update to #{PKG_NAME} gcc tools needed **\n\n"
163+
STDOUT.syswrite "\n** No update to #{PKG_DIR} gcc tools needed **\n\n"
128164
exit 0
129165
else
130-
STDOUT.syswrite "\n#{GRN}** Creating and Uploading #{PKG_NAME} gcc tools 7z **#{RST}\n\n"
166+
STDOUT.syswrite "\n#{GRN}** Creating and Uploading #{PKG_DIR} gcc tools 7z **#{RST}\n\n"
131167
end
132168

133169
copy_to_temp

0 commit comments

Comments
 (0)