]> git.pld-linux.org Git - packages/chef.git/commitdiff
add poldek patch as single patch in pld git
authorElan Ruusamäe <glen@delfi.ee>
Thu, 4 Dec 2014 16:22:44 +0000 (18:22 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 4 Dec 2014 16:29:00 +0000 (18:29 +0200)
chef.spec
poldek.patch [new file with mode: 0644]

index 4cf926f7915bee8162dbee7f982c44ba8586061b..7b39d0897243e6110191cbfdc3c14aa12e149652 100644 (file)
--- 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 (file)
index 0000000..238a4eb
--- /dev/null
@@ -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@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@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
This page took 0.116016 seconds and 4 git commands to generate.