Add support for entropy_keywords type
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Added support for `entropy_splitdebug` and `entropy_splitdebug_mask`
|
- Added support for additional types:
|
||||||
|
- `entropy_splitdebug`
|
||||||
|
- `entropy_splitdebug_mask`
|
||||||
|
- `entropy_keywords`
|
||||||
|
|
||||||
## 2016-10-10 Release 0.0.2
|
## 2016-10-10 Release 0.0.2
|
||||||
|
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -201,6 +201,34 @@ entropy_splitdebug_mask { 'kernel-4.8':
|
|||||||
The same caveats about managint the splitdebug file apply as with the
|
The same caveats about managint the splitdebug file apply as with the
|
||||||
`entropy_mask` type above.
|
`entropy_mask` type above.
|
||||||
|
|
||||||
|
### Managing package keywords
|
||||||
|
|
||||||
|
The `entropy_keywords` type allows managing entries in the `package.keywords`
|
||||||
|
file, which can set missing keywords on packages. A typical example is when
|
||||||
|
installing a `9999` version package straight from source control which hasn't
|
||||||
|
been marked as supported on any platform.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
* `keyword`: The package keyword to apply. Defaults to the OS architecutre,
|
||||||
|
e.g. `amd64` if not specified, but other typical values might be `~amd64`,
|
||||||
|
`-*` or `**`.
|
||||||
|
* `package`: Name of the package, maybe qualified or unqualified.
|
||||||
|
* `operator`: (`<`, `<=`, `=`, `>=`, `>`, applied to version)
|
||||||
|
* `version`: Restrict the keyword to a specifc version or range of versions
|
||||||
|
* `repo`: Restrict the keyword to packages from a specific repo
|
||||||
|
|
||||||
|
At least one of `package` or `repo` must be specified.
|
||||||
|
|
||||||
|
```puppet
|
||||||
|
entropy_keywords { 'sublime-live':
|
||||||
|
package => 'app-text/sublime-text',
|
||||||
|
version => '9999',
|
||||||
|
keyword => '**',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For more info on package keywords, see https://wiki.gentoo.org/wiki/KEYWORDS
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
|
|
||||||
### Classes
|
### Classes
|
||||||
|
|||||||
44
lib/puppet/provider/entropy_keywords/parsed.rb
Normal file
44
lib/puppet/provider/entropy_keywords/parsed.rb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
require 'puppet/provider/parsedfile'
|
||||||
|
file = "/etc/entropy/packages/package.keywords"
|
||||||
|
|
||||||
|
Puppet::Type.type(:entropy_keywords).provide(:parsed,
|
||||||
|
:parent => Puppet::Provider::ParsedFile,
|
||||||
|
:default_target => file,
|
||||||
|
:filetype => :flat
|
||||||
|
) do
|
||||||
|
|
||||||
|
desc "Override keywords for entropy packages"
|
||||||
|
|
||||||
|
defaultfor :operatingsystem => :sabayon
|
||||||
|
|
||||||
|
text_line :blank,
|
||||||
|
:match => /^\s*$/
|
||||||
|
|
||||||
|
text_line :comment,
|
||||||
|
:match => /^\s*#/
|
||||||
|
|
||||||
|
text_line :unmanaged,
|
||||||
|
:match => %r{^(\S+)\s+([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?:\s+repo=([a-zA-Z0-9\._-]+))?\s*$}
|
||||||
|
|
||||||
|
record_line :parsed,
|
||||||
|
:fields => %w{keyword operator package version repo name},
|
||||||
|
:match => %r{^(\S+)\s+([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?:\s+repo=([a-zA-Z0-9\._-]+))?\s+## Puppet Name: (.*)\s*$},
|
||||||
|
:block_eval => :instance do
|
||||||
|
|
||||||
|
def to_line(record)
|
||||||
|
line = record[:keyword] + " "
|
||||||
|
line += record[:operator] if record[:operator]
|
||||||
|
line += record[:package] if record[:package]
|
||||||
|
line += "-" + record[:version] if record[:version]
|
||||||
|
line += " repo=" + record[:repo] if record[:repo]
|
||||||
|
line += " ## Puppet Name: " + record[:name]
|
||||||
|
|
||||||
|
line
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
69
lib/puppet/type/entropy_keywords.rb
Normal file
69
lib/puppet/type/entropy_keywords.rb
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
Puppet::Type.newtype(:entropy_keywords) do
|
||||||
|
@desc = "Override keywords for Entropy packages"
|
||||||
|
|
||||||
|
ensurable
|
||||||
|
|
||||||
|
newparam(:name) do
|
||||||
|
desc "Unique name for this keyword entry"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:keyword) do
|
||||||
|
desc "Keyword to be applied to matching packages"
|
||||||
|
|
||||||
|
defaultto {
|
||||||
|
os = Facter.value(:os)
|
||||||
|
if os.key?('architecture')
|
||||||
|
os['architecture']
|
||||||
|
else
|
||||||
|
'**'
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:operator) do
|
||||||
|
desc "Operator that applies to the version. If not specified, defaults to '=' if a version is provided, not used if no version is provided"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:package) do
|
||||||
|
desc "Name of the package being keyworded"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:version) do
|
||||||
|
desc "Version of the package"
|
||||||
|
|
||||||
|
validate do |value|
|
||||||
|
raise(ArgumentError, "") if value !~ /^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:repo) do
|
||||||
|
desc "Repo for the package"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:target) do
|
||||||
|
desc "Location of the package.keywords file being managed"
|
||||||
|
|
||||||
|
defaultto {
|
||||||
|
if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
|
||||||
|
@resource.class.defaultprovider.default_target
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
validate do
|
||||||
|
raise(ArgumentError, "At least one of package or repo is required") if self[:package].nil? && self[:repo].nil?
|
||||||
|
|
||||||
|
raise(ArgumentError, "Package is required when a version is specified") if self[:package].nil? && !self[:version].nil?
|
||||||
|
|
||||||
|
raise(ArgumentError, "Version is required when an operator is specified") if self[:version].nil? && !self[:operator].nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
autobefore(:package) do
|
||||||
|
[self[:package]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2 expandtab:
|
||||||
|
|
||||||
Reference in New Issue
Block a user