Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/script/autobuild.py

    r740 r988  
    88from optparse import OptionParser
    99import smtplib
     10import email
    1011from email.mime.text import MIMEText
    11 
    12 samba_master = os.getenv('SAMBA_MASTER', 'git://git.samba.org/samba.git')
    13 samba_master_ssh = os.getenv('SAMBA_MASTER_SSH', 'git+ssh://git.samba.org/data/git/samba.git')
     12from email.mime.base import MIMEBase
     13from email.mime.application import MIMEApplication
     14from email.mime.multipart import MIMEMultipart
     15from distutils.sysconfig import get_python_lib
     16import platform
     17
     18# This speeds up testing remarkably.
     19os.environ['TDB_NO_FSYNC'] = '1'
    1420
    1521cleanup_list = []
    1622
    17 os.environ['CC'] = "ccache gcc"
    18 
    1923builddirs = {
    20     "samba3"  : "source3",
    21     "samba3-waf": "source3",
    22     "samba4"  : ".",
    23     "ldb"     : "source4/lib/ldb",
     24    "ctdb"    : "ctdb",
     25    "samba"  : ".",
     26    "samba-xc" : ".",
     27    "samba-ctdb" : ".",
     28    "samba-libs"  : ".",
     29    "samba-static"  : ".",
     30    "ldb"     : "lib/ldb",
    2431    "tdb"     : "lib/tdb",
    2532    "talloc"  : "lib/talloc",
     
    3239    }
    3340
    34 defaulttasks = [ "samba3", "samba3-waf", "samba4", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ]
     41defaulttasks = [ "ctdb", "samba", "samba-xc", "samba-ctdb", "samba-libs", "samba-static", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ]
     42
     43samba_configure_params = " --picky-developer ${PREFIX} --with-profiling-data"
     44
     45samba_libs_envvars =  "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH"
     46samba_libs_envvars += " PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig"
     47samba_libs_envvars += " ADDITIONAL_CFLAGS='-Wmissing-prototypes'"
     48samba_libs_configure_base = samba_libs_envvars + " ./configure --abi-check --enable-debug --picky-developer -C ${PREFIX}"
     49samba_libs_configure_libs = samba_libs_configure_base + " --bundled-libraries=NONE"
     50samba_libs_configure_samba = samba_libs_configure_base + " --bundled-libraries=!talloc,!pytalloc-util,!tdb,!pytdb,!ldb,!pyldb,!pyldb-util,!tevent,!pytevent"
    3551
    3652tasks = {
    37     "samba3" : [ ("autogen", "./autogen.sh", "text/plain"),
    38                  ("configure", "./configure.developer ${PREFIX}", "text/plain"),
    39                  ("make basics", "make basics", "text/plain"),
    40                  ("make", "make -j 4 everything", "text/plain"), # don't use too many processes
    41                  ("install", "make install", "text/plain"),
    42                  ("test", "TDB_NO_FSYNC=1 make test FAIL_IMMEDIATELY=1", "text/plain"),
    43                  ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"),
    44                  ("clean", "make clean", "text/plain") ],
    45 
    46     "samba3-waf" : [ ("autogen", "./autogen-waf.sh", "text/plain"),
    47                  ("configure", "./configure.developer ${PREFIX}", "text/plain"),
    48                  ("make", "make -j", "text/plain"),
    49                  ("install", "make install", "text/plain"),
    50                  ("clean", "make clean", "text/plain") ],
     53    "ctdb" : [ ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"),
     54               ("configure", "./configure ${PREFIX}", "text/plain"),
     55               ("make", "make all", "text/plain"),
     56               ("install", "make install", "text/plain"),
     57               ("test", "make autotest", "text/plain"),
     58               ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"),
     59               ("clean", "make clean", "text/plain") ],
    5160
    5261    # We have 'test' before 'install' because, 'test' should work without 'install'
    53     "samba4" : [ ("configure", "./configure.developer ${PREFIX}", "text/plain"),
    54                  ("make", "make -j", "text/plain"),
    55                  ("test", "TDB_NO_FSYNC=1 make test FAIL_IMMEDIATELY=1", "text/plain"),
    56                  ("install", "make install", "text/plain"),
    57                  ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"),
    58                  ("clean", "make clean", "text/plain") ],
    59 
    60     "ldb" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
    61               ("make", "make -j", "text/plain"),
    62               ("install", "make install", "text/plain"),
    63               ("test", "TDB_NO_FSYNC=1 make test", "text/plain"),
    64               ("check-clean-tree", "../../../script/clean-source-tree.sh", "text/plain"),
    65               ("distcheck", "make distcheck", "text/plain"),
    66               ("clean", "make clean", "text/plain") ],
    67 
    68     # We don't use TDB_NO_FSYNC=1 here, because we want to test the transaction code
    69     "tdb" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
    70               ("make", "make -j", "text/plain"),
     62    "samba" : [ ("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"),
     63                ("make", "make -j", "text/plain"),
     64                ("test", "make test FAIL_IMMEDIATELY=1", "text/plain"),
     65                ("install", "make install", "text/plain"),
     66                ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"),
     67                ("clean", "make clean", "text/plain") ],
     68
     69    # Test cross-compile infrastructure
     70    "samba-xc" : [ ("configure-native", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"),
     71                   ("configure-cross-execute", "./configure.developer -b ./bin-xe --cross-compile --cross-execute=script/identity_cc.sh" \
     72                    " --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xe/ab" + samba_configure_params, "text/plain"),
     73                   ("configure-cross-answers", "./configure.developer -b ./bin-xa --cross-compile" \
     74                    " --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xa/ab" + samba_configure_params, "text/plain"),
     75                   ("compare-results", "script/compare_cc_results.py ./bin/c4che/default.cache.py ./bin-xe/c4che/default.cache.py ./bin-xa/c4che/default.cache.py", "text/plain")],
     76
     77
     78    "samba-ctdb" : [ ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
     79
     80                     # make sure we have tdb around:
     81                     ("tdb-configure", "cd lib/tdb && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
     82                     ("tdb-make", "cd lib/tdb && make", "text/plain"),
     83                     ("tdb-install", "cd lib/tdb && make install", "text/plain"),
     84
     85
     86                     # build samba with cluster support (also building ctdb):
     87                     ("samba-configure", "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure.developer --picky-developer ${PREFIX} --with-selftest-prefix=./bin/ab --with-cluster-support --bundled-libraries=!tdb", "text/plain"),
     88                     ("samba-make", "make", "text/plain"),
     89                     ("samba-check", "./bin/smbd -b | grep CLUSTER_SUPPORT", "text/plain"),
     90                     ("samba-install", "make install", "text/plain"),
     91                     ("ctdb-check", "test -e ${PREFIX_DIR}/sbin/ctdbd", "text/plain"),
     92
     93                     # clean up:
     94                     ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"),
     95                     ("clean", "make clean", "text/plain"),
     96                     ("ctdb-clean", "cd ./ctdb && make clean", "text/plain") ],
     97
     98    "samba-libs" : [
     99                      ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
     100                      ("talloc-configure", "cd lib/talloc && " + samba_libs_configure_libs, "text/plain"),
     101                      ("talloc-make", "cd lib/talloc && make", "text/plain"),
     102                      ("talloc-install", "cd lib/talloc && make install", "text/plain"),
     103
     104                      ("tdb-configure", "cd lib/tdb && " + samba_libs_configure_libs, "text/plain"),
     105                      ("tdb-make", "cd lib/tdb && make", "text/plain"),
     106                      ("tdb-install", "cd lib/tdb && make install", "text/plain"),
     107
     108                      ("tevent-configure", "cd lib/tevent && " + samba_libs_configure_libs, "text/plain"),
     109                      ("tevent-make", "cd lib/tevent && make", "text/plain"),
     110                      ("tevent-install", "cd lib/tevent && make install", "text/plain"),
     111
     112                      ("ldb-configure", "cd lib/ldb && " + samba_libs_configure_libs, "text/plain"),
     113                      ("ldb-make", "cd lib/ldb && make", "text/plain"),
     114                      ("ldb-install", "cd lib/ldb && make install", "text/plain"),
     115
     116                      ("nondevel-configure", "./configure ${PREFIX}", "text/plain"),
     117                      ("nondevel-make", "make -j", "text/plain"),
     118                      ("nondevel-check", "./bin/smbd -b | grep WITH_NTVFS_FILESERVER && exit 1; exit 0", "text/plain"),
     119                      ("nondevel-install", "make install", "text/plain"),
     120                      ("nondevel-dist", "make dist", "text/plain"),
     121
     122                      # retry with all modules shared
     123                      ("allshared-distclean", "make distclean", "text/plain"),
     124                      ("allshared-configure", samba_libs_configure_samba + " --with-shared-modules=ALL", "text/plain"),
     125                      ("allshared-make", "make -j", "text/plain")],
     126
     127    "samba-static" : [
     128                      ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
     129                      # build with all modules static
     130                      ("allstatic-configure", "./configure.developer " + samba_configure_params + " --with-static-modules=ALL", "text/plain"),
     131                      ("allstatic-make", "make -j", "text/plain"),
     132
     133                      # retry without any required modules
     134                      ("none-distclean", "make distclean", "text/plain"),
     135                      ("none-configure", "./configure.developer " + samba_configure_params + " --with-static-modules=!FORCED,!DEFAULT --with-shared-modules=!FORCED,!DEFAULT", "text/plain"),
     136                      ("none-make", "make -j", "text/plain"),
     137
     138                      # retry with nonshared smbd and smbtorture
     139                      ("nonshared-distclean", "make distclean", "text/plain"),
     140                      ("nonshared-configure", "./configure.developer " + samba_configure_params + " --bundled-libraries=talloc,tdb,pytdb,ldb,pyldb,tevent,pytevent --with-static-modules=ALL --nonshared-binary=smbtorture,smbd/smbd", "text/plain"),
     141                      ("nonshared-make", "make -j", "text/plain")],
     142
     143    "ldb" : [
     144              ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
     145              ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
     146              ("make", "make", "text/plain"),
    71147              ("install", "make install", "text/plain"),
    72148              ("test", "make test", "text/plain"),
     
    75151              ("clean", "make clean", "text/plain") ],
    76152
    77     "talloc" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
    78                  ("make", "make -j", "text/plain"),
     153    "tdb" : [
     154              ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
     155              ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
     156              ("make", "make", "text/plain"),
     157              ("install", "make install", "text/plain"),
     158              ("test", "make test", "text/plain"),
     159              ("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
     160              ("distcheck", "make distcheck", "text/plain"),
     161              ("clean", "make clean", "text/plain") ],
     162
     163    "talloc" : [
     164                 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
     165                 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
     166                 ("make", "make", "text/plain"),
    79167                 ("install", "make install", "text/plain"),
    80168                 ("test", "make test", "text/plain"),
     
    83171                 ("clean", "make clean", "text/plain") ],
    84172
    85     "replace" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
    86                   ("make", "make -j", "text/plain"),
     173    "replace" : [
     174                  ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
     175                  ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
     176                  ("make", "make", "text/plain"),
    87177                  ("install", "make install", "text/plain"),
    88178                  ("test", "make test", "text/plain"),
     
    91181                  ("clean", "make clean", "text/plain") ],
    92182
    93     "tevent" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
    94                  ("make", "make -j", "text/plain"),
     183    "tevent" : [
     184                 ("random-sleep", "../../script/random-sleep.sh 60 600", "text/plain"),
     185                 ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
     186                 ("make", "make", "text/plain"),
    95187                 ("install", "make install", "text/plain"),
    96188                 ("test", "make test", "text/plain"),
     
    99191                 ("clean", "make clean", "text/plain") ],
    100192
    101     "pidl" : [ ("configure", "perl Makefile.PL PREFIX=${PREFIX_DIR}", "text/plain"),
     193    "pidl" : [
     194               ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"),
     195               ("configure", "perl Makefile.PL PREFIX=${PREFIX_DIR}", "text/plain"),
    102196               ("touch", "touch *.yp", "text/plain"),
    103197               ("make", "make", "text/plain"),
    104198               ("test", "make test", "text/plain"),
    105199               ("install", "make install", "text/plain"),
     200               ("checkout-yapp-generated", "git checkout lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm", "text/plain"),
    106201               ("check-clean-tree", "../script/clean-source-tree.sh", "text/plain"),
    107202               ("clean", "make clean", "text/plain") ],
     
    111206    'fail' : [ ("fail", 'echo failing && /bin/false', "text/plain") ]
    112207}
    113 
    114 retry_task = [ ( "retry",
    115                  '''set -e
    116                 git remote add -t master master %s
    117                 git fetch master
    118                 while :; do
    119                   sleep 60
    120                   git describe master/master > old_master.desc
    121                   git fetch master
    122                   git describe master/master > master.desc
    123                   diff old_master.desc master.desc
    124                 done
    125                ''' % samba_master, "test/plain" ) ]
    126208
    127209def run_cmd(cmd, dir=".", show=None, output=False, checkfail=True):
     
    141223    '''handle build of one directory'''
    142224
    143     def __init__(self, name, sequence):
     225    def __init__(self, name, sequence, cp=True):
    144226        self.name = name
    145227        self.dir = builddirs[name]
     
    164246        os.makedirs(self.sdir)
    165247        run_cmd("rm -rf %s" % self.sdir)
    166         run_cmd("git clone --shared %s %s" % (test_master, self.sdir), dir=test_master, show=True)
     248        if cp:
     249            run_cmd("cp --recursive --link --archive %s %s" % (test_master, self.sdir), dir=test_master, show=True)
     250        else:
     251            run_cmd("git clone --recursive --shared %s %s" % (test_master, self.sdir), dir=test_master, show=True)
    167252        self.start_next()
    168253
     
    173258            return
    174259        (self.stage, self.cmd, self.output_mime_type) = self.sequence[self.next]
     260        self.cmd = self.cmd.replace("${PYTHON_PREFIX}", get_python_lib(standard_lib=1, prefix=self.prefix))
    175261        self.cmd = self.cmd.replace("${PREFIX}", "--prefix=%s" % self.prefix)
    176262        self.cmd = self.cmd.replace("${PREFIX_DIR}", "%s" % self.prefix)
     
    189275    '''handle build of multiple directories'''
    190276
    191     def __init__(self, tasklist, tasknames):
     277    def __init__(self, tasklist, tasknames, rebase_url, rebase_branch="master"):
    192278        global tasks
    193279        self.tlist = []
     
    196282        if tasknames == []:
    197283            tasknames = defaulttasks
     284        else:
     285            # If we are only running one test,
     286            # do not sleep randomly to wait for it to start
     287            os.environ['AUTOBUILD_RANDOM_SLEEP_OVERRIDE'] = '1'
     288
    198289        for n in tasknames:
    199             b = builder(n, tasks[n])
     290            b = builder(n, tasks[n], cp=n is not "pidl")
    200291            self.tlist.append(b)
    201292        if options.retry:
    202             self.retry = builder('retry', retry_task)
     293            rebase_remote = "rebaseon"
     294            retry_task = [ ("retry",
     295                            '''set -e
     296                            git remote add -t %s %s %s
     297                            git fetch %s
     298                            while :; do
     299                              sleep 60
     300                              git describe %s/%s > old_remote_branch.desc
     301                              git fetch %s
     302                              git describe %s/%s > remote_branch.desc
     303                              diff old_remote_branch.desc remote_branch.desc
     304                            done
     305                           ''' % (
     306                               rebase_branch, rebase_remote, rebase_url,
     307                               rebase_remote,
     308                               rebase_remote, rebase_branch,
     309                               rebase_remote,
     310                               rebase_remote, rebase_branch
     311                           ),
     312                           "test/plain" ) ]
     313
     314            self.retry = builder('retry', retry_task, cp=False)
    203315            self.need_retry = False
    204316
     
    257369        return (0, None, None, None, "All OK")
    258370
     371    def write_system_info(self):
     372        filename = 'system-info.txt'
     373        f = open(filename, 'w')
     374        for cmd in ['uname -a', 'free', 'cat /proc/cpuinfo']:
     375            print >>f, '### %s' % cmd
     376            print >>f, run_cmd(cmd, output=True, checkfail=False)
     377            print >>f
     378        f.close()
     379        return filename
     380
    259381    def tarlogs(self, fname):
    260382        tar = tarfile.open(fname, "w:gz")
     
    264386        if os.path.exists("autobuild.log"):
    265387            tar.add("autobuild.log")
     388        sys_info = self.write_system_info()
     389        tar.add(sys_info)
    266390        tar.close()
    267391
     
    327451
    328452
    329 def rebase_tree(url):
    330     print("Rebasing on %s" % url)
     453def rebase_tree(rebase_url, rebase_branch = "master"):
     454    rebase_remote = "rebaseon"
     455    print("Rebasing on %s" % rebase_url)
    331456    run_cmd("git describe HEAD", show=True, dir=test_master)
    332     run_cmd("git remote add -t master master %s" % url, show=True, dir=test_master)
    333     run_cmd("git fetch master", show=True, dir=test_master)
     457    run_cmd("git remote add -t %s %s %s" %
     458            (rebase_branch, rebase_remote, rebase_url),
     459            show=True, dir=test_master)
     460    run_cmd("git fetch %s" % rebase_remote, show=True, dir=test_master)
    334461    if options.fix_whitespace:
    335         run_cmd("git rebase --whitespace=fix master/master", show=True, dir=test_master)
     462        run_cmd("git rebase --force-rebase --whitespace=fix %s/%s" %
     463                (rebase_remote, rebase_branch),
     464                show=True, dir=test_master)
    336465    else:
    337         run_cmd("git rebase master/master", show=True, dir=test_master)
    338     diff = run_cmd("git --no-pager diff HEAD master/master", dir=test_master, output=True)
     466        run_cmd("git rebase --force-rebase %s/%s" %
     467                (rebase_remote, rebase_branch),
     468                show=True, dir=test_master)
     469    diff = run_cmd("git --no-pager diff HEAD %s/%s" %
     470                   (rebase_remote, rebase_branch),
     471                   dir=test_master, output=True)
    339472    if diff == '':
    340         print("No differences between HEAD and master/master - exiting")
     473        print("No differences between HEAD and %s/%s - exiting" %
     474              (rebase_remote, rebase_branch))
    341475        sys.exit(0)
    342     run_cmd("git describe master/master", show=True, dir=test_master)
     476    run_cmd("git describe %s/%s" %
     477            (rebase_remote, rebase_branch),
     478            show=True, dir=test_master)
    343479    run_cmd("git describe HEAD", show=True, dir=test_master)
    344     run_cmd("git --no-pager diff --stat HEAD master/master", show=True, dir=test_master)
    345 
    346 def push_to(url):
    347     print("Pushing to %s" % url)
     480    run_cmd("git --no-pager diff --stat HEAD %s/%s" %
     481            (rebase_remote, rebase_branch),
     482            show=True, dir=test_master)
     483
     484def push_to(push_url, push_branch = "master"):
     485    push_remote = "pushto"
     486    print("Pushing to %s" % push_url)
    348487    if options.mark:
    349488        run_cmd("git config --replace-all core.editor script/commit_mark.sh", dir=test_master)
     
    351490        # the notes method doesn't work yet, as metze hasn't allowed refs/notes/* in master
    352491        # run_cmd("EDITOR=script/commit_mark.sh git notes edit HEAD", dir=test_master)
    353     run_cmd("git remote add -t master pushto %s" % url, show=True, dir=test_master)
    354     run_cmd("git push pushto +HEAD:master", show=True, dir=test_master)
     492    run_cmd("git remote add -t %s %s %s" %
     493            (push_branch, push_remote, push_url),
     494            show=True, dir=test_master)
     495    run_cmd("git push %s +HEAD:%s" %
     496            (push_remote, push_branch),
     497            show=True, dir=test_master)
    355498
    356499def_testbase = os.getenv("AUTOBUILD_TESTBASE", "/memdisk/%s" % os.getenv('USER'))
     500
     501gitroot = find_git_root()
     502if gitroot is None:
     503    raise Exception("Failed to find git root")
    357504
    358505parser = OptionParser()
     
    367514parser.add_option("", "--rebase", help="rebase on the given tree before testing",
    368515                  default=None, type='str')
    369 parser.add_option("", "--rebase-master", help="rebase on %s before testing" % samba_master,
    370                   default=False, action='store_true')
    371516parser.add_option("", "--pushto", help="push to a git url on success",
    372517                  default=None, type='str')
    373 parser.add_option("", "--push-master", help="push to %s on success" % samba_master_ssh,
    374                   default=False, action='store_true')
    375518parser.add_option("", "--mark", help="add a Tested-By signoff before pushing",
    376519                  default=False, action="store_true")
     
    381524parser.add_option("", "--email", help="send email to the given address on failure",
    382525                  type='str', default=None)
     526parser.add_option("", "--email-from", help="send email from the given address",
     527                  type='str', default="autobuild@samba.org")
     528parser.add_option("", "--email-server", help="send email via the given server",
     529                  type='str', default='localhost')
    383530parser.add_option("", "--always-email", help="always send email, even on success",
    384531                  action="store_true")
    385532parser.add_option("", "--daemon", help="daemonize after initial setup",
    386533                  action="store_true")
    387 
    388 
    389 def email_failure(status, failed_task, failed_stage, failed_tag, errstr):
     534parser.add_option("", "--branch", help="the branch to work on (default=master)",
     535                  default="master", type='str')
     536parser.add_option("", "--log-base", help="location where the logs can be found (default=cwd)",
     537                  default=gitroot, type='str')
     538parser.add_option("", "--attach-logs", help="Attach logs to mails sent on success/failure?",
     539                  default=False, action="store_true")
     540
     541def send_email(subject, text, log_tar):
     542    outer = MIMEMultipart()
     543    outer['Subject'] = subject
     544    outer['To'] = options.email
     545    outer['From'] = options.email_from
     546    outer['Date'] = email.utils.formatdate(localtime = True)
     547    outer.preamble = 'Autobuild mails are now in MIME because we optionally attach the logs.\n'
     548    outer.attach(MIMEText(text, 'plain'))
     549    if options.attach_logs:
     550        fp = open(log_tar, 'rb')
     551        msg = MIMEApplication(fp.read(), 'gzip', email.encoders.encode_base64)
     552        fp.close()
     553        # Set the filename parameter
     554        msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(log_tar))
     555        outer.attach(msg)
     556    content = outer.as_string()
     557    s = smtplib.SMTP(options.email_server)
     558    s.sendmail(options.email_from, [options.email], content)
     559    s.set_debuglevel(1)
     560    s.quit()
     561
     562def email_failure(status, failed_task, failed_stage, failed_tag, errstr,
     563                  elapsed_time, log_base=None):
    390564    '''send an email to options.email about the failure'''
     565    elapsed_minutes = elapsed_time / 60.0
    391566    user = os.getenv("USER")
     567    if log_base is None:
     568        log_base = gitroot
    392569    text = '''
    393570Dear Developer,
    394571
    395 Your autobuild failed when trying to test %s with the following error:
     572Your autobuild on %s failed after %.1f minutes
     573when trying to test %s with the following error:
     574
    396575   %s
    397576
     
    400579A summary of the autobuild process is here:
    401580
    402   http://git.samba.org/%s/samba-autobuild/autobuild.log
    403 ''' % (failed_task, errstr, user)
    404    
     581  %s/autobuild.log
     582''' % (platform.node(), elapsed_minutes, failed_task, errstr, log_base)
     583
    405584    if failed_task != 'rebase':
    406585        text += '''
    407586You can see logs of the failed task here:
    408587
    409   http://git.samba.org/%s/samba-autobuild/%s.stdout
    410   http://git.samba.org/%s/samba-autobuild/%s.stderr
     588  %s/%s.stdout
     589  %s/%s.stderr
    411590
    412591or you can get full logs of all tasks in this job here:
    413592
    414   http://git.samba.org/%s/samba-autobuild/logs.tar.gz
     593  %s/logs.tar.gz
    415594
    416595The top commit for the tree that was built was:
     
    418597%s
    419598
    420 ''' % (user, failed_tag, user, failed_tag, user, top_commit_msg)
    421     msg = MIMEText(text)
    422     msg['Subject'] = 'autobuild failure for task %s during %s' % (failed_task, failed_stage)
    423     msg['From'] = 'autobuild@samba.org'
    424     msg['To'] = options.email
    425 
    426     s = smtplib.SMTP()
    427     s.connect()
    428     s.sendmail(msg['From'], [msg['To']], msg.as_string())
    429     s.quit()
    430 
    431 def email_success():
     599''' % (log_base, failed_tag, log_base, failed_tag, log_base, top_commit_msg)
     600
     601    logs = os.path.join(gitroot, 'logs.tar.gz')
     602    send_email('autobuild failure on %s for task %s during %s'
     603               % (platform.node(), failed_task, failed_stage),
     604               text, logs)
     605
     606def email_success(elapsed_time, log_base=None):
    432607    '''send an email to options.email about a successful build'''
    433608    user = os.getenv("USER")
     609    if log_base is None:
     610        log_base = gitroot
    434611    text = '''
    435612Dear Developer,
    436613
    437 Your autobuild has succeeded.
    438 
    439 '''
     614Your autobuild on %s has succeeded after %.1f minutes.
     615
     616''' % (platform.node(), elapsed_time / 60.)
    440617
    441618    if options.keeplogs:
     
    444621you can get full logs of all tasks in this job here:
    445622
    446   http://git.samba.org/%s/samba-autobuild/logs.tar.gz
    447 
    448 ''' % user
     623  %s/logs.tar.gz
     624
     625''' % log_base
    449626
    450627    text += '''
     
    454631''' % top_commit_msg
    455632
    456     msg = MIMEText(text)
    457     msg['Subject'] = 'autobuild success'
    458     msg['From'] = 'autobuild@samba.org'
    459     msg['To'] = options.email
    460 
    461     s = smtplib.SMTP()
    462     s.connect()
    463     s.sendmail(msg['From'], [msg['To']], msg.as_string())
    464     s.quit()
     633    logs = os.path.join(gitroot, 'logs.tar.gz')
     634    send_email('autobuild sucess on %s ' % platform.node(),
     635               text, logs)
    465636
    466637
     
    468639
    469640if options.retry:
    470     if not options.rebase_master and options.rebase is None:
     641    if options.rebase is None:
    471642        raise Exception('You can only use --retry if you also rebase')
    472643
    473644testbase = "%s/b%u" % (options.testbase, os.getpid())
    474645test_master = "%s/master" % testbase
    475 
    476 gitroot = find_git_root()
    477 if gitroot is None:
    478     raise Exception("Failed to find git root")
    479646
    480647# get the top commit message, for emails
     
    494661write_pidfile(gitroot + "/autobuild.pid")
    495662
     663start_time = time.time()
     664
    496665while True:
    497666    try:
    498667        run_cmd("rm -rf %s" % test_master)
    499668        cleanup_list.append(test_master)
    500         run_cmd("git clone --shared %s %s" % (gitroot, test_master), show=True, dir=gitroot)
    501     except:
     669        run_cmd("git clone --recursive --shared %s %s" % (gitroot, test_master), show=True, dir=gitroot)
     670    except Exception:
    502671        cleanup()
    503672        raise
     
    506675        try:
    507676            if options.rebase is not None:
    508                 rebase_tree(options.rebase)
    509             elif options.rebase_master:
    510                 rebase_tree(samba_master)
    511         except:
    512             email_failure(-1, 'rebase', 'rebase', 'rebase', 'rebase on master failed')
     677                rebase_tree(options.rebase, rebase_branch=options.branch)
     678        except Exception:
     679            cleanup_list.append(gitroot + "/autobuild.pid")
     680            cleanup()
     681            elapsed_time = time.time() - start_time
     682            email_failure(-1, 'rebase', 'rebase', 'rebase',
     683                          'rebase on %s failed' % options.branch,
     684                          elapsed_time, log_base=options.log_base)
    513685            sys.exit(1)
    514         blist = buildlist(tasks, args)
     686        blist = buildlist(tasks, args, options.rebase, rebase_branch=options.branch)
    515687        if options.tail:
    516688            blist.start_tail()
     
    519691            break
    520692        cleanup()
    521     except:
     693    except Exception:
    522694        cleanup()
    523695        raise
     
    530702    time.sleep(1)
    531703
     704elapsed_time = time.time() - start_time
    532705if status == 0:
    533706    print errstr
     
    536709        run_cmd(options.passcmd, dir=test_master)
    537710    if options.pushto is not None:
    538         push_to(options.pushto)
    539     elif options.push_master:
    540         push_to(samba_master_ssh)
    541     if options.keeplogs:
     711        push_to(options.pushto, push_branch=options.branch)
     712    if options.keeplogs or options.attach_logs:
    542713        blist.tarlogs("logs.tar.gz")
    543714        print("Logs in logs.tar.gz")
    544715    if options.always_email:
    545         email_success()
     716        email_success(elapsed_time, log_base=options.log_base)
    546717    blist.remove_logs()
    547718    cleanup()
     
    553724
    554725if options.email is not None:
    555     email_failure(status, failed_task, failed_stage, failed_tag, errstr)
     726    email_failure(status, failed_task, failed_stage, failed_tag, errstr,
     727                  elapsed_time, log_base=options.log_base)
     728else:
     729    elapsed_minutes = elapsed_time / 60.0
     730    print '''
     731
     732####################################################################
     733
     734AUTOBUILD FAILURE
     735
     736Your autobuild on %s failed after %.1f minutes
     737when trying to test %s with the following error:
     738
     739   %s
     740
     741the autobuild has been abandoned. Please fix the error and resubmit.
     742
     743####################################################################
     744
     745''' % (platform.node(), elapsed_minutes, failed_task, errstr)
    556746
    557747cleanup()
Note: See TracChangeset for help on using the changeset viewer.