Ejemplo n.º 1
0
def upgradeMaster(config):
    basedir = os.path.expanduser(config['basedir'])
    m = Maker(config)
    # TODO: check Makefile
    # TODO: check TAC file
    # check web files: index.html, default.css, robots.txt
    m.upgrade_public_html({
          'bg_gradient.jpg' : util.sibpath(__file__, "../status/web/files/bg_gradient.jpg"),
          'default.css' : util.sibpath(__file__, "../status/web/files/default.css"),
          'robots.txt' : util.sibpath(__file__, "../status/web/files/robots.txt"),
      })
    m.populate_if_missing(os.path.join(basedir, "master.cfg.sample"),
                          util.sibpath(__file__, "sample.cfg"),
                          overwrite=True)
    # if index.html exists, use it to override the root page tempalte
    m.move_if_present(os.path.join(basedir, "public_html/index.html"),
                      os.path.join(basedir, "templates/root.html"))

    from buildbot.db import create_or_upgrade_db, DBSpec
    dbspec = DBSpec.from_url(config["db"], basedir)
    # TODO: check that TAC file specifies the right spec
    db = create_or_upgrade_db(dbspec)
    db.start()
    # if we still have a changes.pck, then we need to migrate it
    changes_pickle = os.path.join(basedir, "changes.pck")
    if os.path.exists(changes_pickle):
        if not config['quiet']: print "migrating changes.pck to database"
        migrate_changes_pickle_to_db(changes_pickle, db, silent=config['quiet'])
        if not config['quiet']: print "moving old changes.pck to changes.pck.old"
        os.rename(changes_pickle, changes_pickle+".old")
    db.stop()

    rc = m.check_master_cfg()
    if rc:
        return rc
    if not config['quiet']: print "upgrade complete"
    return 0
Ejemplo n.º 2
0
 def test_create_or_upgrade_db_existingOK(self):
     self.makeFakeDB()
     conn = self.trackConn(db.create_or_upgrade_db(self.dbspec))
     self.assertEqual(conn.runQueryNow("SELECT * from version"), [(1,)])