[103918] trunk/dports

kimuraw at macports.org kimuraw at macports.org
Sat Mar 9 18:04:04 PST 2013


Revision: 103918
          https://trac.macports.org/changeset/103918
Author:   kimuraw at macports.org
Date:     2013-03-09 18:04:04 -0800 (Sat, 09 Mar 2013)
Log Message:
-----------
_resources/port1.0/group/ruby-1.0.tcl, lang/ruby, lang/ruby19: introduce `port select ruby`

file hierarchy:

    ${prefix}/bin
        ruby1.8        - port:ruby
        ruby1.9        - port:ruby19
        nanoc3-1.8     - port:rb-nanoc3
        nanoc3-1.9     - port:rb19-nanoc3
    ${prefix}/libexec/
        ruby1.8/nanoc3 - port:rb-nanoc3
        ruby1.9/nanoc3 - port:rb19-nanoc3
    ${prefix}/etc/select/ruby
        base           - port:ruby_select
        none           - port:ruby_select
        ruby18         - port:ruby
        ruby19         - port:ruby19

Modified Paths:
--------------
    trunk/dports/_resources/port1.0/group/ruby-1.0.tcl
    trunk/dports/lang/ruby/Portfile
    trunk/dports/lang/ruby19/Portfile

Added Paths:
-----------
    trunk/dports/lang/ruby/files/ruby18
    trunk/dports/lang/ruby19/files/ruby19

Modified: trunk/dports/_resources/port1.0/group/ruby-1.0.tcl
===================================================================
--- trunk/dports/_resources/port1.0/group/ruby-1.0.tcl	2013-03-10 02:00:31 UTC (rev 103917)
+++ trunk/dports/_resources/port1.0/group/ruby-1.0.tcl	2013-03-10 02:04:04 UTC (rev 103918)
@@ -30,13 +30,70 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-# Define these variables assuming ruby1.8 to make them accessible in
-# the portfile after port group declaration. They can be modified by
-# ruby.setup, e.g. to use another ruby than 1.8.
-set ruby.bin            ${prefix}/bin/ruby
-set ruby.rdoc           ${prefix}/bin/rdoc
-set ruby.gem            ${prefix}/bin/gem
+# Usage:
+#
+#   1. use ruby.setup
+#
+#     PortGroup        ruby 1.0
+#     ruby.setup       module version type {} ruby19
+#
+#   2. use ruby.branch
+#
+#     PortGroup        ruby 1.0
+#     ruby.branch      1.9
+#     depends_lib      port:ruby${ruby.suffix}
+#     build.cmd        ${ruby.bin}
 
+# options:
+#   ruby.branch: select ruby version. 1.8 or 1.9.
+#   ruby.link_binaries: whether generate suffixed symlink under ${prefix}/bin
+#        or not.
+# values:
+#   ruby.bin, ruby.rdoc, ruby.gem: fullpath to commands for ${ruby.branch}.
+#   ruby.suffix: suffix of portname. port:ruby${ruby.suffix} or
+#        port:rb${ruby.suffix}-foo.
+#   ruby.bindir: install location of commands without suffix from rb-foo.
+#   ruby.gemdir: install location of rubygems.
+#        such as "${prefix}/lib/ruby1.9/gems/1.9.1".
+#   ruby.link_binaries_suffix: suffix of commands from rb-foo under
+#        ${prefix}/bin. such as "-1.8" or "-1.9".
+#   (obsoleted values)
+#   ruby.prog_suffix: use ruby.branch.
+#   ruby.version: use ruby.api_version.
+# values from ruby.setup:
+#   ruby.module: port name without prefix. rb-${ruby.module}.
+#   ruby.project: project name at rubygems, rubyforge or sourceforge.
+
+options ruby.default_branch
+default ruby.default_branch 1.8
+options ruby.branch
+options ruby.bin ruby.rdoc ruby.gem ruby.bindir ruby.gemdir ruby.suffix
+option_proc ruby.branch ruby_set_branch
+proc ruby_set_branch {option action args} {
+    if {$action != "set"} {
+        return
+    }
+    global prefix ruby.branch \
+           ruby.bin ruby.rdoc ruby.gem ruby.bindir ruby.gemdir \
+           ruby.suffix ruby.link_binaries_suffix ruby.api_version
+    set ruby.bin            ${prefix}/bin/ruby${ruby.branch}
+    set ruby.rdoc           ${prefix}/bin/rdoc${ruby.branch}
+    set ruby.gem            ${prefix}/bin/gem${ruby.branch}
+    set ruby.bindir         ${prefix}/libexec/ruby${ruby.branch}
+    set ruby.gemdir         ${prefix}/lib/ruby${ruby.branch}/gems/${ruby.api_version}
+    # gem command for 1.8 from port:rb-rubygems
+    if {${ruby.branch} eq "1.8"} {
+        set ruby.gem        ${ruby.bindir}/gem
+        set ruby.gemdir     ${prefix}/lib/ruby/gems/${ruby.api_version}
+    }
+    set ruby.suffix         [join [split ${ruby.branch} .] {}]
+    if {${ruby.branch} eq "1.8"} {
+        set ruby.suffix     ""
+    }
+    set ruby.link_binaries_suffix -${ruby.branch}
+    set ruby.prog_suffix    ${ruby.branch}
+}
+
 proc ruby.extract_config {var {default ""}} {
     global ruby.bin
     if {[catch {set val [exec ${ruby.bin} -e "require 'rbconfig';puts RbConfig::CONFIG\[\"${var}\"\]"]}]} {
@@ -45,43 +102,48 @@
     return $val
 }
 
-options ruby.version ruby.arch ruby.lib ruby.archlib
-default ruby.version    {[ruby.extract_config ruby_version]}
-default ruby.arch       {[ruby.extract_config arch "${os.arch}-${os.platform}${os.major}"]}
+options ruby.api_version ruby.lib ruby.archlib
+default ruby.api_version    {[ruby.extract_config ruby_version]}
+default ruby.arch           {[ruby.extract_config arch "${os.arch}-${os.platform}${os.major}"]}
 # define installation libraries as vendor location
-default ruby.lib        {[ruby.extract_config vendorlibdir ${prefix}/lib/ruby/vendor_ruby/${ruby.version}]}
-default ruby.archlib    {[ruby.extract_config vendorarchdir ${ruby.lib}/${ruby.arch}]}
+default ruby.lib            {[ruby.extract_config vendorlibdir ${prefix}/lib/ruby/vendor_ruby/${ruby.api_version}]}
+default ruby.archlib        {[ruby.extract_config vendorarchdir ${ruby.lib}/${ruby.arch}]}
+# ruby.version is obsoleted. use ruby.api_version.
+options ruby.version
+default ruby.version        {[ruby.extract_config ruby_version]}
 
-set ruby.module     ""
-set ruby.filename   ""
-set ruby.project    ""
-set ruby.docs       {}
-set ruby.srcdir     ""
+set ruby.module         ""
+set ruby.filename       ""
+set ruby.project        ""
+set ruby.docs           {}
+set ruby.srcdir         ""
 
+options ruby.link_binaries
+default ruby.link_binaries yes
+
+default ruby.branch         ${ruby.default_branch}
+
 # ruby group setup procedure; optional for ruby 1.8 if you want only
 # basic variables, like ruby.lib and ruby.archlib.
 proc ruby.setup {module vers {type "install.rb"} {docs {}} {source "custom"} {implementation "ruby"}} {
     global destroot prefix worksrcpath os.platform
     global ruby.bin ruby.rdoc ruby.gem
-    global ruby.version ruby.lib
+    global ruby.api_version ruby.lib ruby.suffix ruby.bindir ruby.gemdir
     global ruby.module ruby.filename ruby.project ruby.docs ruby.srcdir
+    global ruby.link_binaries_suffix
+    # ruby.version is obsoleted. use ruby.gemdir.
     global ruby.prog_suffix
 
     if {${implementation} eq "ruby19"} {
-        set ruby.port_prefix rb19
-        set ruby.prog_suffix "1.9"
+        ruby.branch 1.9
+        set ruby.prog_suffix 1.9
     } elseif {${implementation} eq "ruby"} {
-        # ruby.bin, ruby.rdoc, and ruby.gem set to 1.8 by default
-        set ruby.port_prefix rb
-        # no program suffix by default, so leave as blank
+        ruby.branch 1.8
         set ruby.prog_suffix ""
     } else {
         ui_error "ruby.setup: unknown implementation '${implementation}' specified (ruby, ruby19 possible)"
         return -code error "ruby.setup failed"
     }
-    set ruby.bin    ${prefix}/bin/ruby${ruby.prog_suffix}
-    set ruby.rdoc   ${prefix}/bin/rdoc${ruby.prog_suffix}
-    set ruby.gem    ${prefix}/bin/gem${ruby.prog_suffix}
 
     # define ruby global names and lists
     # check if module is a list or string
@@ -99,7 +161,7 @@
     }
     set ruby.docs   ${docs}
 
-    name            ${ruby.port_prefix}-[string tolower ${ruby.module}]
+    name            rb${ruby.suffix}-[string tolower ${ruby.module}]
     version         ${vers}
     categories      ruby
 
@@ -199,6 +261,11 @@
             destroot.cmd    ${ruby.bin} -rvendor-specific -rdestroot install.rb
             destroot.target
             destroot.destdir
+            post-destroot {
+                foreach file [readdir ${destroot}${prefix}/bin] {
+                    move [file join ${destroot}${prefix}/bin $file] ${destroot}${ruby.bindir}
+                }
+            }
         }
         copy_install:* {
             set ruby.srcdir [lindex [split ${type} {:}] 1]
@@ -225,7 +292,7 @@
         }
         install.rb {
             configure.cmd       ${ruby.bin} -rvendor-specific install.rb
-            configure.pre_args  config
+            configure.pre_args  config --bin-dir=${destroot}${ruby.bindir}
 
             build.cmd           ${ruby.bin} -rvendor-specific install.rb
             build.target        setup
@@ -264,6 +331,11 @@
             destroot.cmd        ${ruby.bin} -rvendor-specific setup.rb
             destroot.target     install
             destroot.destdir
+            post-destroot {
+                foreach file [readdir ${destroot}${prefix}/bin] {
+                    move [file join ${destroot}${prefix}/bin $file] ${destroot}${ruby.bindir}
+                }
+            }
         }
         extconf.rb {
             configure.cmd       ${ruby.bin} -rvendor-specific extconf.rb
@@ -273,6 +345,11 @@
             build.args          RUBY="${ruby.bin} -rvendor-specific"
 
             destroot.args       RUBY="${ruby.bin} -rvendor-specific"
+            post-destroot {
+                foreach file [readdir ${destroot}${prefix}/bin] {
+                    move [file join ${destroot}${prefix}/bin $file] ${destroot}${ruby.bindir}
+                }
+            }
         }
         gnu {
             build.args          RUBY="${ruby.bin} -rvendor-specific"
@@ -301,16 +378,16 @@
             build {}
 
             pre-destroot {
-                xinstall -d -m 0755 ${destroot}${prefix}/lib/ruby${ruby.prog_suffix}/gems/${ruby.version}
+                xinstall -d -m 0755 ${destroot}${ruby.gemdir}
             }
 
             destroot {
-                system "cd ${worksrcpath} && ${ruby.gem} install --local --force --install-dir ${destroot}${prefix}/lib/ruby${ruby.prog_suffix}/gems/${ruby.version} ${distpath}/${distname}"
+                system "cd ${worksrcpath} && ${ruby.gem} install --no-ri --no-rdoc --local --force --install-dir ${destroot}${ruby.gemdir} ${distpath}/${distname}"
 
-                set binDir ${destroot}${prefix}/lib/ruby${ruby.prog_suffix}/gems/${ruby.version}/bin
+                set binDir ${destroot}${ruby.gemdir}/bin
                 if {[file isdirectory $binDir]} {
                     foreach file [readdir $binDir] {
-                        file copy [file join $binDir $file] ${destroot}${prefix}/bin
+                        file copy [file join $binDir $file] ${destroot}${ruby.bindir}
                     }
                 }
             }
@@ -329,7 +406,18 @@
         configure.universal_args-delete  --disable-dependency-tracking
     }
 
+    pre-destroot {
+        xinstall -d -m 0755 ${destroot}${ruby.bindir}
+    }
+
     post-destroot {
+        if {${ruby.link_binaries}} {
+            foreach bin [glob -nocomplain -tails -directory "${destroot}${ruby.bindir}" *] {
+                if {[catch {file type "${destroot}${prefix}/bin/${bin}${ruby.link_binaries_suffix}"}]} {
+                    ln -s "${ruby.bindir}/${bin}" "${destroot}${prefix}/bin/${bin}${ruby.link_binaries_suffix}"
+                }
+            }
+        }
         # Install documentation files (if specified)
         if {[llength ${ruby.docs}] > 0} {
             set docPath ${prefix}/share/doc/${name}

Modified: trunk/dports/lang/ruby/Portfile
===================================================================
--- trunk/dports/lang/ruby/Portfile	2013-03-10 02:00:31 UTC (rev 103917)
+++ trunk/dports/lang/ruby/Portfile	2013-03-10 02:04:04 UTC (rev 103918)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
 # $Id$
 
 PortSystem		1.0
@@ -2,7 +3,8 @@
 PortGroup		muniversal 1.0
-PortGroup               compiler_blacklist_versions 1.0
+PortGroup		compiler_blacklist_versions 1.0
+PortGroup		select 1.0
 
 name			ruby
 version			1.8.7-p371
-revision		1
+revision		2
 
@@ -37,7 +39,11 @@
 				port:zlib \
 				port:ncurses \
 				port:gdbm
+depends_run		port:ruby_select
 
+select.group	ruby
+select.file		${filespath}/ruby18
+
 # vendordir: enable vendor-specific.rb
 # #3604: gcc4 fails to detect linking at configure
 # #19050: use $(CC) not cc, this change has been merged at ruby-1.8 trunk
@@ -99,10 +105,16 @@
 				--enable-pthread \
 				--without-tk \
 				--with-vendordir=${prefix}/lib/ruby/vendor_ruby \
-				--with-opt-dir=${prefix}
+				--with-opt-dir=${prefix} \
+				--program-suffix=1.8
 # ignore minor version for archdir, like i686-darwin9
 configure.env	UNAME_RELEASE=${os.major}
 
+# force libruby without suffix (backward compatibility)
+post-configure {
+	reinplace "s|^RUBY_SO_NAME=.*|RUBY_SO_NAME=ruby|" ${worksrcpath}/Makefile
+}
+
 if {[variant_isset universal]} {
 	# NOTE: directory layout of port:ruby +universal
 	#   universal binary
@@ -143,6 +155,9 @@
 			destroot.keepdirs-append ${subdir}
 		}
 	}
+	# install destination of commands from port:rb-*
+	xinstall -m 0755 -d ${destroot}${prefix}/libexec/ruby1.8
+	destroot.keepdirs-append ${destroot}${prefix}/libexec/ruby1.8
     # error at activate, for these case sensitive files
 	foreach rdoc {Exception2MessageMapper/fail-i.yaml \
 				  REXML/Parsers/XPathParser/predicate-i.yaml} {

Added: trunk/dports/lang/ruby/files/ruby18
===================================================================
--- trunk/dports/lang/ruby/files/ruby18	                        (rev 0)
+++ trunk/dports/lang/ruby/files/ruby18	2013-03-10 02:04:04 UTC (rev 103918)
@@ -0,0 +1,13 @@
+bin/erb1.8
+-
+bin/irb1.8
+-
+bin/rdoc1.8
+bin/ri1.8
+bin/ruby1.8
+bin/testrb1.8
+-
+-
+-
+-
+share/man/man1/ruby1.8.1.gz

Modified: trunk/dports/lang/ruby19/Portfile
===================================================================
--- trunk/dports/lang/ruby19/Portfile	2013-03-10 02:00:31 UTC (rev 103917)
+++ trunk/dports/lang/ruby19/Portfile	2013-03-10 02:04:04 UTC (rev 103918)
@@ -1,10 +1,12 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
 # $Id$
 
 PortSystem			1.0
+PortGroup			select 1.0
 
 name				ruby19
 version				1.9.3-p392
-revision			0
+revision			1
 
 categories			lang ruby
 maintainers			kimuraw openmaintainer
@@ -40,7 +42,11 @@
 					port:libyaml \
 					port:libffi \
 					port:gdbm
+depends_run			port:ruby_select
 
+select.group		ruby
+select.file			${filespath}/ruby19
+
 default_variants	+doc
 
 # lib-rubygems-specification.rb: fix 'Invalid gemspec in [... json-1.6.1.gemspec]: invalid date
@@ -86,6 +92,10 @@
 			destroot.keepdirs-append ${subdir}
 	}
 
+	# install destination of commands from port:rb-*
+	xinstall -m 0755 -d ${destroot}${prefix}/libexec/ruby1.9
+	destroot.keepdirs-append ${destroot}${prefix}/libexec/ruby1.9
+
     # error at activate, for these case sensitive files
 	foreach rdoc {Exception2MessageMapper/fail-i.yaml \
 				  REXML/Parsers/XPathParser/predicate-i.yaml} {
@@ -108,16 +118,6 @@
 	}
 }
 
-variant nosuffix description "Don't add the 1.9 program suffix to the executables" {
-    conflicts ruby ruby186 rb-rubygems rb-rake
-    post-destroot {
-        # make symlinks no-suffixed binaries
-        foreach file {erb gem irb rake rdoc ri ruby testrb} {
-            ln -s ${prefix}/bin/${file}1.9 ${destroot}${prefix}/bin/${file}
-        }
-    }
-}
-
 variant c_api_docs description "Generate documentation for Ruby C API" {
 	depends_build-append port:doxygen
 

Added: trunk/dports/lang/ruby19/files/ruby19
===================================================================
--- trunk/dports/lang/ruby19/files/ruby19	                        (rev 0)
+++ trunk/dports/lang/ruby19/files/ruby19	2013-03-10 02:04:04 UTC (rev 103918)
@@ -0,0 +1,13 @@
+bin/erb1.9
+bin/gem1.9
+bin/irb1.9
+bin/rake1.9
+bin/rdoc1.9
+bin/ri1.9
+bin/ruby1.9
+bin/testrb1.9
+share/man/man1/erb1.9.1.gz
+share/man/man1/irb1.9.1.gz
+share/man/man1/rake1.9.1.gz
+share/man/man1/ri1.9.1.gz
+share/man/man1/ruby1.9.1.gz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130309/54aecb93/attachment-0001.html>


More information about the macports-changes mailing list