2010-04-27 22:38:28 +02:00
|
|
|
# force.pp
|
|
|
|
# force a package from a specific release
|
|
|
|
|
|
|
|
define apt::force(
|
2013-02-23 16:42:14 +01:00
|
|
|
$release = false,
|
2012-07-09 04:24:49 +02:00
|
|
|
$version = false,
|
|
|
|
$timeout = 300
|
2010-04-27 22:38:28 +02:00
|
|
|
) {
|
2011-03-11 18:02:50 +01:00
|
|
|
|
2013-02-23 16:45:31 +01:00
|
|
|
$provider = $apt::params::provider
|
|
|
|
|
2012-01-14 00:29:47 +01:00
|
|
|
$version_string = $version ? {
|
2012-03-21 14:20:13 +01:00
|
|
|
false => undef,
|
2012-01-14 00:29:47 +01:00
|
|
|
default => "=${version}",
|
|
|
|
}
|
|
|
|
|
2013-02-23 16:42:14 +01:00
|
|
|
$release_string = $release ? {
|
|
|
|
false => undef,
|
|
|
|
default => "-t ${release}",
|
|
|
|
}
|
|
|
|
|
|
|
|
if $version == false {
|
|
|
|
if $release == false {
|
|
|
|
$install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'"
|
|
|
|
} else {
|
|
|
|
# If installed version and candidate version differ, this check returns 1 (false).
|
|
|
|
$install_check = "/usr/bin/test \$(/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if $release == false {
|
|
|
|
$install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'"
|
|
|
|
} else {
|
|
|
|
$install_check = "/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -q 'Installed: ${version}'"
|
|
|
|
}
|
2012-03-21 14:20:13 +01:00
|
|
|
}
|
2013-02-23 16:42:14 +01:00
|
|
|
|
2013-02-23 16:45:31 +01:00
|
|
|
exec { "${provider} -y ${release_string} install ${name}${version_string}":
|
2012-06-07 23:53:41 +02:00
|
|
|
unless => $install_check,
|
|
|
|
logoutput => 'on_failure',
|
2012-07-09 04:24:49 +02:00
|
|
|
timeout => $timeout,
|
2011-05-30 19:24:06 +02:00
|
|
|
}
|
2010-04-27 22:38:28 +02:00
|
|
|
}
|