def METHOD_NAME(tarball, out_dir, arches, toolchain):
    version = utils.GetVersion()
    tarroot = 'dart-%s' % version
    origtarname = 'dart_%s.orig.tar.gz' % version
    if not exists(tarball):
        print('Source tarball not found')
        return -1
    with utils.TempDir() as temp_dir:
        origtarball = join(temp_dir, origtarname)
        copyfile(tarball, origtarball)
        with tarfile.open(origtarball) as tar:
            tar.extractall(path=temp_dir)
        # Build source package.
        print("Building source package")
        RunBuildPackage(['-S', '-us', '-uc'], join(temp_dir, tarroot))
        # Build binary package(s).
        for arch in arches:
            print("Building %s package" % arch)
            RunBuildPackage(
                ['-B', '-a', GN_ARCH_TO_DEBIAN_ARCH[arch], '-us', '-uc'],
                join(temp_dir, tarroot))
        # Copy the Debian package files to the build directory.
        debbase = 'dart_%s' % version
        source_package = [
            '%s-1.dsc' % debbase,
            '%s.orig.tar.gz' % debbase,
            '%s-1.debian.tar.xz' % debbase
        ]
        for name in source_package:
            copyfile(join(temp_dir, name), join(out_dir, name))
        for arch in arches:
            name = '%s-1_%s.deb' % (debbase, GN_ARCH_TO_DEBIAN_ARCH[arch])
            copyfile(join(temp_dir, name), join(out_dir, name))