|
|
121925 |
# The RubyGems root folder.
|
|
|
121925 |
%gem_dir %{_datadir}/gems
|
|
|
121925 |
%gem_archdir %{_libdir}/gems
|
|
|
121925 |
|
|
|
121925 |
# Common gem locations and files.
|
|
|
121925 |
%gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}%{?prerelease}
|
|
|
121925 |
%gem_extdir_mri %{gem_archdir}/%{name}/%{gem_name}-%{version}%{?prerelease}
|
|
|
121925 |
%gem_libdir %{gem_instdir}/lib
|
|
|
121925 |
%gem_cache %{gem_dir}/cache/%{gem_name}-%{version}%{?prerelease}.gem
|
|
|
121925 |
%gem_spec %{gem_dir}/specifications/%{gem_name}-%{version}%{?prerelease}.gemspec
|
|
|
121925 |
%gem_docdir %{gem_dir}/doc/%{gem_name}-%{version}%{?prerelease}
|
|
|
121925 |
|
|
|
121925 |
|
|
|
121925 |
# %gem_install - Install gem into appropriate directory.
|
|
|
121925 |
#
|
|
|
121925 |
# Usage: %gem_install [options]
|
|
|
121925 |
#
|
|
|
121925 |
# -n <gem_file> Overrides gem file name for installation.
|
|
|
121925 |
# -d <install_dir> Set installation directory.
|
|
|
121925 |
#
|
|
|
121925 |
%gem_install(d:n:) \
|
|
|
121925 |
mkdir -p %{-d*}%{!?-d:.%{gem_dir}} \
|
|
|
121925 |
\
|
|
|
121925 |
CONFIGURE_ARGS="--with-cflags='%{optflags}' $CONFIGURE_ARGS" \\\
|
|
|
121925 |
gem install \\\
|
|
|
121925 |
-V \\\
|
|
|
121925 |
--local \\\
|
|
|
121925 |
--install-dir %{-d*}%{!?-d:.%{gem_dir}} \\\
|
|
|
121925 |
--bindir .%{_bindir} \\\
|
|
|
121925 |
--force \\\
|
|
|
121925 |
--document=ri,rdoc \\\
|
|
|
121925 |
%{-n*}%{!?-n:%{gem_name}-%{version}%{?prerelease}.gem} \
|
|
|
121925 |
%{nil}
|
|
|
121925 |
|
|
|
121925 |
|
|
|
121925 |
# For rubygems packages we want to filter out any provides caused by private
|
|
|
121925 |
# libs in %%{gem_archdir}.
|
|
|
121925 |
#
|
|
|
121925 |
# Note that this must be invoked in the spec file, preferably as
|
|
|
121925 |
# "%{?rubygems_default_filter}", before any %description block.
|
|
|
121925 |
%rubygems_default_filter %{expand: \
|
|
|
121925 |
%global __provides_exclude_from %{?__provides_exclude_from:%{__provides_exclude_from}|}^%{gem_extdir_mri}/.*\\\\.so$ \
|
|
|
121925 |
}
|
|
|
121925 |
|
|
|
121925 |
|
|
|
121925 |
# The 'read' command in %%gemspec_* macros is not essential, but it is usefull
|
|
|
121925 |
# to make the sript appear in build log.
|
|
|
121925 |
|
|
|
121925 |
|
|
|
121925 |
# %gemspec_add_dep - Add dependency into .gemspec.
|
|
|
121925 |
#
|
|
|
121925 |
# Usage: %gemspec_add_dep -g <gem> [options] [requirements]
|
|
|
121925 |
#
|
|
|
121925 |
# Add dependency named <gem> to .gemspec file. The macro adds runtime
|
|
|
121925 |
# dependency by default. The [requirements] argument can be used to specify
|
|
|
121925 |
# the dependency constraints more precisely. It is expected to be valid Ruby
|
|
|
121925 |
# code.
|
|
|
121925 |
#
|
|
|
121925 |
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
121925 |
# -d Add development dependecy.
|
|
|
121925 |
#
|
|
|
121925 |
%gemspec_add_dep(g:s:d) \
|
|
|
121925 |
read -d '' gemspec_add_dep_script << 'EOR' || : \
|
|
|
121925 |
gemspec_file = '%{-s*}%{!?-s:./%{gem_name}.gemspec}' \
|
|
|
121925 |
\
|
|
|
121925 |
name = '%{-g*}' \
|
|
|
121925 |
requirements = %{*}%{!?1:nil} \
|
|
|
121925 |
\
|
|
|
121925 |
type = :%{!?-d:runtime}%{?-d:development} \
|
|
|
121925 |
\
|
|
|
121925 |
spec = Gem::Specification.load(gemspec_file) \
|
|
|
121925 |
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
121925 |
\
|
|
|
121925 |
dep = spec.dependencies.detect { |d| d.type == type && d.name == name } \
|
|
|
121925 |
if dep \
|
|
|
121925 |
dep.requirement.concat requirements \
|
|
|
121925 |
else \
|
|
|
121925 |
spec.public_send "add_#{type}_dependency", name, requirements \
|
|
|
121925 |
end \
|
|
|
121925 |
File.write gemspec_file, spec.to_ruby \
|
|
|
121925 |
EOR\
|
|
|
121925 |
echo "$gemspec_add_dep_script" | ruby \
|
|
|
121925 |
unset -v gemspec_add_dep_script \
|
|
|
121925 |
%{nil}
|
|
|
121925 |
|
|
|
121925 |
|
|
|
121925 |
# %gemspec_remove_dep - Remove dependency from .gemspec.
|
|
|
121925 |
#
|
|
|
121925 |
# Usage: %gemspec_remove_dep -g <gem> [options] [requirements]
|
|
|
121925 |
#
|
|
|
121925 |
# Remove dependency named <gem> from .gemspec file. The macro removes runtime
|
|
|
121925 |
# dependency by default. The [requirements] argument can be used to specify
|
|
|
121925 |
# the dependency constraints more precisely. It is expected to be valid Ruby
|
|
|
121925 |
# code. The macro fails if these specific requirements can't be removed.
|
|
|
121925 |
#
|
|
|
121925 |
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
121925 |
# -d Remove development dependecy.
|
|
|
121925 |
#
|
|
|
121925 |
%gemspec_remove_dep(g:s:d) \
|
|
|
121925 |
read -d '' gemspec_remove_dep_script << 'EOR' || : \
|
|
|
121925 |
gemspec_file = '%{-s*}%{!?-s:./%{gem_name}.gemspec}' \
|
|
|
121925 |
\
|
|
|
121925 |
name = '%{-g*}' \
|
|
|
121925 |
requirements = %{*}%{!?1:nil} \
|
|
|
121925 |
\
|
|
|
121925 |
type = :%{!?-d:runtime}%{?-d:development} \
|
|
|
121925 |
\
|
|
|
121925 |
spec = Gem::Specification.load(gemspec_file) \
|
|
|
121925 |
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
121925 |
\
|
|
|
121925 |
dep = spec.dependencies.detect { |d| d.type == type && d.name == name } \
|
|
|
121925 |
if dep \
|
|
|
121925 |
if requirements \
|
|
|
121925 |
requirements = Gem::Requirement.create(requirements).requirements \
|
|
|
121925 |
requirements.each do |r| \
|
|
|
121925 |
unless dep.requirement.requirements.reject! { |dependency_requirements| dependency_requirements == r } \
|
|
|
121925 |
abort("Requirement '#{r.first} #{r.last}' was not possible to remove for dependency '#{dep}'!") \
|
|
|
121925 |
end \
|
|
|
121925 |
end \
|
|
|
121925 |
spec.dependencies.delete dep if dep.requirement.requirements.empty? \
|
|
|
121925 |
else \
|
|
|
121925 |
spec.dependencies.delete dep \
|
|
|
121925 |
end \
|
|
|
121925 |
else \
|
|
|
121925 |
abort("Dependency '#{name}' was not found!") \
|
|
|
121925 |
end \
|
|
|
121925 |
File.write gemspec_file, spec.to_ruby \
|
|
|
121925 |
EOR\
|
|
|
121925 |
echo "$gemspec_remove_dep_script" | ruby \
|
|
|
121925 |
unset -v gemspec_remove_dep_script \
|
|
|
121925 |
%{nil}
|
|
|
121925 |
|
|
|
121925 |
|
|
|
121925 |
# %%gemspec_add_file - Add files to various files lists in .gemspec.
|
|
|
121925 |
#
|
|
|
121925 |
# Usage: %%gemspec_add_file [options] <file>
|
|
|
121925 |
#
|
|
|
121925 |
# Add files to .gemspec file. <file> is expected to be valid Ruby code.
|
|
|
121925 |
# Path to file is expected. Does not check real files in any way.
|
|
|
121925 |
# By default, `files` list is edited.
|
|
|
121925 |
#
|
|
|
121925 |
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
121925 |
# -t Edit test_files only.
|
|
|
121925 |
# -r Edit extra_rdoc_files only.
|
|
|
121925 |
#
|
|
|
121925 |
%gemspec_add_file(s:tr) \
|
|
|
121925 |
read -d '' gemspec_add_file_script << 'EOR' || : \
|
|
|
121925 |
gemspec_file = '%{-s*}%{!?-s:%{_builddir}/%{gem_name}-%{version}.gemspec}' \
|
|
|
121925 |
\
|
|
|
121925 |
abort("gemspec_add_file: Use only one '-t' or '-r' at a time.") if "%{?-t}%{?-r}" == "-t-r" \
|
|
|
121925 |
\
|
|
|
121925 |
filenames = %{*}%{!?1:nil} \
|
|
|
121925 |
filenames = Array(filenames) \
|
|
|
121925 |
\
|
|
|
121925 |
spec = Gem::Specification.load(gemspec_file) \
|
|
|
121925 |
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
121925 |
\
|
|
|
121925 |
spec.%{?-t:test_}%{?-r:extra_rdoc_}files += filenames \
|
|
|
121925 |
File.write gemspec_file, spec.to_ruby \
|
|
|
121925 |
EOR\
|
|
|
121925 |
echo "$gemspec_add_file_script" | ruby \
|
|
|
121925 |
unset -v gemspec_add_file_script \
|
|
|
121925 |
%{nil}
|
|
|
121925 |
|
|
|
121925 |
|
|
|
121925 |
# %%gemspec_remove_file - Remove files from various files lists in .gemspec.
|
|
|
121925 |
#
|
|
|
121925 |
# Usage: %%gemspec_remove_file [options] <file>
|
|
|
121925 |
#
|
|
|
121925 |
# Remove files from .gemspec file. <file> is expected to be valid Ruby code.
|
|
|
121925 |
# Path to file is expected. Does not check/remove real files in any way.
|
|
|
121925 |
# By default, `files` list is edited. File has to be removed from `test_files`
|
|
|
121925 |
# first in order to be removable from `files`.
|
|
|
121925 |
#
|
|
|
121925 |
# -s <gemspec_file> Overrides the default .gemspec location.
|
|
|
121925 |
# -t Edit test_files only.
|
|
|
121925 |
# -r Edit extra_rdoc_files only.
|
|
|
121925 |
#
|
|
|
121925 |
%gemspec_remove_file(s:tr) \
|
|
|
121925 |
read -d '' gemspec_remove_file_script << 'EOR' || : \
|
|
|
121925 |
gemspec_file = '%{-s*}%{!?-s:%{_builddir}/%{gem_name}-%{version}.gemspec}' \
|
|
|
121925 |
\
|
|
|
121925 |
abort("gemspec_remove_file: Use only one '-t' or '-r' at a time.") if "%{?-t}%{?-r}" == "-t-r" \
|
|
|
121925 |
\
|
|
|
121925 |
filenames = %{*}%{!?1:nil} \
|
|
|
121925 |
filenames = Array(filenames) \
|
|
|
121925 |
\
|
|
|
121925 |
spec = Gem::Specification.load(gemspec_file) \
|
|
|
121925 |
abort("#{gemspec_file} is not accessible.") unless spec \
|
|
|
121925 |
\
|
|
|
121925 |
spec.%{?-t:test_}%{?-r:extra_rdoc_}files -= filenames \
|
|
|
121925 |
File.write gemspec_file, spec.to_ruby \
|
|
|
121925 |
EOR\
|
|
|
121925 |
echo "$gemspec_remove_file_script" | ruby \
|
|
|
121925 |
unset -v gemspec_remove_file_script \
|
|
|
121925 |
%{nil}
|