Changeset 27826


Ignore:
Timestamp:
Aug 14, 2007, 9:38:44 PM (13 years ago)
Author:
jmpp@…
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/portmgr/packaging/PortIndex2MySQL.tcl

    r27510 r27826  
    3838
    3939
     40# Error messages reciepient.
     41set SPAM_LOVERS macports-dev@lists.macosforge.org
     42
     43# Place holder proc for error catching and processing.
     44proc bail_on_error {error_log} {
     45   
     46}
     47
     48
    4049# Load macports1.0 so that we can use some of its procs and the portinfo array.
    4150catch {source \
     
    4554# Initialize MacPorts to find the sources.conf file, wherefrom we'll
    4655# get the PortIndex that'll feed the database.
     56#more work needs to be done than just initializing and passing the
     57#ui_options array to get mportinit to output verbose/debugging info;
     58#I'm currently looking into this.
     59array set ui_options {ports_verbose yes}
    4760mportinit
     61
     62# Call the selfupdate procedure to make sure the MacPorts installation
     63# is up-to-date and with a fresh ports tree.
     64macports::selfupdate
    4865
    4966
     
    6279}
    6380
    64 # Needed escaping for some strings output as sql statements.
     81# Database abstraction variables:
     82set sqlfile [file join /tmp ports.sql]
     83set dbcmd [macports::findBinary mysql5]
     84set dbhost 127.0.0.1
     85set dbname macports
     86set dbuser macports
     87set passwdfile [file join . password_file]
     88set dbpasswd [getpasswd $passwdfile]
     89set dbcmdargs "-h $dbhost -u $dbuser -p$dbpasswd $dbname"
     90
     91# Flat text file to which sql statements are written.
     92if {[catch {open $sqlfile w+} sqlfile_fd]} {
     93    ui_error "${::errorCode}: $sqlfile_fd"
     94    exit 1
     95}
     96
     97
     98# SQL string escaping.
    6599proc sql_escape {str} {
    66100        regsub -all -- {'} $str {\\'} str
     
    69103        return $str
    70104}
    71 
    72 
    73 # Abstraction variables:
    74 set sqlfile [file join /tmp ports.sql]
    75 set dbcmd [macports::findBinary mysql5]
    76 set dbname macports
    77 set passwdfile [file join . password_file]
    78 set dbpasswd [getpasswd $passwdfile]
    79 set dbcmdargs "$dbname --password=$dbpasswd"
    80 
    81 
    82 # Flat text file to which sql statements are written.
    83 if {[catch {open $sqlfile w+} sqlfile_fd]} {
    84     ui_error "${::errorCode}: $sqlfile_fd"
    85     exit 1
    86 }
    87 
    88105
    89106# Initial creation of database tables: log, portfiles, categories, maintainers, dependencies, variants and platforms.
Note: See TracChangeset for help on using the changeset viewer.