Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e962f31411 | |||
| 97c1cc97e6 | |||
| bd1fd54bbb | |||
| 3a4c1c85ad | |||
| 0c3db36c4d | |||
| 9115033d04 | |||
| cabc5c19ce | |||
| 7dca7dad51 | |||
| 53bbad2eb1 | |||
| 80644b6813 | |||
| 4020627a15 | |||
| a265caa979 | |||
| 7ce45a207f | |||
| 6d9b130f9d | |||
| f2565cccc1 | |||
| f4bdac2266 | |||
| f90c0fb9ef | |||
| 5e5d056025 | |||
| 0e774c77d5 | |||
| f45895e8dd | |||
| fa20f3aead | |||
| 76ffa4937b | |||
| 24b4a82949 | |||
| 336d8f355a | |||
| 7f069307ee | |||
| 9b9e1281f3 | |||
| 61b3262b7a | |||
| 60329c3dec | |||
| 170787c7ad | |||
| 6a832304e3 | |||
| 60d72803b1 | |||
| d622d6b7dc | |||
| db52bda1c5 | |||
| e5b253546a | |||
| 6c94c710db | |||
| 6e5f65befc | |||
| 5a658c5d7e | |||
| 1072760d2b | |||
| c2ee8a6ca5 | |||
|
|
0f8bfcdc01 | ||
| 614e836827 | |||
| deda75dc92 | |||
| 8ca58a6323 | |||
| 9928a31e06 | |||
| 57c7b3fbce |
1
.pmtignore
Normal file
1
.pmtignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vendor/
|
||||||
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,3 +1,29 @@
|
|||||||
|
## 2016-10-16 Release 0.3.0
|
||||||
|
|
||||||
|
- Add `entropy_repo` type to enable/disable repositories
|
||||||
|
- Add `entropy_repos` fact
|
||||||
|
|
||||||
|
## 2016-10-13 Release 0.2.0
|
||||||
|
|
||||||
|
- Add `locale` fact
|
||||||
|
- Remove obsolete `has_entropy` fact
|
||||||
|
- Improve `entropy` package provider to set locale envvar directly
|
||||||
|
and not shell out to a distributed script to set locale.
|
||||||
|
|
||||||
|
## 2016-10-13 Release 0.1.2
|
||||||
|
|
||||||
|
- Improved package regexes for valdiation and parsing
|
||||||
|
(now following the Gentoo EAPI6 PMS document to ensure correctness)
|
||||||
|
- Removed validation for required parameters in `entropy_*` types
|
||||||
|
|
||||||
|
## 2016-10-13 Release 0.1.0
|
||||||
|
|
||||||
|
- Added support for additional types:
|
||||||
|
- `entropy_splitdebug`
|
||||||
|
- `entropy_splitdebug_mask`
|
||||||
|
- `entropy_keywords`
|
||||||
|
- Added spec tests for most types and providers
|
||||||
|
|
||||||
## 2016-10-10 Release 0.0.2
|
## 2016-10-10 Release 0.0.2
|
||||||
|
|
||||||
- First forge release
|
- First forge release
|
||||||
|
|||||||
164
README.md
164
README.md
@@ -13,25 +13,27 @@
|
|||||||
|
|
||||||
## 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
|
||||||
* Managing `Sabayon Community Repository (SCR)` definitions using `enman`
|
* Managing `Sabayon Community Repository (SCR)` definitions using `enman`
|
||||||
|
* Enabling and disabling entropy repositories
|
||||||
* Entropy package masks and unmasks
|
* Entropy package masks and unmasks
|
||||||
|
* Splitdebug installs for packages
|
||||||
* Using systemd as the default service provider
|
* Using systemd as the default service provider
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
### 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 +44,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 +57,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 +65,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,18 +80,48 @@ not install 'mysql' since there's no way to disambiguate between
|
|||||||
|
|
||||||
### Managing enman repositories
|
### Managing enman repositories
|
||||||
|
|
||||||
```
|
Install an available SCR repository using enman. The title is taken to be the
|
||||||
|
repository name by default, and must be available via enman. Use an `ensure`
|
||||||
|
value of `present` to install the repo, and `absent` to remove it.
|
||||||
|
|
||||||
|
```puppet
|
||||||
enman_repo { 'community':
|
enman_repo { 'community':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Enabling and disabling entropy repositories
|
||||||
|
|
||||||
|
Installed repositories (whether system or SCR repositories) can be enabled and
|
||||||
|
disabled using the `entropy_repo` type.
|
||||||
|
|
||||||
|
To enable a repository, use:
|
||||||
|
```puppet
|
||||||
|
entropy_repo { 'sabayon-limbo':
|
||||||
|
enabled => 'true',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
To disable a repository (only if present), use:
|
||||||
|
```puppet
|
||||||
|
if 'sabayon-limbo' in $facts['entropy_repos'] {
|
||||||
|
entropy_repo { 'sabayon-limbo':
|
||||||
|
enabled => 'false',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This type cannot currently install or remove repositories, only control the
|
||||||
|
enabled state of existing repositories. The repository being managed must
|
||||||
|
already exist on the system.
|
||||||
|
|
||||||
### Masking packages
|
### Masking packages
|
||||||
|
|
||||||
Entropy is very flexible in how to specify which packages can be masked,
|
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 +131,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 +140,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 +148,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 +160,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 +186,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 +195,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 +268,45 @@ above.
|
|||||||
|
|
||||||
### Types
|
### Types
|
||||||
|
|
||||||
* `enman_repo` Manages SCR repositories using enman
|
* `enman_repo`: Manages SCR repositories using enman
|
||||||
* `entropy_mask` Manages entropy package masks
|
* `entropy_repo`: Enables/Disables repositories
|
||||||
* `entropy_unmask` Manages entropy package unmasks
|
* `entropy_mask`: Manages entropy package masks
|
||||||
|
* `entropy_unmask`: Manages entropy package unmasks
|
||||||
|
* `entropy_splitdebug` Manages entropy package debug information
|
||||||
|
* `entropy_splitdebug_mask` Manages entropy package debug information masks
|
||||||
|
|
||||||
|
### Facts
|
||||||
|
|
||||||
|
#### `entropy_repos`
|
||||||
|
|
||||||
|
Provides a structured fact identifying the entropy repos present on the system
|
||||||
|
including their enabled/disabled state, and whether they are enman or entropy
|
||||||
|
repositories.
|
||||||
|
|
||||||
|
Example (in yaml format for readability):
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
sabayonlinux.org:
|
||||||
|
repo_type: "entropy"
|
||||||
|
enabled: "true"
|
||||||
|
sabayon-limbo:
|
||||||
|
repo_type: "entropy"
|
||||||
|
enabled: "false"
|
||||||
|
community:
|
||||||
|
repo_type: "enman"
|
||||||
|
enabled: "true"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `locale`
|
||||||
|
|
||||||
|
Identifies the system-wide default locale, as set by `eselect`.
|
||||||
|
|
||||||
|
This is used internally by the entropy package provider to run `equo` commands
|
||||||
|
using the correct locale.
|
||||||
|
|
||||||
|
#### `operatingsystem`
|
||||||
|
|
||||||
|
Overrides the detection of the operating system on Sabayon systems to `Sabayon`.
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|||||||
22
lib/facter/entropy_repos.rb
Normal file
22
lib/facter/entropy_repos.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Facter.add('entropy_repos') do
|
||||||
|
|
||||||
|
confine :operatingsystem => :Sabayon
|
||||||
|
|
||||||
|
setcode do
|
||||||
|
# Use the types/providers to do the heavy lifting here
|
||||||
|
repos = {}
|
||||||
|
|
||||||
|
Puppet::Type.type(:entropy_repo).provider(:file).instances().each do |repo|
|
||||||
|
Facter.debug(repo.enabled)
|
||||||
|
r = {
|
||||||
|
:repo_type => repo.repo_type,
|
||||||
|
:enabled => repo.enabled,
|
||||||
|
}
|
||||||
|
|
||||||
|
repos[repo.name] = r
|
||||||
|
end
|
||||||
|
|
||||||
|
repos
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
Facter.add(:has_entropy) do
|
|
||||||
confine :kernel => :linux
|
|
||||||
setcode do
|
|
||||||
FileTest.exists?("/usr/bin/equo")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
7
lib/facter/locale.rb
Normal file
7
lib/facter/locale.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Facter.add(:locale) do
|
||||||
|
confine :osfamily => :gentoo
|
||||||
|
setcode do
|
||||||
|
Facter::Core::Execution.exec('eselect --colour=no --brief locale show').strip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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
|
||||||
|
|
||||||
|
|||||||
74
lib/puppet/provider/entropy_repo/file.rb
Normal file
74
lib/puppet/provider/entropy_repo/file.rb
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
Puppet::Type.type(:entropy_repo).provide(:file) do
|
||||||
|
desc "File provider for Entropy Repositories"
|
||||||
|
|
||||||
|
defaultfor :operatingsystem => :sabayon
|
||||||
|
|
||||||
|
mk_resource_methods
|
||||||
|
|
||||||
|
def type_prefix
|
||||||
|
if @property_hash[:repo_type] == 'enman'
|
||||||
|
'enman_'
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def enabled=(value)
|
||||||
|
enabled_filename = "/etc/entropy/repositories.conf.d/entropy_#{type_prefix}#{@property_hash[:name]}"
|
||||||
|
disabled_filename = "/etc/entropy/repositories.conf.d/_entropy_#{type_prefix}#{@property_hash[:name]}"
|
||||||
|
|
||||||
|
if value == 'true' || value == :true
|
||||||
|
if File.exists?(disabled_filename)
|
||||||
|
File.rename(disabled_filename, enabled_filename)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if File.exists?(enabled_filename)
|
||||||
|
File.rename(enabled_filename, disabled_filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@property_hash[:enabled] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.instances
|
||||||
|
repos = Dir.entries('/etc/entropy/repositories.conf.d/')
|
||||||
|
|
||||||
|
repos.collect do |r|
|
||||||
|
if r == '.' || r == '..'
|
||||||
|
nil
|
||||||
|
elsif r =~ /\.example$/
|
||||||
|
nil
|
||||||
|
elsif r !~ /^_?entropy_/
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
matches = /^(_)?entropy_(enman_)?(.*)$/.match(r)
|
||||||
|
enabled = matches[1].nil? ? 'true' : 'false'
|
||||||
|
type = matches[2] == 'enman_' ? 'enman' : 'entropy'
|
||||||
|
name = matches[3]
|
||||||
|
|
||||||
|
repo = {
|
||||||
|
:name => name,
|
||||||
|
:repo_type => type,
|
||||||
|
:enabled => enabled,
|
||||||
|
:provider => :entropy_repo,
|
||||||
|
}
|
||||||
|
|
||||||
|
new(repo)
|
||||||
|
end
|
||||||
|
end.compact
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.prefetch(resources)
|
||||||
|
repos = self.instances()
|
||||||
|
|
||||||
|
resources.each do |name, resource|
|
||||||
|
if provider = repos.find { |r| r.name == name }
|
||||||
|
resources[name].provider = provider
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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-z0-9+_.-]+/)?[a-zA-Z0-9+_-]+)?(?:-(\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
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require 'puppet/provider/package'
|
require 'puppet/provider/package'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
Puppet::Type.type(:package).provide :entropy, :parent => Puppet::Provider::Package do
|
Puppet::Type.type(:package).provide(:entropy, :parent => Puppet::Provider::Package) do
|
||||||
desc "Provides packaging support for Sabayon's entropy system."
|
desc "Provides packaging support for Sabayon's entropy system."
|
||||||
|
|
||||||
has_feature :versionable
|
has_feature :versionable
|
||||||
@@ -9,18 +9,27 @@ Puppet::Type.type(:package).provide :entropy, :parent => Puppet::Provider::Packa
|
|||||||
has_feature :uninstallable
|
has_feature :uninstallable
|
||||||
has_feature :upgradeable
|
has_feature :upgradeable
|
||||||
|
|
||||||
commands :equo => "#{File.dirname(__FILE__)}/entropy/equo_locale"
|
has_command(:equo, "equo") do
|
||||||
|
locale = Facter.value(:locale)
|
||||||
|
environment({
|
||||||
|
:LANG => locale,
|
||||||
|
:LC_ALL => locale,
|
||||||
|
:LANGUAHE => locale,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
confine :has_entropy => true
|
# Require the locale fact exist
|
||||||
|
confine :false => Facter.value(:locale).nil?
|
||||||
|
confine :osfamily => :Gentoo
|
||||||
|
|
||||||
defaultfor :has_entropy => :true, :osfamily => :Gentoo
|
defaultfor :operatingsystem => :Sabayon
|
||||||
|
|
||||||
def self.instances
|
def self.instances
|
||||||
result_format = /^(\S+)\/(\S+)-([\.\d]+(?:_?(?:a(?:lpha)?|b(?:eta)?|pre|rc|p)\d*)?(?:-r\d+)?)(?:#(\S+))?$/
|
result_format = /^(\S+)\/(\S+)-([\.\d]+(?:_?(?:a(?:lpha)?|b(?:eta)?|pre|rc|p)\d*)?(?:-r\d+)?)(?:#(\S+))?$/
|
||||||
result_fields = [:category, :name, :ensure]
|
result_fields = [:category, :name, :ensure]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
search_output = equo "query", "list", "installed", "--quiet", "--verbose"
|
search_output = equo("query", "list", "installed", "--quiet", "--verbose").chomp
|
||||||
|
|
||||||
packages = []
|
packages = []
|
||||||
search_output.each_line do |search_result|
|
search_output.each_line do |search_result|
|
||||||
@@ -32,6 +41,7 @@ Puppet::Type.type(:package).provide :entropy, :parent => Puppet::Provider::Packa
|
|||||||
package[field] = value unless !value or value.empty?
|
package[field] = value unless !value or value.empty?
|
||||||
end
|
end
|
||||||
package[:provider] = :entropy
|
package[:provider] = :entropy
|
||||||
|
|
||||||
packages << new(package)
|
packages << new(package)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -70,13 +80,12 @@ Puppet::Type.type(:package).provide :entropy, :parent => Puppet::Provider::Packa
|
|||||||
end
|
end
|
||||||
|
|
||||||
def query
|
def query
|
||||||
result_format = /^(\S+)\/(\S+)-([\.\d]+(?:_(?:alpha|beta|pre|rc|p)\d+)?(?:-r\d+)?)(?:#(\S+))?$/
|
result_format = /^(\S+)\/(\S+)-([\.\d]+(?:_(?:alpha|beta|pre|rc|p)\d+)?(?:-r\d+)?)(?::[^#]+)?(?:#(\S+))?$/
|
||||||
result_fields = [:category, :name, :version_available]
|
result_fields = [:category, :name, :version_available]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
# Look for an installed package from a known repository
|
# Look for an installed package from a known repository
|
||||||
search_output = equo "match", "--quiet", "--verbose", package_name
|
search_output = equo("match", "--quiet", "--verbose", package_name).chomp
|
||||||
search_output.chomp
|
|
||||||
|
|
||||||
search_match = search_output.match(result_format)
|
search_match = search_output.match(result_format)
|
||||||
if search_match
|
if search_match
|
||||||
@@ -85,8 +94,9 @@ Puppet::Type.type(:package).provide :entropy, :parent => Puppet::Provider::Packa
|
|||||||
package[field] = value unless !value or value.empty?
|
package[field] = value unless !value or value.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
installed_output = equo 'match', '--quiet', '--verbose', '--installed', package_name
|
|
||||||
installed_output.chomp
|
begin
|
||||||
|
installed_output = equo('match', '--quiet', '--verbose', '--installed', package_name).chomp
|
||||||
installed_match = installed_output.match(result_format)
|
installed_match = installed_output.match(result_format)
|
||||||
|
|
||||||
if installed_match
|
if installed_match
|
||||||
@@ -95,14 +105,16 @@ Puppet::Type.type(:package).provide :entropy, :parent => Puppet::Provider::Packa
|
|||||||
else
|
else
|
||||||
package[:ensure] = :absent
|
package[:ensure] = :absent
|
||||||
end
|
end
|
||||||
|
rescue Puppet::ExecutionFailure
|
||||||
|
package[:ensure] = :absent
|
||||||
|
end
|
||||||
|
|
||||||
return package
|
return package
|
||||||
|
|
||||||
else
|
else
|
||||||
# List all installed packages and try and find if it's installed from outside a repository
|
# List all installed packages and try and find if it's installed from outside a repository
|
||||||
# If so, assume the installed version is the latest available
|
# If so, assume the installed version is the latest available
|
||||||
all_installed = equo "query", "list", "installed", "--quiet", "--verbose"
|
all_installed = equo("query", "list", "installed", "--quiet", "--verbose").chomp
|
||||||
all_installed.chomp
|
|
||||||
|
|
||||||
all_installed.split("\n").each do |installed_package|
|
all_installed.split("\n").each do |installed_package|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
source /etc/profile
|
|
||||||
/usr/bin/equo $@
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
65
lib/puppet/type/entropy_keywords.rb
Normal file
65
lib/puppet/type/entropy_keywords.rb
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
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"
|
||||||
|
newvalues(%r{^(?:[A-Za-z0-9+_.-]+\/)?[a-zA-Z0-9+_-]+$})
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:version) do
|
||||||
|
desc "Version of the package"
|
||||||
|
newvalues(%r{^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$})
|
||||||
|
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, "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:
|
||||||
|
|
||||||
@@ -13,14 +13,12 @@ Puppet::Type.newtype(:entropy_mask) do
|
|||||||
|
|
||||||
newproperty(:package) do
|
newproperty(:package) do
|
||||||
desc "Name of the package being masked"
|
desc "Name of the package being masked"
|
||||||
|
newvalues(%r{^(?:[A-Za-z0-9+_.-]+\/)?[a-zA-Z0-9+_-]+$})
|
||||||
end
|
end
|
||||||
|
|
||||||
newproperty(:version) do
|
newproperty(:version) do
|
||||||
desc "Version of the package"
|
desc "Version of the package"
|
||||||
|
newvalues(%r{^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$})
|
||||||
validate do |value|
|
|
||||||
raise(ArgumentError, "") if value !~ /^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$/
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
newproperty(:slot) do
|
newproperty(:slot) do
|
||||||
@@ -52,6 +50,8 @@ Puppet::Type.newtype(:entropy_mask) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
validate do
|
validate do
|
||||||
|
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
|
||||||
|
|
||||||
|
|||||||
22
lib/puppet/type/entropy_repo.rb
Normal file
22
lib/puppet/type/entropy_repo.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
require 'puppet/property/boolean'
|
||||||
|
|
||||||
|
Puppet::Type.newtype(:entropy_repo) do
|
||||||
|
@desc = "Manages Entropy Repositories"
|
||||||
|
|
||||||
|
newparam(:name) do
|
||||||
|
desc "Name of the Entropy Repository"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:repo_type, :readonly => true) do
|
||||||
|
desc "What type of repository this is (enman or entropy)"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:enabled) do
|
||||||
|
desc "Whether the repository is enabled or not"
|
||||||
|
newvalues('true', 'false')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
64
lib/puppet/type/entropy_splitdebug.rb
Normal file
64
lib/puppet/type/entropy_splitdebug.rb
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
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"
|
||||||
|
newvalues(%r{^(?:[A-Za-z0-9+_.-]+\/)?[a-zA-Z0-9+_-]+$})
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:version) do
|
||||||
|
desc "Version of the package"
|
||||||
|
newvalues(%r{^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$})
|
||||||
|
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, "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:
|
||||||
|
|
||||||
64
lib/puppet/type/entropy_splitdebug_mask.rb
Normal file
64
lib/puppet/type/entropy_splitdebug_mask.rb
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
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"
|
||||||
|
newvalues(%r{^(?:[A-Za-z0-9+_.-]+\/)?[a-zA-Z0-9+_-]+$})
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:version) do
|
||||||
|
desc "Version of the package"
|
||||||
|
newvalues(%r{^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$})
|
||||||
|
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, "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:
|
||||||
|
|
||||||
@@ -13,14 +13,12 @@ Puppet::Type.newtype(:entropy_unmask) do
|
|||||||
|
|
||||||
newproperty(:package) do
|
newproperty(:package) do
|
||||||
desc "Name of the package being masked"
|
desc "Name of the package being masked"
|
||||||
|
newvalues(%r{^(?:[A-Za-z0-9+_.-]+\/)?[a-zA-Z0-9+_-]+$})
|
||||||
end
|
end
|
||||||
|
|
||||||
newproperty(:version) do
|
newproperty(:version) do
|
||||||
desc "Version of the package"
|
desc "Version of the package"
|
||||||
|
newvalues(%r{^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$})
|
||||||
validate do |value|
|
|
||||||
raise(ArgumentError, "") if value !~ /^(\d*(?:\.\d+[a-zA-Z]*)*)(?:_((?:alpha|beta|pre|rc)\d*))?(-r\d+)?$/
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
newproperty(:slot) do
|
newproperty(:slot) do
|
||||||
@@ -52,6 +50,8 @@ Puppet::Type.newtype(:entropy_unmask) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
validate do
|
validate do
|
||||||
|
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
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
{
|
{
|
||||||
"name": "optiz0r-sabayon",
|
"name": "optiz0r-sabayon",
|
||||||
"version": "0.0.2",
|
"version": "0.3.0",
|
||||||
"author": "Ben Roberts",
|
"author": "Ben Roberts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"summary": "Extends Puppet with support for the Sabayon Linux distribution",
|
"summary": "Extends Puppet with support for the Sabayon Linux distribution",
|
||||||
"source": "https://github.com/Sabayon/puppet-sabayon.git",
|
"source": "https://github.com/Sabayon/puppet-sabayon.git",
|
||||||
"project_page": "https://github.com/Sabayon/puppet-sabayon",
|
"project_page": "https://github.com/Sabayon/puppet-sabayon",
|
||||||
"issues_url": "https://github.com/Sabayon/puppet-sabayon/issues",
|
"issues_url": "https://github.com/Sabayon/puppet-sabayon/issues",
|
||||||
"tags": ["sabayon", "entropy"],
|
"tags": [
|
||||||
|
"sabayon",
|
||||||
|
"entropy"
|
||||||
|
],
|
||||||
"operatingsystem_support": [
|
"operatingsystem_support": [
|
||||||
{
|
{
|
||||||
"operatingsystem": "Sabayon",
|
"operatingsystem": "Sabayon",
|
||||||
"operatingsystemrelease":[ "16.07", "16.11" ]
|
"operatingsystemrelease": [
|
||||||
|
"16.07",
|
||||||
|
"16.11"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|
||||||
],
|
],
|
||||||
"data_provider": "hiera"
|
"data_provider": "hiera"
|
||||||
}
|
}
|
||||||
|
|||||||
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
|
||||||
61
spec/unit/provider/entropy_repo/file_spec.rb
Normal file
61
spec/unit/provider/entropy_repo/file_spec.rb
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Puppet::Type.type(:entropy_repo).provider(:file) do
|
||||||
|
describe 'when fetching existing resources' do
|
||||||
|
let(:instances) do
|
||||||
|
described_class.instances
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:repos) do
|
||||||
|
[
|
||||||
|
{:name => 'sabayonlinux.org', :type => 'entropy', :enabled => 'true'},
|
||||||
|
{:name => 'sabayon-limbo', :type => 'entropy', :enabled => 'false'},
|
||||||
|
{:name => 'community', :type => 'enman', :enabled => 'true'},
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
Dir.stubs(:entries).with('/etc/entropy/repositories.conf.d/').returns([
|
||||||
|
'.', '..', 'README',
|
||||||
|
'entropy_sabayonlinux.org',
|
||||||
|
'_entropy_sabayon-limbo',
|
||||||
|
'entropy_enman_community',
|
||||||
|
'entropy_foobar.example',
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should identify the correct number of repos' do
|
||||||
|
expect(instances.size).to eq(repos.size)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should identify the correct repo name' do
|
||||||
|
repos.each_with_index do |repo, index|
|
||||||
|
expect(instances[index].name).to eq(repo[:name])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should identify the correct enabled state' do
|
||||||
|
repos.each_with_index do |repo, index|
|
||||||
|
expect(instances[index].enabled).to eq(repo[:enabled])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when enabling a repository' do
|
||||||
|
it 'should enable a disabled repository' do
|
||||||
|
File.stubs(:exists?).with('/etc/entropy/repositories.conf.d/entropy_sabayonlinux.org').returns(true).once
|
||||||
|
File.stubs(:rename).with('/etc/entropy/repositories.conf.d/entropy_sabayonlinux.org', '/etc/entropy/repositories.conf.d/_entropy_sabayonlinux.org').once
|
||||||
|
instance = described_class.new(:name => 'sabayonlinux.org', :enabled => 'true', :type => 'entropy')
|
||||||
|
instance.enabled = 'false'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when disabling a repository' do
|
||||||
|
it 'should disable an enabled repository' do
|
||||||
|
File.stubs(:exists?).with('/etc/entropy/repositories.conf.d/_entropy_sabayon-limbo').returns(true).once
|
||||||
|
File.stubs(:rename).with('/etc/entropy/repositories.conf.d/_entropy_sabayon-limbo', '/etc/entropy/repositories.conf.d/entropy_sabayon-limbo').once
|
||||||
|
instance = described_class.new(:name => 'sabayon-limbo', :enabled => 'false', :type => 'entropy')
|
||||||
|
instance.enabled = 'true'
|
||||||
|
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
|
||||||
71
spec/unit/type/entropy_keywords_spec.rb
Normal file
71
spec/unit/type/entropy_keywords_spec.rb
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
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 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
|
||||||
32
spec/unit/type/entropy_repo_spec.rb
Normal file
32
spec/unit/type/entropy_repo_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
describe Puppet::Type.type(:entropy_repo) do
|
||||||
|
before do
|
||||||
|
@provider = stub 'provider'
|
||||||
|
@provider.stubs(:name).returns(:file)
|
||||||
|
described_class.stubs(:defaultprovider).returns(@provider)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be an instance of Puppet::Type::Entropy_repo" do
|
||||||
|
expect(described_class.new(:name => "test")).to be_an_instance_of Puppet::Type::Entropy_repo
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating attributes" do
|
||||||
|
params = [:name]
|
||||||
|
properties = [:repo_type, :enabled]
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
||||||
118
spec/unit/type/package_types_spec.rb
Normal file
118
spec/unit/type/package_types_spec.rb
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
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
|
||||||
|
packages = [
|
||||||
|
'virtual/package',
|
||||||
|
'package',
|
||||||
|
'package-with-dash',
|
||||||
|
'package_with_underscores',
|
||||||
|
'category-123/package2',
|
||||||
|
'category.with.dots/package'
|
||||||
|
]
|
||||||
|
packages.each do |package|
|
||||||
|
it "should accept valid package name #{package}" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => 'test', :package => package)
|
||||||
|
}.not_to raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
packages = [
|
||||||
|
'two/category/package',
|
||||||
|
'invalid-package-1.2',
|
||||||
|
'/no-category-package',
|
||||||
|
'no-package-category/',
|
||||||
|
]
|
||||||
|
packages.each do |package|
|
||||||
|
it "should reject invalid package name #{package}" do
|
||||||
|
expect {
|
||||||
|
described_class.new(:name => 'test', :package => package)
|
||||||
|
}.to raise_error(Puppet::Error)
|
||||||
|
end
|
||||||
|
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