[35772] trunk/base/src/port1.0/resources/group/ruby-1.0.tcl

eridius at macports.org eridius at macports.org
Sat Apr 5 11:39:54 PDT 2008


Revision: 35772
          http://trac.macosforge.org/projects/macports/changeset/35772
Author:   eridius at macports.org
Date:     2008-04-05 11:39:49 -0700 (Sat, 05 Apr 2008)

Log Message:
-----------
Get rid of all usage of _cd and [exec find ...] in ruby-1.0.tcl

Modified Paths:
--------------
    trunk/base/src/port1.0/resources/group/ruby-1.0.tcl

Modified: trunk/base/src/port1.0/resources/group/ruby-1.0.tcl
===================================================================
--- trunk/base/src/port1.0/resources/group/ruby-1.0.tcl	2008-04-05 16:06:54 UTC (rev 35771)
+++ trunk/base/src/port1.0/resources/group/ruby-1.0.tcl	2008-04-05 18:39:49 UTC (rev 35772)
@@ -180,16 +180,19 @@
 			build			{}
 
 			destroot {
-				_cd ${worksrcpath}/${ruby.srcdir}
+				set root ${worksrcpath}/${ruby.srcdir}
 				xinstall -d -m 0755 ${destroot}${ruby.lib}
-				foreach dir [exec find . -type d] {
-					set dir [strsed ${dir} {s|^[.]/||}]
-					xinstall -d -m 0755 ${destroot}${ruby.lib}/${dir}
+				fs-traverse file $root {
+					set file [trimroot $root $file]
+					if {$file ne ""} {
+						set filepath [file join $root $file]
+						if {[file isdirectory $filepath]} {
+							xinstall -d -m 0755 ${destroot}${ruby.lib}/${file}
+						} else {
+							xinstall -m 0644 $filepath ${destroot}${ruby.lib}/${file}
+						}
+					}
 				}
-				foreach file [exec find . -type f] {
-					set file [strsed ${file} {s|^[.]/||}]
-					xinstall -m 0644 ${file} ${destroot}${ruby.lib}/${file}
-				}
 			}
 		}
 		install.rb {
@@ -272,14 +275,12 @@
 			}
 			
 			destroot {
-			  _cd ${worksrcpath}
-			  system "${prefix}/bin/gem install --local --force --install-dir ${destroot}${prefix}/lib/ruby/gems/${ruby.version} ${distpath}/${distname}"
+			  system "cd ${worksrcpath} && ${prefix}/bin/gem install --local --force --install-dir ${destroot}${prefix}/lib/ruby/gems/${ruby.version} ${distpath}/${distname}"
 			
 				set binDir ${destroot}${prefix}/lib/ruby/gems/${ruby.version}/bin
 				if {[file isdirectory $binDir]} {
-					_cd $binDir
 					foreach file [readdir $binDir] {
-						file copy $file ${destroot}${prefix}/bin
+						file copy [file join $binDir $file] ${destroot}${prefix}/bin
 					}
 				}
 			}
@@ -291,19 +292,24 @@
 	}
 
 	post-destroot {
-		_cd ${worksrcpath}
 		# Install documentation files (if specified)
 		if {[llength ${ruby.docs}] > 0} {
 			set docPath ${prefix}/share/doc/${name}
 			xinstall -d -m 0755 ${destroot}${docPath}
 			foreach docitem ${ruby.docs} {
+				set docitem [file join ${worksrcpath} ${docitem}]
 				if {[file isdirectory ${docitem}]} {
-					foreach dir [exec find ${docitem} -type d] {
-						xinstall -d -m 0755 ${destroot}${docPath}/${dir}
+					fs-traverse $file $docitem {
+						set file [trimroot $root $file]
+						if {$file ne ""} {
+							set filepath [file join $root $file]
+							if {[file isdirectory $filepath]} {
+								xinstall -d -m 0755 ${destroot}${docPath}/${file}
+							} else {
+								xinstall -m 0644 $filepath ${destroot}${docPath}/${file}
+							}
+						}
 					}
-					foreach file [exec find ${docitem} -type f] {
-						xinstall -m 0644 ${file} ${destroot}${docPath}/${file}
-					}
 				} else {
 					xinstall -m 0644 ${docitem} ${destroot}${docPath}
 				}
@@ -311,3 +317,25 @@
 		}
 	}
 }
+
+proc trimroot {root path} {
+	set acc {}
+	set skiproot no
+	foreach rootf [file split $root] pathf [file split $path] {
+		if {$pathf eq ""} {
+			# we've hit the end of the path
+			break
+		} elseif {$skiproot eq "yes" || $rootf eq ""} {
+			lappend acc $pathf
+		} elseif {$rootf ne $pathf} {
+			# diverged from the root
+			lappend acc $pathf
+			set skiproot yes
+		}
+	}
+	if {[llength $acc] == 0} {
+		return ""
+	} else {
+		return [eval [subst -nobackslashes -nocommands {file join $acc}]]
+	}
+}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080405/4177be45/attachment.html


More information about the macports-changes mailing list