Module: Y2Network::Helpers
- Includes:
- Yast::Logger
- Defined in:
- src/lib/y2network/helpers.rb
Constant Summary collapse
- ROOT_PATH =
"/".freeze
Instance Method Summary collapse
-
#copy_to_target(path, include: nil, target: inst_dir) ⇒ Boolean
Convenvenience method for copying a list of files into the target system.
- #inst_dir ⇒ Object
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
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_dir ⇒ Object
28 29 30 |
# File 'src/lib/y2network/helpers.rb', line 28 def inst_dir Yast::Installation.destdir end |