Class: Packages::PackageDownloader
- Inherits:
-
Object
- Object
- Packages::PackageDownloader
- Includes:
- Yast::I18n, Yast::Logger
- Defined in:
- library/packages/src/lib/packages/package_downloader.rb
Overview
Note:
For downloading files outside of a libzypp repository use the
Downloads a package from a known package manager (libzypp) repository.
FileFromUrl::get_file_from_url method: https://github.com/yast/yast-installation/blob/fba82c3c9abfc44e3d31c8658bf96079d74e0298/src/lib/transfer/file_from_url.rb#L89
Instance Attribute Summary collapse
-
#package_name ⇒ String
readonly
Name of the package.
-
#repo_id ⇒ Integer
readonly
Repository ID.
Instance Method Summary collapse
-
#download(path) ⇒ Object
Download the package locally to the given path.
-
#initialize(repo_id, package_name) ⇒ PackageDownloader
constructor
Constructor.
Constructor Details
#initialize(repo_id, package_name) ⇒ PackageDownloader
Constructor
55 56 57 58 59 60 |
# File 'library/packages/src/lib/packages/package_downloader.rb', line 55 def initialize(repo_id, package_name) textdomain "base" @repo_id = repo_id @package_name = package_name end |
Instance Attribute Details
#package_name ⇒ String (readonly)
Returns Name of the package.
49 50 51 |
# File 'library/packages/src/lib/packages/package_downloader.rb', line 49 def package_name @package_name end |
#repo_id ⇒ Integer (readonly)
Returns Repository ID.
47 48 49 |
# File 'library/packages/src/lib/packages/package_downloader.rb', line 47 def repo_id @repo_id end |
Instance Method Details
#download(path) ⇒ Object
Download the package locally to the given path.
It is responsibility of the caller to remove the downloaded package when it is not needed anymore.
70 71 72 73 74 75 76 |
# File 'library/packages/src/lib/packages/package_downloader.rb', line 70 def download(path) log.info("Downloading package #{package_name} from repo #{repo_id} to #{path}") return if Yast::Pkg.ProvidePackage(repo_id, package_name, path.to_s) log.error("Package #{package_name} could not be retrieved.") raise Y2Packager::PackageFetchError end |