private function getRequiredPool($packageName, $textConstraint, $onlyLocal)
    {
        if ($onlyLocal === false) {
            return $this->getPool();
        }
        $composer = $this->getComposer();
        $pool = new Pool();

        // Prepare repositories and set up a pool
        $platformOverrides = $composer->getConfig()->get('platform') ?: [];
        /** @var BasePackage $rootPackage */
        $rootPackage = $composer->getPackage();
        if ($rootPackage->getRepository() === null) {
            $packageRepo = new ArrayRepository([$composer->getPackage()]);

            $localRepo = $composer->getRepositoryManager()->getLocalRepository();
            $platformRepo = new PlatformRepository([], $platformOverrides);
            $compositeRepository = new CompositeRepository([$packageRepo, $localRepo, $platformRepo]);

            $pool->addRepository($compositeRepository);

            $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
            $match = $defaultRepos->findPackage($packageName, $textConstraint);
            if ($match) {
                $compositeRepository->addRepository(new ArrayRepository([clone $match]));
            }
        }

        return $pool;
    }