'Build the bundle.'

def build(self):

    builddir = self.builddir
    if (builddir and (not os.path.exists(builddir))):
        os.mkdir(builddir)
    self.message(('Building    %s' % repr(self.bundlepath)), 1)
    if os.path.exists(self.bundlepath):
        shutil.rmtree(self.bundlepath)
    if os.path.exists((self.bundlepath + '~')):
        shutil.rmtree((self.bundlepath + '~'))
    bp = self.bundlepath
    self.bundlepath = (bp + '~')
    try:
        os.mkdir(self.bundlepath)
        self.preProcess()
        self._copyFiles()
        self._addMetaFiles()
        self.postProcess()
        os.rename(self.bundlepath, bp)
    finally:
        self.bundlepath = bp
    self.message('Done.', 1)
