wok rev 3590

tazbb: Add tazbbmail (Python mailer for unbuilt pkgs)
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jun 28 01:50:53 2009 +0200 (2009-06-28)
parents d1675d177124
children 3540268bb56c
files tazbb/receipt tazbb/stuff/tazbb tazbb/stuff/tazbbmail
line diff
     1.1 --- a/tazbb/receipt	Sat Jun 27 22:23:09 2009 +0200
     1.2 +++ b/tazbb/receipt	Sun Jun 28 01:50:53 2009 +0200
     1.3 @@ -1,11 +1,12 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="tazbb"
     1.7 -VERSION="1.0"
     1.8 +VERSION="1.1"
     1.9  CATEGORY="development"
    1.10 -SHORT_DESC="SliTaz Build bot."
    1.11 +SHORT_DESC="SliTaz Build Bot."
    1.12  MAINTAINER="pankso@slitaz.org"
    1.13 -DEPENDS="tazpkg tazwok mercurial slitaz-toolchain"
    1.14 +DEPENDS="tazpkg tazwok python mercurial"
    1.15 +SUGGESTED="slitaz-toolchain postfix"
    1.16  WEB_SITE="http://labs.slitaz.org/wiki/distro/Bb"
    1.17  
    1.18  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.19 @@ -17,6 +18,7 @@
    1.20  		$fs/var/lib/tazbb \
    1.21  		$fs/var/log/tazbb
    1.22  	cp stuff/tazbb $fs/usr/bin
    1.23 +	cp stuff/tazbbmail $fs/usr/bin
    1.24  	cp stuff/tazbb.conf $fs/etc/slitaz
    1.25  	cp -a stuff/web $fs/var/lib/tazbb
    1.26  	chmod 755 $fs/usr/bin/*
     2.1 --- a/tazbb/stuff/tazbb	Sat Jun 27 22:23:09 2009 +0200
     2.2 +++ b/tazbb/stuff/tazbb	Sun Jun 28 01:50:53 2009 +0200
     2.3 @@ -48,6 +48,7 @@
     2.4    cook-commit  Cook all packages affected by a commit in the last update.
     2.5    test-pkgs    Execute a test suite on all packages [--verbose].
     2.6    [un]block    Block or unblock a package to skip or enable building.
     2.7 +  mail         Sent mail to packahe maitainer with tazbbmail.
     2.8    clean-up     Remove old packages [--verbose|--dry-run].
     2.9    clean-log    Remove all generated build log files.\n"
    2.10  }
    2.11 @@ -485,6 +486,10 @@
    2.12  		#
    2.13  		test_packages $@
    2.14  		script -c "tazwok check" $LOG_DIR/test-suite.log ;;
    2.15 +	mail)
    2.16 +		# Tazbbmail Pythom script wrapper.
    2.17 +		PACKAGE=$2
    2.18 +		tazbbmail $PACKAGE ;;
    2.19  	clean-up)
    2.20  		# Remove old packages and generate new packages lists.
    2.21  		update_wok $@
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tazbb/stuff/tazbbmail	Sun Jun 28 01:50:53 2009 +0200
     3.3 @@ -0,0 +1,50 @@
     3.4 +#!/usr/bin/python
     3.5 +#
     3.6 +# Part of SliTaz Build Bot - Send mail with cooklog url to a maintainer.
     3.7 +# (C) 2009 SliTaz GNU/Linux project -  GNU gpl v3
     3.8 +#
     3.9 +
    3.10 +import sys
    3.11 +import smtplib
    3.12 +
    3.13 +# We need a package name.
    3.14 +if len(sys.argv) != 2:
    3.15 +	print "Usage: tazbbmail package"
    3.16 +	sys.exit(1)
    3.17 +
    3.18 +# From, package name, receipt for email and version.
    3.19 +mailer  = "tazbb@slitaz.org"
    3.20 +package = (sys.argv[1])
    3.21 +receipt = "/home/slitaz/wok/%s/receipt" % package
    3.22 +
    3.23 +for line in open(receipt) :
    3.24 +	if "VERSION=" in line:
    3.25 +		version = line.split('"')[1]
    3.26 +	if "MAINTAINER=" in line:
    3.27 +		mailto = line.split('"')[1]
    3.28 +
    3.29 +# Format mail.
    3.30 +subject = "[tazbb] Unbuilt %s Cooklog" % package
    3.31 +cooklog = "http://bb.slitaz.org/log/%s.log" % package
    3.32 +
    3.33 +message = """\
    3.34 +From: %s
    3.35 +To: %s
    3.36 +Subject: %s
    3.37 +
    3.38 +Package : %s
    3.39 +Version : %s
    3.40 +Cooklog : %s
    3.41 +
    3.42 +--
    3.43 +Tazbb Mailer
    3.44 +""" % (mailer, mailto, subject, package, version, cooklog)
    3.45 +
    3.46 +# Send mail.
    3.47 +try:
    3.48 +	server = smtplib.SMTP("localhost")
    3.49 +	server.sendmail(mailer, mailto, message)
    3.50 +	server.quit()
    3.51 +	print "Successfully sent mail to: %s" % mailto
    3.52 +except SMTPException:
    3.53 +	print "Unable to send mail"