Compare commits
22 Commits
v0.0.2
...
feature_pr
| Author | SHA1 | Date | |
|---|---|---|---|
| 336d8f355a | |||
| 7f069307ee | |||
| 9b9e1281f3 | |||
| 61b3262b7a | |||
| 60329c3dec | |||
| 170787c7ad | |||
| 6a832304e3 | |||
| 60d72803b1 | |||
| d622d6b7dc | |||
| db52bda1c5 | |||
| e5b253546a | |||
| 6c94c710db | |||
| 6e5f65befc | |||
| 5a658c5d7e | |||
| 1072760d2b | |||
| c2ee8a6ca5 | |||
|
|
0f8bfcdc01 | ||
| 614e836827 | |||
| deda75dc92 | |||
| 8ca58a6323 | |||
| 9928a31e06 | |||
| 57c7b3fbce |
@@ -1,3 +1,10 @@
|
|||||||
|
## Unreleased
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
- First forge release
|
- First forge release
|
||||||
|
|||||||
99
README.md
99
README.md
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
This module extends puppet with support for the Sabayon Linux disttribution.
|
This module extends puppet with support for the Sabayon Linux distribution.
|
||||||
|
|
||||||
It adds support for:
|
It adds support for:
|
||||||
* The Entropy package manager
|
* The Entropy package manager
|
||||||
@@ -25,13 +25,13 @@ It adds support for:
|
|||||||
|
|
||||||
### What the sabayon module affects
|
### What the sabayon module affects
|
||||||
|
|
||||||
* `operatingsystem` fact
|
* `operatingsystem` fact:
|
||||||
This module overrides the operatingsystem fact to `Sabayon` on Sabayon
|
This module overrides the operatingsystem fact to `Sabayon` on Sabayon
|
||||||
systems.
|
systems.
|
||||||
* `Service` provider
|
* `Service` provider:
|
||||||
This module overrides the default provider for `service` resources to
|
This module overrides the default provider for `service` resources to
|
||||||
force use of `systemd`
|
force use of `systemd`
|
||||||
* `Package` provider
|
* `Package` provider:
|
||||||
This module overrides the default provider for `package` resources to
|
This module overrides the default provider for `package` resources to
|
||||||
force use of `entropy`
|
force use of `entropy`
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ setup, as long as the required packages are already installed. To let this
|
|||||||
module take care of installing the required packages, simply include the
|
module take care of installing the required packages, simply include the
|
||||||
`sabayon` class.
|
`sabayon` class.
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
class { 'sabayon': }
|
class { 'sabayon': }
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ so no special configuration is required.
|
|||||||
|
|
||||||
The provider supports package names in both the fully-qualified format, e.g.
|
The provider supports package names in both the fully-qualified format, e.g.
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
package { 'net-misc/openssh':
|
package { 'net-misc/openssh':
|
||||||
ensure => installed,
|
ensure => installed,
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ package { 'net-misc/openssh':
|
|||||||
|
|
||||||
Or the more verbose format:
|
Or the more verbose format:
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
package { 'ssh-server':
|
package { 'ssh-server':
|
||||||
ensure => installed,
|
ensure => installed,
|
||||||
category => 'net-misc',
|
category => 'net-misc',
|
||||||
@@ -78,7 +78,7 @@ not install 'mysql' since there's no way to disambiguate between
|
|||||||
|
|
||||||
### Managing enman repositories
|
### Managing enman repositories
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
enman_repo { 'community':
|
enman_repo { 'community':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
}
|
}
|
||||||
@@ -90,6 +90,7 @@ Entropy is very flexible in how to specify which packages can be masked,
|
|||||||
and supports some or all of the following in the atom specification.
|
and supports some or all of the following in the atom specification.
|
||||||
|
|
||||||
All of these parameters are optional, but at least one must be specified
|
All of these parameters are optional, but at least one must be specified
|
||||||
|
|
||||||
* `package` (either fully qualified or unqualified package name)
|
* `package` (either fully qualified or unqualified package name)
|
||||||
* `operator` (`<`, `<=`, `=`, `>=`, `>`. applied to version)
|
* `operator` (`<`, `<=`, `=`, `>=`, `>`. applied to version)
|
||||||
* `version`
|
* `version`
|
||||||
@@ -99,6 +100,7 @@ All of these parameters are optional, but at least one must be specified
|
|||||||
* `repo`
|
* `repo`
|
||||||
|
|
||||||
The `entropy_mask` type also takes the following optional parameters:
|
The `entropy_mask` type also takes the following optional parameters:
|
||||||
|
|
||||||
* `target` (The path to the mask file, defaults to
|
* `target` (The path to the mask file, defaults to
|
||||||
`/etc/entropy/packages/package.mask`)
|
`/etc/entropy/packages/package.mask`)
|
||||||
|
|
||||||
@@ -107,7 +109,7 @@ The `entropy_mask` type also takes the following optional parameters:
|
|||||||
To mask all packages within the `community` repository by default
|
To mask all packages within the `community` repository by default
|
||||||
and later unmask specific packages, you could use something like:
|
and later unmask specific packages, you could use something like:
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
entropy_mask { 'mask-community-by-default':
|
entropy_mask { 'mask-community-by-default':
|
||||||
repo => 'community',
|
repo => 'community',
|
||||||
}
|
}
|
||||||
@@ -115,7 +117,7 @@ entropy_mask { 'mask-community-by-default':
|
|||||||
|
|
||||||
Alternatively, you could mask newer versions of a package
|
Alternatively, you could mask newer versions of a package
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
entropy_mask { 'mask-postgresql-9.5+':
|
entropy_mask { 'mask-postgresql-9.5+':
|
||||||
package => 'app-shells/bash',
|
package => 'app-shells/bash',
|
||||||
operator => '>=',
|
operator => '>=',
|
||||||
@@ -127,7 +129,7 @@ Or mask a package with an undesirable set of use flags, e.g.
|
|||||||
to ensure any installed version of openssh supports ldap, mask
|
to ensure any installed version of openssh supports ldap, mask
|
||||||
all versions of openssh which don't include ldap support with:
|
all versions of openssh which don't include ldap support with:
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
entropy_mask { 'openssh-without-ldap-support':
|
entropy_mask { 'openssh-without-ldap-support':
|
||||||
package => 'net-misc/openssh',
|
package => 'net-misc/openssh',
|
||||||
use => '-ldap',
|
use => '-ldap',
|
||||||
@@ -153,7 +155,7 @@ in the example above you have masked everything in the `community` repository
|
|||||||
you could enable installing a particular package from that repository again
|
you could enable installing a particular package from that repository again
|
||||||
using:
|
using:
|
||||||
|
|
||||||
```
|
```puppet
|
||||||
entropy_unmask { 'sublime':
|
entropy_unmask { 'sublime':
|
||||||
package => 'app-editors/sublime-text',
|
package => 'app-editors/sublime-text',
|
||||||
}
|
}
|
||||||
@@ -162,6 +164,71 @@ entropy_unmask { 'sublime':
|
|||||||
The same caveats about managing the unmask file apply as with `entropy_mask`
|
The same caveats about managing the unmask file apply as with `entropy_mask`
|
||||||
above.
|
above.
|
||||||
|
|
||||||
|
### Enabling splitdebug for packages
|
||||||
|
|
||||||
|
Entropy splits debug information for packages into separate objects which are
|
||||||
|
installed at the same time as the package only if splitdebug is enabled
|
||||||
|
globally, or for specific packages listed in the `package.splitdebug` file.
|
||||||
|
|
||||||
|
This type behaves similarly to masks/unmasks and manages entries in the
|
||||||
|
splitdebug file to define packages for which debug information should be
|
||||||
|
installed. All the same parameters are supported as with `entropy_mask`.
|
||||||
|
|
||||||
|
```puppet
|
||||||
|
entropy_splitdebug { 'kernel':
|
||||||
|
package => 'sys-kernel/linux-sabayon',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The same caveats about managint the splitdebug file apply as with the
|
||||||
|
`entropy_mask` type above.
|
||||||
|
|
||||||
|
### Enabling splitdebug masks for packages
|
||||||
|
|
||||||
|
This type inverts the `entropy_splitdebug` behaviour, and prevents splitdebug
|
||||||
|
from being installed for matching packages even when otherwise enabled by an
|
||||||
|
`entropy_splitdebug` entry. Masks take precedence, and anything matched by an
|
||||||
|
`entropy_splitdebug_mask` entry will never have debug information installed.
|
||||||
|
All the same parameters are supported as with `entropy_mask`.
|
||||||
|
|
||||||
|
```puppet
|
||||||
|
entropy_splitdebug_mask { 'kernel-4.8':
|
||||||
|
package => 'sys-kernel/linux-sabayon',
|
||||||
|
slot => '4.8',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The same caveats about managint the splitdebug file apply as with the
|
||||||
|
`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
|
||||||
@@ -170,9 +237,11 @@ above.
|
|||||||
|
|
||||||
### Types
|
### Types
|
||||||
|
|
||||||
* `enman_repo` Manages SCR repositories using enman
|
* `enman_repo`: Manages SCR repositories using enman
|
||||||
* `entropy_mask` Manages entropy package masks
|
* `entropy_mask`: Manages entropy package masks
|
||||||
* `entropy_unmask` Manages entropy package unmasks
|
* `entropy_unmask`: Manages entropy package unmasks
|
||||||
|
* `entropy_splitdebug` Manages entropy package debug information
|
||||||
|
* `entropy_splitdebug_mask` Manages entropy package debug information masks
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|||||||
41
lib/puppet/provider/entropy_keywords/parsed.rb
Normal file
41
lib/puppet/provider/entropy_keywords/parsed.rb
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
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*$},
|
||||||
|
:to_line => proc { |record|
|
||||||
|
line = record[:keyword] + " "
|
||||||
|
line += record[:operator] if record[:operator]
|
||||||
|
line += record[:package] if record[:package]
|
||||||
|
line += "-" + record[:version] if record[:version]
|
||||||
|
line += " " if record[:package] && record[:repo]
|
||||||
|
line += "repo=" + record[:repo] if record[:repo]
|
||||||
|
line += " ## Puppet Name: " + record[:name]
|
||||||
|
|
||||||
|
line
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
@@ -18,28 +18,24 @@ Puppet::Type.type(:entropy_mask).provide(:parsed,
|
|||||||
:match => /^\s*#/
|
:match => /^\s*#/
|
||||||
|
|
||||||
text_line :unmanaged,
|
text_line :unmanaged,
|
||||||
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::(\w+))?(?:\[([^\]]*)\])?(?:#(\w+))?(?:::(\w+))?\s*$}
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9._-]+))?(?:::([a-zA-Z0-9\._-]+))?\s*$}
|
||||||
|
|
||||||
record_line :parsed,
|
record_line :parsed,
|
||||||
:fields => %w{operator package version slot use tag repo name},
|
:fields => %w{operator package version slot use tag repo name},
|
||||||
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::(\w+))?(?:\[([^\]]*)\])?(?:#(\w+))?(?:::(\w+))?\s+# Puppet Name: (.*)\s*$},
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9._-]+))?(?:::([a-zA-Z0-9\._-]+))?\s+#+ Puppet Name: (.*)\s*$},
|
||||||
:block_eval => :instance do
|
:to_line => proc { |record|
|
||||||
|
|
||||||
def to_line(record)
|
|
||||||
line = ""
|
line = ""
|
||||||
line += record[:operator] if record[:operator]
|
line += record[:operator] if record[:operator]
|
||||||
line += record[:package]
|
line += record[:package] if record[:package]
|
||||||
line += "-" + record[:version] if record[:version]
|
line += "-" + record[:version] if record[:version]
|
||||||
line += ":" + record[:slot] if record[:slot]
|
line += ":" + record[:slot] if record[:slot]
|
||||||
line += "[" + record[:use] + "]" if record[:use]
|
line += "[" + record[:use] + "]" if record[:use]
|
||||||
line += "#" + record[:tag] if record[:tag]
|
line += "#" + record[:tag] if record[:tag]
|
||||||
line += "::" + record[:repo] if record[:repo]
|
line += "::" + record[:repo] if record[:repo]
|
||||||
line += " # Puppet Name: " + record[:name]
|
line += " ## Puppet Name: " + record[:name]
|
||||||
|
|
||||||
line
|
line
|
||||||
end
|
}
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
43
lib/puppet/provider/entropy_splitdebug/parsed.rb
Normal file
43
lib/puppet/provider/entropy_splitdebug/parsed.rb
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
require 'puppet/provider/parsedfile'
|
||||||
|
file = "/etc/entropy/packages/package.splitdebug"
|
||||||
|
|
||||||
|
Puppet::Type.type(:entropy_splitdebug).provide(:parsed,
|
||||||
|
:parent => Puppet::Provider::ParsedFile,
|
||||||
|
:default_target => file,
|
||||||
|
:filetype => :flat
|
||||||
|
) do
|
||||||
|
|
||||||
|
desc "File splitdebug provider for entropy packages"
|
||||||
|
|
||||||
|
defaultfor :operatingsystem => :sabayon
|
||||||
|
|
||||||
|
text_line :blank,
|
||||||
|
:match => /^\s*$/
|
||||||
|
|
||||||
|
text_line :comment,
|
||||||
|
:match => /^\s*#/
|
||||||
|
|
||||||
|
text_line :unmanaged,
|
||||||
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9\._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9\._-]+))?(?:::([a-zA-Z0-9\._-]+))?\s*$}
|
||||||
|
|
||||||
|
record_line :parsed,
|
||||||
|
:fields => %w{operator package version slot use tag repo name},
|
||||||
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9\._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9\._-]+))?(?:::([a-zA-Z0-9\._-]+))?\s+#+ Puppet Name: (.*)\s*$},
|
||||||
|
:to_line => proc { |record|
|
||||||
|
line = ""
|
||||||
|
line += record[:operator] if record[:operator]
|
||||||
|
line += record[:package] if record[:package]
|
||||||
|
line += "-" + record[:version] if record[:version]
|
||||||
|
line += ":" + record[:slot] if record[:slot]
|
||||||
|
line += "[" + record[:use] + "]" if record[:use]
|
||||||
|
line += "#" + record[:tag] if record[:tag]
|
||||||
|
line += "::" + record[:repo] if record[:repo]
|
||||||
|
line += " ## Puppet Name: " + record[:name]
|
||||||
|
|
||||||
|
line
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
43
lib/puppet/provider/entropy_splitdebug_mask/parsed.rb
Normal file
43
lib/puppet/provider/entropy_splitdebug_mask/parsed.rb
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
require 'puppet/provider/parsedfile'
|
||||||
|
file = "/etc/entropy/packages/package.splitdebug.mask"
|
||||||
|
|
||||||
|
Puppet::Type.type(:entropy_splitdebug_mask).provide(:parsed,
|
||||||
|
:parent => Puppet::Provider::ParsedFile,
|
||||||
|
:default_target => file,
|
||||||
|
:filetype => :flat
|
||||||
|
) do
|
||||||
|
|
||||||
|
desc "File splitdebug mask provider for entropy packages"
|
||||||
|
|
||||||
|
defaultfor :operatingsystem => :sabayon
|
||||||
|
|
||||||
|
text_line :blank,
|
||||||
|
:match => /^\s*$/
|
||||||
|
|
||||||
|
text_line :comment,
|
||||||
|
:match => /^\s*#/
|
||||||
|
|
||||||
|
text_line :unmanaged,
|
||||||
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9\._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9._-]+))?(?:::([a-zA-Z0-9._-]+))?\s*$}
|
||||||
|
|
||||||
|
record_line :parsed,
|
||||||
|
:fields => %w{operator package version slot use tag repo name},
|
||||||
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9._-]+))?(?:::([a-zA-Z0-9._-]+))?\s+#+ Puppet Name: (.*)\s*$},
|
||||||
|
:to_line => proc { |record|
|
||||||
|
line = ""
|
||||||
|
line += record[:operator] if record[:operator]
|
||||||
|
line += record[:package] if record[:package]
|
||||||
|
line += "-" + record[:version] if record[:version]
|
||||||
|
line += ":" + record[:slot] if record[:slot]
|
||||||
|
line += "[" + record[:use] + "]" if record[:use]
|
||||||
|
line += "#" + record[:tag] if record[:tag]
|
||||||
|
line += "::" + record[:repo] if record[:repo]
|
||||||
|
line += " ## Puppet Name: " + record[:name]
|
||||||
|
|
||||||
|
line
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
@@ -18,28 +18,24 @@ Puppet::Type.type(:entropy_unmask).provide(:parsed,
|
|||||||
:match => /^\s*#/
|
:match => /^\s*#/
|
||||||
|
|
||||||
text_line :unmanaged,
|
text_line :unmanaged,
|
||||||
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::(\w+))?(?:\[([^\]]*)\])?(?:#(\w+))?(?:::(\w+))?\s*$}
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9._-]+))?(?:::([a-zA-Z0-9._-]+))?\s*$}
|
||||||
|
|
||||||
record_line :parsed,
|
record_line :parsed,
|
||||||
:fields => %w{operator package version slot use tag repo name},
|
:fields => %w{operator package version slot use tag repo name},
|
||||||
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::(\w+))?(?:\[([^\]]*)\])?(?:#(\w+))?(?:::(\w+))?\s+# Puppet Name: (.*)\s*$},
|
:match => %r{^([<>]?=)?([a-zA-Z+\/-]*)(?:-(\d+(?:\.\d+)*[a-z]*(?:_(?:alpha|beta|pre|p|rc)\d*)?(?:-r\d+)?))?(?::([a-zA-Z0-9._-]+))?(?:\[([^\]]*)\])?(?:#([a-zA-Z0-9._-]+))?(?:::([a-zA-Z0-9._-]+))?\s+#+ Puppet Name: (.*)\s*$},
|
||||||
:block_eval => :instance do
|
:to_line => proc { |record|
|
||||||
|
|
||||||
def to_line(record)
|
|
||||||
line = ""
|
line = ""
|
||||||
line += record[:operator] if record[:operator]
|
line += record[:operator] if record[:operator]
|
||||||
line += record[:package]
|
line += record[:package] if record[:package]
|
||||||
line += "-" + record[:version] if record[:version]
|
line += "-" + record[:version] if record[:version]
|
||||||
line += ":" + record[:slot] if record[:slot]
|
line += ":" + record[:slot] if record[:slot]
|
||||||
line += "[" + record[:use] + "]" if record[:use]
|
line += "[" + record[:use] + "]" if record[:use]
|
||||||
line += "#" + record[:tag] if record[:tag]
|
line += "#" + record[:tag] if record[:tag]
|
||||||
line += "::" + record[:repo] if record[:repo]
|
line += "::" + record[:repo] if record[:repo]
|
||||||
line += " # Puppet Name: " + record[:name]
|
line += " ## Puppet Name: " + record[:name]
|
||||||
|
|
||||||
line
|
line
|
||||||
end
|
}
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
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:
|
||||||
|
|
||||||
@@ -52,6 +52,10 @@ Puppet::Type.newtype(:entropy_mask) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
validate do
|
validate do
|
||||||
|
raise(ArgumentError, "At least one of package, tag or repo is required") if self[:package].nil? && self[:tag].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?
|
raise(ArgumentError, "Version is required when an operator is specified") if self[:version].nil? && !self[:operator].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
68
lib/puppet/type/entropy_splitdebug.rb
Normal file
68
lib/puppet/type/entropy_splitdebug.rb
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
Puppet::Type.newtype(:entropy_splitdebug) do
|
||||||
|
@desc = "Manages splitdebug for packages in Entropy"
|
||||||
|
|
||||||
|
ensurable
|
||||||
|
|
||||||
|
newparam(:name) do
|
||||||
|
desc "Unique name for this splitdebug specification"
|
||||||
|
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 with splitdebug"
|
||||||
|
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(:slot) do
|
||||||
|
desc "Slot the package is in"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:use) do
|
||||||
|
desc "Useflags for the package"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:tag) do
|
||||||
|
desc "Tag for the package"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:repo) do
|
||||||
|
desc "Repo for the package"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:target) do
|
||||||
|
desc "Location of the package.splitdebug 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, tag or repo is required") if self[:package].nil? && self[:tag].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:
|
||||||
|
|
||||||
68
lib/puppet/type/entropy_splitdebug_mask.rb
Normal file
68
lib/puppet/type/entropy_splitdebug_mask.rb
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
Puppet::Type.newtype(:entropy_splitdebug_mask) do
|
||||||
|
@desc = "Manages splitdebug masks for packages in Entropy"
|
||||||
|
|
||||||
|
ensurable
|
||||||
|
|
||||||
|
newparam(:name) do
|
||||||
|
desc "Unique name for this splitdebug mask specification"
|
||||||
|
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 with splitdebug mask"
|
||||||
|
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(:slot) do
|
||||||
|
desc "Slot the package is in"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:use) do
|
||||||
|
desc "Useflags for the package"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:tag) do
|
||||||
|
desc "Tag for the package"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:repo) do
|
||||||
|
desc "Repo for the package"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:target) do
|
||||||
|
desc "Location of the package.splitdebug.mask 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, tag or repo is required") if self[:package].nil? && self[:tag].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:
|
||||||
|
|
||||||
@@ -52,6 +52,10 @@ Puppet::Type.newtype(:entropy_unmask) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
validate do
|
validate do
|
||||||
|
raise(ArgumentError, "At least one of package, tag or repo is required") if self[:package].nil? && self[:tag].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?
|
raise(ArgumentError, "Version is required when an operator is specified") if self[:version].nil? && !self[:operator].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
233
spec/unit/provider/entropy_keywords/parsed_spec.rb
Normal file
233
spec/unit/provider/entropy_keywords/parsed_spec.rb
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Puppet::Type.type(:entropy_keywords).provider(:parsed) do
|
||||||
|
before do
|
||||||
|
described_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
|
||||||
|
described_class.stubs(:filetype=)
|
||||||
|
@default_target = described_class.default_target
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'should have a default target of /etc/entropy/packages/package.keywords' do
|
||||||
|
it do
|
||||||
|
expect(described_class.default_target).to eq('/etc/entropy/packages/package.keywords')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when parsing' do
|
||||||
|
it 'should parse out the name' do
|
||||||
|
line = '** app-admin/foobar ## Puppet Name: foobar'
|
||||||
|
expect(described_class.parse_line(line)[:name]).to eq('foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with just a package name' do
|
||||||
|
line = '** app-admin/foobar ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the keyword' do
|
||||||
|
expect(parsed[:keyword]).to eq('**')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :version, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a versioned package' do
|
||||||
|
line = '** app-admin/foobar-1.2.3_alpha1-r1 ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the keyword' do
|
||||||
|
expect(parsed[:keyword]).to eq('**')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the version' do
|
||||||
|
expect(parsed[:version]).to eq('1.2.3_alpha1-r1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a package range' do
|
||||||
|
line = '** >=app-admin/foobar-1.2.3_alpha1-r1 ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the keyword' do
|
||||||
|
expect(parsed[:keyword]).to eq('**')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the version' do
|
||||||
|
expect(parsed[:version]).to eq('1.2.3_alpha1-r1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the operator' do
|
||||||
|
expect(parsed[:operator]).to eq('>=')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a package from a specific repo' do
|
||||||
|
line = '** app-admin/foobar repo=community ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the keyword' do
|
||||||
|
expect(parsed[:keyword]).to eq('**')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the repo' do
|
||||||
|
expect(parsed[:repo]).to eq('community')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :version].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with all packages from a specific repo' do
|
||||||
|
line = 'amd64 repo=community ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the keyword' do
|
||||||
|
expect(parsed[:keyword]).to eq('amd64')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the repo' do
|
||||||
|
expect(parsed[:repo]).to eq('community')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:package, :operator, :version].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with everything' do
|
||||||
|
line = '** >=app-admin/foobar-1.2.3a_alpha1-r1 repo=community ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
expected = {
|
||||||
|
:name => 'foobar',
|
||||||
|
:keyword => '**',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:operator => '>=',
|
||||||
|
:version => '1.2.3a_alpha1-r1',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'should parse out all parameters' do
|
||||||
|
expected.each do |param, value|
|
||||||
|
expect(parsed[param]).to eq(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when flushing' do
|
||||||
|
before :each do
|
||||||
|
@ramfile = Puppet::Util::FileType::FileTypeRam.new(@default_target)
|
||||||
|
File.stubs(:exist?).with(@default_target).returns(true)
|
||||||
|
described_class.any_instance.stubs(:target_object).returns(@ramfile)
|
||||||
|
end
|
||||||
|
|
||||||
|
after :each do
|
||||||
|
described_class.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a single package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:keyword => '**',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('** app-admin/foobar ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a versioned package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:keyword => '**',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:version => '1.2.3',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('** app-admin/foobar-1.2.3 ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a ranged versioned package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:keyword => '**',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:version => '1.2.3',
|
||||||
|
:operator => '>=',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('** >=app-admin/foobar-1.2.3 ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a repo-specific package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:keyword => '**',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('** app-admin/foobar repo=community ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a whole-repo entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:keyword => '**',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('** repo=community ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output all fields for a package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:keyword => '**',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:operator => '>=',
|
||||||
|
:version => '1.2.3',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('** >=app-admin/foobar-1.2.3 repo=community ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
304
spec/unit/provider/package_types/parsed_spec.rb
Normal file
304
spec/unit/provider/package_types/parsed_spec.rb
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'puppet/type/entropy_mask'
|
||||||
|
require 'puppet/type/entropy_unmask'
|
||||||
|
require 'puppet/type/entropy_splitdebug'
|
||||||
|
require 'puppet/type/entropy_splitdebug_mask'
|
||||||
|
|
||||||
|
types = {
|
||||||
|
:entropy_mask => Puppet::Type::Entropy_mask,
|
||||||
|
:entropy_unmask => Puppet::Type::Entropy_unmask,
|
||||||
|
:entropy_splitdebug => Puppet::Type::Entropy_splitdebug,
|
||||||
|
:entropy_splitdebug_mask => Puppet::Type::Entropy_splitdebug_mask,
|
||||||
|
}
|
||||||
|
|
||||||
|
default_targets = {
|
||||||
|
:entropy_mask => '/etc/entropy/packages/package.mask',
|
||||||
|
:entropy_unmask => '/etc/entropy/packages/package.unmask',
|
||||||
|
:entropy_splitdebug => '/etc/entropy/packages/package.splitdebug',
|
||||||
|
:entropy_splitdebug_mask => '/etc/entropy/packages/package.splitdebug.mask',
|
||||||
|
}
|
||||||
|
|
||||||
|
types.each do |type_name, type|
|
||||||
|
describe Puppet::Type.type(type_name).provider(:parsed) do
|
||||||
|
before do
|
||||||
|
described_class.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
|
||||||
|
described_class.stubs(:filetype=)
|
||||||
|
@default_target = described_class.default_target
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "should have a default target of #{default_targets[type_name]}" do
|
||||||
|
it do
|
||||||
|
expect(described_class.default_target).to eq(default_targets[type_name])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when parsing' do
|
||||||
|
it 'should parse out the name' do
|
||||||
|
line = 'app-admin/foobar ## Puppet Name: foobar'
|
||||||
|
expect(described_class.parse_line(line)[:name]).to eq('foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with just a package name' do
|
||||||
|
line = 'app-admin/foobar ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :version, :slot, :use, :tag, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a versioned package' do
|
||||||
|
line = 'app-admin/foobar-1.2.3_alpha1-r1 ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the version' do
|
||||||
|
expect(parsed[:version]).to eq('1.2.3_alpha1-r1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :slot, :use, :tag, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a package range' do
|
||||||
|
line = '>=app-admin/foobar-1.2.3_alpha1-r1 ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the version' do
|
||||||
|
expect(parsed[:version]).to eq('1.2.3_alpha1-r1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the operator' do
|
||||||
|
expect(parsed[:operator]).to eq('>=')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:slot, :use, :tag, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a slotted package' do
|
||||||
|
line = 'app-admin/foobar:1.1 ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the slot' do
|
||||||
|
expect(parsed[:slot]).to eq('1.1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :version, :use, :tag, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a package with use restrictions' do
|
||||||
|
line = 'app-admin/foobar[-foo,bar] ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the use' do
|
||||||
|
expect(parsed[:use]).to eq('-foo,bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :version, :slot, :tag, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a tagged package' do
|
||||||
|
line = 'app-admin/foobar#server ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the tag' do
|
||||||
|
expect(parsed[:tag]).to eq('server')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :version, :slot, :use, :repo].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a package from a specific repo' do
|
||||||
|
line = 'app-admin/foobar::community ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
it 'should parse out the package name' do
|
||||||
|
expect(parsed[:package]).to eq('app-admin/foobar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse out the repo' do
|
||||||
|
expect(parsed[:repo]).to eq('community')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have all other parameters undefined' do
|
||||||
|
[:operator, :version, :slot, :use, :tag].each do |param|
|
||||||
|
expect(parsed[param]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with everything' do
|
||||||
|
line = '>=app-admin/foobar-1.2.3a_alpha1-r1:1[-foo]#server::community ## Puppet Name: foobar'
|
||||||
|
parsed = described_class.parse_line(line)
|
||||||
|
|
||||||
|
expected = {
|
||||||
|
:name => 'foobar',
|
||||||
|
:operator => '>=',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:version => '1.2.3a_alpha1-r1',
|
||||||
|
:slot => '1',
|
||||||
|
:use => '-foo',
|
||||||
|
:tag => 'server',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'should parse out all parameters' do
|
||||||
|
expected.each do |param, value|
|
||||||
|
expect(parsed[param]).to eq(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when flushing' do
|
||||||
|
before :each do
|
||||||
|
@ramfile = Puppet::Util::FileType::FileTypeRam.new(@default_target)
|
||||||
|
File.stubs(:exist?).with(default_targets[type_name]).returns(true)
|
||||||
|
described_class.any_instance.stubs(:target_object).returns(@ramfile)
|
||||||
|
end
|
||||||
|
|
||||||
|
after :each do
|
||||||
|
described_class.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a single package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('app-admin/foobar ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a versioned package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:version => '1.2.3',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('app-admin/foobar-1.2.3 ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a ranged versioned package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:version => '1.2.3',
|
||||||
|
:operator => '>=',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('>=app-admin/foobar-1.2.3 ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a use-restricted package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:use => '-foo,bar',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('app-admin/foobar[-foo,bar] ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a slotted package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:slot => '1.1',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('app-admin/foobar:1.1 ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a tagged package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:tag => 'server',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('app-admin/foobar#server ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a repo-specific package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('app-admin/foobar::community ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output a whole-repo entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('::community ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should output all fields for a package entry' do
|
||||||
|
resource = {
|
||||||
|
:record_type => :parsed,
|
||||||
|
:name => 'test',
|
||||||
|
:package => 'app-admin/foobar',
|
||||||
|
:operator => '>=',
|
||||||
|
:version => '1.2.3',
|
||||||
|
:slot => '1.1',
|
||||||
|
:use => '-foo,bar',
|
||||||
|
:tag => 'server',
|
||||||
|
:repo => 'community',
|
||||||
|
}
|
||||||
|
expect(described_class.to_line(resource)).to eq ('>=app-admin/foobar-1.2.3:1.1[-foo,bar]#server::community ## Puppet Name: test')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
25
spec/unit/type/enman_repo_spec.rb
Normal file
25
spec/unit/type/enman_repo_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
describe Puppet::Type.type(:enman_repo) do
|
||||||
|
before do
|
||||||
|
@provider = stub 'provider'
|
||||||
|
@provider.stubs(:name).returns(:enman)
|
||||||
|
described_class.stubs(:defaultprovider).returns(@provider)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be an instance of Puppet::Type::Enman_repo" do
|
||||||
|
expect(described_class.new(:name => "test")).to be_an_instance_of Puppet::Type::Enman_repo
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating attributes" do
|
||||||
|
params = [:name]
|
||||||
|
|
||||||
|
params.each do |param|
|
||||||
|
it "should have the #{param} param" do
|
||||||
|
expect(described_class.attrtype(param)).to eq :param
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should have name as the namevar" do
|
||||||
|
expect(described_class.key_attributes).to eq [:name]
|
||||||
|
end
|
||||||
|
end
|
||||||
77
spec/unit/type/entropy_keywords_spec.rb
Normal file
77
spec/unit/type/entropy_keywords_spec.rb
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
describe Puppet::Type.type(:entropy_keywords) do
|
||||||
|
before do
|
||||||
|
@provider = stub 'provider'
|
||||||
|
@provider.stubs(:name).returns(:parsed)
|
||||||
|
@provider.stubs(:ancestors).returns([Puppet::Provider::ParsedFile])
|
||||||
|
@provider.stubs(:default_target).returns("defaulttarget")
|
||||||
|
described_class.stubs(:defaultprovider).returns(@provider)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be an instance of Puppet::Type::Entropy_keywords" do
|
||||||
|
expect(described_class.new(:name => "test", :package => "app-admin/dummy")).to be_an_instance_of Puppet::Type::Entropy_keywords
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating attributes" do
|
||||||
|
params = [:name]
|
||||||
|
properties = [:package, :operator, :version, :repo, :target]
|
||||||
|
|
||||||
|
params.each do |param|
|
||||||
|
it "should have the #{param} param" do
|
||||||
|
expect(described_class.attrtype(param)).to eq :param
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
properties.each do |property|
|
||||||
|
it "should have the #{property} property" do
|
||||||
|
expect(described_class.attrtype(property)).to eq :property
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should have name as the namevar" do
|
||||||
|
expect(described_class.key_attributes).to eq [:name]
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating the target property" do
|
||||||
|
it "should default to the provider's default target" do
|
||||||
|
expect(described_class.new(:name => "test", :package => "app-admin/dummy").should(:target)).to eq "defaulttarget"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating required properties" do
|
||||||
|
it "should raise an error when no required attributes are passed" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => "test")
|
||||||
|
}.to raise_error(Puppet::Error, /At least one of (.*) is required/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should raise an error when a version is passed with no package" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => "test", :repo => "test", :version => "1.2.3")
|
||||||
|
}.to raise_error(Puppet::Error, /Package is required/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should raise an error when an operator is passed with no version" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => "test", :package => "app-admin/dummy", :operator => "<=")
|
||||||
|
}.to raise_error(Puppet::Error, /Version is required/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when the catalog includes a matching package" do
|
||||||
|
it "should have an autobefore relationship" do
|
||||||
|
resource = described_class.new(:name => "test", :package => "app-admin/dummy")
|
||||||
|
package = Puppet::Type.type(:package).new(:title => 'app-admin/dummy')
|
||||||
|
|
||||||
|
catalog = Puppet::Resource::Catalog.new
|
||||||
|
catalog.add_resource package
|
||||||
|
catalog.add_resource resource
|
||||||
|
|
||||||
|
befores = resource.autobefore
|
||||||
|
expect(befores.size).to eq 1
|
||||||
|
expect(befores[0].source).to eq resource
|
||||||
|
expect(befores[0].target).to eq package
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
94
spec/unit/type/package_types_spec.rb
Normal file
94
spec/unit/type/package_types_spec.rb
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'puppet/type/entropy_mask'
|
||||||
|
require 'puppet/type/entropy_unmask'
|
||||||
|
require 'puppet/type/entropy_splitdebug'
|
||||||
|
require 'puppet/type/entropy_splitdebug_mask'
|
||||||
|
|
||||||
|
types = {
|
||||||
|
:entropy_mask => Puppet::Type::Entropy_mask,
|
||||||
|
:entropy_unmask => Puppet::Type::Entropy_unmask,
|
||||||
|
:entropy_splitdebug => Puppet::Type::Entropy_splitdebug,
|
||||||
|
:entropy_splitdebug_mask => Puppet::Type::Entropy_splitdebug_mask,
|
||||||
|
}
|
||||||
|
|
||||||
|
types.each do |type_name, type|
|
||||||
|
describe Puppet::Type.type(type_name) do
|
||||||
|
before do
|
||||||
|
@provider = stub 'provider'
|
||||||
|
@provider.stubs(:name).returns(:parsed)
|
||||||
|
@provider.stubs(:ancestors).returns([Puppet::Provider::ParsedFile])
|
||||||
|
@provider.stubs(:default_target).returns("defaulttarget")
|
||||||
|
described_class.stubs(:defaultprovider).returns(@provider)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be an instance of #{type.class.name}" do
|
||||||
|
expect(described_class.new(:name => "test", :package => "app-admin/dummy")).to be_an_instance_of type
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating attributes" do
|
||||||
|
params = [:name]
|
||||||
|
properties = [:package, :operator, :version, :slot, :use, :tag, :repo, :target]
|
||||||
|
|
||||||
|
params.each do |param|
|
||||||
|
it "should have the #{param} param" do
|
||||||
|
expect(described_class.attrtype(param)).to eq :param
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
properties.each do |property|
|
||||||
|
it "should have the #{property} property" do
|
||||||
|
expect(described_class.attrtype(property)).to eq :property
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should have name as the namevar" do
|
||||||
|
expect(described_class.key_attributes).to eq [:name]
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating the target property" do
|
||||||
|
it "should default to the provider's default target" do
|
||||||
|
expect(described_class.new(:name => "test", :package => "app-admin/dummy").should(:target)).to eq "defaulttarget"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating required properties" do
|
||||||
|
it "should raise an error when no required attributes are passed" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => "test")
|
||||||
|
}.to raise_error(Puppet::Error, /At least one of (.*) is required/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should raise an error when a version is passed with no package" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => "test", :repo => "test", :version => "1.2.3")
|
||||||
|
}.to raise_error(Puppet::Error, /Package is required/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should raise an error when an operator is passed with no version" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => "test", :package => "app-admin/dummy", :operator => "<=")
|
||||||
|
}.to raise_error(Puppet::Error, /Version is required/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when the catalog includes a matching package" do
|
||||||
|
it "should have an autobefore relationship" do
|
||||||
|
resource = described_class.new(:name => "test", :package => "app-admin/dummy")
|
||||||
|
package = Puppet::Type.type(:package).new(:title => 'app-admin/dummy')
|
||||||
|
|
||||||
|
catalog = Puppet::Resource::Catalog.new
|
||||||
|
catalog.add_resource package
|
||||||
|
catalog.add_resource resource
|
||||||
|
|
||||||
|
befores = resource.autobefore
|
||||||
|
expect(befores.size).to eq 1
|
||||||
|
expect(befores[0].source).to eq resource
|
||||||
|
expect(befores[0].target).to eq package
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2 expandtab:
|
||||||
Reference in New Issue
Block a user