diff -Nru puppet-3.8.5/debian/changelog puppet-3.8.5/debian/changelog --- puppet-3.8.5/debian/changelog 2016-03-15 11:28:53.000000000 +0000 +++ puppet-3.8.5/debian/changelog 2016-06-02 23:06:36.000000000 +0000 @@ -1,3 +1,10 @@ +puppet (3.8.5-2ubuntu1) xenial; urgency=medium + + * Add d/p/0008-use-best-service-provider-on-ubuntu.patch + LP: #1570472 + + -- Simon Deziel Thu, 02 Jun 2016 22:16:35 +0000 + puppet (3.8.5-2) unstable; urgency=medium * [7b9bf62] sysvinit: fix service restart. diff -Nru puppet-3.8.5/debian/patches/0008-use-best-service-provider-on-ubuntu.patch puppet-3.8.5/debian/patches/0008-use-best-service-provider-on-ubuntu.patch --- puppet-3.8.5/debian/patches/0008-use-best-service-provider-on-ubuntu.patch 1970-01-01 00:00:00.000000000 +0000 +++ puppet-3.8.5/debian/patches/0008-use-best-service-provider-on-ubuntu.patch 2016-06-02 22:25:34.000000000 +0000 @@ -0,0 +1,170 @@ +Description: Make systemd the default service provider for Ubuntu 15.04 to 16.04 + Also make upstart the default service provider for versions prior to 15.04. +Bug: https://tickets.puppetlabs.com/browse/PUP-5897 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/puppet/+bug/1570472 + +Index: puppet-3.8.5/lib/puppet/provider/service/systemd.rb +=================================================================== +--- puppet-3.8.5.orig/lib/puppet/provider/service/systemd.rb ++++ puppet-3.8.5/lib/puppet/provider/service/systemd.rb +@@ -5,9 +5,20 @@ Puppet::Type.type(:service).provide :sys + + commands :systemctl => "systemctl" + ++ if Facter.value(:osfamily).downcase == 'debian' ++ # With multiple init systems on Debian, it is possible to have ++ # pieces of systemd around (e.g. systemctl) but not really be ++ # using systemd. We do not do this on other platforms as it can ++ # cause issues when running in a chroot without /run mounted ++ # (PUP-5577) ++ confine :exists => "/run/systemd/system" ++ end ++ + defaultfor :osfamily => [:archlinux] + defaultfor :osfamily => :redhat, :operatingsystemmajrelease => "7" + defaultfor :osfamily => :redhat, :operatingsystem => :fedora, :operatingsystemmajrelease => ["17", "18", "19", "20", "21"] ++ defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => "8" ++ defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["15.04","15.10","16.04"] + + def self.instances + i = [] +@@ -26,6 +37,10 @@ Puppet::Type.type(:service).provide :sys + raise Puppet::Error, "Could not disable #{self.name}: #{output}", $!.backtrace + end + ++ def get_start_link_count ++ Dir.glob("/etc/rc*.d/S??#{@resource[:name]}").length ++ end ++ + def enabled? + begin + systemctl("is-enabled", @resource[:name]) +@@ -36,6 +51,29 @@ Puppet::Type.type(:service).provide :sys + :true + end + ++ def debian_enabled?(svc_info) ++ # If UnitFileState == UnitFileState then we query the older way. ++ if svc_info[:UnitFileState] == 'UnitFileState' ++ system("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start") ++ if [104, 106].include?($CHILD_STATUS.exitstatus) ++ return :true ++ elsif [101, 105].include?($CHILD_STATUS.exitstatus) ++ # 101 is action not allowed, which means we have to do the check manually. ++ # 105 is unknown, which generally means the iniscript does not support query ++ # The debian policy states that the initscript should support methods of query ++ # For those that do not, peform the checks manually ++ # http://www.debian.org/doc/debian-policy/ch-opersys.html ++ if get_start_link_count >= 4 ++ return :true ++ else ++ return :false ++ end ++ else ++ return :false ++ end ++ end ++ end ++ + def status + begin + systemctl("is-active", @resource[:name]) +Index: puppet-3.8.5/lib/puppet/provider/service/upstart.rb +=================================================================== +--- puppet-3.8.5.orig/lib/puppet/provider/service/upstart.rb ++++ puppet-3.8.5/lib/puppet/provider/service/upstart.rb +@@ -16,7 +16,7 @@ Puppet::Type.type(:service).provide :ups + (Facter.value(:osfamily) == 'RedHat' and Facter.value(:operatingsystemrelease) =~ /^6\./), + ] + +- defaultfor :operatingsystem => :ubuntu ++ defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["10.04", "12.04", "14.04", "14.10"] + + commands :start => "/sbin/start", + :stop => "/sbin/stop", +Index: puppet-3.8.5/spec/unit/provider/service/systemd_spec.rb +=================================================================== +--- puppet-3.8.5.orig/spec/unit/provider/service/systemd_spec.rb ++++ puppet-3.8.5/spec/unit/provider/service/systemd_spec.rb +@@ -35,7 +35,7 @@ describe Puppet::Type.type(:service).pro + # In Ruby 1.8.7, the order of hash elements differs from 1.9+ and + # caused short-circuiting of the logic used by default.all? in the + # provider. As a workaround we need to use stubs() instead of +- # expects() here. ++ # expects() here. + Facter.expects(:value).with(:osfamily).at_least_once.returns(:redhat) + Facter.stubs(:value).with(:operatingsystem).returns(:redhat) + Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}") +@@ -52,6 +52,48 @@ describe Puppet::Type.type(:service).pro + end + end + ++ it "should not be the default provider on debian7" do ++ Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian) ++ Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:debian) ++ Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("7") ++ expect(described_class).not_to be_default ++ end ++ ++ it "should be the default provider on debian8" do ++ Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian) ++ Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:debian) ++ Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("8") ++ expect(described_class).to be_default ++ end ++ ++ it "should not be the default provider on ubuntu14.04" do ++ Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian) ++ Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:ubuntu) ++ Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("14.04") ++ expect(described_class).not_to be_default ++ end ++ ++ it "should be the default provider on ubuntu15.04" do ++ Facter.expects(:value).with(:osfamily).at_least_once.returns(:debian) ++ Facter.expects(:value).with(:operatingsystem).at_least_once.returns(:ubuntu) ++ Facter.expects(:value).with(:operatingsystemmajrelease).at_least_once.returns("15.04") ++ expect(described_class).to be_default ++ end ++ ++ it "should be the default provider on ubuntu15.10" do ++ Facter.stubs(:value).with(:osfamily).returns(:debian) ++ Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu) ++ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("15.10") ++ expect(described_class).to be_default ++ end ++ ++ it "should be the default provider on ubuntu16.04" do ++ Facter.stubs(:value).with(:osfamily).returns(:debian) ++ Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu) ++ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("16.04") ++ expect(described_class).to be_default ++ end ++ + [:enabled?, :enable, :disable, :start, :stop, :status, :restart].each do |method| + it "should have a #{method} method" do + provider.should respond_to(method) +@@ -167,8 +209,6 @@ describe Puppet::Type.type(:service).pro + end + + it "(#16451) has command systemctl without being fully qualified" do +- described_class.instance_variable_get(:@commands). +- should include(:systemctl => 'systemctl') ++ expect(described_class.instance_variable_get(:@commands)).to include(:systemctl => 'systemctl') + end +- + end +Index: puppet-3.8.5/spec/unit/provider/service/upstart_spec.rb +=================================================================== +--- puppet-3.8.5.orig/spec/unit/provider/service/upstart_spec.rb ++++ puppet-3.8.5/spec/unit/provider/service/upstart_spec.rb +@@ -24,7 +24,8 @@ describe Puppet::Type.type(:service).pro + + it "should be the default provider on Ubuntu" do + Facter.expects(:value).with(:operatingsystem).returns("Ubuntu") +- described_class.default?.should be_true ++ Facter.expects(:value).with(:operatingsystemmajrelease).returns("12.04") ++ expect(described_class.default?).to be_truthy + end + + describe "excluding services" do diff -Nru puppet-3.8.5/debian/patches/series puppet-3.8.5/debian/patches/series --- puppet-3.8.5/debian/patches/series 2016-03-15 11:28:53.000000000 +0000 +++ puppet-3.8.5/debian/patches/series 2016-06-02 21:43:18.000000000 +0000 @@ -5,3 +5,4 @@ 0005-Fix-service-listing-and-enable-disable-in-Debian.patch 0006-Stored-configs-compatibility-with-ActiveRecord-4.x.patch 0007-PUP-4633-fix-non-ASCII-user-comment-with-ruby-2.1.patch +0008-use-best-service-provider-on-ubuntu.patch