2016-06-29 17:31:14 +02:00
|
|
|
# Install a package either to a certain version, or while making sure that it's
|
|
|
|
# always the latest version that's installed.
|
2013-01-02 14:12:11 +01:00
|
|
|
define apt::upgrade_package (
|
|
|
|
$version = ''
|
|
|
|
) {
|
2010-12-07 19:18:41 +01:00
|
|
|
|
2010-12-15 09:47:57 +01:00
|
|
|
$version_suffix = $version ? {
|
|
|
|
'' => '',
|
|
|
|
'latest' => '',
|
|
|
|
default => "=${version}",
|
|
|
|
}
|
|
|
|
|
2010-12-16 18:14:23 +01:00
|
|
|
if !defined(Package['apt-show-versions']) {
|
|
|
|
package { 'apt-show-versions':
|
2013-01-02 14:12:11 +01:00
|
|
|
ensure => installed,
|
2010-12-16 18:14:23 +01:00
|
|
|
require => undef,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !defined(Package['dctrl-tools']) {
|
|
|
|
package { 'dctrl-tools':
|
2013-01-02 14:12:11 +01:00
|
|
|
ensure => installed,
|
2010-12-16 18:14:23 +01:00
|
|
|
require => undef,
|
|
|
|
}
|
2010-12-15 15:18:16 +01:00
|
|
|
}
|
|
|
|
|
2010-12-18 21:47:11 +01:00
|
|
|
exec { "apt-get -q -y -o 'DPkg::Options::=--force-confold' install ${name}${version_suffix}":
|
2016-06-29 17:31:14 +02:00
|
|
|
onlyif => [ "grep-status -F Status installed -a -P ${name} -q", "apt-show-versions -u ${name} | grep -q upgradeable" ],
|
2016-01-26 15:18:22 +01:00
|
|
|
require => Package['apt-show-versions', 'dctrl-tools'],
|
|
|
|
before => Exec['apt_updated']
|
2009-10-30 20:20:42 +01:00
|
|
|
}
|
2010-12-15 09:47:57 +01:00
|
|
|
|
2009-10-30 20:20:42 +01:00
|
|
|
}
|