<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build(self, client, nobuild=False, usecache=True, pull=False):
 """ Drives the build of the final image - get the list of steps and execute them. Args: client (docker.Client):
 docker client object that will build the image nobuild (bool):
 just create dockerfiles, don't actually build the image usecache (bool):
 use docker cache, or rebuild everything from scratch? pull (bool):
 try to pull new versions of repository images? """

        if not nobuild:
            self.update_source_images(client,
                                      usecache=usecache,
                                      pull=pull)

        width = utils.get_console_width()
        cprint('\n' + '='*width,
               color='white', attrs=['bold'])

        line = 'STARTING BUILD for "%s" (image definition "%s" from %s)\n' % (
            self.targetname, self.imagename, self.steps[-1].sourcefile)

        cprint(_centered(line, width), color='blue', attrs=['bold'])

        for istep, step in enumerate(self.steps):
            print(colored('* Step','blue'),
                  colored('%d/%d' % (istep+1, len(self.steps)), 'blue', attrs=['bold']),
                  colored('for image', color='blue'),
                  colored(self.imagename, color='blue', attrs=['bold']))

            if not nobuild:
                if step.bust_cache:
                    stackkey = self._get_stack_key(istep)
                    if stackkey in _rebuilt:
                        step.bust_cache = False

                step.build(client, usecache=usecache)
                print(colored("* Created intermediate image", 'green'),
                      colored(step.buildname, 'green', attrs=['bold']),
                      end='\n\n')

                if step.bust_cache:
                    _rebuilt.add(stackkey)

        finalimage = step.buildname

        if not nobuild:
            self.finalizenames(client, finalimage)
            line = 'FINISHED BUILDING "%s" (image definition "%s" from %s)'%(
                self.targetname, self.imagename, self.steps[-1].sourcefile)
            cprint(_centered(line, width),
                   color='green', attrs=['bold'])
            cprint('=' * width, color='white', attrs=['bold'], end='\n\n')