11 Commits

Author SHA1 Message Date
9115033d04 [blacksmith] Bump version to 0.2.0 2016-10-13 22:18:18 +01:00
cabc5c19ce Update changelog for 0.2.0 release 2016-10-13 22:17:13 +01:00
7dca7dad51 Update README with information about bundled facts 2016-10-13 22:14:32 +01:00
53bbad2eb1 Fix entropy providers use of equo with locale
Previous attempt didn't work properly. This version uses the proper
`provider.has_command` api to specify the env vars which should be used.

Also catches the exit 1 thrown when `equo match --installed` doesn't
find anything, now that the wrapper script is no longer hiding the exit
code behind an explicit `exit 0`.
2016-10-13 22:08:04 +01:00
80644b6813 Update changelog 2016-10-13 18:56:38 +01:00
4020627a15 Remove obsolete has_entropy fact 2016-10-13 18:55:24 +01:00
a265caa979 Update entropy package provider to use locale without shelling out 2016-10-13 18:55:07 +01:00
7ce45a207f Add a locale fact which uses eselect locale to retrieve system default 2016-10-13 18:54:28 +01:00
6d9b130f9d Update changelog version to 0.1.2, workaround blacksmith problem 2016-10-13 17:07:04 +01:00
f2565cccc1 [blacksmith] Bump version to 0.1.3 2016-10-13 17:05:36 +01:00
f4bdac2266 [blacksmith] Bump version to 0.1.2 2016-10-13 17:04:51 +01:00
7 changed files with 59 additions and 33 deletions

View File

@@ -1,4 +1,11 @@
## 2016-10-13 Release 0.1.1 ## 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 - Improved package regexes for valdiation and parsing
(now following the Gentoo EAPI6 PMS document to ensure correctness) (now following the Gentoo EAPI6 PMS document to ensure correctness)

View File

@@ -243,6 +243,19 @@ For more info on package keywords, see https://wiki.gentoo.org/wiki/KEYWORDS
* `entropy_splitdebug` Manages entropy package debug information * `entropy_splitdebug` Manages entropy package debug information
* `entropy_splitdebug_mask` Manages entropy package debug information masks * `entropy_splitdebug_mask` Manages entropy package debug information masks
### Facts
#### `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
This module is actively used by the developer against current Sabayon versions. This module is actively used by the developer against current Sabayon versions.

View File

@@ -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
View 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

View File

@@ -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|

View File

@@ -1,6 +0,0 @@
#!/bin/bash
source /etc/profile
/usr/bin/equo $@
exit 0

View File

@@ -1,6 +1,6 @@
{ {
"name": "optiz0r-sabayon", "name": "optiz0r-sabayon",
"version": "0.1.1", "version": "0.2.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",