diff --git a/lib/omnibus/packagers/deb.rb b/lib/omnibus/packagers/deb.rb index af92c01b0..8fecde2e6 100644 --- a/lib/omnibus/packagers/deb.rb +++ b/lib/omnibus/packagers/deb.rb @@ -319,6 +319,7 @@ def write_control_file section: section, conflicts: project.conflicts, replaces: project.replaces, + provides: project.provides, dependencies: project.runtime_dependencies, } ) diff --git a/lib/omnibus/packagers/rpm.rb b/lib/omnibus/packagers/rpm.rb index 20772e83a..8c76f5d36 100644 --- a/lib/omnibus/packagers/rpm.rb +++ b/lib/omnibus/packagers/rpm.rb @@ -374,6 +374,7 @@ def write_rpm_spec category: category, conflicts: project.conflicts, replaces: project.replaces, + provides: project.provides, dependencies: project.runtime_dependencies, user: project.package_user, group: project.package_group, diff --git a/lib/omnibus/project.rb b/lib/omnibus/project.rb index 9190fb061..cbab397ff 100644 --- a/lib/omnibus/project.rb +++ b/lib/omnibus/project.rb @@ -285,6 +285,23 @@ def description(val = NULL) end expose :description + # + # Add to the list of packages this one provides. + # + # @example + # provide 'the-virtual-package' + # + # @param [String] val + # the name of the package to provide + # + # @return [String] + # + def provide(val = NULL) + provides << val + provides.dup + end + expose :provide + # # Add to the list of packages this one replaces. # @@ -897,6 +914,15 @@ def replaces @replaces ||= [] end + # + # The list of things this project provides. + # + # @return [Array] + # + def provides + @provides ||= [] + end + # # The list of exclusions for this project. # diff --git a/resources/deb/control.erb b/resources/deb/control.erb index df91e3463..a8d834cb4 100644 --- a/resources/deb/control.erb +++ b/resources/deb/control.erb @@ -14,6 +14,9 @@ Conflicts: <%= conflicts.join(', ') %> <% unless replaces.empty? -%> Replaces: <%= replaces.join(', ') %> <% end -%> +<% unless provides.empty? -%> +Provides: <%= provides.join(', ') %> +<% end -%> Section: <%= section %> Priority: <%= priority %> Homepage: <%= homepage %> diff --git a/spec/unit/packagers/deb_spec.rb b/spec/unit/packagers/deb_spec.rb index 3fe453422..35cc84ae4 100644 --- a/spec/unit/packagers/deb_spec.rb +++ b/spec/unit/packagers/deb_spec.rb @@ -10,6 +10,7 @@ module Omnibus project.build_version("1.2.3") project.build_iteration("2") project.maintainer("Chef Software") + project.provide("chefy-package") project.license(project_license) if project_license end end @@ -178,6 +179,7 @@ module Omnibus expect(contents).to include("Vendor: Omnibus ") expect(contents).to include("Architecture: amd64") expect(contents).to include("Maintainer: Chef Software") + expect(contents).to include("Provides: chefy-package") expect(contents).to include("Installed-Size: 0") expect(contents).to include("Section: misc") expect(contents).to include("Priority: extra") diff --git a/spec/unit/packagers/rpm_spec.rb b/spec/unit/packagers/rpm_spec.rb index 8367ceaf0..2ee85bfa2 100644 --- a/spec/unit/packagers/rpm_spec.rb +++ b/spec/unit/packagers/rpm_spec.rb @@ -11,6 +11,7 @@ module Omnibus project.build_iteration("2") project.maintainer("Chef Software") project.replace("old-project") + project.provide("chefy-package") project.license(project_license) if project_license end end diff --git a/spec/unit/project_spec.rb b/spec/unit/project_spec.rb index 75851da49..e574ea06c 100644 --- a/spec/unit/project_spec.rb +++ b/spec/unit/project_spec.rb @@ -28,6 +28,7 @@ module Omnibus it_behaves_like "a cleanroom setter", :homepage, %{homepage 'https://getchef.com'} it_behaves_like "a cleanroom setter", :description, %{description 'Installs the thing'} it_behaves_like "a cleanroom setter", :replace, %{replace 'old-chef'} + it_behaves_like "a cleanroom setter", :provide, %{provide 'chefy-package'} it_behaves_like "a cleanroom setter", :conflict, %{conflict 'puppet'} it_behaves_like "a cleanroom setter", :build_version, %{build_version '1.2.3'} it_behaves_like "a cleanroom setter", :build_iteration, %{build_iteration 1}