From 2d19d8664e5e1b680deec7d487875c5d53b3ac39 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 14:19:18 -0700 Subject: [PATCH] Add functionality to support apt pinning to more than just the release. Write the pin preference filename as ${name} rather than ${release}, so that we can pin more than one thing. Change apt::source so that when pin is set, that it pins to the origin rather than the release. --- manifests/pin.pp | 13 +++++++++++-- manifests/source.pp | 10 ++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 29fddfb..2664c9b 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -5,19 +5,28 @@ define apt::pin( $ensure = present, $packages = '*', $priority = 0, - $release = $name + $release = '', + $origin = '' ) { include apt::params $preferences_d = $apt::params::preferences_d + if $release != '' { + $pin = "release a=${release}" + } elsif $origin != '' { + $pin = "origin \"${origin}\"" + } else { + err("Apt::Pin needs either $release or $origin") + } + file { "${name}.pref": ensure => $ensure, path => "${preferences_d}/${name}", owner => root, group => root, mode => '0644', - content => "# ${name}\nPackage: ${packages}\nPin: release a=${release}\nPin-Priority: ${priority}", + content => "# ${name}\nPackage: ${packages}\nPin: ${pin}\nPin-Priority: ${priority}", } } diff --git a/manifests/source.pp b/manifests/source.pp index f3fc7b9..0040c14 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -35,10 +35,16 @@ define apt::source( notify => Exec['apt_update'], } + if ($pin != false) and ($ensure == 'present') { - apt::pin { $release: + # Get the host portion out of the url so we can pin to origin + $url_split = split($location, '/') + $host = $url_split[2] + + apt::pin { $name: priority => $pin, - before => File["${name}.list"] + before => File["${name}.list"], + origin => $host, } } -- 2.32.3