File osc-CentOS_7.spec of Package osc

# spec file for package osc
# 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

%if 0%{?suse_version} >= 1500 || 0%{?fedora_version} >= 29 || 0%{?centos_version} >= 700
%define use_python python3
%define use_python python

%define version_unconverted 0.168.2
%define osc_plugin_dir %{_prefix}/lib/osc-plugins
%define macros_file macros.osc

%define _default_patch_fuzz 3

Name:           osc
Version:        0.168.2
Release:        0
Summary:        Open Build Service Commander
License:        GPL-2.0-or-later
Group:          Development/Tools/Other
Source:         %{name}-%{version}.tar.gz
Source2:        gnome-keyring-pam-setup
Patch01:        01-osc_devlab_config.patch
Patch02:        02-osc_editor.patch
Patch03:        03-osc_gnome_keyring.patch
#Patch04:	00-osc_fix_importsrcpkg_name_option.patch
Patch05:        05-trust_all_projects.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  %{use_python}-devel
BuildRequires:  %{use_python}-setuptools
BuildRequires:  diffstat
%if 0%{?mandriva_version} || 0%{?mageia}
BuildRequires:  python-rpm
Requires:       python-rpm
%if 0%{?suse_version} >= 1500 || 0%{?fedora_version} >= 32 || 0%{?centos_version} >= 800
BuildRequires:  %{use_python}-rpm
Requires:       %{use_python}-rpm
BuildRequires:  rpm-python
Requires:       rpm-python
%if 0%{?suse_version} == 0 || 0%{?suse_version} >= 1120
BuildArch:      noarch
%if 0%{?suse_version}
Requires:       %{use_python}
Recommends:     %{use_python}-progressbar
BuildRequires:  %{use_python}-xml
Requires:       %{use_python}-xml
%if !%{with python3} && 0%{?suse_version} < 1020
BuildRequires:  python-elementtree
Requires:       python-elementtree
%if 0%{?suse_version} > 1000
Recommends:     diffstat
Recommends:     build
Recommends:     sudo
Recommends:     powerpc32
Recommends:     ca-certificates 
# These packages are needed for "osc add $URL"
Recommends:     obs-service-recompress
Recommends:     obs-service-set_version
Recommends:     obs-service-tar_scm
Recommends:     obs-service-obs_scm
Recommends:     obs-service-verify_file
Recommends:     obs-service-download_files
Recommends:     obs-service-format_spec_file
Recommends:     obs-service-source_validator
Recommends:     xdg-utils
# for osc >= 0.167.0 the newest build version is needed. 
# Otherwise osc chroot might not work correctly.
Conflicts:      build < 20200106
# needed for storing credentials in kwallet/gnome-keyring
%if 0%{?suse_version} > 1000 || 0%{?mandriva_version} || 0%{?mdkversion}
Recommends:     python-keyring
%if 0%{?rhel_version} 
%if 0%{?rhel_version} < 600
BuildRequires:  python-elementtree
Requires:       python-elementtree
#Requires:       dbus-x11
#Requires:       gnome-keyring-pam%{?_isa}
#Requires:       gnome-python-desktop
#Requires:       pygobject2
#BuildRequires:  gnome-python-desktop
#BuildRequires:  python-gnomekeyring
#BuildRequires:  python-pycurl
%if 0%{?centos_version} 
%if 0%{?centos_version} <= 600
BuildRequires:  python-elementtree
Requires:       python-elementtree
BuildRequires:  %{use_python}-pycurl
BuildRequires:  python%{python3_version_nodots}-cryptography
BuildRequires:  python%{python3_version_nodots}-dbus
BuildRequires:  python%{python3_version}dist(keyring)
BuildRequires:  python%{python3_version}dist(secretstorage)
Requires:       dbus-x11
Requires:       gnome-keyring-pam%{?_isa}
Requires:       python%{python3_version_nodots}-cryptography
Requires:       python%{python3_version_nodots}-dbus
Requires:       python%{python3_version}dist(keyring)
Requires:       python%{python3_version}dist(secretstorage)
%if 0%{?suse_version} || 0%{?mandriva_version} || 0%{?mageia}
%if 0%{?suse_version} >= 1500
BuildRequires:  %{use_python}-M2Crypto > 0.19
BuildRequires:  %{use_python}-chardet
Requires:       %{use_python}-M2Crypto > 0.19
Requires:       %{use_python}-chardet
BuildRequires:  python-m2crypto > 0.19
Requires:       python-m2crypto > 0.19
%if 0%{?fedora_version} >= 29  || 0%{?centos_version} >= 700
BuildRequires:  %{use_python}-m2crypto
Requires:       %{use_python}-m2crypto >= 0.30.1
Requires:       obs-build
BuildRequires:  m2crypto > 0.19
Requires:       m2crypto > 0.19

Provides:       %{use_python}-osc

%if %{with python3}
%define python_sitelib %(%{use_python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
%define python_sitearch %(%{use_python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
%{!?python_sitelib: %define python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?python_sitearch: %define python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
Commandline client for the Open Build Service.

See , as well as for a general

%setup -q
%patch01 -p1 -b .devlab-conf
%patch02 -p1 -b .osc_editor
%if 0%{?centos_version} || 0%{?rhel_version}
%patch03 -p1 -b .gnome_keyring
#%patch04 -p1 -b .importsrcpkg
%patch05 -p1 -b .trustall 

# the PATH hack/rewrite is needed for Fedora 20 builds, because /bin
# is a symlink to /usr/bin and /bin precedes /usr/bin in PATH
# => a "wrong" interpreter line ("#!/bin/python") is constructed
# ("wrong", because no package provides "/bin/python").
PATH="/usr/bin:$PATH" CFLAGS="%{optflags}" %{use_python} build

cat << eom > %{macros_file}
%%osc_plugin_dir %{osc_plugin_dir}
echo >> %{macros_file}

%{use_python} install --prefix=%{_prefix} --root=%{buildroot}
perl -p -i -e 's{#!.*python}{#!%{_bindir}/%{use_python}}'
ln -s %{buildroot}/%{_bindir}/osc
mkdir -p %{buildroot}%{osc_plugin_dir}
mkdir -p %{buildroot}%{_localstatedir}/lib/osc-plugins
install -Dm0644 dist/complete.csh %{buildroot}%{_sysconfdir}/profile.d/osc.csh
%if 0%{?suse_version}
install -Dm0644 dist/ %{buildroot}%{_sysconfdir}/bash_completion.d/
install -Dm0644 dist/ %{buildroot}%{_sysconfdir}/profile.d/
%if 0%{?suse_version} > 1110
install -Dm0755 dist/osc.complete %{buildroot}%{_prefix}/lib/osc/complete
install -Dm0755 dist/osc.complete %{buildroot}%{_libdir}/osc/complete
%if 0%{?rhel_version} || 0%{?centos_version}
install -Dm0555 %{SOURCE1} %{buildroot}%{_sysconfdir}/profile.d/
install -Dm0555 %{SOURCE2} %{buildroot}%{_sbindir}/gnome-keyring-pam-setup

install -m644 %{macros_file} -D %{buildroot}%{_sysconfdir}/rpm/%{macros_file}

%if 0%{?suse_version} >= 1500
cd tests

rm -rf %{buildroot}

%if 0%{?rhel_version} || 0%{?centos_version}

%{_sbindir}/gnome-keyring-pam-setup install
if [ $1 -eq 1 ]; then
  echo "+-----------------------------------------------------------------------------+"
  echo "| This is a new installation of the pam_gnome_keyring package.  You must      |"
  echo "| logout and log back in for the GNOME keyring daemon to be started and the   |"
  echo "| environment to be setup correctly.                                          |"
  echo "+-----------------------------------------------------------------------------+"

if [ $1 -eq 0 ]; then
  %{_sbindir}/gnome-keyring-pam-setup uninstall

%if 0%{?suse_version} >= 1500
%license COPYING
%if %{?centos_version} >= 700 
%config %{_sysconfdir}/profile.d/osc.csh
%if 0%{?suse_version}
%config %{_sysconfdir}/bash_completion.d/
%config %{_sysconfdir}/profile.d/
%config %{_sysconfdir}/rpm/%{macros_file}
%dir %{_localstatedir}/lib/osc-plugins
%if 0%{?suse_version} > 1110
%dir %{osc_plugin_dir}

openSUSE Build Service is sponsored by