[52987] trunk/base/src/registry1.0

jmr at macports.org jmr at macports.org
Fri Jun 26 22:32:24 PDT 2009


Revision: 52987
          http://trac.macports.org/changeset/52987
Author:   jmr at macports.org
Date:     2009-06-26 22:32:24 -0700 (Fri, 26 Jun 2009)
Log Message:
-----------
registry, portimage: use -- in filesystem calls to guard against filenames that look like options

Modified Paths:
--------------
    trunk/base/src/registry1.0/portimage.tcl
    trunk/base/src/registry1.0/receipt_flat.tcl

Modified: trunk/base/src/registry1.0/portimage.tcl
===================================================================
--- trunk/base/src/registry1.0/portimage.tcl	2009-06-27 04:52:55 UTC (rev 52986)
+++ trunk/base/src/registry1.0/portimage.tcl	2009-06-27 05:32:24 UTC (rev 52987)
@@ -286,7 +286,7 @@
 			file mtime $dstfile [file mtime $srcfile]
 		}
 	} elseif { [file type $srcfile] == "link" } {
-		file copy -force $srcfile $dstfile
+		file copy -force -- $srcfile $dstfile
 	} else {
 		# Try a hard link first and if that fails, a symlink
 		if {[catch {file link -hard $dstfile $srcfile}]} {
@@ -345,7 +345,7 @@
 
 			if {[file exists $file]} {
 				ui_warn "File $file already exists.  Moving to: $bakfile."
-				file rename -force $file $bakfile
+				file rename -force -- $file $bakfile
 			}
 			
 			if { $port != 0 } {

Modified: trunk/base/src/registry1.0/receipt_flat.tcl
===================================================================
--- trunk/base/src/registry1.0/receipt_flat.tcl	2009-06-27 04:52:55 UTC (rev 52986)
+++ trunk/base/src/registry1.0/receipt_flat.tcl	2009-06-27 05:32:24 UTC (rev 52987)
@@ -74,7 +74,7 @@
 
     # regex match case
     if {$portversion == 0} {
-	set x [glob -nocomplain [file join ${macports::registry.path} receipts ${portname}-*]]
+	set x [glob -nocomplain -directory [file join ${macports::registry.path} receipts] -- ${portname}-*]
 	if {[string length $x]} {
 	    set matchfile [lindex $x 0]
 		# Remove trailing .bz2, if any.
@@ -136,7 +136,7 @@
 		if { $version == "" } {
 			# xxx: If we're in image mode, we really should have had the 
 			# version given to us.  How should we handle this?
-			set x [glob -nocomplain [file join ${receipt_path} *]]
+			set x [glob -nocomplain -directory ${receipt_path} *]
 			if { [string length $x] } {
 				set v [lindex [file split [lindex $x 0]] end]
 				regexp {([-_a-zA-Z0-9\.]+)_([0-9]*)([+-_a-zA-Z0-9]*)$} $v match version revision variants
@@ -180,7 +180,7 @@
 		# move the old receipt
 		set convertedDirPath [file join ${macports::registry.path} receipts_converted]
 		file mkdir $convertedDirPath
-		file rename $receipt_file $convertedDirPath
+		file rename -- $receipt_file $convertedDirPath
 	} elseif {[string match "# Version: *" $receipt_contents]} {
 		# This is new format
 		if {![string match "# Version: 1.0*" $receipt_contents]} {
@@ -329,12 +329,12 @@
 	close $receipt_handle
 
 	if { [file exists ${receipt_file}] } {
-		file delete -force "${receipt_file}"
+		file delete -force -- "${receipt_file}"
 	} elseif { [file exists ${receipt_file}.bz2] } {
-		file delete -force "${receipt_file}.bz2"
+		file delete -force -- "${receipt_file}.bz2"
 	}
 
-	file rename -force "${receipt_file}.tmp" "${receipt_file}"
+	file rename -force -- "${receipt_file}.tmp" "${receipt_file}"
 
 	if { [file exists ${receipt_file}] && [file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
 		system "${registry::autoconf::bzip2_path} -f ${receipt_file}"
@@ -423,14 +423,14 @@
 	if { [file exists ${receipt_path}] } {
 		# remove port receipt directory
 		ui_debug "deleting directory: ${receipt_path}"
-		file delete -force ${receipt_path}
+		file delete -force -- ${receipt_path}
 		# remove port receipt parent directory (if empty)
 		set receipt_dir [file join ${macports::registry.path} receipts ${name}]
 		if { [file isdirectory ${receipt_dir}] } {
 			# 0 item means empty.
 			if { [llength [readdir ${receipt_dir}]] == 0 } {
 				ui_debug "deleting directory: ${receipt_dir}"
-				file delete -force ${receipt_dir}
+				file delete -force -- ${receipt_dir}
 			} else {
 				ui_debug "${receipt_dir} is not empty"
 			}
@@ -848,9 +848,9 @@
 	close $map_handle
 
     # don't both checking for presence, file delete doesn't error if file doesn't exist
-    file delete ${map_file} ${map_file}.bz2
+    file delete -- ${map_file} ${map_file}.bz2
 
-    file rename ${map_file}.tmp ${map_file}
+    file rename -- ${map_file}.tmp ${map_file}
 
 	if { [file exists ${map_file}] && [file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
 		system "${registry::autoconf::bzip2_path} -f ${map_file}"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090626/5e238496/attachment.html>


More information about the macports-changes mailing list