Ver Fonte

Implement fancy progress bars configuration.

Ubuntu 14.04 ships with apt 0.9.15, has a ``fancy progress bar'', which
is a green bar that shows at the bottom of the terminal showing progress
throughout install.

This patch enables the progress bar, which is usually done by running
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
Oliver Chick há 10 anos atrás
pai
commit
2cdcd3b06d
3 ficheiros alterados com 50 adições e 2 exclusões
  1. 2 1
      README.md
  2. 20 1
      manifests/init.pp
  3. 28 0
      spec/acceptance/apt_spec.rb

+ 2 - 1
README.md

@@ -53,7 +53,8 @@ The parameters for `apt` are not required in general and are predominantly for d
       purge_sources_list   => false,
       purge_sources_list_d => false,
       purge_preferences_d  => false,
-      update_timeout       => undef
+      update_timeout       => undef,
+      fancy_progress       => undef
     }
 
 Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content.

+ 20 - 1
manifests/init.pp

@@ -36,7 +36,8 @@ class apt(
   $purge_preferences_d  = false,
   $update_timeout       = undef,
   $update_tries         = undef,
-  $sources              = undef
+  $sources              = undef,
+  $fancy_progress       = undef
 ) {
 
   if $::osfamily != 'Debian' {
@@ -111,6 +112,24 @@ Package: bogus-package\n",
     recurse => $purge_preferences_d,
   }
 
+  case $fancy_progress {
+    true: {
+      file { '99progressbar':
+        ensure  => present,
+        content => 'Dpkg::Progress-Fancy "1";',
+        path    => "${apt_conf_d}/99progressbar",
+      }
+    }
+    false: {
+      file { '99progressbar':
+        ensure  => absent,
+        path    => "${apt_conf_d}/99progressbar",
+      }
+    }
+    undef: {} # do nothing
+    default: { fail('Valid values for fancy_progress are true or false') }
+  }
+
   case $disable_keys {
     true: {
       file { '99unauth':

+ 28 - 0
spec/acceptance/apt_spec.rb

@@ -274,6 +274,34 @@ describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')
     end
   end
 
+  context 'fancy_progress => true' do
+    it 'should work with no errors' do
+      pp = <<-EOS
+      class { 'apt': fancy_progress => true }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    describe file('/etc/apt/apt.conf.d/99progressbar') do
+      it { should be_file }
+      it { should contain 'Dpkg::Progress-Fancy "1";' }
+    end
+  end
+  context 'fancy_progress => false' do
+    it 'should work with no errors' do
+      pp = <<-EOS
+      class { 'apt': fancy_progress => false }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    describe file('/etc/apt/apt.conf.d/99progressbar') do
+      it { should_not be_file }
+    end
+  end
+
   context 'reset' do
     it 'fixes the sources.list' do
       shell('cp /tmp/sources.list /etc/apt')