(MODULES-3983) Update parallel_tests for ruby 2.0.0
[puppet-modules/puppetlabs-apt.git] / manifests / backports.pp
1 class apt::backports (
2   $location = undef,
3   $release  = undef,
4   $repos    = undef,
5   $key      = undef,
6   $pin      = 200,
7 ){
8   if $location {
9     validate_string($location)
10     $_location = $location
11   }
12   if $release {
13     validate_string($release)
14     $_release = $release
15   }
16   if $repos {
17     validate_string($repos)
18     $_repos = $repos
19   }
20   if $key {
21     unless is_hash($key) {
22       validate_string($key)
23     }
24     $_key = $key
25   }
26   if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') {
27     unless $location {
28       $_location = $::apt::backports['location']
29     }
30     unless $release {
31       $_release = "${::apt::xfacts['lsbdistcodename']}-backports"
32     }
33     unless $repos {
34       $_repos = $::apt::backports['repos']
35     }
36     unless $key {
37       $_key =  $::apt::backports['key']
38     }
39   } else {
40     unless $location and $release and $repos and $key {
41       fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key')
42     }
43   }
44
45   if is_hash($pin) {
46     $_pin = $pin
47   } elsif is_numeric($pin) or is_string($pin) {
48     # apt::source defaults to pinning to origin, but we should pin to release
49     # for backports
50     $_pin = {
51       'priority' => $pin,
52       'release'  => $_release,
53     }
54   } else {
55     fail('pin must be either a string, number or hash')
56   }
57
58   apt::source { 'backports':
59     location => $_location,
60     release  => $_release,
61     repos    => $_repos,
62     key      => $_key,
63     pin      => $_pin,
64   }
65 }