# ---
# ## used by gem2rpm
# :summary: this is a custom summary
# ## used by gem2rpm
# :description: |-
#   this is a custom description
#
#   it can be multiline
# ## used by gem2rpm
# :license: MIT or Ruby
# ## used by gem2rpm and gem_packages
# :version_suffix: '-1.10'
# ## used by gem2rpm and gem_packages
# :disable_docs: true
# ## used by gem2rpm
# :disable_automatic_rdoc_dep: true
# ## used by gem2rpm
:preamble: |-
  %if 0%{?suse_version} == 1500
  %define rb_build_versions  ruby31     ruby27
  %define rb_build_ruby_abis ruby:3.1.0 ruby:2.7.0
  %endif
  BuildRequires:  %{rubygem mini_portile2 >= 2.8}
  BuildRequires:  %{rubygem openssl}
  BuildRequires:  %{rubygem pkg-config}
  BuildRequires:  libxml2-devel >= 2.6.21
  BuildRequires:  libxslt-devel
#   BuildRequires: foobar
#   Requires: foobar
# ## used by gem2rpm
# :patches:
#  no-more-mini_portile.patch: -p0
:sources:
  - rubygem-nokogiri-rpmlintrc
# - foo.desktop
# - bar.desktop
# :gem_install_args: '....'
# ## used by gem2rpm
:pre_install: |-
  %gem_unpack
  perl -p -i.back -e 's/.*mini_portile.*//g' %{mod_full_name}.gemspec
  diff -urN %{mod_full_name}.gemspec{.back,} ||:
  rm -f %{mod_full_name}.gemspec.back

  MINI_PORTILE2_VERSION="2.8.2"

  if grep -q "~> ${MINI_PORTILE2_VERSION}" ext/nokogiri/extconf.rb ; then
    perl -p -i.back -e 's/~> ${MINI_PORTILE2_VERSION}/>= ${MINI_PORTILE2_VERSION}/g' ext/nokogiri/extconf.rb
    diff -urN ext/nokogiri/extconf.rb{.back,} ||:
    rm -f ext/nokogiri/extconf.rb.back
  else
    echo "Check which version of mini_portile2 we need to build nokogiri now"
    exit 1
  fi
  find -type f -print0 | xargs -0 touch -r %{S:0}
  %gem_build
  cd ..
  export NOKOGIRI_USE_SYSTEM_LIBRARIES=1
:post_install: |-
  rm -rvf %{buildroot}%{_libdir}/ruby/gems/*/gems/%{mod_full_name}/ports
#   %if 0%{?use_system_libev}
#   export USE_VENDORED_LIBEV="no"
#   %endif
# ## used by gem2rpm
# :post_install: |-
#   # delete custom files here or do other fancy stuff
#   install -D -m 0644 %{S:1} %{buildroot}%{_bindir}/gem2rpm-opensuse
# ## used by gem2rpm
# :testsuite_command: |-
#   (pushd %{buildroot}%{gem_base}/gems/%{mod_full_name} && rake test)
# ## used by gem2rpm
# :filelist: |-
#   /usr/bin/gem2rpm-opensuse
# ## used by gem2rpm
# :scripts:
#   :post: |-
#     /bin/echo foo
# ## used by gem_packages
# :main:
#   :preamble: |-
#     Requires: util-linux
#     Recommends: pwgen
#   :filelist: |-
#     /usr/bin/gem2rpm-opensuse
# ## used by gem_packages
# :custom:
#   apache:
#     :preamble: |-
#       Requires: .....
#     :filelist: |-
#       /etc/apache2/conf.d/passenger.conf
#     :summary: Custom summary is optional
#     :description: |-
#       Custom description is optional
#
#       bar
#     :post: |-
#       /bin/echo foo
#
