Blob Blame History Raw
%bcond check 1
%bcond qt 1

%global gnupg2_min_ver 2.2.24
%global libgpg_error_min_ver 1.36

Name:           gpgme
Summary:        GnuPG Made Easy - high level crypto API
Version:        1.17.1
Release:        %autorelease

# MIT: src/cJSON.{c,h} (used by gpgme-json)
License:        LGPL-2.1-or-later AND MIT
Source2:        gpgme-multilib.h

## downstream patches
# Don't add extra libs/cflags in gpgme-config/cmake equivalent
Patch1001:      0001-don-t-add-extra-libraries-for-linking.patch
# add -D_FILE_OFFSET_BITS... to gpgme-config, upstreamable
Patch1002:      gpgme-1.3.2-largefile.patch
# Let's fix stupid AX_PYTHON_DEVEL
Patch1003:      0001-fix-stupid-ax_python_devel.patch
# Allow extra options to be passed to during installation
Patch1004:      0002-setup_py_extra_opts.patch

## upstream patches dealing with date and time overflow on 32-bit machines
# Before gpgme 1.18.0
Patch2001:      0001-qt-Prevent-u32-overflow-when-calculating-expiration.patch
Patch2002:      0002-qt-tests-Allow-1-day-offset-for-expiration-date.patch
# After gpgme 1.18.0
Patch2003:      0003-qt-Make-sure-expiration-time-is-interpreted-as-unsigned.patch
Patch2004:      0004-qt-tests-Log-the-actual-error-code-if-the-assertion-fails.patch
Patch2005:      0005-qt-tests-Make-sure-expiration-time-is-interpreted-as-unsigned.patch
Patch2006:      0006-qt-tests-Make-test-pass-on-32-bit-systems.patch
Patch2007:      0007-cpp-Fix-handling-of-no-key-or-invalid-time-situation.patch

#BuildRequires:  autoconf
#BuildRequires:  automake
BuildRequires:  make
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  gawk
BuildRequires:  gnupg2 >= %{gnupg2_min_ver}
BuildRequires:  gnupg2-smime
BuildRequires:  libgpg-error-devel >= %{libgpg_error_min_ver}
BuildRequires:  libassuan-devel >= 2.4.2

# For python bindings
BuildRequires:  swig

# to remove RPATH
BuildRequires:  chrpath

# For AutoReq cmake-filesystem
BuildRequires:  cmake

Requires:       gnupg2 >= %{gnupg2_min_ver}

# On the following architectures workaround multiarch conflict of -devel packages:
%define multilib_arches %{ix86} x86_64 ia64 ppc ppc64 s390 s390x %{sparc}

GnuPG Made Easy (GPGME) is a library designed to make access to GnuPG
easier for applications.  It provides a high-level crypto API for
encryption, decryption, signing, signature verification and key

%package devel
Summary:        Development headers and libraries for %{name}
Requires:       %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires:       libgpg-error-devel%{?_isa} >= %{libgpg_error_min_ver}

%description devel

%package -n %{name}pp
Summary:        C++ bindings/wrapper for GPGME
Obsoletes:      gpgme-pp < 1.8.0-7
Provides:       gpgme-pp = %{?epoch:%{epoch}:}%{version}-%{release}
Provides:       gpgme-pp%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires:       %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}

%description -n %{name}pp

%package -n %{name}pp-devel
Summary:        Development libraries and header files for %{name}-pp
Obsoletes:      gpgme-pp-devel < 1.8.0-7
Provides:       gpgme-pp-devel = %{?epoch:%{epoch}:}%{version}-%{release}
Provides:       gpgme-pp-devel%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires:       %{name}pp%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires:       %{name}-devel%{?_isa}
# For automatic provides
BuildRequires:  cmake

%description -n %{name}pp-devel

%if %{with qt}
%package -n q%{name}
Summary:        Qt API bindings/wrapper for GPGME
Requires:       %{name}pp%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Test)

%description -n q%{name}

%package -n q%{name}-devel
Summary:        Development libraries and header files for %{name}
# before symlink was moved to avoid conflict
Conflicts:      kdepimlibs-devel < 4.14.10-17
Requires:       q%{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires:       %{name}pp-devel%{?_isa}
# For automatic provides
BuildRequires:  cmake

%description -n q%{name}-devel

%package -n python3-gpg
Summary:        %{name} bindings for Python 3
BuildRequires:  python3-devel
# Needed since Python 3.12+ drops distutils
BuildRequires:  python3-setuptools
Requires:       %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes:      platform-python-gpg < %{version}-%{release}

%description -n python3-gpg

%autosetup -p1

# The config script already suppresses the -L if it's /usr/lib, so cheat and
# set it to a value which we know will be suppressed.
sed -i -e 's|^libdir=@libdir@$|libdir=@exec_prefix@/lib|g' src/

# The build machinery does not support Python 3.9+ yet
sed -i 's/3.8/%{python3_version}/g' configure

# People neeed to learn that you can't run anymore

# Since 1.16.0, we need to explicitly pass -D_LARGEFILE_SOURCE and
# -D_FILE_OFFSET_BITS=64 for the QT binding to build successfully on 32-bit
# platforms.
# Explicit new lines in C(XX)FLAGS can break naive build scripts
export CFLAGS="$(echo ${CFLAGS} | tr '\n\\' '  ')"
export CXXFLAGS="$(echo ${CXXFLAGS} | tr '\n\\' '  ')"

%configure --disable-static --disable-silent-rules --enable-languages=cpp,%{?with_qt:qt,}python

# When using distutils from setuptools 60+, ./ install use
# the .egg format. This forces setuptools to use .egg-info format.
# SETUP_PY_EXTRA_OPTS is introduced by the Patch1004 above.
export SETUP_PY_EXTRA_OPTS="--single-version-externally-managed --root=/"

# unpackaged files
rm -fv %{buildroot}%{_infodir}/dir
rm -fv %{buildroot}%{_libdir}/lib*.la

# Hack to resolve multiarch conflict (#341351)
%ifarch %{multilib_arches}
mv %{buildroot}%{_bindir}/gpgme-config{,.%{_target_cpu}}
cat > <<__END__
exec %{_bindir}/gpgme-config.\$(arch) \$@
install -D -p %{buildroot}%{_bindir}/gpgme-config
mv %{buildroot}%{_includedir}/gpgme.h \
install -m644 -p -D %{SOURCE2} %{buildroot}%{_includedir}/gpgme.h
chrpath -d %{buildroot}%{_bindir}/%{name}-tool
chrpath -d %{buildroot}%{_bindir}/%{name}-json
chrpath -d %{buildroot}%{_libdir}/lib%{name}*
%if %{with qt}
chrpath -d %{buildroot}%{_libdir}/libq%{name}.so*

# autofoo installs useless stuff for uninstall
rm -vf %{buildroot}%{python2_sitelib}/gpg/install_files.txt
rm -vf %{buildroot}%{python3_sitelib}/gpg/install_files.txt

%if %{with check}
make check


%files devel
%ifarch %{multilib_arches}

%files -n %{name}pp
%doc lang/cpp/README

%files -n %{name}pp-devel

%if %{with qt}
%files -n q%{name}
%doc lang/qt/README

%files -n q%{name}-devel

%files -n python3-gpg
%doc lang/python/README