Skip to content

Commit

Permalink
Fixes #26223 - Copies modular rpms on cv publish (Katello#8014)
Browse files Browse the repository at this point in the history
* Fixes #26223 - Copies modular rpms on cv publish

This commit contains code related to automatically copying all the
modular rpms from source repo to destination repo during a cv publish.
Modular rpms are dependencies bound by the modules they are attached to.
Since the content view publish copies all modules over, all the rpm
dependencies belonging to those modules must also get copied over.

This commit also adds code to prevent the user from adding a modular rpm
in a package rule.
  • Loading branch information
parthaa authored Mar 29, 2019
1 parent 5c1a0d0 commit 1c2c46f
Show file tree
Hide file tree
Showing 11 changed files with 13,398 additions and 2,242 deletions.
4 changes: 4 additions & 0 deletions app/controllers/katello/api/v2/packages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def auto_complete_name
rpms = Rpm.in_repositories(@repositories)
col = "#{Rpm.table_name}.name"
rpms = rpms.where("#{Rpm.table_name}.name ILIKE ?", "#{params[:term]}%").select(col).group(col).order(col).limit(page_size)
rpms = rpms.modular if ::Foreman::Cast.to_bool(params[:modular_only])
rpms = rpms.non_modular if ::Foreman::Cast.to_bool(params[:non_modular_only])
render :json => rpms.pluck(col)
end

Expand All @@ -19,6 +21,8 @@ def auto_complete_arch
rpms = Rpm.in_repositories(@repositories)
col = "#{Rpm.table_name}.arch"
rpms = rpms.where("#{col} ILIKE ?", "%#{params[:term]}%").select(col).group(col).order(col).limit(page_size)
rpms = rpms.modular if ::Foreman::Cast.to_bool(params[:modular_only])
rpms = rpms.non_modular if ::Foreman::Cast.to_bool(params[:non_modular_only])
render :json => rpms.pluck(col)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/katello/content_view_package_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def original_packages=(value)

def query_rpms(repo, rule)
query_name = rule.name.tr("*", "%")
query = Rpm.in_repositories(repo).where("#{Rpm.table_name}.name ilike ?", query_name)
query = Rpm.in_repositories(repo).non_modular.where("#{Rpm.table_name}.name ilike ?", query_name)
if rule.architecture
query_arch = rule.architecture.tr("*", "%")
query = query.where("#{Rpm.table_name}.arch ilike ?", query_arch)
Expand Down
4 changes: 4 additions & 0 deletions app/services/katello/pulp/repository/yum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def copy_contents(destination_repo, options = {})
filters: {unit: rpm_remove_clauses})
end

# always copy modular rpms
modular_includes = {filters: {unit: { 'filename' => { '$in' => repo.rpms.modular.pluck(:filename) } }}}
smart_proxy.pulp_api.extensions.rpm.copy(repo.pulp_id, destination_repo.pulp_id, modular_includes)

[:srpm, :errata, :package_group, :yum_repo_metadata_file, :distribution, :module, :module_default].each do |type|
tasks << smart_proxy.pulp_api.extensions.send(type).copy(repo.pulp_id, destination_repo.pulp_id)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ angular.module('Bastion.content-views').controller('PackageFilterController',
var repositoryIds = $scope.contentView['repository_ids'],
promise;

promise = Package.autocompleteName({'repoids[]': repositoryIds, term: term}).$promise;
promise = Package.autocompleteName({'repoids[]': repositoryIds, term: term, 'non_modular_only': true}).$promise;

return promise.then(function (data) {
return data.results;
Expand All @@ -152,7 +152,7 @@ angular.module('Bastion.content-views').controller('PackageFilterController',
var repositoryIds = $scope.contentView['repository_ids'],
promise;

promise = Package.autocompleteArch({'repoids[]': repositoryIds, term: term}).$promise;
promise = Package.autocompleteArch({'repoids[]': repositoryIds, term: term, 'non_modular_only': true}).$promise;

return promise.then(function (data) {
return data.results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<header class="details-header">
<h3>{{ filter.name }}</h3>
<small translate>Type: {{ filter.inclusion | filterType }} {{ filter.type | filterContentType }}</small>
<br/>
<i class="fa fa-warning inline-icon" ng-if="filter.type === 'rpm' || filter.type === 'errata'">&nbsp;<span translate>
RPMs belonging to Module Streams will not be affected by filters. These RPMs will automatically be included in a Content View Version along with the associated Module Streams.</span></i>
</header>

<div ui-view></div>
Loading

0 comments on commit 1c2c46f

Please sign in to comment.