[24688] trunk/base/portmgr/autosubmit.tcl

source_changes at macosforge.org source_changes at macosforge.org
Sun Apr 29 23:30:44 PDT 2007


Revision: 24688
          http://trac.macosforge.org/projects/macports/changeset/24688
Author:   jberry at macports.org
Date:     2007-04-29 23:30:43 -0700 (Sun, 29 Apr 2007)

Log Message:
-----------
Partial implementation of code to autosubmit changed ports to mpwa

Added Paths:
-----------
    trunk/base/portmgr/autosubmit.tcl

Added: trunk/base/portmgr/autosubmit.tcl
===================================================================
--- trunk/base/portmgr/autosubmit.tcl	                        (rev 0)
+++ trunk/base/portmgr/autosubmit.tcl	2007-04-30 06:30:43 UTC (rev 24688)
@@ -0,0 +1,101 @@
+#!/bin/sh
+#\
+exec /usr/bin/tclsh "$0" "$@"
+
+# Updates the distfiles to current distfiles by deleting old stuff.
+# Uses the database.
+# $Id: portmirror.tcl 24631 2007-04-29 05:35:59Z jmpp at macports.org $
+
+catch {source \
+	[file join "@TCL_PACKAGE_DIR@" darwinports1.0 darwinports_fastload.tcl]}
+package require darwinports
+package require sqlite3
+
+
+proc open_db {} {
+	# Open/create our database
+	sqlite3 db "/Users/jberry/autosubmit.sqlite3"
+	db timeout 10000
+	if { [llength [db eval {pragma table_info('SubmitInfo')}]] == 0 } {
+		db eval {
+			create table SubmitInfo (
+				porturl text unique,
+				lastsubmit datetime
+			)
+		}
+	}
+}
+
+
+proc close_db {} {
+	db close
+}
+
+
+proc sql_date { datetime } {
+	return [clock format $datetime -format "%Y-%m-%d %H:%M:%S"]
+}
+
+
+proc check_ports {} {
+	if {[catch {set res [dportsearch "^commons-.*\$"]} result]} {
+		puts "port search failed: $result"
+		exit 1
+	}
+	
+	foreach {name array} $res {
+		global prefix
+		array unset portinfo
+		array set portinfo $array
+	
+		if {![info exists portinfo(porturl)]} {
+			puts stderr "Internal error: no porturl for $name"
+			continue
+		}
+		
+		set porturl $portinfo(porturl)
+		if { 0 && 0 != [regexp {file://(.*)} $porturl match path] } {
+			set portdir [file normalize $path]
+		} else {
+			set portdir [file normalize [darwinports::getportdir $porturl]]
+		}
+		set portfile "${portdir}/Portfile"
+		puts "checking ${name}"
+	
+		if {[file readable $portfile]} {
+			set moddate [sql_date [file mtime $portfile]]
+			set values [db eval { select * from submitinfo where porturl=$porturl and $moddate <= lastsubmit }]
+			if { [llength $values] == 0 } {
+				puts "submitting ${name}"
+				
+				if {[catch {set workername [dportopen $porturl]} result]} {
+					global errorInfo
+					ui_debug "$errorInfo"
+					puts "Unable to open port: $result"
+					continue
+				}
+				
+				if {[catch {set result [dportexec $workername submit]} result]} {
+					global errorInfo
+					dportclose $workername
+					ui_debug "$errorInfo"
+					puts "Unable to execute port: $result"
+					continue
+				}
+		
+				dportclose $workername
+		
+				
+				db eval { insert or replace into submitinfo (porturl,lastsubmit) values ($porturl, $moddate) }
+			}
+		}
+		
+	}
+}
+
+
+# Initialize dports api
+dportinit
+open_db
+check_ports
+close_db
\ No newline at end of file


Property changes on: trunk/base/portmgr/autosubmit.tcl
___________________________________________________________________
Name: svn:executable
   + *

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


More information about the macports-changes mailing list