@@ -30,6 +30,7 @@ module Common
3030 TAG = 'msys2-gcc-pkgs' # GitHub release tag
3131 MSYS2_ROOT = 'C:/msys64'
3232 PACMAN = 'C:/msys64/usr/bin/pacman.exe'
33+ BASH = 'C:/msys64/usr/bin/bash.exe'
3334
3435 def gh_api_graphql ( http , query )
3536 body = { }
@@ -241,6 +242,35 @@ def update_release_notes(old_body, name, time)
241242 }
242243 end
243244
245+ def gpg_conf_key_server ( old_uri , new_uri )
246+ fn = "#{ MSYS2_ROOT } /etc/pacman.d/gnupg/gpg.conf"
247+ str = File . binread fn
248+ if str . include? old_uri
249+ str . sub! old_uri , new_uri
250+ File . binwrite fn , str
251+ STDOUT . syswrite "\n gpg.conf - changed '#{ old_uri } ' to '#{ new_uri } '"
252+ end
253+ end
254+
255+ def refresh_keys
256+ STDOUT . syswrite "\n #{ YEL } #{ LINE } Refresh keys#{ RST } \n "
257+ gpg_conf_key_server 'pool.sks-keyservers.net' , 'keyserver.ubuntu.com'
258+
259+ str = ''
260+ cmd = "#{ BASH } -c \" pacman-key --refresh-keys\" "
261+
262+ IO . popen ( cmd , err : [ :child , :out ] ) { |io | str = io . read }
263+
264+ system 'taskkill /f /fi "MODULES eq msys-2.0.dll"'
265+
266+ if str . match? ( /new signatures:|signatures cleaned:/ )
267+ STDOUT . syswrite str
268+ true
269+ else
270+ nil
271+ end
272+ end
273+
244274 def pacman_syuu
245275 usr_bin = "#{ MSYS2_ROOT } /usr/bin"
246276
@@ -253,6 +283,8 @@ def pacman_syuu
253283 exec_check 'Updating all installed packages (2nd pass)' , "#{ PACMAN } -Syuu --noconfirm"
254284
255285 system 'taskkill /f /fi "MODULES eq msys-2.0.dll"'
286+
287+ refresh_keys
256288 end
257289
258290 # logs message and runs cmd, checking for error
0 commit comments