[packages/chef] add poldek patch as single patch in pld git

glen glen at pld-linux.org
Thu Dec 4 17:29:56 CET 2014


commit 0e535bd2cb055ea43d75579f37e480b4a519c33c
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu Dec 4 18:22:44 2014 +0200

    add poldek patch as single patch in pld git

 chef.spec    |   3 +-
 poldek.patch | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 179 insertions(+), 2 deletions(-)
---
diff --git a/chef.spec b/chef.spec
index 4cf926f..7b39d08 100644
--- a/chef.spec
+++ b/chef.spec
@@ -18,8 +18,7 @@ Source3:	https://raw.github.com/stevendanna/knife-hacks/master/shell/knife_compl
 # Source3-md5:	a4c1e41370be8088a59ddb3b2e7ea397
 Patch0:		platform-pld.patch
 Patch1:		FHS.patch
-Patch2:		https://github.com/glensc/chef/compare/poldek.patch
-# Patch2-md5:	8fd92d572b7ebce759e9034097bfc399
+Patch2:		poldek.patch
 Patch3:		https://github.com/glensc/chef/compare/pld-knife-boostrap.patch
 # Patch3-md5:	8ff0fdfde6dc90018698775bf8f13062
 URL:		https://wiki.opscode.com/display/chef/
diff --git a/poldek.patch b/poldek.patch
new file mode 100644
index 0000000..238a4eb
--- /dev/null
+++ b/poldek.patch
@@ -0,0 +1,178 @@
+poldek package manager support
+
+https://tickets.opscode.com/browse/CHEF-4476
+https://github.com/opscode/chef/pull/1225
+
+--- chef-11.12.8/lib/chef/provider/package/poldek.rb	1970-01-01 02:00:00.000000000 +0200
++++ chef-11.12.8.poldek/lib/chef/provider/package/poldek.rb	2014-12-04 18:27:24.468416380 +0200
+@@ -0,0 +1,123 @@
++#
++# Author:: Elan Ruusamäe (glen at pld-linux.org)
++# Copyright:: Copyright (c) 2013 Elan Ruusamäe
++# License:: Apache License, Version 2.0
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++#     http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
++#
++
++require 'digest/md5'
++require 'chef/provider/package'
++require 'chef/mixin/shell_out'
++require 'chef/resource/package'
++require 'chef/mixin/get_source_from_package'
++
++class Chef
++  class Provider
++    class Package
++      class Poldek < Chef::Provider::Package
++        include Chef::Mixin::ShellOut
++        attr_accessor :is_virtual_package
++
++        def load_current_resource
++            Chef::Log.debug("#{@new_resource} loading current resource")
++            @current_resource = Chef::Resource::Package.new(@new_resource.name)
++            @current_resource.package_name(@new_resource.package_name)
++            @current_resource.version(nil)
++            check_package_state
++            @current_resource # modified by check_package_state
++        end
++
++        def check_package_state()
++            Chef::Log.debug("#{@new_resource} checking package #{@new_resource.package_name}")
++
++            installed = false
++            @current_resource.version(nil)
++
++            out = shell_out!("rpm -q #{@new_resource.package_name}", :env => nil, :returns => [0,1])
++            if out.stdout
++                Chef::Log.debug("rpm STDOUT: #{out.stdout}");
++                version = version_from_nvra(out.stdout)
++                if version
++                    @current_resource.version(version)
++                    installed = true
++                end
++            end
++
++            return installed
++        end
++
++        def candidate_version
++            Chef::Log.debug("poldek check candidate version for #{@new_resource.package_name}");
++            return @candidate_version if @candidate_version
++
++            update_indexes
++            cmd = "poldek -q --uniq --skip-installed #{expand_options(@new_resource.options)} --cmd 'ls #{@new_resource.package_name}'"
++            out = shell_out!(cmd, :env => nil, :returns => [0,1,255])
++            if out.stdout
++                Chef::Log.debug("poldek STDOUT: #{out.stdout}");
++                version = version_from_nvra(out.stdout)
++                if version
++                    @candidate_version = version
++                end
++            end
++            unless @candidate_version
++                raise Chef::Exceptions::Package, "poldek does not have a version of package #{@new_resource.package_name}"
++            end
++            @candidate_version
++        end
++
++        def install_package(name, version)
++            Chef::Log.debug("#{@new_resource} installing package #{name}-#{version}")
++            package = "#{name}-#{version}"
++            update_indexes
++            out = shell_out!("poldek --noask #{expand_options(@new_resource.options)} -u #{package}", :env => nil)
++        end
++
++        def upgrade_package(name, version)
++            Chef::Log.debug("#{@new_resource} upgrading package #{name}-#{version}")
++            install_package(name, version)
++        end
++
++        def remove_package(name, version)
++            Chef::Log.debug("#{@new_resource} removing package #{name}-#{version}")
++            package = "#{name}-#{version}"
++            out = shell_out!("poldek --noask #{expand_options(@new_resource.options)} -e #{package}", :env => nil)
++        end
++
++        def purge_package(name, version)
++            remove_package(name, version)
++        end
++
++        private
++        @@updated = Hash.new
++
++        def version_from_nvra(stdout)
++            stdout[/^#{Regexp.escape(@new_resource.package_name)}-(.+)/, 1]
++        end
++
++        def update_indexes()
++            Chef::Log.debug("#{@new_resource} call update indexes #{expand_options(@new_resource.options)}")
++            checksum = Digest::MD5.hexdigest(@new_resource.options || '').to_s
++
++            if @@updated[checksum]
++                return
++            end
++            Chef::Log.debug("#{@new_resource} updating package indexes: #{expand_options(@new_resource.options)}")
++            shell_out!("poldek --up #{expand_options(@new_resource.options)}", :env => nil)
++            @@updated[checksum] = true
++        end
++      end
++    end
++  end
++end
+--- chef-11.12.8/lib/chef/providers.rb	2014-12-04 18:27:52.686448859 +0200
++++ chef-11.12.8.poldek/lib/chef/providers.rb	2014-12-04 18:27:24.438414927 +0200
+@@ -60,6 +60,7 @@
+ require 'chef/provider/package/macports'
+ require 'chef/provider/package/pacman'
+ require 'chef/provider/package/portage'
++require 'chef/provider/package/poldek'
+ require 'chef/provider/package/rpm'
+ require 'chef/provider/package/rubygems'
+ require 'chef/provider/package/yum'
+--- chef-11.12.8/lib/chef/resource/poldek_package.rb	1970-01-01 02:00:00.000000000 +0200
++++ chef-11.12.8.poldek/lib/chef/resource/poldek_package.rb	2014-12-04 18:27:24.438414927 +0200
+@@ -0,0 +1,34 @@
++#
++# Author:: Elan Ruusamäe (glen at pld-linux.org)
++# Copyright:: Copyright (c) 2013 Elan Ruusamäe
++# License:: Apache License, Version 2.0
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++#     http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
++#
++
++require 'chef/resource/package'
++require 'chef/provider/package/poldek'
++
++class Chef
++  class Resource
++    class PoldekPackage < Chef::Resource::Package
++
++      def initialize(name, run_context=nil)
++        super
++        @resource_name = :poldek_package
++        @provider = Chef::Provider::Package::Poldek
++      end
++
++    end
++  end
++end
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/chef.git/commitdiff/0e535bd2cb055ea43d75579f37e480b4a519c33c



More information about the pld-cvs-commit mailing list