File freenginx.spec of Package freenginx

#
# spec file for package freenginx
#
# Copyright (c) 2025 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


#
%define pkg_name freenginx
%define progname nginx
#
%define ngx_prefix     %{_prefix}
%define ngx_sbin_path  %{_sbindir}/nginx
%define ngx_conf_dir   %{_sysconfdir}/nginx
%define ngx_conf_path  %{ngx_conf_dir}/nginx.conf
%define ngx_log_dir    %{_localstatedir}/log/nginx
%define ngx_error_log  %{ngx_log_dir}/error.log
%define ngx_access_log %{ngx_log_dir}/access.log
%define ngx_pid_path   %{_localstatedir}/run/nginx.pid
%define ngx_lock_path  %{_localstatedir}/run/nginx.lock
%define ngx_home       %{_localstatedir}/lib/nginx
%define ngx_tmp_http   %{ngx_home}/tmp/
%define ngx_tmp_proxy  %{ngx_home}/proxy/
%define ngx_tmp_fcgi   %{ngx_home}/fastcgi/
%define ngx_tmp_scgi   %{ngx_home}/scgi/
%define ngx_tmp_uwsgi  %{ngx_home}/uwsgi/
%define ngx_user_group nginx

Name:           freenginx
Version:        1.29.7
Release:        %mkrel 1
Summary:        An HTTP server and IMAP/POP3 proxy server
License:        BSD-2-Clause
Group:          Productivity/Networking/Web/Proxy
#
Url:            https://freenginx.org/
Source0:        https://freenginx.org/download/freenginx-%{version}.tar.gz
Source2:	nginx.keyring
Source3:        nginx.init
Source4:        nginx.service
Source5:        freenginx.logrotate
# PATCH-FIX-UPSTREAM nginx-0.4.0-no_Werror.patch
Patch0:         nginx-0.4.0-no_Werror.patch
# PATCH-FIX-UPSTREAM nginx-1.2.4-perl_vendor_install.patch
Patch3:         nginx-1.2.4-perl_vendor_install.patch
# PATCH-FIX-UPSTREAM nginx-1.5.4_default_config.patch
Patch4:         nginx-1.5.4_default_config.patch
#BuildRequires:  GeoIP-devel
BuildRequires:  lib64gd-devel
BuildRequires:  lib64xslt-devel
BuildRequires:  lib64pcre-devel
BuildRequires:  lib64pcre2-devel
BuildRequires:  lib64openssl-devel
%if %{mageia} >= 10
BuildRequires:	lib64z-devel
BuildRequires:	lib64quictls-devel
%else
BuildRequires:  lib64zlib-devel
%endif
BuildRequires:  perl
BuildRequires:  pkgconfig
#PreReq:         pwdutils
Recommends:     logrotate
#
Provides:       http_daemon
Provides:       httpd
Provides:	webserver
#
Conflicts:	nginx
Requires(post):   rpm-helper >= %{rpmhelper_required_version}
Requires(preun):  rpm-helper >= %{rpmhelper_required_version}
Requires(postun): rpm-helper >= %{rpmhelper_required_version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
freenginx [free engine x] is an HTTP server and IMAP/POP3 proxy server written by Igor Sysoev.

%global debug_package %{nil}

%prep
%setup -q

%patch -P 0 -p0
%patch -P 3 -p0
%patch -P 4 -p1

perl -pi -e 's|\r\n|\n|g' contrib/geo2nginx.pl

%build

./configure                                          \
  --prefix=%{ngx_prefix}/                            \
  --sbin-path=%{ngx_sbin_path}                       \
  --conf-path=%{ngx_conf_path}                       \
  --error-log-path=%{ngx_error_log}                  \
  --http-log-path=%{ngx_access_log}                  \
  --pid-path=%{ngx_pid_path}                         \
  --lock-path=%{ngx_lock_path}                       \
  --http-client-body-temp-path=%{ngx_tmp_http}       \
  --http-proxy-temp-path=%{ngx_tmp_proxy}            \
  --http-fastcgi-temp-path=%{ngx_tmp_fcgi}           \
  --http-uwsgi-temp-path=%{ngx_tmp_uwsgi}            \
  --http-scgi-temp-path=%{ngx_tmp_scgi}              \
  --user=%{ngx_user_group} --group=%{ngx_user_group} \
  --with-http_ssl_module                             \
  --with-openssl-opt=enable-ktls                     \
  --with-http_addition_module                        \
  --with-http_v2_module                              \
  --with-http_v3_module                              \
  --with-stream                                      \
  --without-select_module                            \
  --with-poll_module                                 \
  --with-file-aio                                    \
  --with-http_gzip_static_module                     \
  --with-http_stub_status_module                     \
  --with-pcre                                        \
  --with-cc-opt="%{optflags} -D_GNU_SOURCE -std=gnu99 -fstack-protector-strong -O3 -I/usr/include/openssl-quic/openssl" \
  --with-ld-opt="-L %{_libdir}"

make %{?_smp_mflags}

%install
make %{?_smp_mflags} DESTDIR=%{buildroot} install

install -d -m 0750 %{buildroot}%{ngx_home}/{,tmp,proxy,fastcgi,scgi,uwsgi}

mkdir -p -m 755 %{buildroot}/srv/www/htdocs

install -D -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/nginx.service
sed -i 's|%{_initddir}/nginx reopen|%{_bindir}/systemctl reload nginx|' %{SOURCE5}

install -D -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/logrotate.d/%{pkg_name}

gzip -9 man/%{progname}.8
install -D -m 644 man/%{progname}.8.gz %{buildroot}/%{_mandir}/man8/%{progname}.8.gz

mv -f %{buildroot}%{_prefix}/html/50x.html %{buildroot}/srv/www/htdocs
mv -f %{buildroot}%{_prefix}/html/index.html %{buildroot}/srv/www/htdocs
rm -rf %{buildroot}%{_prefix}/html
rm -f %{buildroot}%{ngx_conf_dir}/*.default
mkdir -p %{buildroot}%{ngx_conf_dir}/{ssl,vhosts}

%pre
%{_sbindir}/groupadd -r %{ngx_user_group} &>/dev/null ||:
%{_sbindir}/useradd -g %{ngx_user_group} -s /bin/false -r -c "user for %{ngx_user_group}" -d %{ngx_home} %{ngx_user_group} &>/dev/null ||:

%post
%_post_service %{progname}
 
%preun
%_preun_service %{progname}
 
%postun
%_postun_userdel %{progname}

%files
%defattr(-,root,root,-)
%dir %{ngx_conf_dir}
%dir %{ngx_conf_dir}/ssl
%dir %{ngx_conf_dir}/vhosts
%config(noreplace) %{ngx_conf_dir}/*
%{ngx_sbin_path}
%config(noreplace) /srv/www/htdocs/*.html
%{_unitdir}/%{progname}.service
%config(noreplace) %{_sysconfdir}/logrotate.d/%{pkg_name}
%dir %attr(755,%{ngx_user_group},%{ngx_user_group}) %{_localstatedir}/log/nginx/
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_home}/
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_http}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_proxy}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_fcgi}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_scgi}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_uwsgi}
%{_mandir}/man8/*
%doc CHANGES*
%doc contrib/

%changelog
openSUSE Build Service is sponsored by