'Fetch the package into dest_dir from repo_url. By default repo_url
is None and the package is looked in all the repositories specified.
Otherwise it fetches it from the specific repo_url.
pkg_name     : name of the package (ex: test-sleeptest.tar.bz2,
dep-gcc.tar.bz2, kernel.1-1.rpm)
repo_url     : the URL of the repository where the package is located.
dest_path    : complete path of where the package will be fetched to.
use_checksum : This is set to False to fetch the packages.checksum file
so that the checksum comparison is bypassed for the
checksum file itself. This is used internally by the
packaging system. It should be ignored by externals
callers of this method who use it fetch custom packages.
install      : install path has unique name and destination requirements
that vary based on the fetcher that is used.  So call them
here as opposed to install_pkg.'

def fetch_pkg(self, pkg_name, dest_path, repo_url=None, use_checksum=False, install=False):

    try:
        self._run_command(('ls    %s' % os.path.dirname(dest_path)))
    except (error.CmdError, error.AutoservRunError):
        raise error.PackageFetchError(('Please    provide    a    valid    destination:    %s    ' % dest_path))
    pkg_exists = False
    try:
        self._run_command(('ls    %s' % dest_path))
        pkg_exists = True
    except (error.CmdError, error.AutoservRunError):
        pass
    if repo_url:
        repositories = [self.get_fetcher(repo_url)]
    elif self.repositories:
        repositories = self.repositories
    else:
        raise error.PackageFetchError('No    repository    urls    specified')
    for fetcher in reversed(repositories):
        try:
            if isinstance(fetcher, GitFetcher):
                use_checksum = False
            dest = fetcher.install_pkg_setup(pkg_name, dest_path, install)[1]
            need_to_fetch = ((not use_checksum) or (not pkg_exists) or (not self.compare_checksum(dest, fetcher.url)))
            if need_to_fetch:
                fetcher.fetch_pkg_file(pkg_name, dest)
                if use_checksum:
                    self.update_checksum(dest)
            return fetcher
        except (error.PackageFetchError, error.AutoservRunError):
            logging.debug('%s    could    not    be    fetched    from    %s', pkg_name, fetcher.url)
    repo_url_list = [repo.url for repo in repositories]
    message = ('%s    could    not    be    fetched    from    any    of    the    repos    %s' % (pkg_name, repo_url_list))
    logging.error(message)
    raise error.PackageFetchError(message)
