Class: Y2Packager::SelfUpdateAddonRepo

Inherits:
Object
  • Object
show all
Extended by:
Yast::Logger
Defined in:
src/lib/y2packager/self_update_addon_repo.rb

Overview

create a local add-on repository from a self-update repository

Constant Summary collapse

REPO_PATH =
File.join(Yast::Directory.vardir, "self_update_addon").freeze

Class Method Summary collapse

Class Method Details

.copy_packages(repo_id, path = REPO_PATH) ⇒ Boolean

Create an addon repository from the self-update repository containing specific packages. The repository is a plaindir type and does not contain any metadata.

Parameters:

  • repo_id (Integer)

    repo_id repository ID

  • path (String) (defaults to: REPO_PATH)

    path where to download the packages

Returns:

  • (Boolean)

    true if a repository has been created, false when no addon package was found in the self update repository


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'src/lib/y2packager/self_update_addon_repo.rb', line 48

def self.copy_packages(repo_id, path = REPO_PATH)
  pkgs = SelfUpdateAddonFilter.packages(repo_id)
  return false if pkgs.empty?

  log.info("Addon packages to download: #{pkgs}")

  ::FileUtils.mkdir_p(path)

  pkgs.each do |pkg|
    downloader = Packages::PackageDownloader.new(repo_id, pkg)
    log.info("Downloading package #{pkg}...")
    downloader.download(File.join(path, "#{pkg}.rpm"))
  end

  log.info("Downloaded packages: #{Dir["#{path}/*"]}")

  true
end

.create_repo(path = REPO_PATH) ⇒ Boolean

Create a repository from a directory, uses “Plaindir” type, the package metadata are not required.

Parameters:

  • path (String) (defaults to: REPO_PATH)

    path to the repository

Returns:

  • (Boolean)

    true on success, false if failed


90
91
92
93
94
95
# File 'src/lib/y2packager/self_update_addon_repo.rb', line 90

def self.create_repo(path = REPO_PATH)
  ret = Yast::Pkg.SourceCreateType("dir://#{URI.escape(path)}?alias=SelfUpdate0",
    "", "Plaindir")
  log.info("Created self update addon repo: #{ret}")
  ret
end

.present?(path = REPO_PATH) ⇒ Boolean

Is a repository present at the path? (It is enough if it is just an empty directory.)

Parameters:

  • path (String) (defaults to: REPO_PATH)

    path to the repository

Returns:

  • (Boolean)

    true if a repository was found, false otherwise


75
76
77
78
79
80
# File 'src/lib/y2packager/self_update_addon_repo.rb', line 75

def self.present?(path = REPO_PATH)
  # the directory exists and is not empty
  ret = File.exist?(path) && !Dir.empty?(path)
  log.info("Repository #{path} exists: #{ret}")
  ret
end