SVN: toys/stbr/stbr.tcl

shadzik shadzik at pld-linux.org
Fri Sep 26 17:29:02 CEST 2008


Author: shadzik
Date: Fri Sep 26 17:29:02 2008
New Revision: 9876

Modified:
   toys/stbr/stbr.tcl
Log:
- version 0.8 (RC2)
- add maintenance mode
- add Titanium functionality


Modified: toys/stbr/stbr.tcl
==============================================================================
--- toys/stbr/stbr.tcl	(original)
+++ toys/stbr/stbr.tcl	Fri Sep 26 17:29:02 2008
@@ -1,31 +1,32 @@
 # Send To Builder Request TCL by shadzik at pld-linux.org
 
-set reqbook "./scripts/requesters.txt"
+set cmdbook "./scripts/cmdbook.txt"
 set logfile "/home/users/stbr/db/stbrlog.db"
-set file "./scripts/cvslog.sh"
+set script "./scripts/cvslog.sh"
 set makereq "./pld-builder.new/client/make-request.sh"
 set back &
 set cntr 0
 set cvsroot ":pserver:cvs at cvs.pld-linux.org:/cvsroot"
-set usage "Usage: !stbr \[help\] \[url\] \[no\]upgrade spec1\[:BRANCH\] spec2\[:BRANCH\] ..."
+set usage "Usage: !stbr \[help\] \[url\] th\|ti \[command \<valid builder command\>\] \[no\]upgrade spec1\[:BRANCH\] spec2\[:BRANCH\] ..."
 set nickpass "stbr-bot"
+set cmdtxt "./scripts/cmd.txt"
+set maintenance "./scripts/maintenance.txt"
 
 bind notc - "*This nickname is owned by someone else*" identify
 bind dcc n identify man_identify 
 
 proc man_identify { hand idx mask } {
-	global nickpass
+global nickpass
 	putserv "PRIVMSG NickServ :identify $nickpass"
 	putlog "Sending Identify to NickServ"
 }
 
 proc identify { nick uhost hand text } {
-	global nickpass
+global nickpass
 	putserv "PRIVMSG NickServ :identify $nickpass"
 	putlog "Sending Identify to NickServ"
 }
 
-
 proc help {nick} {
 	global usage
 	putserv "privmsg $nick :$usage"
@@ -44,9 +45,8 @@
 	putserv "privmsg $nick :Visit http://stbr.pld-linux.org/ to see the status of your request."
 }
 
-proc random {} {
-	global reqbook
-	set file [open $reqbook r]
+proc random {book} {
+	set file [open $book r]
 	gets $file hands
 	set range [llength $hands]
 	close $file
@@ -54,19 +54,28 @@
 	return [lindex $hands $whichone]
 }
 
-proc sendto {spec branch} {
-	global cvsroot reqbook
-	if {([string match HEAD $branch])} {set cmd "-N"} {set cmd "-r$branch"}
-	if {[catch {exec cvs -d $cvsroot log $cmd SPECS/$spec | awk {/author/{a = $6; sub(/;/, "", a); if (!seen[a]) print a; seen[a] = 1}}} results]} {return 0}
-	set file [open $reqbook r]
-	gets $file lista
-	close $file
-	foreach devil $results {
-		foreach requester $lista {
-			if {([string match $requester $devil])} {return $devil}
+proc sendto {dist spec branch} {
+global cvsroot
+if {([string match ti $dist])} {
+	set reqbook "./scripts/requesters-ti.txt"
+} {
+	set reqbook "./scripts/requesters.txt"
 }
+if {([string match HEAD $branch])} {set cmd "-N"} {set cmd "-r$branch"}
+if {[catch {exec cvs -d $cvsroot log $cmd SPECS/$spec | awk {/author/{a = $5; sub(/;/, "", a); if (!seen[a]) print a; seen[a] = 1}}} results]} {return 0}
+set file [open $reqbook r]
+gets $file lista
+close $file
+foreach devil $results {
+	foreach requester $lista {
+		if {([string match $requester $devil])} {return $devil}
+	}
 }
-random
+random $reqbook
+}
+
+proc command {exe} {
+if {[catch {exec which $exe} results]} {return 0}
 }
 
 bind pub * !stbr pub:stbr
@@ -74,35 +83,52 @@
 bind pub * stbr, pub:stbr
 
 proc pub:stbr {nick host hand chan arg} {
-	global file back cntr logfile usage makereq
-	putcmdlog "#$hand# Noticed Send To Build Request Mail command";
-	set first [lindex $arg 0]
-	if {([string match help $first])} {help $nick; return 0}
-	if {([string match url $first])} {url $nick; return 0}
-	set second [lindex $arg 1]
-	set specs ""; append specs $second; append specs " "; append specs [lrange $arg 2 end]
-	set rspecs ""
-	set tspecs ""
-	if {!([string match th-ready $first] || [string match th-test $first] || [string match noupgrade $first] || [string match upgrade $first])} {putserv "privmsg $chan :$nick: $usage"; return 0}
-	if {([string length $second]<2)} {putserv "privmsg $chan :$nick: $usage"; return 0}
-	if {$cntr<1} {incr cntr} {utimer 30 "set cntr 0"; putserv "privmsg $chan :$nick: I reached my STBR time limit (30sec). Please try later."; return 0}
-	if {([string match th-test $first] || [string match noupgrade $first])} {set first "test-build"}
-	if {([string match th-ready $first])} {set first "upgrade"}
-	set time [clock seconds]
-	set date [clock format $time -format "%Y-%m-%d %H:%M:%S"]
-	foreach spec $specs {
-		if {([string match *:* $spec])} {set splited [split $spec ":"];set spec [lindex $splited 0]; set branch [lindex $splited 1]} {set branch "HEAD"}
-		if {!([string match *.spec $spec])} { append spec ".spec"}
-		set towho [sendto $spec $branch]
-		if {($towho == 0)} {putserv "privmsg $chan :$nick: There is no such spec ($spec) on branch $branch in PLD's repository."; return 0}
-		lappend rspecs $spec; append rspecs ":$branch (to $towho)"
-		lappend tspecs $spec; append tspecs ":$branch"
-		if {([string match test-build $first])} {
-			if {[utimer 5 "exec $makereq -t $spec:$branch"]==0} {putserv "privmsg $chan :$nick: An error occured. Couldn't send test-build request for $spec to builders."; return 1}
-			exec sqlite $logfile "INSERT INTO application VALUES('$date','$spec','$branch','stbr','$first');"
+global script back cntr logfile usage makereq cmdbook cmdtxt maintenance
+if {([file exists $maintenance]) && (![matchattr $hand n|m])} {
+	set plik [open $maintenance r]
+	gets $plik reason
+	close $plik
+	putcmdlog "Maintenance mode active"
+	putserv "privmsg $chan :$nick: I'm now in maintenance mode (reason: $reason). Only owners may perform real actions."
+	return 0
+}
+putcmdlog "#$hand# Noticed Send To Build Request Mail command";
+set time [clock seconds]
+set date [clock format $time -format "%Y-%m-%d %H:%M:%S"]
+set first [lindex $arg 0]
+if {([string match help $first])} {help $nick; return 0}
+if {([string match url $first])} {url $nick; return 0}
+if {!([string match th $first] || [string match ti $first])} {
+	putserv "privmsg $chan :$nick: $usage"; return 0
+}
+set dist $first
+set second [lindex $arg 1]
+set third [lindex $arg 2]
+if {([string match command $second])} {
+	putserv "privmsg $chan :$nick: command not implemented yet."; return 0
+}
+set specs ""; append specs $third; append specs " "; append specs [lrange $arg 3 end]
+set rspecs ""
+set tspecs ""
+if {!([string match noupgrade $second] || [string match upgrade $second])} {
+	putserv "privmsg $chan :$nick: $usage"; return 0
+}
+if {([string length $third]<2)} {putserv "privmsg $chan :$nick: $usage"; return 0}
+if {$cntr<1} {incr cntr} {utimer 30 "set cntr 0"; putserv "privmsg $chan :$nick: I reached my STBR time limit (30sec). Please try later."; return 0}
+if {([string match noupgrade $second])} {set second "test-build"}
+foreach spec $specs {
+if {([string match *:* $spec])} {set splited [split $spec ":"];set spec [lindex $splited 0]; set branch [lindex $splited 1]} {set branch "HEAD"}
+if {!([string match *.spec $spec])} { append spec ".spec"}
+set towho [sendto $dist $spec $branch]
+if {($towho == 0)} {putserv "privmsg $chan :$nick: There is no such spec ($spec) on branch $branch in PLD's repository."; return 0}
+lappend rspecs $spec; append rspecs ":$branch (to $towho)"
+lappend tspecs $spec; append tspecs ":$branch"
+if {([string match test-build $second])} {
+	if {[utimer 5 "exec $makereq -d $dist -t $spec:$branch >/dev/null 2>&1"]==0} {putserv "privmsg $chan :$nick: An error occured. Couldn't send test-build request for $spec to builders."; return 1}
+	exec sqlite $logfile "INSERT INTO application VALUES('$date','$spec','$branch','stbr','$second','$dist');"
 } {
-	if {[exec $file $nick $first $spec $branch $towho]==0} {putserv "privmsg $chan :$nick: An error occured. Couldn't send STBR Mail for $spec to $towho."; return 1}
-	exec sqlite $logfile "INSERT INTO application VALUES('$date','$spec','$branch','$towho','$first');"
+	if {[exec $script $dist $nick $second $spec $branch $towho]==0} {putserv "privmsg $chan :$nick: An error occured. Couldn't send STBR Mail for $spec to $towho."; return 1}
+	exec sqlite $logfile "INSERT INTO application VALUES('$date','$spec','$branch','$towho','$second','$dist');"
 }
 }
 exec sqlite $logfile "INSERT INTO stbr VALUES('$date','$nick');"
@@ -110,12 +136,12 @@
 set day  [lindex $date 0]
 set hour [lindex $date 1]
 set space "%20"
-if {([string match test-build $first])} {
-	putserv "privmsg $chan :$nick: Sent $first request for $tspecs directly to builders. Visit http://stbr.pld-linux.org/?show=$nick&date=$day$space$hour to track your request."
+if {([string match test-build $second])} {
+	putserv "privmsg $chan :$nick: Sent $second request for $tspecs directly to PLD-$dist builders. Visit http://stbr.pld-linux.org/?show=$nick&date=$day$space$hour to track your request."
 } {
-	putserv "privmsg $chan :$nick: Sent STBR Mail for $rspecs. An $first will be performed. Visit http://stbr.pld-linux.org/?show=$nick&date=$day$space$hour to track your request."
+	putserv "privmsg $chan :$nick: Sent STBR Mail for $rspecs. An $second will be performed on PLD-$dist line. Visit http://stbr.pld-linux.org/?show=$nick&date=$day$space$hour to track your request."
 }
 if {$cntr<1} {incr cntr} {utimer 30 "set cntr 0"; return 1}
 }
 
-putlog "Send To Builder Request TCL v0.6 by shadzik loaded."
+putlog "Send To Builder Request TCL v0.8 by shadzik loaded."


More information about the pld-cvs-commit mailing list