File fai-toolkit.spec of Package fai-toolkit

#
# spec file for package rubygem-fai-toolkit
#
# Copyright (c) 2021 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/
#

%if "%{_vendor}" != "debbuild"
Name:           rubygem-fai-toolkit
%else
Name:           ruby-fai-toolkit
%endif
Version:        2.0.2
Release:        0
%define mod_name fai-toolkit
%define mod_full_name %{mod_name}-%{version}
Provides:       %{mod_name}
BuildRequires:  %{ruby >= 2.5.0}
BuildRequires:  ruby-macros >= 5
BuildRequires:  %{rubygem gem2rpm}
%if "%{_vendor}" != "debbuild"
BuildRequires:  update-alternatives
PreReq:         update-alternatives
%else
# Manual deps needed for debbuild as %%gem_packages does not work with debbuild.
Requires:       %{rubygem optimist}
%endif

# Hint: SUSE requires/recommends are in gem2rpm.yml.

%if 0%{?rhel_version} > 0
BuildRequires: scl-utils-build
BuildRequires: %{scl_prefix_ruby}scldevel
Requires: %scl_require %{scl_ruby}
%else
Requires:       ruby >= 2.3.0
%endif

%if 0%{?rhel_version} > 0
Requires:       squashfs-tools
Requires:       dosfstools
Requires:       xorriso
%endif

Url:            https://git.sr.ht/~smar/fai-toolkit
Source0:        https://rubygems.org/gems/%{mod_full_name}.gem
Source1:        gem2rpm.yml
Summary:        Tools for installing and updating tools with FAI
License:        ISC
Group:          Development/Languages/Ruby

%description
Modern utilities and tools for FAI operations, like creating an nfsroot or an
update medium.

%prep

%build

%install
%if "%{_vendor}" == "debbuild"
# “gem install” for some reaon does not create bindir automatically.
mkdir -p "%{buildroot}%{_bindir}"
%endif

%gem_install \
  --symlink-binaries \
  --doc-files="CHANGELOG.md LICENSE README.md" \
  -f

%if "%{_vendor}" != "debbuild"
%gem_packages
%else
##
## THIS ALL OF FOLLOWING IS FOR DEBBUILD !!
##
## debbuild does not support %%expand, which is required for %%gem_packages.

#ln  -s %%{_bindir}/ft2.5 %%{buildroot}%%{_bindir}/ft

%package -n %{name}-doc
Summary:        RDoc documentation for fai-toolkit
Group:          Development/Languages/Ruby
Requires:       %{name} = %{version}

%description -n %{name}-doc
Documentation generated at gem installation time.
Usually in RDoc and RI formats.


%post
/usr/bin/update-alternatives --install \
    /usr/bin/ft                      ft /usr/bin/ft2.5 $(echo %%{version} | sed 's/\.//g')

%preun
if [ ! -f %{_bindir}/%{name} ] ; then
    /usr/bin/update-alternatives --remove ft /usr/bin/ft2.5-%{version}
fi

%files
%defattr(-,root,root,-)
#/usr/share/doc/packages/ruby2.5-rubygem-%%{name}
/usr/bin/ft2.5
%ghost /usr/bin/ft
%ghost /etc/alternatives/ft
%ghost /etc/alternatives/ft2.5
# cache file
/var/lib/gems/2.5.0/cache/%{mod_full_name}.gem
/var/lib/gems/2.5.0/gems/%{mod_full_name}
/var/lib/gems/2.5.0/build_info
/var/lib/gems/2.5.0/specifications/%{mod_full_name}.gemspec

%files -n %{name}-doc
%defattr(-,root,root,-)
#%%doc /var/lib/gems/2.5.0/doc/%%{name}-%%{version}
## End of debbuild subpackage definition.
%endif

%changelog