[53949] branches/images-and-archives/base/src/port1.0/portimagefile.tcl

blb at macports.org blb at macports.org
Thu Jul 16 17:31:15 PDT 2009


Revision: 53949
          http://trac.macports.org/changeset/53949
Author:   blb at macports.org
Date:     2009-07-16 17:31:14 -0700 (Thu, 16 Jul 2009)
Log Message:
-----------
Use "string trimright" instead of the manual method; use a safe regsub and comment what is going on better

Modified Paths:
--------------
    branches/images-and-archives/base/src/port1.0/portimagefile.tcl

Modified: branches/images-and-archives/base/src/port1.0/portimagefile.tcl
===================================================================
--- branches/images-and-archives/base/src/port1.0/portimagefile.tcl	2009-07-17 00:11:57 UTC (rev 53948)
+++ branches/images-and-archives/base/src/port1.0/portimagefile.tcl	2009-07-17 00:31:14 UTC (rev 53949)
@@ -116,9 +116,7 @@
 # Build up a list of information which describes each file within the
 # destroot, which matches that information which is found in receipts.
 proc portimagefile::filelist_for_path {startpath} {
-    if {[string index $startpath end] == "/"} {
-        set startpath [string range $startpath 0 end-1]
-    }
+    set startpath [string trimright $startpath /]
     set filelist {}
     fs-traverse element $startpath {
         if {[file type $element] != "directory"} {
@@ -126,7 +124,15 @@
             # so we must run it against the stuff in the destroot, then strip
             # out that path to get to what will be the final install path
             set fileinfo [registry_fileinfo_for_file $element]
-            lappend filelist [regsub -all "^$startpath" $fileinfo ""]
+
+            # Note that we don't anchor $startpath since it will occur
+            # twice in $fileinfo.
+            # Also, there is a theoretical possiblity that $startpath
+            # will occur a second time in the full path, but
+            # the likelihood is very, very, very small. eg, how often
+            # will /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_<category>_<portname>/work/destroot
+            # appear in a path besides what MacPorts uses (or its equivalent)?
+            lappend filelist [regsub -all "(?q)$startpath" $fileinfo ""]
         }
     }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090716/8132cd89/attachment.html>


More information about the macports-changes mailing list