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