Class: Yast::SaveHwStatusFinishClient

Inherits:
Client
  • Object
show all
Defined in:
src/lib/installation/clients/save_hw_status_finish.rb

Instance Method Summary collapse

Instance Method Details

#mainObject



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
# File 'src/lib/installation/clients/save_hw_status_finish.rb', line 34

def main
  textdomain "installation"

  Yast.import "Mode"
  Yast.import "HwStatus"
  Yast.import "HWConfig"
  Yast.import "Package"

  @ret = nil
  @func = ""
  @param = {}

  # Check arguments
  if Ops.greater_than(Builtins.size(WFM.Args), 0) &&
      Ops.is_string?(WFM.Args(0))
    @func = Convert.to_string(WFM.Args(0))
    if Ops.greater_than(Builtins.size(WFM.Args), 1) &&
        Ops.is_map?(WFM.Args(1))
      @param = Convert.to_map(WFM.Args(1))
    end
  end

  Builtins.y2milestone("starting save_hw_status_finish")
  Builtins.y2debug("func=%1", @func)
  Builtins.y2debug("param=%1", @param)

  case @func
  when "Info"
    return {
      "steps" => 1,
      # progress step title
      "title" => _("Saving hardware configuration..."),
      "when"  => [:installation, :update, :autoinst]
    }
  when "Write"
    # Package yast2-printer needs to be installed
    if Package.Installed("yast2-printer")
      @parports = Convert.convert(
        SCR.Read(path(".proc.parport.devices")),
        from: "any",
        to:   "list <string>"
      )
      if !@parports.nil? && Ops.greater_than(Builtins.size(@parports), 0)
        HWConfig.SetValue("static-printer", "STARTMODE", "auto")
        HWConfig.SetValue("static-printer", "MODULE", "lp")
      end
    else
      Builtins.y2warning(
        "Package yast2-printer is not installed, skipping static-printer write..."
      )
    end

    # PS/2 mouse on PPC
    @out = Convert.to_map(
      SCR.Execute(
        path(".target.bash_output"),
        "#!/bin/sh\n" \
        "set -e\n" \
        "if test -f /etc/sysconfig/hardware/hwcfg-static-psmouse\n" \
        "then\n" \
        " exit 0\n" \
        "fi\n" \
        "if test -d /proc/device-tree\n" \
        "then\n" \
        "cd /proc/device-tree\n" \
        "if find * -name name -print0 | xargs -0 grep -qw 8042\n" \
        "then\n" \
        "cat > /etc/sysconfig/hardware/hwcfg-static-psmouse <<EOF\n" \
        "MODULE='psmouse'\n" \
        "EOF\n" \
        "fi\n" \
        "fi\n"
      )
    )
    if Ops.get_integer(@out, "exit", 0) == 0
      Builtins.y2milestone("PS/2 mouse saving process returnes: %1", @out)
    else
      Builtins.y2error("Error saving PS/2 mouse: %1", @out)
    end

    Builtins.y2milestone("PS/2 mouse saving process returnes: %1", @out)
    if Mode.update
      # ensure "no" status for all pci and isapnp devices
      HwStatus.Update
    end

    # write "yes" status for known devices (mouse, keyboard, storage, etc.)
    HwStatus.Save
  else
    Builtins.y2error("unknown function: %1", @func)
    @ret = nil
  end

  Builtins.y2debug("ret=%1", @ret)
  Builtins.y2milestone("save_hw_status_finish finished")
  deep_copy(@ret)
end