Skip to content

Commit bf67cb4

Browse files
committed
Fix PostgreSQL support on CentOS and Fedora
1 parent f41d577 commit bf67cb4

File tree

8 files changed

+66
-39
lines changed

8 files changed

+66
-39
lines changed

.kitchen.docker.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ driver:
55

66
# If you add new platforms below, include them in the .travis.yml file matrix
77
platforms:
8-
- name: centos-5
98
- name: centos-6
109
- name: centos-7
1110
- name: debian-7

.kitchen.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@ platforms:
1515
run_list: ["recipe[apt]"]
1616
- name: ubuntu-14.04
1717
run_list: ["recipe[apt]"]
18-
- name: ubuntu-14.10
18+
- name: ubuntu-16.04
1919
run_list: ["recipe[apt]"]
20-
- name: debian-7.8
20+
- name: ubuntu-16.10
2121
run_list: ["recipe[apt]"]
22-
- name: debian-8.7
22+
- name: debian-7.11
2323
run_list: ["recipe[apt]"]
24-
- name: centos-6.6
24+
- name: debian-8.6
25+
run_list: ["recipe[apt]"]
26+
- name: centos-6.8
27+
run_list: ["recipe[selinux::disabled]"]
28+
- name: centos-7.3
2529
run_list: ["recipe[selinux::disabled]"]
26-
- name: centos-7.0
30+
- name: fedora-23
31+
- name: fedora-24
2732
run_list: ["recipe[selinux::disabled]"]
28-
- name: fedora-20
33+
- name: fedora-25
2934
run_list: ["recipe[selinux::disabled]"]
3035

3136
suites:
@@ -66,7 +71,12 @@ suites:
6671
# - ubuntu-12.04
6772
# - debian-6.0.10
6873
# - debian-7.8
69-
# - centos-6.6
7074
# - fedora-20
75+
# File "/.../chef-12.19.36/lib/chef/provider/package/dnf/dnf_helper.py", line 56, in query
76+
# pkgs = q.latest(1).run() TypeError: latest() takes 1 positional argument but 2 were given
77+
- fedora-23
78+
# Unknown system type: Linux 3.16.0-4-amd64
79+
- centos-6
80+
- centos-7
7181
run_list:
7282
- recipe[postfix-dovecot_test::postfix_postgresql]

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2626
- README: Remove documentation about locale (old).
2727

2828
### Fixed
29+
- Fix PostgreSQL support on CentOS and Fedora.
2930
- Fix Chef `13` deprecation warnings.
3031

3132
## [2.0.1] - 2015-09-03

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ Please, [let us know](https://github.com/zuazo/postfix-dovecot-cookbook/issues/n
2626

2727
## Required Cookbooks
2828

29+
* [chef-vault](https://supermarket.chef.io/cookbooks/chef-vault)
30+
* [build-essential](https://supermarket.chef.io/cookbooks/build-essential)
2931
* [dovecot](https://supermarket.chef.io/cookbooks/dovecot)
3032
* [onddo-spamassassin](https://supermarket.chef.io/cookbooks/onddo-spamassassin)
3133
* [postfixadmin](https://supermarket.chef.io/cookbooks/postfixadmin)
3234
* [postfix-full](https://supermarket.chef.io/cookbooks/postfix-full) by [Malte Swart](https://github.com/mswart)
3335
* [ssl_certificate](https://supermarket.chef.io/cookbooks/ssl_certificate)
36+
* [yum](https://supermarket.chef.io/cookbooks/yum)
3437

3538
## Required Applications
3639

attributes/postfix_postgresql.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@
2828
srpm_default['packages'] = %w(
2929
postgresql-devel rpm-build zlib-devel openldap-devel libdb-devel
3030
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
31-
mariadb-devel
31+
mariadb-devel pkgconfig ed
3232
)
3333
srpm_default['rpm_regexp'] = [
34-
/\.src\./, ".centos.#{node['kernel']['machine']}."
34+
/\.src\./, ".#{node['platform']}.#{node['kernel']['machine']}."
3535
]
3636
srpm_default['rpm_build_args'] = '--with=pgsql'
3737
else
3838
srpm_default['packages'] = %w(
3939
postgresql-devel rpm-build zlib-devel openldap-devel db4-devel
4040
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
41-
mysql-devel
41+
mysql-devel pkgconfig ed
4242
)
4343
srpm_default['rpm_regexp'] = [
44-
/_[0-9]+\.src\./, ".#{node['kernel']['machine']}."
44+
/_[0-9]+(\.[0-9]+)?\.src\./, "\\1.#{node['kernel']['machine']}."
4545
]
4646
srpm_default['rpm_build_args'] = '--define="PGSQL 1"'
4747

@@ -76,8 +76,9 @@
7676
srpm_default['packages'] = %w(
7777
postgresql-devel rpm-build zlib-devel openldap-devel libdb-devel
7878
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
79-
mariadb-devel
79+
mariadb-devel pkgconfig ed libicu-devel sqlite-devel tinycdb-devel
8080
)
81+
8182
srpm_default['rpm_regexp'] = [
8283
/\.src\./, ".#{node['kernel']['machine']}."
8384
]
@@ -90,7 +91,7 @@
9091
srpm_default['packages'] = %w(
9192
postgresql-devel rpm-build zlib-devel openldap-devel db4-devel
9293
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
93-
mysql-devel
94+
mysql-devel pkgconfig ed
9495
)
9596
srpm_default['rpm_regexp'] = [
9697
/\.src\./, ".#{node['kernel']['machine']}."

metadata.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
recipe 'postfix-dovecot::dovecot', 'Installs and configures Dovecot 2.'
5555

5656
depends 'chef-vault', '~> 2.0'
57+
depends 'build-essential', '~> 8.0'
5758
depends 'dovecot', '~> 3.0'
5859
depends 'onddo-spamassassin', '~> 1.0'
5960
depends 'postfixadmin', '~> 3.0'

recipes/postfix_postgresql.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
# limitations under the License.
2020
#
2121

22-
case node['platform']
23-
when 'debian', 'ubuntu'
22+
if %w(debian ubuntu).include?(node['platform']) ||
23+
(node['platform'] == 'fedora' && node['platform_version'].to_i >= 23)
2424
package 'postfix'
2525
package 'postfix-pgsql'
26-
when 'centos', 'fedora', 'redhat', 'amazon', 'scientific'
26+
elsif %w(centos fedora redhat amazon scientific).include?(node['platform'])
27+
include_recipe 'build-essential'
2728

2829
node['postfix-dovecot']['postfix']['srpm']['packages'].each do |pkg|
2930
package pkg
@@ -90,6 +91,7 @@
9091

9192
rpm_regexp = node['postfix-dovecot']['postfix']['srpm']['rpm_regexp']
9293
rpm = rpm_regexp.nil? ? srpm : srpm.sub(rpm_regexp[0], rpm_regexp[1])
94+
rpm_file = "#{buildroot}/RPMS/#{node['kernel']['machine']}/#{rpm}"
9395

9496
yum_package 'postfix (without postgresql)' do
9597
package_name 'postfix'
@@ -107,7 +109,7 @@
107109
end
108110

109111
execute 'install postfix from SRPM' do
110-
command "rpm -i '#{buildroot}/RPMS/#{node['kernel']['machine']}/#{rpm}'"
112+
command "rpm -i '#{rpm_file}'"
111113
not_if { rpm.nil? }
112114
not_if 'rpm -q postfix'
113115
end

test/unit/recipes/postfix_postgresql_spec.rb

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@
9090
node.set['postfix-dovecot']['postfix']['srpm']['rpm_regexp'] =
9191
rpm_regexp
9292
expect(chef_run).to run_execute('install postfix from SRPM')
93-
.with_command(
94-
"rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'"
95-
)
93+
.with_command("rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'")
9694
end
9795
end
9896

@@ -122,7 +120,10 @@
122120
end
123121

124122
context 'with CentOS 7' do
125-
let(:rpm) { "foobar-1.0_19.centos.#{node['kernel']['machine']}.tar.gz" }
123+
let(:rpm) do
124+
"postfix-2.10.1-6.el7.centos.#{node['kernel']['machine']}.rpm"
125+
end
126+
let(:srpm) { 'postfix-2.10.1-6.el7.src.rpm' }
126127
let(:rpmbuild_args) { '--with=pgsql' }
127128
before do
128129
node.automatic['platform'] = 'centos'
@@ -132,7 +133,7 @@
132133
%w(
133134
postgresql-devel rpm-build zlib-devel openldap-devel libdb-devel
134135
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
135-
mariadb-devel
136+
mariadb-devel pkgconfig ed
136137
).each do |pkg|
137138
it "installs #{pkg} package" do
138139
expect(chef_run).to install_package(pkg)
@@ -141,9 +142,7 @@
141142

142143
it 'installs the correct RPM' do
143144
expect(chef_run).to run_execute('install postfix from SRPM')
144-
.with_command(
145-
"rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'"
146-
)
145+
.with_command("rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'")
147146
end
148147

149148
it 'uses the correct rpmbuild args' do
@@ -155,7 +154,8 @@
155154
end # context on CentOS 7
156155

157156
context 'with CentOS 6' do
158-
let(:rpm) { "foobar-1.0.#{node['kernel']['machine']}.tar.gz" }
157+
let(:rpm) { "postfix-2.6.6-6.el6.1.#{node['kernel']['machine']}.rpm" }
158+
let(:srpm) { 'postfix-2.6.6-6.el6_7.1.src.rpm' }
159159
let(:rpmbuild_args) { '--define="PGSQL 1"' }
160160
before do
161161
node.automatic['platform'] = 'centos'
@@ -165,7 +165,7 @@
165165
%w(
166166
postgresql-devel rpm-build zlib-devel openldap-devel db4-devel
167167
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
168-
mysql-devel
168+
mysql-devel pkgconfig ed
169169
).each do |pkg|
170170
it "installs #{pkg} package" do
171171
expect(chef_run).to install_package(pkg)
@@ -174,9 +174,7 @@
174174

175175
it 'installs the correct RPM' do
176176
expect(chef_run).to run_execute('install postfix from SRPM')
177-
.with_command(
178-
"rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'"
179-
)
177+
.with_command("rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'")
180178
end
181179

182180
it 'uses the correct rpmbuild args' do
@@ -208,7 +206,7 @@
208206
%w(
209207
postgresql-devel rpm-build zlib-devel openldap-devel libdb-devel
210208
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
211-
mariadb-devel
209+
mariadb-devel pkgconfig ed libicu-devel sqlite-devel tinycdb-devel
212210
).each do |pkg|
213211
it "installs #{pkg} package" do
214212
expect(chef_run).to install_package(pkg)
@@ -217,9 +215,7 @@
217215

218216
it 'installs the correct RPM' do
219217
expect(chef_run).to run_execute('install postfix from SRPM')
220-
.with_command(
221-
"rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'"
222-
)
218+
.with_command("rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'")
223219
end
224220

225221
it 'uses the correct rpmbuild args' do
@@ -230,6 +226,22 @@
230226
end
231227
end # context on Fedora
232228

229+
context 'with Fedora 24' do
230+
before do
231+
node.automatic['platform'] = 'fedora'
232+
node.automatic['platform_version'] = '23.0'
233+
end
234+
235+
%w(
236+
postfix
237+
postfix-pgsql
238+
).each do |pkg|
239+
it "installs #{pkg} package" do
240+
expect(chef_run).to install_package(pkg)
241+
end
242+
end
243+
end # context on Fedora 23
244+
233245
context 'with Amazon' do
234246
let(:pc_shell_out) { instance_double('Mixlib::ShellOut') }
235247
let(:gr_shell_out) { instance_double('Mixlib::ShellOut') }
@@ -286,7 +298,7 @@
286298
%w(
287299
postgresql-devel rpm-build zlib-devel openldap-devel db4-devel
288300
cyrus-sasl-devel pcre-devel openssl-devel perl-Date-Calc gcc
289-
mysql-devel
301+
mysql-devel pkgconfig ed
290302
).each do |pkg|
291303
it "installs #{pkg} package" do
292304
expect(chef_run).to install_package(pkg)
@@ -295,9 +307,7 @@
295307

296308
it 'installs the correct RPM' do
297309
expect(chef_run).to run_execute('install postfix from SRPM')
298-
.with_command(
299-
"rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'"
300-
)
310+
.with_command("rpm -i '#{buildroot}/RPMS/x86_64/#{rpm}'")
301311
end
302312

303313
it 'uses the correct rpmbuild args' do

0 commit comments

Comments
 (0)