Class: Katello::Pulp3::Rpm

Inherits:
PulpContentUnit show all
Includes:
LazyAccessor
Defined in:
app/services/katello/pulp3/rpm.rb

Constant Summary collapse

CONTENT_TYPE =
"rpm".freeze
PULP_INDEXED_FIELDS =
%w(pulp_href name version release arch epoch summary is_modular rpm_sourcerpm location_href pkgId).freeze

Instance Attribute Summary

Attributes inherited from PulpContentUnit

#backend_data, #uuid

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LazyAccessor

included

Methods inherited from PulpContentUnit

add_timestamps, backend_unit_identifier, content_api_create, content_type, content_unit_list, create_content, #fetch_backend_data, fetch_content_list, find_duplicate_unit, #initialize, model_class, pulp_data, pulp_units_batch_all, pulp_units_batch_for_repo, pulp_units_for_ids, supports_id_fetch?, unit_identifier

Constructor Details

This class inherits a constructor from Katello::Pulp3::PulpContentUnit

Class Method Details

.content_apiObject



13
14
15
# File 'app/services/katello/pulp3/rpm.rb', line 13

def self.content_api
  PulpRpmClient::ContentPackagesApi.new(Katello::Pulp3::Api::Yum.new(SmartProxy.pulp_primary!).api_client)
end

.generate_model_row(unit) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/services/katello/pulp3/rpm.rb', line 88

def self.generate_model_row(unit)
  custom_json = {}
  custom_json['modular'] = unit['is_modular']
  custom_json['pulp_id'] = unit['pulp_href']
  (PULP_INDEXED_FIELDS - ['is_modular', 'pulp_href', 'rpm_sourcerpm', 'pkgId', 'location_href']).
    each { |field| custom_json[field] = unit[field] }
  custom_json['release_sortable'] = Util::Package.sortable_version(unit['release'])
  custom_json['version_sortable'] = Util::Package.sortable_version(unit['version'])
  custom_json['filename'] = parse_filename(unit['location_href']) #location_href is the relative path of the rpm in the upstream repo
  custom_json['checksum'] = unit['pkgId']
  custom_json['sourcerpm'] = unit['rpm_sourcerpm']
  custom_json['nvra'] = Util::Package.build_nvra(custom_json.with_indifferent_access)
  custom_json['summary'] = custom_json['summary']&.truncate(255)
  custom_json
end

.ids_for_repository(repo_id) ⇒ Object



17
18
19
20
21
# File 'app/services/katello/pulp3/rpm.rb', line 17

def self.ids_for_repository(repo_id)
  repo = Katello::Pulp3::Repository::Yum.new(Katello::Repository.find(repo_id), SmartProxy.pulp_primary)
  repo_content_list = repo.content_list
  repo_content_list.map { |content| content.try(:pulp_href) }
end

.page_options(page_opts = {}) ⇒ Object



23
24
25
26
# File 'app/services/katello/pulp3/rpm.rb', line 23

def self.page_options(page_opts = {})
  page_opts["arch__ne"] = "src"
  page_opts
end

.parse_filename(path) ⇒ Object



84
85
86
# File 'app/services/katello/pulp3/rpm.rb', line 84

def self.parse_filename(path)
  File.split(path).last unless path.blank?
end

Instance Method Details

#build_timeObject



72
73
74
# File 'app/services/katello/pulp3/rpm.rb', line 72

def build_time
  backend_data['time_build']
end

#buildhostObject



48
49
50
# File 'app/services/katello/pulp3/rpm.rb', line 48

def buildhost
  backend_data['rpm_buildhost']
end

#changelogObject



64
65
66
# File 'app/services/katello/pulp3/rpm.rb', line 64

def changelog
  backend_data['changelogs']
end

#checksumtypeObject



60
61
62
# File 'app/services/katello/pulp3/rpm.rb', line 60

def checksumtype
  backend_data['checksum_type']
end

#filesObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/services/katello/pulp3/rpm.rb', line 36

def files
  files = backend_data['files'].collect do |file_and_path|
    # First item in the array might be a directive like "dir" or "ghost"
    if file_and_path[0][0] != '/'
      file_and_path.shift
    end
    file_and_path.join('')
  end

  files.uniq
end

#groupObject



68
69
70
# File 'app/services/katello/pulp3/rpm.rb', line 68

def group
  backend_data['rpm_group']
end

#licenseObject



80
81
82
# File 'app/services/katello/pulp3/rpm.rb', line 80

def license
  backend_data['rpm_license']
end

#providesObject



32
33
34
# File 'app/services/katello/pulp3/rpm.rb', line 32

def provides
  Util::Package.parse_dependencies(backend_data['provides'])
end

#relativepathObject



56
57
58
# File 'app/services/katello/pulp3/rpm.rb', line 56

def relativepath
  backend_data['location_href']
end

#requiresObject



28
29
30
# File 'app/services/katello/pulp3/rpm.rb', line 28

def requires
  Util::Package.parse_dependencies(backend_data['requires'])
end

#sizeObject



76
77
78
# File 'app/services/katello/pulp3/rpm.rb', line 76

def size
  backend_data['size_package']
end

#vendorObject



52
53
54
# File 'app/services/katello/pulp3/rpm.rb', line 52

def vendor
  backend_data['rpm_vendor']
end