From 4d3d8189a9c8e341475a80f2d22303a06573bcd3 Mon Sep 17 00:00:00 2001 From: Frederik Deweerdt Date: Mon, 10 Oct 2016 15:57:21 -0700 Subject: [PATCH 1/2] Add 'Project.provide()' for virtual packages --- lib/omnibus/packagers/rpm.rb | 1 + lib/omnibus/project.rb | 26 ++++++++++++++++++++++++++ resources/deb/control.erb | 3 +++ 3 files changed, 30 insertions(+) diff --git a/lib/omnibus/packagers/rpm.rb b/lib/omnibus/packagers/rpm.rb index 97297e93a..ad890c92d 100644 --- a/lib/omnibus/packagers/rpm.rb +++ b/lib/omnibus/packagers/rpm.rb @@ -324,6 +324,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 3d249b370..1d781d22b 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 %> From 67f479392700fd7320b4705d85421e61bf37f5e1 Mon Sep 17 00:00:00 2001 From: Frederik Deweerdt Date: Mon, 10 Oct 2016 16:51:28 -0700 Subject: [PATCH 2/2] Fix unit tests --- lib/omnibus/packagers/deb.rb | 1 + spec/unit/packagers/deb_spec.rb | 2 ++ spec/unit/packagers/rpm_spec.rb | 1 + spec/unit/project_spec.rb | 1 + 4 files changed, 5 insertions(+) diff --git a/lib/omnibus/packagers/deb.rb b/lib/omnibus/packagers/deb.rb index 17525b17f..255b841c5 100644 --- a/lib/omnibus/packagers/deb.rb +++ b/lib/omnibus/packagers/deb.rb @@ -214,6 +214,7 @@ def write_control_file section: section, conflicts: project.conflicts, replaces: project.replaces, + provides: project.provides, dependencies: project.runtime_dependencies, } ) diff --git a/spec/unit/packagers/deb_spec.rb b/spec/unit/packagers/deb_spec.rb index fbb99bd51..7c80695a0 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 @@ -136,6 +137,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 28489452b..ef5d2c8ff 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 f090a14db..edb11bec3 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}