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
PULPCORE_CONTENT_TYPE =
"rpm.package".freeze
PULP_INDEXED_FIELDS =
%w(pulp_href prn 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, katello_name_from_pulpcore_name, 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



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

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

.generate_model_row(unit) ⇒ Object



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

def self.generate_model_row(unit)
  custom_json = {}
  custom_json['modular'] = unit['is_modular']
  custom_json['pulp_id'] = unit['pulp_href']
  custom_json['pulp_prn'] = unit['prn'] # Also store PRN alongside pulp_id
  (PULP_INDEXED_FIELDS - ['is_modular', 'pulp_href', 'prn', '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



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

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



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

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

.parse_filename(path) ⇒ Object



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

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

Instance Method Details

#build_timeObject



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

def build_time
  backend_data['time_build']
end

#buildhostObject



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

def buildhost
  backend_data['rpm_buildhost']
end

#changelogObject



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

def changelog
  backend_data['changelogs']
end

#checksumtypeObject



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

def checksumtype
  backend_data['checksum_type']
end

#filesObject



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

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



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

def group
  backend_data['rpm_group']
end

#licenseObject



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

def license
  backend_data['rpm_license']
end

#providesObject



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

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

#relativepathObject



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

def relativepath
  backend_data['location_href']
end

#requiresObject



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

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

#sizeObject



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

def size
  backend_data['size_package']
end

#vendorObject



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

def vendor
  backend_data['rpm_vendor']
end