1+ # we don't want separate debuginfo packages
2+ %global _enable_debug_package 0
3+ %define debug_package %{nil }
4+ # do not strip binaries
5+ %global __strip /bin/true
16%define __spec_install_post %{nil }
2- %define debug_package %{nil }
3- %define __os_install_post %{_dbpath }/brp-compress
7+ %define __os_install_post %{_dbpath }/brp-compress %{nil }
48
59Summary: A high-performance MySQL and PostgreSQL proxy
610Name: proxysql
@@ -9,8 +13,12 @@ Release: 1
913License: GPL-3.0 -only
1014Source: %{name }-%{version }.tar.gz
1115URL: https://proxysql.com/
12- Requires: gnutls, (openssl >= 3.0.0 or openssl3 >= 3.0.0)
16+ Requires: gnutls
17+ Requires: (openssl >= 3.0.0 or openssl3 >= 3.0.0)
18+ #BuildRequires: systemd-rpm-macros
1319BuildRoot: %{_tmppath }/%{name }-%{version }-%{release }-root
20+ Provides: user(%{name })
21+ Provides: group(%{name })
1422
1523%description
1624%{summary }
@@ -19,72 +27,56 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
1927%setup -q
2028
2129%pre
22- # Cleanup artifacts
23- if [ -f /var/lib/%{name}/PROXYSQL_UPGRADE ]; then
24- rm -fr /var/lib/%{name}/PROXYSQL_UPGRADE
25- fi
30+ # setup user, group
31+ getent passwd %{name } & > /dev/null || useradd -r -U -s /bin/false -d /var/lib/%{name } -c " ProxySQL Server" %{name }
2632
2733%build
2834# Packages are pre-built, nothing to do
2935
3036%install
37+ export DONT_STRIP=1
3138# Clean buildroot and install files
32- /bin/rm -rf %{buildroot }
33- /bin/mkdir -p %{buildroot }
34- /bin/cp -a * %{buildroot }
39+ rm -rf %{buildroot }
40+ mkdir -p %{buildroot }
41+ cp -a * %{buildroot }
42+ mkdir -p %{buildroot }/var/run/%{name }
43+ mkdir -p %{buildroot }/var/lib/%{name }
3544
3645%clean
37- /bin/ rm -rf %{buildroot }
46+ rm -rf %{buildroot }
3847
3948%post
40- # Create relevant user, directories and configuration files
41- if [ ! -d /var/run/%{name} ]; then /bin/mkdir /var/run/%{name} ; fi
42- if [ ! -d /var/lib/%{name} ]; then /bin/mkdir /var/lib/%{name} ; fi
43- if ! id -u %{name} > /dev/null 2>&1 ; then useradd -r -U -s /bin/false -d /var/lib/%{name} -c " ProxySQL Server" %{name}; fi
44- /bin/chown -R %{name }: /var/lib/%{name } /var/run/%{name }
45- /bin/chown root:%{name } /etc/%{name }.cnf
46- /bin/chmod 640 /etc/%{name }.cnf
47- # Configure systemd appropriately.
48- /bin/systemctl daemon-reload
49- /bin/systemctl enable %{name }.service
50- # Notify that a package update is in progress in order to start service.
51- if [ $1 -eq 2 ]; then /bin/touch /var/lib/%{name}/PROXYSQL_UPGRADE ; fi
49+ # install service
50+ %systemd_post %{name }.service
51+ #%systemd_post_with_reload %{name}.service
5252
5353%preun
54- # When uninstalling always try stop the service, ignore failures
55- /bin/systemctl stop %{name } || true
54+ # remove service
55+ % systemd_preun %{name }.service
5656
5757%postun
58- if [ $1 -eq 0 ]; then
59- # This is a pure uninstall, systemd unit file removed
60- # only daemon-reload is needed.
61- /bin/systemctl daemon-reload
62- else
63- # This is an upgrade, ProxySQL should be started. This
64- # logic works for packages newer than 2.0.7 and ensures
65- # a faster restart time.
66- /bin/systemctl start %{name}.service
67- /bin/rm -fr /var/lib/%{name}/PROXYSQL_UPGRADE
68- fi
58+ # remove user, group on uninstall
59+ # dont, its against the recommended practice
60+ #if [ "$1" == "0" ]; then
61+ # groupdel %{name}
62+ # userdel %{name}
63+ #fi
6964
7065%posttrans
71- if [ -f /var/lib/%{name}/PROXYSQL_UPGRADE ]; then
72- # This is a safeguard to start the service after an update
73- # which supports legacy "preun" / "postun" logic and will
74- # only execute for packages before 2.0.7.
75- /bin/systemctl start %{name}.service
76- /bin/rm -fr /var/lib/%{name}/PROXYSQL_UPGRADE
77- fi
66+ # reload, restart service
67+ #%systemd_posttrans_with_reload %{name}.service
68+ #%systemd_posttrans_with_restart %{name}.service
7869
7970%files
8071%defattr(-,root,root,-)
81- %config(noreplace) %{_sysconfdir }/%{name }.cnf
82- %attr(640,root,%{name}) %{_sysconfdir }/%{name }.cnf
72+ %config(noreplace) %attr(640,root,%{name}) %{_sysconfdir }/%{name }.cnf
8373%config(noreplace) %attr(640,root,%{name}) %{_sysconfdir }/logrotate.d/%{name }
8474%{_bindir }/*
8575%{_sysconfdir }/systemd/system/%{name }.service
8676%{_sysconfdir }/systemd/system/%{name }-initial.service
8777/usr/share/proxysql/tools/proxysql_galera_checker.sh
8878/usr/share/proxysql/tools/proxysql_galera_writer.pl
79+ %config(noreplace) %attr(750,%{name},%{name}) /var/run/%{name }/
80+ %config(noreplace) %attr(750,%{name},%{name}) /var/lib/%{name }/
8981
9082%changelog
0 commit comments