/
rpm.rb
52 lines (47 loc) · 1.89 KB
/
rpm.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ------------------------------------------------------------------------------
# Copyright (c) 2018 SUSE LLC, All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of version 2 of the GNU General Public License as published by the
# Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# ------------------------------------------------------------------------------
require "y2packager/licenses_fetchers/base"
module Y2Packager
module LicensesFetchers
class Rpm < Base
# Return the license text to be confirmed
#
# It will return the empty string ("") if the license does not exist or if
# it was already confirmed.
#
# @param lang [String] Language
# @return [String,nil] Product's license; nil if the product was not found.
def license_content(lang)
Yast::Pkg.PrdGetLicenseToConfirm(product_name, lang)
end
# Return available locales for product's license
#
# @return [Array<String>] Language codes ("de_DE", "en_US", etc.)
def license_locales
locales = Yast::Pkg.PrdLicenseLocales(product_name)
if locales.nil?
log.error "Error getting the list of available license translations for '#{product_name}'"
return []
end
empty_idx = locales.index("")
locales[empty_idx] = License::DEFAULT_LANG if empty_idx
locales
end
# Determine whether the license should be accepted or not
#
# @return [Boolean] true if the license acceptance is required
def license_confirmation_required?
Yast::Pkg.PrdNeedToAcceptLicense(product_name)
end
end
end
end