Module: Y2Network::Helpers

Includes:
Yast::Logger
Included in:
NetworkManager::ConfigCopier, Wicked::ConfigCopier, Yast::SaveNetworkClient
Defined in:
src/lib/y2network/helpers.rb

Constant Summary collapse

ROOT_PATH =
"/".freeze

Instance Method Summary collapse

Instance Method Details

#copy_to_target(path, include: nil, target: inst_dir) ⇒ Boolean

Convenvenience method for copying a list of files into the target system. It takes care of creating the target directory but only if some file needs to be copied

copied in the target system

Parameters:

  • path (String)

    path where the files resides and where will be

Returns:

  • (Boolean)

    whether some file was copied



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'src/lib/y2network/helpers.rb', line 39

def copy_to_target(path, include: nil, target: inst_dir)
  dest_path = ::File.join(target, path)
  files = if include
    include.map { |f| File.join(ROOT_PATH, path, f) }
  else
    File.join(ROOT_PATH, path)
  end
  glob_files = ::Dir.glob(files)
  return false if glob_files.empty?

  dest_dir = include ? dest_path : ::File.dirname(dest_path)
  log.info("Copying '#{glob_files.join(",")}' to '#{dest_dir}'.")

  ::FileUtils.mkdir_p(dest_dir)
  ::FileUtils.cp(glob_files, dest_dir, preserve: true)
  true
end

#inst_dirObject



28
29
30
# File 'src/lib/y2network/helpers.rb', line 28

def inst_dir
  Yast::Installation.destdir
end