[software-collections-guide: 1/17] Add Extending the ruby193 and ruby200 SCLs

Petr Kovář pmkovar at fedoraproject.org
Fri Jul 11 16:08:15 UTC 2014


commit 20c7248d0f42937bb20adc3e8f831c4f13758400
Author: Petr Kovar <pkovar at redhat.com>
Date:   Mon Apr 28 21:53:21 2014 +0200

    Add Extending the ruby193 and ruby200 SCLs

 en-US/Extending_Red_Hat_Software_Collections.xml |  271 +++++++++++++++++++++-
 1 files changed, 270 insertions(+), 1 deletions(-)
---
diff --git a/en-US/Extending_Red_Hat_Software_Collections.xml b/en-US/Extending_Red_Hat_Software_Collections.xml
index c02ba0e..6048fc1 100644
--- a/en-US/Extending_Red_Hat_Software_Collections.xml
+++ b/en-US/Extending_Red_Hat_Software_Collections.xml
@@ -28,7 +28,7 @@
           This expands to, for example, <package>python27-scldevel</package>.
         </para>
         <para>
-          The <package>python27-scldevel</package> package ships two important macros, <code>%scl_python</code> and <code>%scl_prefix_python</code>. Note that these macros are defined at the top of the spec file. The definitions are not required, they only provide a hint that the vt191 &DSCL; has been designed to be built on top of the python27 &DSCL;. They also serve as a fallback value.
+          The <package>python27-scldevel</package> package ships two important macros, <code>%scl_python</code> and <code>%scl_prefix_python</code>. Note that these macros are defined at the top of the spec file. Although the definitions are not required, they provide a visual hint that the vt191 &DSCL; has been designed to be built on top of the python27 &DSCL;. They also serve as a fallback value.
         </para>
       </listitem>
       <listitem>
@@ -284,4 +284,273 @@ Smart replacement for plain tuple used in __version__
     </procedure>
     </section>
   </section>
+  <section id="sect-Extending_the_ruby193_and_ruby200_Software_Collections">
+    <title>Extending the ruby193 and ruby200 &DSCL;s</title>
+    <para>In Red Hat Software Collection 1.1, it is possible to extend the ruby193 and ruby200 &DSCL;s by adding dependent packages. The Ruby on Rails 4.0 (ror40) &DSCL;, which is built on top of Ruby 2.0.0 provided by the ruby200 &DSCL;, is one example of such an extension.</para>
+    <para>This section provides detailed information about the <package>ror40</package> metapackage and the <package>ror40-rubygem-bcrypt-ruby</package> package, which are both part of the ruby200 &DSCL;.</para>
+    <section id="sect-The_ror40_Software_Collection">
+      <title>The ror40 Software Collection</title>
+    <para>This section contains a commented example of the Ruby on Rails 4.0 metapackage for the ror40 &DSCL;. The ror40 &DSCL; depends on the ror200 &DSCL;.</para>
+    <para>Note the following in the ror40 &DSCL; spec file example:</para>
+    <itemizedlist>
+      <listitem>
+        <para>The ror40 &DSCL; spec file has the following build dependencies set:</para>
+        <programlisting language="RPM Spec">BuildRequires: %{scl_prefix_ruby}scldevel
+BuildRequires: %{scl_prefix_ruby}rubygems-devel</programlisting>
+    <para>This expands to, for example, <package>ruby200-scldevel</package> and <package>ruby200-rubygems-devel</package>.</para>
+    <para>The <package>ruby200-scldevel</package> package contains two important macros, <code>%scl_ruby</code> and <code>%scl_prefix_ruby</code>. The <package>ruby200-scldevel</package> package should be available in the build root. It specifies which of the available Ruby &DSCL;s you want to use. You can also replace it with the <package>ruby193-scldevel</package> package.</para>
+    <para>Note that the <code>%scl_ruby</code> and <code>%scl_prefix_ruby</code> macros are also defined at the top of the spec file. Although the definitions are not required, they provide a visual hint that the ror40 &DSCL; has been designed to be built on top of the ruby200 &DSCL;. They also serve as a fallback value.</para>
+    </listitem>
+    <listitem>
+      <para>The <package>ror40-runtime</package> subpackage must depend on the <package>runtime</package> subpackage of the &DSCL; it depends on. This dependency is specified as follows:</para>
+      <programlisting language="RPM Spec">%package runtime
+Requires: %{scl_prefix_ruby}runtime</programlisting>
+      <para>This expands to ruby200-runtime in the case of the ruby200 &DSCL;, and to <package>ruby193-runtime</package> in the case when the package is built against the ruby193 &DSCL;.</para>
+    </listitem>
+    <listitem>
+      <para>The <package>ror40-build</package> subpackage must depend on the <package>scldevel</package> subpackage of the &DSCL; it depends on. This is to ensure that all other packages of this &DSCL; will have the same macros defined, thus it is built against the same Ruby version.</para>
+      <programlisting language="RPM Spec">%package build
+Requires: %{scl_prefix_ruby}scldevel</programlisting>
+      <para>In the case of the ruby200 &DSCL;, this expands to <package>ruby200-scldevel</package>.</para>
+    </listitem>
+    <listitem>
+      <para>The <filename>enable</filename> scriptlet for the ror40 &DSCL; contains the following line:</para>
+      <programlisting language="RPM Spec">. scl_source enable %{scl_ruby}</programlisting>
+      <para>This makes the Ruby &DSCL; start implicitly when the ror40 &DSCL; is started so that the user can only type <command>scl enable ror40 <replaceable>command</replaceable></command> instead of <command>scl enable ruby200 ror40 <replaceable>command</replaceable></command> to run <replaceable>command</replaceable> in the &DSCL; environment.</para>
+      </listitem>
+      <listitem>
+        <para>The <package>ror40-scldevel</package> package is provided so that it is available in case you need it to build a &DSCL; which extends the ror40 &DSCL;. The package provides the <code>%{scl_ror}</code> and <code>%{scl_prefix_ror}</code> macros, which can be used to extend the ror40 &DSCL;.</para>
+      </listitem>
+      <listitem>
+        <para>Because the ror40 &DSCL;'s gems are installed in a separate root directory structure, you need to ensure that the correct ownership for the rubygems directories is set. This is done by using a snippet to generate a file list <package>rubygems_filesystem.list</package>.
+</para>
+      </listitem>
+      <listitem>
+        <para>You are advised to set the <package>runtime</package> package to own all directories which would, if located in the root file system, be owned by another package. One example of such directories in the case of the ror40 &DSCL; is the Rubygem directory structure<!--, but it might be pkgconfig directories, etc-->.</para>
+      </listitem>
+    </itemizedlist>
+    <programlisting language="RPM Spec"><![CDATA[%global scl_name_base ror
+%global scl_name_version 40
+
+%global scl %{scl_name_base}%{scl_name_version}
+%scl_package %scl
+
+# Fallback to ruby200. ruby200-scldevel is unlikely to be available in
+# the build root.
+%{!?scl_ruby:%global scl_ruby ruby200}
+%{!?scl_prefix_ruby:%global scl_prefix_ruby %{scl_ruby}-}
+
+Summary: Package that installs %scl
+Name: %scl_name
+Version: 1.1
+Release: 3%{?dist}
+License: GPLv2+
+]]><!--# TODO: This should be removed as soon as scl-utils automatically generates
+# dependencies on scl -runtime (rhbz#1054711).--><![CDATA[
+BuildRequires: help2man
+BuildRequires: scl-utils-build
+BuildRequires: %{scl_prefix_ruby}scldevel
+BuildRequires: %{scl_prefix_ruby}rubygems-devel
+
+%description
+This is the main package for %scl Software Collection.
+
+%package runtime
+Summary: Package that handles %scl Software Collection.
+Requires: scl-utils
+Requires: %{scl_prefix_ruby}runtime
+
+%description runtime
+Package shipping essential scripts to work with %scl Software Collection.
+
+%package build
+Summary: Package shipping basic build configuration
+Requires: scl-utils-build
+Requires: %{scl_runtime}
+Requires: %{scl_prefix_ruby}scldevel
+
+%description build
+Package shipping essential configuration macros to build %scl Software Collection.
+
+%package scldevel
+Summary: Package shipping development files for %scl
+
+%description scldevel
+Package shipping development files, especially usefull for development of
+packages depending on %scl Software Collection.
+
+%prep
+%setup -T -c
+
+%install
+%scl_install
+
+cat >> %{buildroot}%{_scl_scripts}/enable << EOF
+export PATH=%{_bindir}\${PATH:+:\${PATH}}
+export LD_LIBRARY_PATH=%{_libdir}\${LD_LIBRARY_PATH:+:\${LD_LIBRARY_PATH}}
+export MANPATH=%{_mandir}:\${MANPATH}
+export PKG_CONFIG_PATH=%{_libdir}/pkgconfig\${PKG_CONFIG_PATH:+:\${PKG_CONFIG_PATH}}
+export GEM_PATH=%{gem_dir}:\${GEM_PATH:+\${GEM_PATH}}\${GEM_PATH:-\`scl enable %{scl_ruby} -- ruby -e "print Gem.path.join(':')"\`}
+
+. scl_source enable %{scl_ruby}
+EOF
+
+cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel << EOF
+%%scl_%{scl_name_base} %{scl}
+%%scl_prefix_%{scl_name_base} %{scl_prefix}
+EOF
+
+
+scl enable %{scl_ruby} - << \EOF
+# Fake ror40 Software Collection environment.
+GEM_PATH=%{gem_dir}:${GEM_PATH:+${GEM_PATH}}${GEM_PATH:-`ruby -e "print Gem.path.join(':')"`} \
+X_SCLS=ror40 \
+ruby -rfileutils > rubygems_filesystem.list << \EOR
+  # Create the RubyGems file system.
+  Gem.ensure_gem_subdirectories '%{buildroot}%{gem_dir}'
+  FileUtils.mkdir_p File.join '%{buildroot}', Gem.default_ext_dir_for('%{gem_dir}')
+
+  # Output the relevant directories.
+  Gem.default_dirs[:%{scl}_system].each { |k, p| puts p }
+EOR
+EOF
+
+%files
+
+%files runtime -f rubygems_filesystem.list
+%scl_files
+
+%files build
+%{_root_sysconfdir}/rpm/macros.%{scl}-config
+
+%files scldevel
+%{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel
+
+
+%changelog
+* Thu Jan 16 2014 John Doe <jdoe at example.com> - 1-1
+- Initial package.]]></programlisting>
+  </section>
+  <section id="sect-The_ror40-rubygem-bcrypt-ruby_Package">
+    <title>The ror40-rubygem-bcrypt-ruby Package</title>
+    <para>Below is a commented example of the <package>ror40-rubygem-bcrypt-ruby</package> package spec file. This package provides the bcryp-ruby gem. For more information on bcryp-ruby, see the following website:</para>
+    <itemizedlist>
+      <listitem>
+        <para><ulink url="http://rubygems.org/gems/bcrypt-ruby">http://rubygems.org/gems/bcrypt-ruby</ulink></para>
+      </listitem>
+    </itemizedlist>
+    <para>Note that the only significant difference between the <package>ror40-rubygem-bcrypt-ruby</package> package spec file and a normal &DSCL; package spec file is the following:</para>
+    <itemizedlist>
+      <listitem>
+        <para>The <code>BuildRequires</code> tags are prefixed with <code>%{?scl_prefix_ruby}</code> instead of <code>%{scl_prefix}</code>.</para>
+      </listitem>
+    </itemizedlist>
+    <programlisting language="RPM Spec"><![CDATA[%{!?scl:%global pkg_name %{name}}
+%{?scl:%scl_package rubygem-%{gem_name}}
+
+# Generated from bcrypt-ruby-2.1.2.gem by gem2rpm -*- rpm-spec -*-
+%global gem_name bcrypt-ruby
+
+Summary: Wrapper around bcrypt() password hashing algorithm
+Name: %{?scl:%scl_prefix}rubygem-%{gem_name}
+Version: 3.1.2
+Release: 4%{?dist}
+Group: Development/Languages
+# ext/* - Public Domain
+# spec/TestBCrypt.java - ISC
+License: MIT and Public Domain and ISC
+URL: http://bcrypt-ruby.rubyforge.org
+Source0: http://rubygems.org/downloads/%{gem_name}-%{version}.gem
+Requires: %{?scl_prefix_ruby}ruby(rubygems)
+Requires: %{?scl_prefix_ruby}ruby(release)
+BuildRequires: %{?scl_prefix_ruby}rubygems-devel
+BuildRequires: %{?scl_prefix_ruby}ruby-devel
+BuildRequires: %{?scl_prefix}rubygem(rspec)
+Provides: %{?scl_prefix}rubygem(%{gem_name}) = %{version}
+
+%description
+bcrypt() is a sophisticated and secure hash algorithm designed by The
+OpenBSD project
+for hashing passwords. bcrypt-ruby provides a simple, humane wrapper for
+safely handling
+passwords.
+
+
+%prep
+%setup -q -c -T
+
+%build
+export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
+%{?scl:scl enable %{scl} - << \EOF}
+%gem_install -n %{SOURCE0}
+%{?scl:EOF}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{gem_dir}
+mkdir -p %{buildroot}%{gem_extdir_mri}/lib
+cp -a .%{gem_dir}/* %{buildroot}%{gem_dir}/
+
+mv %{buildroot}%{gem_libdir}/bcrypt_ext.so %{buildroot}%{gem_extdir_mri}/lib
+
+%check
+pushd .%{gem_instdir}
+%{?scl:scl enable %{scl} - << \EOF}
+rspec spec
+%{?scl:EOF}
+popd
+
+%files
+%dir %{gem_instdir}
+%exclude %{gem_instdir}/.*
+%{gem_instdir}/bcrypt-ruby.gemspec
+%doc %{gem_instdir}/CHANGELOG
+%doc %{gem_instdir}/COPYING
+%exclude %{gem_instdir}/ext
+%{gem_instdir}/Gemfile*
+%{gem_instdir}/Rakefile
+%doc %{gem_instdir}/README.md
+%{gem_libdir}
+%{gem_extdir_mri}
+%{gem_instdir}/spec
+%doc %{gem_docdir}
+%exclude %{gem_cache}
+%{gem_spec}
+
+
+%changelog
+* Fri Mar 21 2014 John Doe <jdoe at example.com> - 3.1.2-4
+- Initial package.]]></programlisting>
+  </section>
+  <section id="sect-Building_the_ror40_Software_Collection">
+    <title>Building the ror40 &DSCL;</title>
+    <para>To build the ror40 &DSCL;:</para>
+    <procedure>
+      <step>
+        <para>Install the <package>ruby200-scldevel</package> package which is a part of Red Hat Software Collections.</para>
+      </step>
+      <step>
+        <para>Build <filename>ror40.spec</filename> and install the <package>ror40-runtime</package> and <package>ror40-build</package> packages.</para>
+      </step>
+      <step>
+        <para>Build <filename>rubygem-bcrypt-ruby.spec</filename>.</para>
+      </step>
+    </procedure>
+  </section>
+  <section id="sect-Testing_the_vt191_Software_Collection">
+    <title>Testing the vt191 &DSCL;</title>
+    <para>To test the ror40 &DSCL;:</para>
+    <procedure>
+      <step>
+        <para>Install the <package>ror40-rubygem-bcryp-ruby</package> package.</para>
+      </step>
+      <step>
+        <para>Run the following command:</para>
+        <screen><computeroutput>$ </computeroutput><userinput>scl enable ror40 -- ruby -r bcrypt -e "puts BCrypt::Password.create('my password')"</userinput></screen>
+        <para>The output should contain the following line:</para>
+        <screen>$2a$10$s./ReniLY.wXPHVBQ9npoeyZf5KzywfpvI5lhjG6Ams3u0hKqwVbW</screen>
+      </step>
+    </procedure>
+  </section>
+  </section>
 </chapter>


More information about the docs-commits mailing list