File john.spec of Package john
#
# spec file for package john
#
# Copyright (c) 2020 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/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if 0%{?sle_version} >= 150200
%define DisOMPI1 ExclusiveArch: do_not_build
%endif
%if !0%{?is_opensuse} && 0%{?sle_version:1} && 0%{?sle_version} < 150200
%define DisOMPI3 ExclusiveArch: do_not_build
%endif
%if 0%{?is_opensuse} && 0%{?sle_version:1} && 0%{?sle_version} <= 150200
%define DisOMPI4 ExclusiveArch: do_not_build
%endif
%if "%flavor" == "avx"
%define avx avx
%endif
%if "%flavor" == "avx512"
%define avx avx512
%endif
%if "%flavor" == "openmpi2-avx"
%{?DisOMPI2}
%define mpi_family openmpi
%define mpi_ver 2
%define avx avx
%endif
%if "%flavor" == "openmpi1"
%{?DisOMPI1}
%define mpi_family openmpi
%define mpi_ver 1
%endif
%if "%flavor" == "openmpi2"
%{?DisOMPI2}
%define mpi_family openmpi
%define mpi_ver 2
%endif
%if "%flavor" == "openmpi3"
%{?DisOMPI3}
%define mpi_family openmpi
%define mpi_ver 3
%endif
%if "%flavor" == "openmpi4"
%{?DisOMPI4}
%define mpi_family openmpi
%define mpi_ver 4
%endif
# openmpi 1 was called just "openmpi" in Leap 15.x/SLE15
%if 0%{?suse_version} >= 1550 || "%{mpi_family}" != "openmpi" || "%{mpi_ver}" != "1"
%define mpi_ext %{?mpi_ver}
%endif
%if 0%{?mpi_family:1}
%{bcond_without mpi}
%if 0%{?avx:1}
%define pkgname john-%{mpi_family}%{?mpi_ext}-%{avx}
%else
%define pkgname john-%{mpi_family}%{?mpi_ext}
%endif
%else
%{bcond_with mpi}
%if 0%{?avx:1}
%define pkgname john-%{avx}
%else
%define pkgname john
%endif
%endif
%define _name john
%define johndir %{_datadir}/john
%define baseversion 1.9.0
Name: %{pkgname}
Version: 1.9.0jumbo1+git20210607.f9b340eec
Release: 0
Summary: Utility to detect weak passwords
License: GPL-2.0-or-later
Group: Productivity/Security
URL: https://www.openwall.com/john/
Source: https://www.openwall.com/john/k/%{_name}-%{baseversion}.tar.xz
Source1: https://www.openwall.com/john/k/%{_name}-%{baseversion}.tar.xz.sign
Source2: %{_name}.8.gz
Source3: %{_name}-rpmlintrc
Source6: mailer.8
Source7: relbench.8
Source8: %{_name}-%{version}.tar.xz
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: gmp-devel
BuildRequires: libpcap-devel
BuildRequires: libusb-devel
BuildRequires: opencl-headers
BuildRequires: pkgconfig
BuildRequires: pkgconfig(OpenCL)
BuildRequires: pkgconfig(bzip2)
BuildRequires: pkgconfig(openssl)
%if %{with mpi}
BuildRequires: %{mpi_family}%{?mpi_ext}-devel
Requires: %{mpi_family}%{?mpi_ext}
Recommends: lam
%endif
%description
John the Ripper is a password cracker (password security auditing
tool). Its primary purpose is to detect weak passwords, and a
number of other hash types are supported to that end.
%prep
%setup -q -a8 -n %{_name}-%{baseversion}
cd %{_name}-%{version} && cp -a ./* ..
cd ..
rm -r %{_name}-%{version}
# adapt the configs
sed -E -i 's|^(#define JOHN_SYSTEMWIDE_EXEC\t+).*|\1 "%{_bindir}"|' src/params.h
%build
%if %{with mpi}
export CC=%{_libdir}/mpi/gcc/%{mpi_family}%{?mpi_ext}/bin/mpicc
export LDFLAGS="-Wl,-rpath=%{_libdir}/mpi/gcc/%{mpi_family}%{?mpi_ext}/lib64"
%endif
pushd src
%configure --with-systemwide \
--enable-fuzz \
--enable-experimental-code \
--enable-pkg-config \
%if %{with mpi}
--enable-mpi \
%endif
%ifarch x86_64
%if "%{avx}" == "avx512"
--enable-simd="avx512bw" \
%endif
%if "%{avx}" == "avx"
--enable-simd=avx \
%endif
%if !0%{?avx:1}
--enable-simd=avx2 \
%endif
%endif
--disable-native-tests
make -s clean
make %{?_smp_mflags}
popd
# fix shebang
sed -i 's|#!/usr/bin/env perl|#!/usr/bin/perl|' run/*.pl
sed -i 's|#! /usr/bin/env perl|#!/usr/bin/perl|' run/*.pl
sed -i 's|#!/usr/bin/env python|#!/usr/bin/python|' run/*.py
sed -i 's|#! /usr/bin/env python|#!/usr/bin/python|' run/*.py
sed -i 's|#!/usr/bin/env perl|#!/usr/bin/perl|' run/relbench
sed -i '1 i\#!/usr/bin/python' run/pkcs12kdf.py
%install
mkdir -p %{buildroot}{%{_bindir},%{johndir},%{johndir}/wordlists,%{_sysconfdir},%{_mandir}/man8}
install -m 755 run/john %{buildroot}%{_bindir}/
install -m 755 run/*.py %{buildroot}%{_bindir}/
install -m 755 run/*.pl %{buildroot}%{_bindir}/
install -m 755 run/un* %{buildroot}%{_bindir}/
install -m 755 run/*2john %{buildroot}%{_bindir}/
install -m 755 run/base64conv %{buildroot}%{_bindir}/
install -m 755 run/relbench %{buildroot}%{_bindir}/
install -m 755 -p run/mailer %{buildroot}%{_bindir}/
install -m 644 -p run/{password.lst,*.chr,d*.conf,h*.conf,k*.conf,r*.conf} %{buildroot}%{johndir}/
install -m 644 -p run/john.conf %{buildroot}%{johndir}/
mkdir -p %{buildroot}%{johndir}/opencl
cp -r run/opencl/* %{buildroot}%{johndir}/opencl/
mkdir -p %{buildroot}%{johndir}/rules
cp -r run/rules/* %{buildroot}%{johndir}/rules/
mkdir -p %{buildroot}%{johndir}/ztex
cp -r run/rules/* %{buildroot}%{johndir}/ztex/
cp -r run/bip-0039/* %{buildroot}%{johndir}/wordlists/
# handle documentation - makes rpmlint happy
mkdir -p %{buildroot}%{_defaultdocdir}/%{_name}
cp README.md %{buildroot}%{_defaultdocdir}/%{_name}/
cp -r doc/* %{buildroot}%{_defaultdocdir}/%{_name}/
rm %{buildroot}%{_defaultdocdir}/%{_name}/INSTALL
rm %{buildroot}%{_defaultdocdir}/%{_name}/README
rm %{buildroot}%{_defaultdocdir}/%{_name}/LICENSE*
# install man pages
install -m 644 -p %{SOURCE2} %{buildroot}%{_mandir}/man8/
install -Dm644 %{SOURCE6} %{buildroot}%{_mandir}/man8/mailer.8
install -Dm644 %{SOURCE7} %{buildroot}%{_mandir}/man8/relbench.8
dos2unix %{buildroot}%{_defaultdocdir}/%{_name}/README.krb5tgs-17-18-23.md
%fdupes -s %{buildroot}
%files
%doc %{_defaultdocdir}/%{_name}/
%license doc/LICENSE doc/LICENSE.mpi
%{_mandir}/man8/john.8%{?ext_man}
%{_mandir}/man8/mailer.8%{?ext_man}
%{_mandir}/man8/relbench.8%{?ext_man}
%{_bindir}/*
%dir %{johndir}
%dir %{johndir}/opencl/
%{johndir}/opencl/*
%dir %{johndir}/rules/
%{johndir}/rules/*
%dir %{johndir}/ztex/
%{johndir}/ztex/*
%dir %{johndir}/wordlists
%{johndir}/wordlists/*
%attr(644,root,root) %{johndir}/password.lst
%attr(644,root,root) %{johndir}/*.chr
%attr(644,root,root) %{johndir}/d*.conf
%attr(644,root,root) %{johndir}/h*.conf
%attr(644,root,root) %{johndir}/k*.conf
%attr(644,root,root) %{johndir}/r*.conf
%config (noreplace) %{johndir}/john.conf
%changelog