Class: Installation::CopyLogsFinish

Inherits:
FinishClient
  • Object
show all
Includes:
Yast::I18n
Defined in:
src/lib/installation/copy_logs_finish.rb

Constant Summary collapse

LOCAL_BASH =
Yast::Path.new(".local.bash")
PREFIX_SIZE =
"y2log-".size
STORAGE_DUMP_DIR =
"storage-inst".freeze

Instance Method Summary collapse

Constructor Details

#initializeCopyLogsFinish

Returns a new instance of CopyLogsFinish.



30
31
32
33
34
35
36
37
# File 'src/lib/installation/copy_logs_finish.rb', line 30

def initialize
  super
  textdomain "installation"

  Yast.import "Directory"
  Yast.import "Installation"
  Yast.import "ProductFeatures"
end

Instance Method Details

#modesObject



47
48
49
# File 'src/lib/installation/copy_logs_finish.rb', line 47

def modes
  [:installation, :live_installation, :update, :autoinst]
end

#stepsObject



39
40
41
# File 'src/lib/installation/copy_logs_finish.rb', line 39

def steps
  1
end

#titleObject



43
44
45
# File 'src/lib/installation/copy_logs_finish.rb', line 43

def title
  _("Copying log files to installed system...")
end

#writeObject



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
# File 'src/lib/installation/copy_logs_finish.rb', line 54

def write
  log_files = Yast::WFM.Read(Yast::Path.new(".local.dir"), Yast::Directory.logdir)

  log_files.each do |file|
    log.debug "Processing file #{file}"

    case file
    when "y2log", /\Ay2log-\d+\z/
      # Prepare y2log, y2log-* for log rotation
      target_no = 1

      target_no = file[PREFIX_SIZE..-1].to_i + 1 if file != "y2log"

      target_basename = "y2log-#{target_no}"
      copy_log_to_target(file, target_basename)

      target_path = ::File.join(
        Yast::Installation.destdir,
        Yast::Directory.logdir,
        target_basename
      )
      # call gzip with -f to avoid stuck during race condition when log
      # rotator also gzip file and gzip then wait for input (bnc#897091)
      shell_cmd("/usr/bin/gzip -f '#{target_path}'")
    when /\Ay2log-\d+\.gz\z/
      target_no = file[/y2log-(\d+)/, 1].to_i + 1
      copy_log_to_target(file, "y2log-#{target_no}.gz")
    when "zypp.log"
      # Save zypp.log from the inst-sys
      copy_log_to_target(file, "zypp.log-1") # not y2log, y2log-*
    when "pbl.log"
      copy_log_to_target("pbl.log", "pbl-instsys.log")
    when STORAGE_DUMP_DIR
      copy_storage_inst_subdir
    else
      copy_log_to_target(file)
    end
  end

  # Saving y2logs
  WFM.CallFunction("save_y2logs")

  nil
end