Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Project.provide()' for virtual packages #721

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/omnibus/packagers/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def write_control_file
section: section,
conflicts: project.conflicts,
replaces: project.replaces,
provides: project.provides,
dependencies: project.runtime_dependencies,
}
)
Expand Down
1 change: 1 addition & 0 deletions lib/omnibus/packagers/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions lib/omnibus/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -897,6 +914,15 @@ def replaces
@replaces ||= []
end

#
# The list of things this project provides.
#
# @return [Array<String>]
#
def provides
@provides ||= []
end

#
# The list of exclusions for this project.
#
Expand Down
3 changes: 3 additions & 0 deletions resources/deb/control.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
2 changes: 2 additions & 0 deletions spec/unit/packagers/deb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -178,6 +179,7 @@ module Omnibus
expect(contents).to include("Vendor: Omnibus <[email protected]>")
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")
Expand Down
1 change: 1 addition & 0 deletions spec/unit/packagers/rpm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/unit/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down