File google-compute-engine.spec of Package google-compute-engine.5968

#
# spec file for package google-compute-engine
#
# 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/
#


%define setup_version 2.7.2

Name:           google-compute-engine
Version:        20171129
Release:        0
Summary:        GCE Instance Initialization
License:        Apache-2.0
Group:          System/Daemons
Url:            https://github.com/GoogleCloudPlatform/compute-image-packages
Source0:        compute-image-packages-%{version}.tar.gz
Source1:        google-accounts-daemon.suse
Source2:        google-clock-skew-daemon.suse
Source3:        google-instance-setup.suse
Source4:        google-ip-forwarding-daemon.suse
Source5:        google-shutdown-scripts.suse
Source6:        google-startup-scripts.suse
Source7:        google-compute-engine-rpmlintrc
Source8:        baselibs.conf
Patch1:         gcei-hide-py-deps.patch
Patch2:         gcei-scripts-after-reg.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Google Compute Engine instance code.

%package init
Summary:        GCE Instance Initialization
Group:          System/Daemons
Requires:       google-compute-engine-oslogin == %{version}
%if 0%{?suse_version} && 0%{?suse_version} > 1315
Requires:       python3-setuptools
%else
Requires:       python-setuptools
%endif
%if 0%{?suse_version} > 1140
Recommends:     google-cloud-sdk
Requires:       systemd
%endif
%{?systemd_requires}
%if 0%{?suse_version} < 1140
Requires:       insserv
Requires:       sysvinit
%endif
%if 0%{?suse_version} && 0%{?suse_version} > 1315
BuildRequires:  python3-setuptools
%else
BuildRequires:  python-setuptools
%endif
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif
%if 0%{?suse_version} && 0%{?suse_version} <= 1315
# These packages were not released in SLE 15 and later, thus no conflict needed
Conflicts:      google-startup-scripts
Conflicts:      google-daemon
Conflicts:      gcimagebundle
%endif

%description init
Initialization code for Google Compute Engine instances.

%package oslogin
Summary:        OS Login Functionality for Google Compute Engine
Group:          Hardware

Requires:       pam
Requires(post): openssh
Requires(post): glibc
BuildRequires:  gcc-c++
BuildRequires:  libcurl-devel
BuildRequires:  libjson-c-devel
BuildRequires:  make
BuildRequires:  pam-devel

%description oslogin
Libraries and scripts  to enable OS Login functionality for
Google Compute Engine. Modifies sshd, nsswitch, and sshd_pam configurations.


%prep
%setup -q -n compute-image-packages-%{version}
%patch1
%patch2
find -name "*.py" | xargs sed -i 'sm#!/usr/bin/pythonmm'

%build
%if 0%{?suse_version} && 0%{?suse_version} > 1315
python3 setup.py build
%else
python setup.py build
%endif
pushd google_compute_engine_oslogin
make %{?_smp_mflags} LIBS="-lcurl -ljson-c"
popd

%install
%if 0%{?suse_version} && 0%{?suse_version} > 1315
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
%else
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
%endif
mkdir -p %{buildroot}%{_sbindir}
# Init
%if 0%{?suse_version} > 1140
mkdir -p %{buildroot}%{_unitdir}
cp google_compute_engine_init/systemd/*.service %{buildroot}%{_unitdir}
for srv_name in %{buildroot}%{_unitdir}/*.service; do rc_name=$(basename -s '.service' $srv_name); ln -s service %{buildroot}%{_sbindir}/rc$rc_name; done
%else
mkdir -p %{buildroot}%{_initddir}
cp %{SOURCE1} %{buildroot}%{_initddir}/google-accounts-daemon
cp %{SOURCE2} %{buildroot}%{_initddir}/google-clock-skew-daemon
cp %{SOURCE3} %{buildroot}%{_initddir}/google-instance-setup
cp %{SOURCE4} %{buildroot}%{_initddir}/google-ip-forwarding-daemon
cp %{SOURCE5} %{buildroot}%{_initddir}/google-shutdown-scripts
cp %{SOURCE6} %{buildroot}%{_initddir}/google-startup-scripts
for srv_name in %{buildroot}%{_initddir}/*; do rc_name=$(basename $srv_name); ln -s %{_initddir}/$rc_name %{buildroot}%{_sbindir}/rc$rc_name; done
%endif
# Sysconfig
mkdir -p %{buildroot}%{_sysconfdir}/sysctl.d
cp google_config/sysctl/11-gce-network-security.conf %{buildroot}%{_sysconfdir}/sysctl.d
# udev
%if 0%{?suse_version} < 1230
mkdir -p %{buildroot}/lib/udev/rules.d
cp google_config/udev/* %{buildroot}/lib/udev/rules.d
%else
mkdir -p %{buildroot}/usr/lib/udev/rules.d
cp google_config/udev/* %{buildroot}/usr/lib/udev/rules.d
%endif
# syslog
mkdir %{buildroot}/%{_sysconfdir}/rsyslog.d
cp google_config/rsyslog/* %{buildroot}/%{_sysconfdir}/rsyslog.d
# oslogin
pushd google_compute_engine_oslogin
make install DESTDIR=%{buildroot} NSS_INSTALL_PATH=%{_lib} PAM_INSTALL_PATH=%{_lib}/security
popd

%pre
%if 0%{?suse_version} > 1140
    %service_add_pre google-accounts-daemon.service google-clock-skew-daemon.service google-instance-setup.service google-ip-forwarding-daemon.service google-shutdown-scripts.service google-startup-scripts.service
%endif

%post
%if 0%{?suse_version} > 1140
    %service_add_post google-accounts-daemon.service google-clock-skew-daemon.service google-instance-setup.service google-ip-forwarding-daemon.service google-shutdown-scripts.service google-startup-scripts.service
%else
    %fillup_and_insserv -fy google-accounts-daemon
    %fillup_and_insserv -fy google-clock-skew-daemon
    %fillup_and_insserv -fy google-instance-setup
    %fillup_and_insserv -fy google-shutdown-scripts
    %fillup_and_insserv -fy google-startup-scripts
%endif

%post oslogin
/sbin/ldconfig

%preun
%if 0%{?suse_version} > 1140
    %service_del_preun google-accounts-daemon.service google-clock-skew-daemon.service google-instance-setup.service google-ip-forwarding-daemon.service google-shutdown-scripts.service google-startup-scripts.service
%else
    %stop_on_removal google-accounts-daemon
    %stop_on_removal google-clock-skew-daemon
    %stop_on_removal google-ip-forwarding-daemon
%endif

%postun
%restart_on_update
%if 0%{?suse_version} > 1140
    %service_del_postun google-accounts-daemon.service google-clock-skew-daemon.service google-instance-setup.service google-ip-forwarding-daemon.service google-shutdown-scripts.service google-startup-scripts.service
%else
    %insserv_cleanup
%endif

%postun oslogin
/sbin/ldconfig

%files init
%defattr(0644,root,root,0755)
%doc CONTRIB.md LICENSE README.md
%if 0%{?suse_version} && 0%{?suse_version} > 1315
%dir %{python3_sitelib}/google_compute_engine
%dir %{python3_sitelib}/google_compute_engine-%{setup_version}-py%{py3_ver}.egg-info
%else
%dir %{python_sitelib}/google_compute_engine
%dir %{python_sitelib}/google_compute_engine-%{setup_version}-py%{py_ver}.egg-info
%endif
%exclude %{_bindir}/google_oslogin_control
%exclude %{_bindir}/google_authorized_keys
%attr(0755,root,root) %{_bindir}/*
%if 0%{?suse_version} && 0%{?suse_version} > 1315
%{_sbindir}/*
%else
%attr(0755,root,root) %{_sbindir}/*
%endif
%if 0%{?suse_version} && 0%{?suse_version} > 1315
%{python3_sitelib}/google_compute_engine/*
%else
%{python_sitelib}/google_compute_engine/*
%endif
%if 0%{?suse_version} && 0%{?suse_version} > 1315
%{python3_sitelib}/google_compute_engine-%{setup_version}-py%{py3_ver}.egg-info/*
%else
%{python_sitelib}/google_compute_engine-%{setup_version}-py%{py_ver}.egg-info/*
%endif
%if 0%{?suse_version} > 1140
%{_unitdir}/*.service
%else
%attr(0755,root,root) %{_initddir}/*
%endif
%config %{_sysconfdir}/sysctl.d/*
%if 0%{?suse_version} < 1230
%dir %{_sysconfdir}/sysctl.d
%dir /lib/udev
%dir /lib/udev/rules.d
/lib/udev/rules.d/*
%else
%dir /usr/lib/udev
%dir /usr/lib/udev/rules.d
/usr/lib/udev/rules.d/*
%endif
%dir %{_sysconfdir}/rsyslog.d
%config %{_sysconfdir}/rsyslog.d/*

%files oslogin
%defattr(0644,root,root,0755)
%attr(0755,root,root) %{_bindir}/google_oslogin_control
%attr(0755,root,root) %{_bindir}/google_authorized_keys
/%{_lib}/*
%if 0%{?suse_version} > 1140
%exclude /%{_lib}/udev*
%endif

%changelog
openSUSE Build Service is sponsored by