Class: Yast::MtabClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
src/modules/Mtab.rb

Overview

Handling of /etc/mtab and /mnt/etc/mtab

Constant Summary collapse

MTABNAME =
"/etc/mtab".freeze

Instance Method Summary collapse

Instance Method Details

#clone_to_targetObject

Reading /etc/mtab from inst-sys, removing all /mnt headings and writing this patched mtab into target system.


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'src/modules/Mtab.rb', line 19

def clone_to_target
  log.info("Copying /etc/mtab to the target system...")
  mtab = WFM.Read(path(".local.string"), MTABNAME)
  # remove non-existing mount points
  mtab_lines = mtab.split("\n")
  mtab_lines.map! do |mtab_line|
    # Filter out all non-existing entries/directories
    columns = mtab_line.split
    next unless File.directory?(columns[1])
    # remove heading /mnt from directory entry
    columns[1] = columns[1][4..-1] if columns[1].start_with?("/mnt")
    columns.join(" ")
  end

  # join back the lines
  mtab = mtab_lines.compact.join("\n")
  log.info("Target /etc/mtab file: #{mtab}")
  SCR.Write(path(".target.string"),
    File.join(Installation.destdir, MTABNAME), mtab)
end

#mainObject


11
12
13
# File 'src/modules/Mtab.rb', line 11

def main
  Yast.import "Installation"
end