File certbot.spec of Package certbot

#
# spec file for package certbot
#
# Copyright (c) 2017 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/
#


# See also http://en.opensuse.org/openSUSE:Specfile_guidelines

Name:           certbot
Version:        0.15.0
Release:        0
Summary:        Let's Encrypt
License:        Apache-2.0
Group:          Productivity/Security
Url:            https://certbot.eff.org/
Source0:        https://github.com/certbot/certbot/archive/v%{version}.tar.gz
Source1:        %{name}.cron
Source90:       README.SUSE
Source99:       %{name}.rpmlintrc
Patch0:         %{name}-cli.ini.patch
Patch1:         %{name}-fix_constants.patch
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires:  cron
BuildRequires:  dialog
BuildRequires:  dos2unix
BuildRequires:  fdupes
BuildRequires:  pkg-config
BuildRequires:  python-setuptools >= 1.0
BuildRequires:  swig
BuildRequires:  unzip
BuildRequires:  pkgconfig(libffi)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(python) >= 2.6.6
# install_requires
#BuildRequires:  acme
BuildRequires:  python-acme = %{version}
BuildRequires:  python-argparse
BuildRequires:  python-configargparse
BuildRequires:  python-configobj
BuildRequires:  python-cryptography >= 0.8
BuildRequires:  python-dialog >= 3.2.2rc1
BuildRequires:  python-future
BuildRequires:  python-jsonschema
BuildRequires:  python-mock
BuildRequires:  python-parsedatetime
BuildRequires:  python-psutil >= 2.2.1
BuildRequires:  python-pyOpenSSL >= 0.15
BuildRequires:  python-pyRFC3339
BuildRequires:  python-pytz
%if 0%{?suse_version} >= 1330
BuildRequires:  python2-requests >= 2.10
%else
BuildRequires:  python-requests >= 2.10
%endif
BuildRequires:  python-six
BuildRequires:  python-zope.component
BuildRequires:  python-zope.interface
# dev_extras
BuildRequires:  python-astroid >= 1.3.5
BuildRequires:  python-pylint >= 1.4.2
BuildRequires:  python-twine
BuildRequires:  python-wheel
# docs_extras
BuildRequires:  python-Sphinx >= 1.0
BuildRequires:  python-autodoc
BuildRequires:  python-repoze.sphinx.autointerface
BuildRequires:  python-sphinx_rtd_theme
BuildRequires:  python-sphinxcontrib-programoutput
# testing_extras
BuildRequires:  python-coverage
BuildRequires:  python-nose
BuildRequires:  python-nosexcover
BuildRequires:  python-pep8
BuildRequires:  python-tox
# install_requires acme
BuildRequires:  python-ndg-httpsclient
BuildRequires:  python-pyasn1 >= 0.1.7
BuildRequires:  python-pyasn1-modules
BuildRequires:  python-werkzeug
# install_requires apache
BuildRequires:  augeas-lenses
BuildRequires:  python-augeas
# install_requires nginx
BuildRequires:  python-pyparsing >= 1.5.5
# install_requires openSUSE build
BuildRequires:  python-packaging

# requires
Requires:       ca-certificates
Requires:       cron
Requires:       python-acme = %{version}
Requires:       python-argparse
Requires:       python-certbot = %{version}
Requires:       python-configargparse
Requires:       python-configobj
Requires:       python-cryptography >= 0.8
Requires:       python-dialog >= 3.2.2rc1
Requires:       python-mock
Requires:       python-parsedatetime
Requires:       python-psutil >= 2.2.1
Requires:       python-pyOpenSSL >= 0.15
Requires:       python-pyRFC3339
Requires:       python-pytz
%if 0%{?suse_version} >= 1330
Requires:       python2-requests >= 2.10
%else
Requires:       python-requests >= 2.10
%endif
Requires:       python-setuptools >= 1.0
Requires:       python-six
Requires:       python-zope.component
Requires:       python-zope.interface

Obsoletes:      letsencrypt < %{version}
Provides:       letsencrypt = %{version}

%description
Certbot (previously, the Let's Encrypt client) is an easy-to-use automatic client that fetches and deploys 
SSL/TLS certificates for your webserver. 
Certbot was developed by EFF and others as a client for Let’s Encrypt and was previously known as 
“the official Let’s Encrypt client” or “the Let’s Encrypt Python client.” 
Certbot will also work with any other CAs that support the ACME protocol.

While there are many other clients that implement the ACME protocol to fetch certificates, Certbot is the
most extensive client and can automatically configure your webserver to start serving over HTTPS immediately. 
For Apache, it can also optionally automate security tasks such as tuning ciphersuites and enabling important 
security features such as HTTP → HTTPS redirects, OCSP stapling, HSTS, and upgrade-insecure-requests.

Certbot is part of EFF’s larger effort to encrypt the entire Internet. Websites need to use HTTPS to secure 
the web. Along with HTTPS Everywhere, Certbot aims to build a network that is more structurally private,
safe, and protected against censorship.

%package doc
Summary:        Documentation for Certbot
Group:          Documentation/Other

%description doc
epub and html documentation for Certbot

%package -n letshelp-certbot
Summary:        Simple help script for Let’s Encrypt Project
Group:          Development/Libraries/Python
Requires:       apache2
Requires:       python-mock
Obsoletes:      letshelp-letsencrypt < %{version}
Provides:       letshelp-letsencrypt = %{version}

%description -n letshelp-certbot
Let's Help is a simple script you can run to help out the Let's Encrypt
project. Since Let's Encrypt will support automatically configuring HTTPS on
many servers, we want to test this functionality on as many configurations as
possible. This script will create a sanitized copy of your Apache
configuration, notifying you of the files that have been selected. If (and only
if) you approve this selection, these files will be sent to the Let's Encrypt
developers.

%package -n python-certbot
Summary:        Python module for Certbot 
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       python-future
Obsoletes:      python-letsencrypt < %{version}
Provides:       python-letsencrypt = %{version}

%description -n python-certbot
The Python module for Certbot.

%package -n python-certbot-apache
Summary:        Apache plugin for Certbot 
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       apache2
Requires:       augeas-lenses
Requires:       python-augeas
Obsoletes:      python-letsencrypt-apache < %{version}
Provides:       python-letsencrypt-apache = %{version}

%description -n python-certbot-apache
The Apache plugin for Certbot.

%package -n python-certbot-nginx
Summary:        Nginx plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       nginx
Requires:       python-pyparsing >= 1.5.5
Obsoletes:      python-letsencrypt-nginx < %{version}
Provides:       python-letsencrypt-nginx = %{version}

%description -n python-certbot-nginx
The Nginx plugin for Certbot.

%package -n python-certbot-dns-cloudflare
Summary:        Cloudflare Authenticator plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description -n python-certbot-dns-cloudflare
Cloudflare DNS Authenticator plugin for Certbot.

%package -n python-certbot-dns-cloudxns
Summary:        Cloudxns Authenticator plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description -n python-certbot-dns-cloudxns
Cloudxns DNS Authenticator plugin for Certbot.

%package -n python-certbot-dns-digitalocean
Summary:        Digitalocean Authenticator plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description -n python-certbot-dns-digitalocean
Digitalocean DNS Authenticator plugin for Certbot.

%package -n python-certbot-dns-dnsimple
Summary:        Dnsimple Authenticator plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description -n python-certbot-dns-dnsimple
Dnsimple DNS Authenticator plugin for Certbot.

%package -n python-certbot-dns-google
Summary:        Google Authenticator plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description -n python-certbot-dns-google
Google DNS Authenticator plugin for Certbot.

%package -n python-certbot-dns-nsone
Summary:        Nsone Authenticator plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description -n python-certbot-dns-nsone
Nsone DNS Authenticator plugin for Certbot.

%package -n python-certbot-dns-route53
Summary:        Route53 Authenticator plugin for Certbot
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}

%description -n python-certbot-dns-route53
Route53 DNS Authenticator plugin for Certbot.


%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
install -m644 %{S:90} .
%{__sed} -i 's|PyOpenSSL>=0.15|pyOpenSSL>=0.15|g' setup.py

#Is this still needed?
# certbot-auto not for packages
#sed -i 's/letsencrypt-auto/letsencrypt/g' letsencrypt/cli.py

# rpmlint
find -type f -name ".gitignore" -exec rm {} \;

%build
# build packages certbot, certbot-apache, certbot-nginx, letshelp-certbot 
for PACKAGE in . certbot-apache certbot-nginx letshelp-certbot certbot-dns-cloudflare certbot-dns-cloudxns certbot-dns-digitalocean certbot-dns-dnsimple certbot-dns-google certbot-dns-nsone certbot-dns-route53 ; do
pushd $PACKAGE > /dev/null
python setup.py build
popd > /dev/null
done

# docs certbot
python setup.py install --user
make %{?_smp_mflags} -C docs html PATH=${HOME}/.local/bin:$PATH || true
make %{?_smp_mflags} -C docs epub PATH=${HOME}/.local/bin:$PATH || true
make %{?_smp_mflags} -C docs text PATH=${HOME}/.local/bin:$PATH || true
make %{?_smp_mflags} -C docs man PATH=${HOME}/.local/bin:$PATH || true
rm -rf docs/_build/html/{.buildinfo,_sources}

# docs letshelp-certbot
pushd letshelp-certbot > /dev/null
make %{?_smp_mflags} -C docs html PATH=${HOME}/.local/bin:$PATH || true
make %{?_smp_mflags} -C docs epub PATH=${HOME}/.local/bin:$PATH || true
make %{?_smp_mflags} -C docs text PATH=${HOME}/.local/bin:$PATH || true
make %{?_smp_mflags} -C docs man PATH=${HOME}/.local/bin:$PATH || true
popd > /dev/null

# move docs so i can use one doc-package
mkdir docs/html
mkdir docs/text
mv docs/_build/html docs/html/certbot
mv docs/_build/text docs/text/certbot
mv letshelp-certbot/docs/_build/html docs/html/letshelp-certbot
mv letshelp-certbot/docs/_build/text docs/text/letshelp-certbot

# rpmlint
find -type f -name ".buildinfo" -exec rm {} \;
find -type f -name "jquery.js" -exec dos2unix {} \;

%install
# install packages certbot, certbot-apache, certbot-nginx, letshelp-certbot
for PACKAGE in . certbot-apache certbot-nginx letshelp-certbot certbot-dns-cloudflare certbot-dns-cloudxns certbot-dns-digitalocean certbot-dns-dnsimple certbot-dns-google certbot-dns-nsone certbot-dns-route53 ; do
pushd $PACKAGE > /dev/null
python setup.py install -O1 --skip-build --prefix=%{_prefix} --root=%{buildroot}
popd > /dev/null
done
%fdupes %{buildroot}
# config
install -d -m 0755 %{buildroot}%{_sysconfdir}
install -d -m 0755 %{buildroot}%{_sysconfdir}/certbot
install -d -m 0755 %{buildroot}%{_sysconfdir}/certbot/archive
install -d -m 0755 %{buildroot}%{_sysconfdir}/certbot/keys
install -d -m 0755 %{buildroot}%{_sysconfdir}/certbot/live
# man
install -d -m 0775 %{buildroot}%{_mandir}
install -d -m 0775 %{buildroot}%{_mandir}/man1
install -d -m 0775 %{buildroot}%{_mandir}/man7
cp -a docs/_build/man/*.1 %{buildroot}%{_mandir}/man1/
cp -a docs/_build/man/*.7 %{buildroot}%{_mandir}/man7/
cp -a letshelp-certbot/docs/_build/man/*.1 %{buildroot}%{_mandir}/man1/
# log
install -d -m 0775 %{buildroot}/var/log/%{name}
# cli.ini
install -m 0644 examples/cli.ini %{buildroot}%{_sysconfdir}/%{name}/cli.ini
install -m 0644 examples/dev-cli.ini %{buildroot}%{_sysconfdir}/%{name}/dev-cli.ini
# cron
install -d -m 0755 %{buildroot}%{_sysconfdir}/cron.d
install -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/cron.d/%{name}

%check
# nginx produce error
#for PACKAGE in . certbot-apache certbot-nginx letshelp-certbot ; do
#pushd $PACKAGE > /dev/null
#python setup.py test
#popd > /dev/null
#done

%files
%defattr(-,root,root)
%doc CHANGES.rst LICENSE.txt README.rst README.SUSE
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/archive
%dir %attr(0700,root,root) %{_sysconfdir}/%{name}/keys
%dir %{_sysconfdir}/%{name}/live
%config(noreplace) %{_sysconfdir}/%{name}/*cli.ini
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%{_mandir}/*/certbot*
%{_bindir}/%{name}
%dir /var/log/%{name}

%files doc
%defattr(-,root,root)
%doc docs/_build/epub/Certbot.epub
%doc letshelp-certbot/docs/_build/epub/letshelp-certbot.epub
%doc docs/html
%doc docs/text 

%files -n letshelp-certbot
%defattr(-,root,root)
%{_mandir}/*/letshelp*
%{_bindir}/letshelp-certbot-apache
%{python_sitelib}/letshelp_certbot*
%exclude %{python_sitelib}/letshelp_certbot/testdata

%files -n python-certbot
%defattr(-,root,root)
%{python_sitelib}/%{name}
%{python_sitelib}/%{name}-*
%exclude %{python_sitelib}/%{name}/tests

%files -n python-certbot-apache
%defattr(-,root,root)
%{python_sitelib}/%{name}_apache*
%exclude %{python_sitelib}/certbot_apache/tests

%files -n python-certbot-nginx
%defattr(-,root,root)
%{python_sitelib}/%{name}_nginx*
%exclude %{python_sitelib}/certbot_nginx/tests

%files -n python-certbot-dns-cloudflare
%defattr(-,root,root)
%{python_sitelib}/%{name}_dns_cloudflare*

%files -n python-certbot-dns-cloudxns
%defattr(-,root,root)
%{python_sitelib}/%{name}_dns_cloudxns*

%files -n python-certbot-dns-digitalocean
%defattr(-,root,root)
%{python_sitelib}/%{name}_dns_digitalocean*

%files -n python-certbot-dns-dnsimple
%defattr(-,root,root)
%{python_sitelib}/%{name}_dns_dnsimple*

%files -n python-certbot-dns-google
%defattr(-,root,root)
%{python_sitelib}/%{name}_dns_google*

%files -n python-certbot-dns-nsone
%defattr(-,root,root)
%{python_sitelib}/%{name}_dns_nsone*

%files -n python-certbot-dns-route53
%defattr(-,root,root)
%{python_sitelib}/%{name}_dns_route53*

%changelog