[29359] trunk/base/portmgr/PortIndex2MySQL.tcl
source_changes at macosforge.org
source_changes at macosforge.org
Fri Sep 21 19:16:16 PDT 2007
Revision: 29359
http://trac.macosforge.org/projects/macports/changeset/29359
Author: jmpp at macports.org
Date: 2007-09-21 19:16:15 -0700 (Fri, 21 Sep 2007)
Log Message:
-----------
Reworked cleanup proc that handles a variable number of arguments, thus letting us cherry pick what file to clean
whenever we need to call it up (I know the overall result might seem a little too involved for what should be an
otherwise simple script... but at least things are working dandy ;-).
Modified Paths:
--------------
trunk/base/portmgr/PortIndex2MySQL.tcl
Modified: trunk/base/portmgr/PortIndex2MySQL.tcl
===================================================================
--- trunk/base/portmgr/PortIndex2MySQL.tcl 2007-09-22 01:02:49 UTC (rev 29358)
+++ trunk/base/portmgr/PortIndex2MySQL.tcl 2007-09-22 02:16:15 UTC (rev 29359)
@@ -72,12 +72,13 @@
set SPAM_LOVERS macports-dev at lists.macosforge.org
# House keeping on exit.
-proc cleanup {} {
- global sqlfile sqlfile_fd
- global lockfile lockfile_fd
- close $sqlfile_fd
- close $lockfile_fd
- file delete -force $sqlfile $lockfile
+proc cleanup {args} {
+ foreach file_to_clean $args {
+ upvar $file_to_clean up_file_to_clean
+ upvar ${file_to_clean}_fd up_file_to_clean_fd
+ close $up_file_to_clean_fd
+ file delete -force $up_file_to_clean
+ }
}
# What to do when terminating execution, depending on the $exit_status condition.
@@ -145,7 +146,7 @@
if {[catch {mportinit ui_options} errstr]} {
ui_error "${::errorInfo}"
ui_error "Failed to initialize MacPorts, $errstr"
-#(BUG: need to cleanup lock file here!)
+ cleanup lockfile
terminate 1
}
@@ -154,7 +155,7 @@
if {[catch {macports::selfupdate} errstr]} {
ui_error "${::errorInfo}"
ui_error "Failed to update the ports tree, $errstr"
-#(BUG: need to cleanup lock file here!)
+ cleanup lockfile
terminate 1
}
@@ -163,13 +164,13 @@
proc getpasswd {passwdfile} {
if {[catch {open $passwdfile r} passwdfile_fd]} {
ui_error "${::errorCode}: $passwdfile_fd"
-#(BUG: need to cleanup lock file here!)
+ cleanup lockfile
terminate 1
}
if {[gets $passwdfile_fd passwd] <= 0} {
close $passwdfile_fd
ui_error "No password found in $passwdfile!"
-#(BUG: need to cleanup lock file here!)
+ cleanup lockfile
terminate 1
}
close $passwdfile_fd
@@ -187,10 +188,9 @@
# Flat text file to which sql statements are written.
-#(BUG: need to cleanup lock file here!)
if {[catch {open $sqlfile w+} sqlfile_fd]} {
ui_error "${::errorCode}: $sqlfile_fd"
-#(BUG: need to cleanup lock file here!)
+ cleanup lockfile
terminate 1
}
@@ -231,7 +231,7 @@
if {[catch {set ports [mportsearch ".+"]} errstr]} {
ui_error "${::errorInfo}"
ui_error "port search failed: $errstr"
- cleanup
+ cleanup sqlfile lockfile
terminate 1
}
@@ -338,16 +338,16 @@
# reading from the file descriptor for the raw sql file to assure completeness.
if {[catch {seek $sqlfile_fd 0 start} errstr]} {
ui_error "${::errorCode}: $errstr"
- cleanup
+ cleanup sqlfile lockfile
terminate 1
}
if {[catch {exec -- $dbcmd --host=$dbhost --user=$dbuser --password=$dbpasswd --database=$dbname <@ $sqlfile_fd} errstr]} {
ui_error "${::errorCode}: $errstr"
- cleanup
+ cleanup sqlfile lockfile
terminate 1
}
# And we're done regen'ing the MacPorts dabase! Cleanup and exit successfully.
-cleanup
+cleanup sqlfile lockfile
terminate 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070921/47774932/attachment.html
More information about the macports-changes
mailing list