[58126] branches/release_1_8

jmr at macports.org jmr at macports.org
Tue Sep 22 10:29:58 PDT 2009


Revision: 58126
          http://trac.macports.org/changeset/58126
Author:   jmr at macports.org
Date:     2009-09-22 10:29:57 -0700 (Tue, 22 Sep 2009)
Log Message:
-----------
merge r57436 and r57441 from trunk:
 add realpath command to try to fix #21082

Revision Links:
--------------
    http://trac.macports.org/changeset/57436
    http://trac.macports.org/changeset/57441

Modified Paths:
--------------
    branches/release_1_8/base/src/macports1.0/Makefile
    branches/release_1_8/base/src/macports1.0/macports.c
    branches/release_1_8/base/src/macports1.0/macports.tcl
    branches/release_1_8/base/src/registry1.0/portimage.tcl
    branches/release_1_8/base/src/registry1.0/portuninstall.tcl
    branches/release_1_8/base/src/registry2.0/portimage.tcl
    branches/release_1_8/base/src/registry2.0/portuninstall.tcl

Added Paths:
-----------
    branches/release_1_8/base/src/macports1.0/realpath.c
    branches/release_1_8/base/src/macports1.0/realpath.h

Property Changed:
----------------
    branches/release_1_8/
    branches/release_1_8/base/


Property changes on: branches/release_1_8
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:55268,55279,55281,55285,55317,55385,55417,55591,55594,55679,55767,55793,56147,56160,56162,56435,56448,57026,57255,57784,57801,57871,57974
   + /trunk:55268,55279,55281,55285,55317,55385,55417,55591,55594,55679,55767,55793,56147,56160,56162,56435,56448,57026,57255,57436,57441,57784,57801,57871,57974


Property changes on: branches/release_1_8/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:55268,55279,55281,55285,55317,55385,55417,55591,55594,55679,55767,55793,55825,56147,56160,56162,56435,56448,56472-56474,56666,56889,57026,57048,57055,57131,57255,57784,57801,57820,57871,57974,57979,57982,58093
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692
   + /branches/gsoc08-privileges/base:37343-46937
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:55268,55279,55281,55285,55317,55385,55417,55591,55594,55679,55767,55793,55825,56147,56160,56162,56435,56448,56472-56474,56666,56889,57026,57048,57055,57131,57255,57436,57441,57784,57801,57820,57871,57974,57979,57982,58093
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692

Modified: branches/release_1_8/base/src/macports1.0/Makefile
===================================================================
--- branches/release_1_8/base/src/macports1.0/Makefile	2009-09-22 13:53:43 UTC (rev 58125)
+++ branches/release_1_8/base/src/macports1.0/Makefile	2009-09-22 17:29:57 UTC (rev 58126)
@@ -1,6 +1,6 @@
 SRCS=		macports.tcl macports_dlist.tcl macports_util.tcl \
 		macports_autoconf.tcl macports_index.tcl macports_fastload.tcl
-OBJS=		macports.o get_systemconfiguration_proxies.o sysctl.o
+OBJS=		macports.o get_systemconfiguration_proxies.o realpath.o sysctl.o
 SHLIB_NAME=	MacPorts${SHLIB_SUFFIX}
 
 INSTALLDIR=	${DESTDIR}${TCL_PACKAGE_DIR}/macports1.0

Modified: branches/release_1_8/base/src/macports1.0/macports.c
===================================================================
--- branches/release_1_8/base/src/macports1.0/macports.c	2009-09-22 13:53:43 UTC (rev 58125)
+++ branches/release_1_8/base/src/macports1.0/macports.c	2009-09-22 17:29:57 UTC (rev 58126)
@@ -38,6 +38,7 @@
 #include <tcl.h>
 
 #include "get_systemconfiguration_proxies.h"
+#include "realpath.h"
 #include "sysctl.h"
 
 static int
@@ -58,6 +59,7 @@
 		return TCL_ERROR;
 	Tcl_CreateObjCommand(interp, "macports::version", macports__version, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "get_systemconfiguration_proxies", GetSystemConfigurationProxiesCmd, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "realpath", RealpathCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "sysctl", SysctlCmd, NULL, NULL);
 	if (Tcl_PkgProvide(interp, "macports", "1.0") != TCL_OK)
 		return TCL_ERROR;

Modified: branches/release_1_8/base/src/macports1.0/macports.tcl
===================================================================
--- branches/release_1_8/base/src/macports1.0/macports.tcl	2009-09-22 13:53:43 UTC (rev 58125)
+++ branches/release_1_8/base/src/macports1.0/macports.tcl	2009-09-22 17:29:57 UTC (rev 58126)
@@ -832,6 +832,7 @@
     $workername alias findBinary macports::findBinary
     $workername alias binaryInPath macports::binaryInPath
     $workername alias sysctl sysctl
+    $workername alias realpath realpath
 
     # New Registry/Receipts stuff
     $workername alias registry_new registry::new_entry

Copied: branches/release_1_8/base/src/macports1.0/realpath.c (from rev 57436, trunk/base/src/macports1.0/realpath.c)
===================================================================
--- branches/release_1_8/base/src/macports1.0/realpath.c	                        (rev 0)
+++ branches/release_1_8/base/src/macports1.0/realpath.c	2009-09-22 17:29:57 UTC (rev 58126)
@@ -0,0 +1,80 @@
+/*
+ * realpath.c
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of MacPorts Team nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tcl.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "realpath.h"
+
+/**
+ * realpath command entry point.
+ *
+ * @param interp		current interpreter
+ * @param objc			number of parameters
+ * @param objv			parameters
+ */
+int RealpathCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+    const char error_message[] = "realpath failed: ";
+    Tcl_Obj *tcl_result;
+    char *path;
+    char *rpath = malloc(PATH_MAX+1);
+    char *res;
+
+    if (objc != 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "path");
+        return TCL_ERROR;
+    }
+
+    path = Tcl_GetString(objv[1]);
+    res = realpath(path, rpath);
+    if (!res) {
+        free(rpath);
+        tcl_result = Tcl_NewStringObj(error_message, sizeof(error_message) - 1);
+        Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(strerror(errno), -1));
+        Tcl_SetObjResult(interp, tcl_result);
+        return TCL_ERROR;
+    } else {
+        tcl_result = Tcl_NewStringObj(rpath, -1);
+    }
+    
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
+}

Copied: branches/release_1_8/base/src/macports1.0/realpath.h (from rev 57436, trunk/base/src/macports1.0/realpath.h)
===================================================================
--- branches/release_1_8/base/src/macports1.0/realpath.h	                        (rev 0)
+++ branches/release_1_8/base/src/macports1.0/realpath.h	2009-09-22 17:29:57 UTC (rev 58126)
@@ -0,0 +1,49 @@
+/*
+ * realpath.h
+ * $Id$
+ *
+ * Copyright (c) 2009 The MacPorts Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of MacPorts Team nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _REALPATH_H
+#define _REALPATH_H
+
+#include <tcl.h>
+
+/**
+ * A native command to handle a limitation of old versions of Tcl.
+ *
+ * The syntax is:
+ * realpath path
+ *	Normalize path like file normalize does.
+ *  Fixes a problem with Tcl installations affected by not defining HAVE_REALPATH (this is
+ *	the case with the Tcl in OS X shipped prior to 10.6)
+ */
+int RealpathCmd(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]);
+
+#endif /* _REALPATH_H */

Modified: branches/release_1_8/base/src/registry1.0/portimage.tcl
===================================================================
--- branches/release_1_8/base/src/registry1.0/portimage.tcl	2009-09-22 13:53:43 UTC (rev 58125)
+++ branches/release_1_8/base/src/registry1.0/portimage.tcl	2009-09-22 17:29:57 UTC (rev 58126)
@@ -414,8 +414,9 @@
 			lappend files $theFile
 			
 			# Split out the filename's subpaths and add them to the image list as
-			# well.
-			set directory [file dirname $theFile]
+			# well. The realpath call is necessary because file normalize
+			# does not resolve symlinks on OS X < 10.6
+			set directory [realpath [file dirname $theFile]]
 			while { [lsearch -exact $files $directory] == -1 } { 
 				lappend files $directory
 				set directory [file dirname $directory]

Modified: branches/release_1_8/base/src/registry1.0/portuninstall.tcl
===================================================================
--- branches/release_1_8/base/src/registry1.0/portuninstall.tcl	2009-09-22 13:53:43 UTC (rev 58125)
+++ branches/release_1_8/base/src/registry1.0/portuninstall.tcl	2009-09-22 17:29:57 UTC (rev 58126)
@@ -194,8 +194,9 @@
 			lappend files $theFile
 
 			# Split out the filename's subpaths and add them to the
-			# list as well.
-			set directory [file dirname $theFile]
+			# list as well. The realpath call is necessary because file normalize
+			# does not resolve symlinks on OS X < 10.6
+			set directory [realpath [file dirname $theFile]]
 			while { [lsearch -exact $files $directory] == -1 } { 
 				lappend files $directory
 				set directory [file dirname $directory]

Modified: branches/release_1_8/base/src/registry2.0/portimage.tcl
===================================================================
--- branches/release_1_8/base/src/registry2.0/portimage.tcl	2009-09-22 13:53:43 UTC (rev 58125)
+++ branches/release_1_8/base/src/registry2.0/portimage.tcl	2009-09-22 17:29:57 UTC (rev 58126)
@@ -400,7 +400,7 @@
 
             # Split out the filename's subpaths and add them to the image list
             # as well.
-            set directory [file dirname $theFile]
+            set directory [realpath [file dirname $theFile]]
             while { [lsearch -exact $files $directory] == -1 } {
                 lappend files $directory
                 set directory [file dirname $directory]

Modified: branches/release_1_8/base/src/registry2.0/portuninstall.tcl
===================================================================
--- branches/release_1_8/base/src/registry2.0/portuninstall.tcl	2009-09-22 13:53:43 UTC (rev 58125)
+++ branches/release_1_8/base/src/registry2.0/portuninstall.tcl	2009-09-22 17:29:57 UTC (rev 58126)
@@ -129,7 +129,7 @@
 
         # Split out the filename's subpaths and add them to the
         # list as well.
-        set directory [file dirname $theFile]
+        set directory [realpath [file dirname $theFile]]
         while { [lsearch -exact $files $directory] == -1 } { 
             lappend files $directory
             set directory [file dirname $directory]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090922/00f39089/attachment.html>


More information about the macports-changes mailing list