File bftpd.spec of Package bftpd

# #
# spec file for package bftpd
#
# Copyright (c) 2025 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


# Disable debuginfo and debugsource package generation due to failing builds on FEDORA 42/Rawhide
%define debug_package %{nil}
#
# For MAGEIA Only; This MACRO is non-existing there
%if 0%{?mageia}
%define _mandir       %{_datadir}/man/
%endif
#


Name:           bftpd
Version:        6.2
Release:        0
Summary:        A lightweight, portable and fast FTP server for Unix systems
License:        GPL-2.0-only
URL:            https://sourceforge.net/projects/%{name}/
Source0:        https://sourceforge.net/projects/%{name}/files/%{name}/%{name}-%{version}/%{name}-%{version}.tar.gz
Source1:        %{name}.service
Source2:        %{name}@.service
Source3:        %{name}.socket
Source4:        %{name}.logrotate
Source5:        %{name}.rpmlintrc
Patch0:         %{name}-install.patch

BuildRequires:  autoconf
BuildRequires:  fdupes
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  m4
BuildRequires:  make
BuildRequires:  pam-devel
BuildRequires:  (systemd-mini or systemd-sysvcompat or initscripts or initscripts-service)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(zlib)

Requires:       logrotate
Requires:       (systemd-mini or systemd-sysvcompat or initscripts or initscripts-service)

Recommends:     xinetd

Suggests:       pax-utils


%description
Bftpd is a lightweight and highly configurable FTP server designed for
Unix-like systems, including Linux, BSD, Solaris, and others.
It supports both standalone operation and integration with inetd,
making it versatile for various environments.

Key features include:

Ease of Configuration:
Bftpd is simple to set up, with options for user-specific and
directory-specific configurations.

Security:
It offers chroot support for isolating file access and does not
require additional files in the chroot environment.

Performance:
Designed for speed, it efficiently handles FTP commands and
supports on-the-fly compression and archiving.

Portability:
Tested across multiple operating systems,ensuring reliability in diverse setups

%prep
%autosetup -p1 -n %{name}

# Remove bundled upstream pre-generated Configure & Makefile files
rm         -vf  %{_builddir}/%{name}/config.{log,status}
rm         -vf  %{_builddir}/%{name}/{configure,Makefile}
#
# Rename `configure.in` as `configure.ac` - `*.in` is incorrect for configure
mv         -vf "%{_builddir}/%{name}/configure.in" "%{_builddir}/%{name}/configure.ac"
#

%build
# Include common C/C++ Flags
export CFLAGS+=" %{optflags} -fcommon"
export CXXFLAGS="%{optflags}"
#
# Update & Generate Configuration for Makefile
autoupdate -v -f

autoconf   -v -f -W all
#
# Messy upstream (pre-)configuration; requires custom changes
%configure                 \
    --prefix='/usr'        \
    --enable-pam           \
    --enable-libz          \
    --sysconfdir='/etc'    \
    --localstatedir='/var'
#
%make_build

%install
%make_install

# Install extra essential files from SOURCE to SYSTEM
install -Dm644 %{SOURCE1} -t "%{buildroot}/usr/lib/systemd/system/"
install -Dm644 %{SOURCE2} -t "%{buildroot}/usr/lib/systemd/system/"
install -Dm644 %{SOURCE3} -t "%{buildroot}/usr/lib/systemd/system/"
install -Dm644 %{SOURCE4}    "%{buildroot}/%{_sysconfdir}/logrotate.d/%{name}"
#
# Only for SUSE
%if 0%{?suse_version} > 1600 || 0%{?suse_version} == 1600 && 0%{?is_opensuse} || 0%{?sle_version} == 150600 && 0%{?is_opensuse} || 0%{?sle_version} == 150500 && 0%{?is_opensuse}
# Link /usr/sbin/ with /usr/bin/ -- RPM "${_sbindir}" Macro conflicts between SUSE and Fedora
mkdir   -p     %{buildroot}/%{_bindir}/
ln      -f -s "%{_sbindir}/%{name}" -t %{buildroot}/%{_bindir}/
#
%endif
#
# Create SUSE/FEDORA-specific RC symlink for SystemD service
mkdir   -p     %{buildroot}/%{_sbindir}/
ln      -fs   "%{_sbindir}/service"   "%{buildroot}/%{_sbindir}/rc%{name}"
#
# Strip binaries to remove any potential residual debug symbols
find %{buildroot}/ -type f -executable -exec strip --strip-unneeded {} \;
#

%check
%fdupes %{buildroot}/

%preun
%if 0%{?fedora}
%systemd_preun     "%{name}.service" "%{name}.socket"
%else
%service_del_preun "%{name}.service" "%{name}.socket"
%endif

%pre
# Only for SUSE
%if 0%{?suse_version} > 1600 || 0%{?suse_version} == 1600 && 0%{?is_opensuse} || 0%{?sle_version} == 150600 && 0%{?is_opensuse} || 0%{?sle_version} == 150500 && 0%{?is_opensuse}
%service_add_pre "%{name}.service" "%{name}.socket"
%endif
#

%postun
%systemd_postun_with_restart "%{name}.service" "%{name}.socket"

%post
%if 0%{?fedora}
%systemd_post     "%{name}.service" "%{name}.socket"
%else
%service_add_post "%{name}.service" "%{name}.socket"
%endif

%files
%doc README CHANGELOG

%license COPYING

%config(noreplace) "%{_sysconfdir}/%{name}.conf"
%dir               "%{_sysconfdir}/logrotate.d/"
%config(noreplace) "%{_sysconfdir}/logrotate.d/%{name}"

        %{_mandir}/man8/%{name}.8*%{?ext_man}*

# Only for SUSE
%if 0%{?suse_version} > 1600 || 0%{?suse_version} == 1600 && 0%{?is_opensuse} || 0%{?sle_version} == 150600 && 0%{?is_opensuse} || 0%{?sle_version} == 150500 && 0%{?is_opensuse}
        %{_bindir}/%{name}
%endif
#
       "%{_sbindir}/rc%{name}"
       "%{_prefix}/sbin/%{name}"

%dir   "%{_prefix}/lib/systemd/system/"
       "%{_prefix}/lib/systemd/system/%{name}.service"
       "%{_prefix}/lib/systemd/system/%{name}@.service"
       "%{_prefix}/lib/systemd/system/%{name}.socket"

%changelog
openSUSE Build Service is sponsored by