File SUSEConnect.spec of Package SUSEConnect.1259

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


Name:           SUSEConnect
Version:        0.2.14.42
Release:        0
%define mod_name suse-connect
%define mod_full_name %{mod_name}-%{version}
# MANUAL
%define rb_build_versions %{rb_default_ruby}
Requires:       ca-certificates-mozilla
Requires:       coreutils
Requires:       hwinfo
Requires:       net-tools
Requires:       util-linux
Requires:       zypper
Requires:       rubygem(%{rb_default_ruby_abi}:%{mod_name})
Conflicts:      suseRegister
%ifarch x86_64
PreReq:         dmidecode
%endif
# /MANUAL
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  %{ruby >= 2.0}
BuildRequires:  %{rubygem gem2rpm}
BuildRequires:  ruby-macros >= 5
BuildRequires:  update-alternatives
Url:            https://github.com/SUSE/connect
Source:         http://rubygems.org/gems/%{mod_full_name}.gem
Source1:        suse-connect-%{version}.gem
Source2:        %{name}.5.gz
Source3:        %{name}.8.gz
Source4:        %{name}.example
Source5:        gem2rpm.yml
# MANUAL
Patch0:         url-implies-writeconfig.diff
# /MANUAL
Summary:        SUSE Connect utility to register a system with the SUSE Customer
License:        LGPL-2.1
Group:          Development/Languages/Ruby
PreReq:         update-alternatives

%description
This package provides a command line tool and rubygem library for connecting a
client system to the SUSE Customer Center. It will connect the system to your
product subscriptions and enable the product repositories/services locally.

%prep
%gem_unpack
%patch0 -p1
%gem_build

%build

%install
%gem_install \
  --no-rdoc --no-ri \
  --symlink-binaries \
  --doc-files="LICENSE README.md" \
  -f
# MANUAL
install -D -m 644 %_sourcedir/SUSEConnect.5.gz %{buildroot}%_mandir/man5/SUSEConnect.5.gz
install -D -m 644 %_sourcedir/SUSEConnect.8.gz %{buildroot}%_mandir/man8/SUSEConnect.8.gz
install -D -m 644 %_sourcedir/SUSEConnect.example %{buildroot}%_sysconfdir/SUSEConnect.example

ln -s SUSEConnect.8.gz %{buildroot}%_mandir/man8/SUSEConnect-%{version}.8.gz
mkdir %{buildroot}%{_sbindir}
ln -s %{_bindir}/SUSEConnect %{buildroot}%{_sbindir}/SUSEConnect
# /MANUAL

%files
%defattr(-,root,root,-)
%_mandir/man5/SUSEConnect*
%_mandir/man8/SUSEConnect*
%{_sbindir}/SUSEConnect
%_sysconfdir/SUSEConnect.example

%post
if [ -s /etc/zypp/credentials.d/NCCcredentials ] && [ ! -e /etc/zypp/credentials.d/SCCcredentials ]; then
    echo "Imported NCC system credentials to /etc/zypp/credentials.d/SCCcredentials"
    cp /etc/zypp/credentials.d/NCCcredentials /etc/zypp/credentials.d/SCCcredentials
fi

if [ -s /etc/suseRegister.conf ]; then
    reg_server=$(sed -n "s/^[[:space:]]*url[[:space:]]*=[[:space:]]*\(https\?:\/\/[^\/]*\).*/\1/p" /etc/suseRegister.conf)
    # if we have a custom regserver and no SCC config yet, write it
    if [ -n "$reg_server" ] && [ "$reg_server" != "https://secure-www.novell.com" ] && [ ! -e /etc/SUSEConnect ]; then
        echo "Imported /etc/suseRegister.conf registration server url to /etc/SUSEConnect"
        echo "url: $reg_server" > /etc/SUSEConnect
    fi
fi

%gem_packages

%changelog
openSUSE Build Service is sponsored by