|
77 | 77 | default => "--proxy=${proxy}",
|
78 | 78 | }
|
79 | 79 |
|
80 |
| - $grep_regex = $pkgname ? { |
81 |
| - /==/ => "^${pkgname}\$", |
82 |
| - default => "^${pkgname}==", |
| 80 | + # If pkgname is not specified, use name (title) instead. |
| 81 | + $use_pkgname = $pkgname ? { |
| 82 | + undef => $name, |
| 83 | + default => $pkgname |
| 84 | + } |
| 85 | + |
| 86 | + # Check if searching by explicit version. |
| 87 | + if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/ { |
| 88 | + $grep_regex = "^${use_pkgname}==${ensure}\$" |
| 89 | + } else { |
| 90 | + $grep_regex = $use_pkgname ? { |
| 91 | + /==/ => "^${use_pkgname}\$", |
| 92 | + default => "^${use_pkgname}==", |
| 93 | + } |
83 | 94 | }
|
84 | 95 |
|
85 | 96 | $egg_name = $egg ? {
|
86 |
| - false => $pkgname, |
| 97 | + false => $use_pkgname, |
87 | 98 | default => $egg
|
88 | 99 | }
|
89 | 100 |
|
90 | 101 | $source = $url ? {
|
91 |
| - false => $pkgname, |
| 102 | + false => $use_pkgname, |
92 | 103 | default => "${url}#egg=${egg_name}",
|
93 | 104 | }
|
94 | 105 |
|
|
108 | 119 |
|
109 | 120 |
|
110 | 121 | case $ensure {
|
| 122 | + /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/: { |
| 123 | + # Version formats as per http://guide.python-distribute.org/specification.html#standard-versioning-schemes |
| 124 | + # Explicit version. |
| 125 | + exec { "pip_install_${name}": |
| 126 | + command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${source}==${ensure}", |
| 127 | + unless => "${pip_env} freeze | grep -i -e ${grep_regex}", |
| 128 | + user => $owner, |
| 129 | + environment => $environment, |
| 130 | + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], |
| 131 | + } |
| 132 | + } |
| 133 | + |
111 | 134 | present: {
|
| 135 | + # Whatever version is available. |
112 | 136 | exec { "pip_install_${name}":
|
113 | 137 | command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${source}",
|
114 | 138 | unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
|
|
119 | 143 | }
|
120 | 144 |
|
121 | 145 | latest: {
|
| 146 | + # Latest version. |
122 | 147 | exec { "pip_install_${name}":
|
123 | 148 | command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}",
|
124 | 149 | user => $owner,
|
|
128 | 153 | }
|
129 | 154 |
|
130 | 155 | default: {
|
| 156 | + # Anti-action, uninstall. |
131 | 157 | exec { "pip_uninstall_${name}":
|
132 |
| - command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${pkgname}", |
| 158 | + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${use_pkgname}", |
133 | 159 | onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}",
|
134 | 160 | user => $owner,
|
135 | 161 | environment => $environment,
|
|
0 commit comments