[27826] trunk/base/portmgr/packaging/PortIndex2MySQL.tcl

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 14 14:38:44 PDT 2007


Revision: 27826
          http://trac.macosforge.org/projects/macports/changeset/27826
Author:   jmpp at macports.org
Date:     2007-08-14 14:38:44 -0700 (Tue, 14 Aug 2007)

Log Message:
-----------

Add still place-holder proc for proper error reporting and processing to the PortIndex2MySQL.tcl script,
pending on the still being worked on macports1.0 intialization through mportinit's args to get verbose/debugging
output (gotta review how port(1) does this to get it right, possibly integrating some of the functionality
into macports1.0's default implementation).

Also add a call to macports::selfupdate (leveraging the now optional arg API change) to insure the tree we're
working with is always fresh.

Improve the db command call and relocate the sql string escaping proc.

Modified Paths:
--------------
    trunk/base/portmgr/packaging/PortIndex2MySQL.tcl

Modified: trunk/base/portmgr/packaging/PortIndex2MySQL.tcl
===================================================================
--- trunk/base/portmgr/packaging/PortIndex2MySQL.tcl	2007-08-14 20:58:43 UTC (rev 27825)
+++ trunk/base/portmgr/packaging/PortIndex2MySQL.tcl	2007-08-14 21:38:44 UTC (rev 27826)
@@ -37,6 +37,15 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 
+# Error messages reciepient.
+set SPAM_LOVERS macports-dev at lists.macosforge.org
+
+# Place holder proc for error catching and processing.
+proc bail_on_error {error_log} {
+    
+}
+
+
 # Load macports1.0 so that we can use some of its procs and the portinfo array.
 catch {source \
 	   [file join "@TCL_PACKAGE_DIR@" macports1.0 macports_fastload.tcl]}
@@ -44,9 +53,17 @@
 
 # Initialize MacPorts to find the sources.conf file, wherefrom we'll
 # get the PortIndex that'll feed the database.
+#more work needs to be done than just initializing and passing the
+#ui_options array to get mportinit to output verbose/debugging info;
+#I'm currently looking into this.
+array set ui_options {ports_verbose yes}
 mportinit
 
+# Call the selfupdate procedure to make sure the MacPorts installation
+# is up-to-date and with a fresh ports tree.
+macports::selfupdate
 
+
 # Procedure to catch the database password from a protected file.
 proc getpasswd {passwdfile} {
     if {[catch {open $passwdfile r} passwdfile_fd]} {
@@ -61,24 +78,16 @@
     return $passwd
 }
 
-# Needed escaping for some strings output as sql statements.
-proc sql_escape {str} {
-        regsub -all -- {'} $str {\\'} str
-        regsub -all -- {"} $str {\\"} str
-        regsub -all -- {\n} $str {\\n} str
-        return $str
-}
-
-
-# Abstraction variables:
+# Database abstraction variables:
 set sqlfile [file join /tmp ports.sql]
 set dbcmd [macports::findBinary mysql5]
+set dbhost 127.0.0.1
 set dbname macports
+set dbuser macports
 set passwdfile [file join . password_file]
 set dbpasswd [getpasswd $passwdfile]
-set dbcmdargs "$dbname --password=$dbpasswd"
+set dbcmdargs "-h $dbhost -u $dbuser -p$dbpasswd $dbname"
 
-
 # Flat text file to which sql statements are written.
 if {[catch {open $sqlfile w+} sqlfile_fd]} {
     ui_error "${::errorCode}: $sqlfile_fd"
@@ -86,6 +95,14 @@
 }
 
 
+# SQL string escaping.
+proc sql_escape {str} {
+        regsub -all -- {'} $str {\\'} str
+        regsub -all -- {"} $str {\\"} str
+        regsub -all -- {\n} $str {\\n} str
+        return $str
+}
+
 # Initial creation of database tables: log, portfiles, categories, maintainers, dependencies, variants and platforms.
 # Do we need any other?
 puts $sqlfile_fd "DROP TABLE log"

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


More information about the macports-changes mailing list