Class: Yast::ModulesConfClass

Inherits:
Module
  • Object
show all
Defined in:
library/system/src/modules/ModulesConf.rb

Instance Method Summary collapse

Instance Method Details

#mainObject



41
42
43
44
45
46
47
48
49
# File 'library/system/src/modules/ModulesConf.rb', line 41

def main
  Yast.import "Arch"
  Yast.import "Misc"
  Yast.import "Mode"

  textdomain "base"

  @modules = {}
end

#ModuleArgs(name, arg) ⇒ Object

ModuleArgs save arguments for a kernel module

Parameters:

  • name (String)

    string, name of kernel module

  • arg (String)

    string, arguments (“opt1=val1 opt2=val2 …”)



55
56
57
58
59
60
61
62
63
# File 'library/system/src/modules/ModulesConf.rb', line 55

def ModuleArgs(name, arg)
  return if name == ""

  moduledata = Ops.get(@modules, name, {})
  Ops.set(moduledata, "options", arg) if arg != ""
  Ops.set(@modules, name, moduledata)

  nil
end

#RunDepmod(force) ⇒ Object

RunDepmod runs /sbin/depmod !! call only when SCR runs on target !!

Parameters:

  • force (Boolean)

    boolean, force depmod run (option “-a” instead of “-A”)



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
# File 'library/system/src/modules/ModulesConf.rb', line 69

def RunDepmod(force)
  Yast.import "Kernel"

  kernel_version = Convert.to_string(
    SCR.Read(
      path(".boot.vmlinuz_version"),
      [Ops.add("/boot/", Kernel.GetBinary)]
    )
  )

  Builtins.y2milestone("running /sbin/depmod")

  if Ops.greater_than(Builtins.size(kernel_version), 0)
    SCR.Execute(
      path(".target.bash"),
      Ops.add(
        Ops.add(
          Ops.add(
            "unset MODPATH; /sbin/depmod " + (force ? "-a" : "-A") +
              " -F /boot/System.map-",
            kernel_version
          ),
          " "
        ),
        kernel_version
      )
    )
  else
    SCR.Execute(
      path(".target.bash"),
      "unset MODPATH; /sbin/depmod " + (force ? "-a" : "-A") +
        " -F /boot/System.map-`uname -r` `uname -r`"
    )
  end

  nil
end

#Save(force) ⇒ Object

Save save module names and arguments to /etc/modules.conf !! call only when SCR runs on target !!

Parameters:

  • force (Boolean)

    boolean, force depmod run even if /etc/modules.conf is unchanged



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'library/system/src/modules/ModulesConf.rb', line 111

def Save(force)
  # make module names to one long string
  # start with modules from linuxrc

  # write module options to modules.conf, mk_initrd handles the rest

  modules_conf_changed = false

  Builtins.foreach(@modules) do |mname, mdata|
    options = Ops.get_string(mdata, "options", "")
    if options != ""
      # we have options, pass them to modules.conf

      current_options = Convert.to_map(
        SCR.Read(Builtins.add(path(".modules.options"), mname))
      )

      new_options = Misc.SplitOptions(options, current_options)

      SCR.Write(Builtins.add(path(".modules.options"), mname), new_options)
      modules_conf_changed = true
    end
  end

  # Network module handling removed (#39135)
  # #24836, Alias needs special treatment because of multiple cards

  # if needed, re-write /etc/modules.conf and run /sbin/depmod

  SCR.Write(path(".modules"), nil) if modules_conf_changed

  RunDepmod(true) if (modules_conf_changed || force) && !Mode.test

  nil
end