123456789_123456789_123456789_123456789_123456789_

Class: RubyInstaller::Build::Components::PacmanUpdate

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base, Rake::Task
Instance Chain:
Inherits: RubyInstaller::Build::Components::Base
Defined in: lib/ruby_installer/build/components/02_pacman_update.rb

Constant Summary

::RubyInstaller::Build::Colors - Included

ColorMap, ESC, NND

Class Method Summary

Base - Inherited

Instance Attribute Summary

Instance Method Summary

Constructor Details

This class inherits a constructor from RubyInstaller::Build::Components::Base

Class Method Details

.depends

[ GitHub ]

  
# File 'lib/ruby_installer/build/components/02_pacman_update.rb', line 5

def self.depends
  %w[msys2]
end

Instance Method Details

#description

[ GitHub ]

  
# File 'lib/ruby_installer/build/components/02_pacman_update.rb', line 9

def description
  "MSYS2 system update (optional)"
end

#execute(args)

[ GitHub ]

  
# File 'lib/ruby_installer/build/components/02_pacman_update.rb', line 13

def execute(args)
  require "tempfile"

  msys.with_msys_apps_enabled do
    puts "Check msys2-keyring version:"
    IO.popen(%w[pacman -Q msys2-keyring>=1~20240410-1], err: :out, &:read)
    if $?.success?
      puts green(" -> up-to-date")
    else
      puts yellow(" -> Update keyring according to https://www.msys2.org/news/#2020-06-29-new-packagers")

      tar_path = File.join(builtin_packages_dir, "msys2-keyring-1~20240410-1-any.pkg.tar.zst")
      tf = Tempfile.new
      run_verbose("pacman", "-U", "--noconfirm", "--config", tf.path, tar_path)
    end

    puts "Remove catgets to avoid conflicts while update  ..."
    # See https://github.com/Alexpux/MSYS2-packages/issues/1141
    run_verbose("pacman", "-Rdd", "catgets", "libcatgets", "--noconfirm")

    puts "#{description} part 1  ..."
    # Update the package database and core system packages
    res = run_verbose("pacman", "-Syu", *pacman_args)
    puts "#{description} #{res ? green("succeeded") : red("failed")}"
    raise "pacman failed" unless res

    kill_all_msys2_processes
    autorebase

    # Update the rest
    puts "#{description} part 2 ..."
    res = run_verbose("pacman", "-Syu", *pacman_args)
    puts "#{description} #{res ? green("succeeded") : red("failed")}"
    raise "pacman failed" unless res

    autorebase
  end
end