2013-04-19 10:58:01 +00:00
|
|
|
# The RubyGems root folder.
|
|
|
|
%gem_dir %{_datadir}/gems
|
2013-04-30 12:39:52 +00:00
|
|
|
%gem_archdir %{_libdir}/gems
|
2013-04-19 10:58:01 +00:00
|
|
|
|
|
|
|
# Common gem locations and files.
|
2017-01-09 14:58:21 +00:00
|
|
|
%gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}%{?prerelease}
|
|
|
|
%gem_extdir_mri %{gem_archdir}/%{name}/%{gem_name}-%{version}%{?prerelease}
|
2013-04-19 10:58:01 +00:00
|
|
|
%gem_libdir %{gem_instdir}/lib
|
2017-01-09 14:58:21 +00:00
|
|
|
%gem_cache %{gem_dir}/cache/%{gem_name}-%{version}%{?prerelease}.gem
|
|
|
|
%gem_spec %{gem_dir}/specifications/%{gem_name}-%{version}%{?prerelease}.gemspec
|
|
|
|
%gem_docdir %{gem_dir}/doc/%{gem_name}-%{version}%{?prerelease}
|
2021-06-01 10:02:21 +00:00
|
|
|
%gem_plugin %{gem_dir}/plugins/%{gem_name}_plugin.rb
|
2013-04-19 10:58:01 +00:00
|
|
|
|
2016-10-21 10:36:39 +00:00
|
|
|
|
|
|
|
# %gem_install - Install gem into appropriate directory.
|
|
|
|
#
|
|
|
|
# Usage: %gem_install [options]
|
|
|
|
#
|
|
|
|
# -n <gem_file> Overrides gem file name for installation.
|
|
|
|
# -d <install_dir> Set installation directory.
|
|
|
|
#
|
2013-04-19 10:58:01 +00:00
|
|
|
%gem_install(d:n:) \
|
|
|
|
mkdir -p %{-d*}%{!?-d:.%{gem_dir}} \
|
|
|
|
\
|
2021-07-20 15:38:30 +00:00
|
|
|
CONFIGURE_ARGS="--with-cflags='%{optflags}' --with-cxxflags='%{optflags}' --with-ldflags='%{build_ldflags}' $CONFIGURE_ARGS" \\\
|
2013-04-19 10:58:01 +00:00
|
|
|
gem install \\\
|
|
|
|
-V \\\
|
|
|
|
--local \\\
|
2016-01-05 09:58:10 +00:00
|
|
|
--build-root %{-d*}%{!?-d:.} \\\
|
2013-04-19 10:58:01 +00:00
|
|
|
--force \\\
|
|
|
|
--document=ri,rdoc \\\
|
2017-01-09 14:58:21 +00:00
|
|
|
%{-n*}%{!?-n:%{gem_name}-%{version}%{?prerelease}.gem} \
|
2013-04-19 10:58:01 +00:00
|
|
|
%{nil}
|
2013-04-30 12:43:26 +00:00
|
|
|
|
2016-10-21 10:36:39 +00:00
|
|
|
|
2018-05-03 12:53:28 +00:00
|
|
|
# The 'read' command in %%gemspec_* macros is not essential, but it is usefull
|
|
|
|
# to make the sript appear in build log.
|
2016-10-20 11:55:21 +00:00
|
|
|
|
2016-10-21 10:36:39 +00:00
|
|
|
|
|
|
|
# %gemspec_add_dep - Add dependency into .gemspec.
|
|
|
|
#
|
|
|
|
# Usage: %gemspec_add_dep -g <gem> [options] [requirements]
|
|
|
|
#
|
|
|
|
# Add dependency named <gem> to .gemspec file. The macro adds runtime
|
|
|
|
# dependency by default. The [requirements] argument can be used to specify
|
|
|
|
# the dependency constraints more precisely. It is expected to be valid Ruby
|
|
|
|
# code.
|
|
|
|
#
|
|
|
|
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
|
# -d Add development dependecy.
|
2016-10-20 11:55:21 +00:00
|
|
|
#
|
|
|
|
%gemspec_add_dep(g:s:d) \
|
|
|
|
read -d '' gemspec_add_dep_script << 'EOR' || : \
|
2019-06-25 11:48:27 +00:00
|
|
|
gemspec_file = '%{-s*}%{!?-s:%{_builddir}/%{gem_name}-%{version}%{?prerelease}.gemspec}' \
|
2016-10-20 11:55:21 +00:00
|
|
|
\
|
|
|
|
name = '%{-g*}' \
|
|
|
|
requirements = %{*}%{!?1:nil} \
|
|
|
|
\
|
|
|
|
type = :%{!?-d:runtime}%{?-d:development} \
|
|
|
|
\
|
|
|
|
spec = Gem::Specification.load(gemspec_file) \
|
|
|
|
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
|
\
|
|
|
|
dep = spec.dependencies.detect { |d| d.type == type && d.name == name } \
|
|
|
|
if dep \
|
|
|
|
dep.requirement.concat requirements \
|
|
|
|
else \
|
|
|
|
spec.public_send "add_#{type}_dependency", name, requirements \
|
|
|
|
end \
|
|
|
|
File.write gemspec_file, spec.to_ruby \
|
|
|
|
EOR\
|
|
|
|
echo "$gemspec_add_dep_script" | ruby \
|
|
|
|
unset -v gemspec_add_dep_script \
|
|
|
|
%{nil}
|
|
|
|
|
2016-10-21 10:36:39 +00:00
|
|
|
|
|
|
|
# %gemspec_remove_dep - Remove dependency from .gemspec.
|
|
|
|
#
|
|
|
|
# Usage: %gemspec_remove_dep -g <gem> [options] [requirements]
|
|
|
|
#
|
|
|
|
# Remove dependency named <gem> from .gemspec file. The macro removes runtime
|
|
|
|
# dependency by default. The [requirements] argument can be used to specify
|
|
|
|
# the dependency constraints more precisely. It is expected to be valid Ruby
|
|
|
|
# code. The macro fails if these specific requirements can't be removed.
|
|
|
|
#
|
|
|
|
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
|
# -d Remove development dependecy.
|
2016-10-20 11:55:21 +00:00
|
|
|
#
|
|
|
|
%gemspec_remove_dep(g:s:d) \
|
|
|
|
read -d '' gemspec_remove_dep_script << 'EOR' || : \
|
2019-06-25 11:48:27 +00:00
|
|
|
gemspec_file = '%{-s*}%{!?-s:%{_builddir}/%{gem_name}-%{version}%{?prerelease}.gemspec}' \
|
2016-10-20 11:55:21 +00:00
|
|
|
\
|
|
|
|
name = '%{-g*}' \
|
|
|
|
requirements = %{*}%{!?1:nil} \
|
|
|
|
\
|
|
|
|
type = :%{!?-d:runtime}%{?-d:development} \
|
|
|
|
\
|
|
|
|
spec = Gem::Specification.load(gemspec_file) \
|
|
|
|
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
|
\
|
|
|
|
dep = spec.dependencies.detect { |d| d.type == type && d.name == name } \
|
|
|
|
if dep \
|
|
|
|
if requirements \
|
|
|
|
requirements = Gem::Requirement.create(requirements).requirements \
|
|
|
|
requirements.each do |r| \
|
|
|
|
unless dep.requirement.requirements.reject! { |dependency_requirements| dependency_requirements == r } \
|
|
|
|
abort("Requirement '#{r.first} #{r.last}' was not possible to remove for dependency '#{dep}'!") \
|
|
|
|
end \
|
|
|
|
end \
|
|
|
|
spec.dependencies.delete dep if dep.requirement.requirements.empty? \
|
|
|
|
else \
|
|
|
|
spec.dependencies.delete dep \
|
|
|
|
end \
|
|
|
|
else \
|
|
|
|
abort("Dependency '#{name}' was not found!") \
|
|
|
|
end \
|
|
|
|
File.write gemspec_file, spec.to_ruby \
|
|
|
|
EOR\
|
|
|
|
echo "$gemspec_remove_dep_script" | ruby \
|
|
|
|
unset -v gemspec_remove_dep_script \
|
|
|
|
%{nil}
|
2018-05-03 12:53:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
# %%gemspec_add_file - Add files to various files lists in .gemspec.
|
|
|
|
#
|
|
|
|
# Usage: %%gemspec_add_file [options] <file>
|
|
|
|
#
|
|
|
|
# Add files to .gemspec file. <file> is expected to be valid Ruby code.
|
|
|
|
# Path to file is expected. Does not check real files in any way.
|
|
|
|
# By default, `files` list is edited.
|
|
|
|
#
|
|
|
|
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
|
# -t Edit test_files only.
|
|
|
|
# -r Edit extra_rdoc_files only.
|
|
|
|
#
|
|
|
|
%gemspec_add_file(s:tr) \
|
|
|
|
read -d '' gemspec_add_file_script << 'EOR' || : \
|
2019-06-25 11:48:27 +00:00
|
|
|
gemspec_file = '%{-s*}%{!?-s:%{_builddir}/%{gem_name}-%{version}%{?prerelease}.gemspec}' \
|
2018-05-03 12:53:28 +00:00
|
|
|
\
|
|
|
|
abort("gemspec_add_file: Use only one '-t' or '-r' at a time.") if "%{?-t}%{?-r}" == "-t-r" \
|
|
|
|
\
|
|
|
|
filenames = %{*}%{!?1:nil} \
|
|
|
|
filenames = Array(filenames) \
|
|
|
|
\
|
|
|
|
spec = Gem::Specification.load(gemspec_file) \
|
|
|
|
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
|
\
|
|
|
|
spec.%{?-t:test_}%{?-r:extra_rdoc_}files += filenames \
|
|
|
|
File.write gemspec_file, spec.to_ruby \
|
|
|
|
EOR\
|
|
|
|
echo "$gemspec_add_file_script" | ruby \
|
|
|
|
unset -v gemspec_add_file_script \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
|
|
|
|
# %%gemspec_remove_file - Remove files from various files lists in .gemspec.
|
|
|
|
#
|
|
|
|
# Usage: %%gemspec_remove_file [options] <file>
|
|
|
|
#
|
|
|
|
# Remove files from .gemspec file. <file> is expected to be valid Ruby code.
|
|
|
|
# Path to file is expected. Does not check/remove real files in any way.
|
|
|
|
# By default, `files` list is edited. File has to be removed from `test_files`
|
|
|
|
# first in order to be removable from `files`.
|
|
|
|
#
|
|
|
|
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
|
# -t Edit test_files only.
|
|
|
|
# -r Edit extra_rdoc_files only.
|
|
|
|
#
|
|
|
|
%gemspec_remove_file(s:tr) \
|
|
|
|
read -d '' gemspec_remove_file_script << 'EOR' || : \
|
2019-06-25 11:48:27 +00:00
|
|
|
gemspec_file = '%{-s*}%{!?-s:%{_builddir}/%{gem_name}-%{version}%{?prerelease}.gemspec}' \
|
2018-05-03 12:53:28 +00:00
|
|
|
\
|
|
|
|
abort("gemspec_remove_file: Use only one '-t' or '-r' at a time.") if "%{?-t}%{?-r}" == "-t-r" \
|
|
|
|
\
|
|
|
|
filenames = %{*}%{!?1:nil} \
|
|
|
|
filenames = Array(filenames) \
|
|
|
|
\
|
|
|
|
spec = Gem::Specification.load(gemspec_file) \
|
|
|
|
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
|
\
|
|
|
|
spec.%{?-t:test_}%{?-r:extra_rdoc_}files -= filenames \
|
|
|
|
File.write gemspec_file, spec.to_ruby \
|
|
|
|
EOR\
|
|
|
|
echo "$gemspec_remove_file_script" | ruby \
|
|
|
|
unset -v gemspec_remove_file_script \
|
|
|
|
%{nil}
|