Class: Yast::ModulesConfClass

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

Instance Method Summary collapse

Instance Method Details

#mainObject



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

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 ...")



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

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")



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

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"),
      "unset MODPATH; /sbin/depmod " + (force ? "-a" : "-A") +
        " -F /boot/System.map-#{kernel_version.shellescape} #{kernel_version.shellescape}"
    )
  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



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
131
132
133
134
135
# File 'library/system/src/modules/ModulesConf.rb', line 101

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