void testing_compile_base_meta_target::instantiate_impl(instantiation_context& ctx,
                                                        const main_target* owner,
                                                        const feature_set& build_request,
                                                        std::vector<basic_target*>* result,
                                                        feature_set* usage_requirements) const
{
   auto* suite = find_suite(get_project(), ctx);
   if (!suite) {
      typed_meta_target::instantiate_impl(ctx, owner, build_request, result, usage_requirements);
      return;
   }

   // we need to add <use> feature for sources found in testing.suite common-sources
   feature_set& new_build_request = *build_request.clone();
   for (const source_decl s : suite->common_sources()) {
      feature* source = get_engine().feature_registry().create_feature("use", "");
      source->set_dependency_data(s, &get_project());
      new_build_request.join(source);
   }

   typed_meta_target::instantiate_impl(ctx, owner, new_build_request, result, usage_requirements);
}
static int validate_mirror(void) {
	char *mir;
	char *host;
	char *dir;
	int valid;

	mir = add_protocol("mirror");
	host = add_protocol("hostname");
	dir = add_protocol("directory");

	if (! manual_entry) {
		char *mirror;

		/*
		 * Copy information about the selected
		 * mirror into mirror/{protocol}/{hostname,directory},
		 * which is the standard location other
		 * tools can look at.
		 */
		debconf_get(debconf, mir);
		mirror = strdup(debconf->value);
		debconf_set(debconf, host, mirror);
		debconf_set(debconf, dir, mirror_root(mirror));
		free(mirror);

		if (base_on_cd) {
			/* We have the base system on the CD, so instead of
			 * trying to contact the mirror (which might take
			 * some time to time out if there's no network
			 * connection), let's just assume that the CD will
			 * be sufficient to get a basic system up, setting
			 * suite to PREFERRED_DISTRIBUTION if unset and
			 * codename = suite. Note that this is an
			 * Ubuntu-specific change since (a) Debian netinst
			 * CDs etc. may not be able to install a complete
			 * system from the network and (b) codename != suite
			 * in Debian.
			 *
			 * We only do this for mirrors in our mirror list,
			 * since we assume that those have a good chance of
			 * not being typoed. For manually-entered mirrors,
			 * we still do full mirror validation.
			 */
			di_log(DI_LOG_LEVEL_INFO, "base system installable from CD; skipping mirror check");
			debconf_get(debconf, DEBCONF_BASE "suite");
			if (!*debconf->value) {
				di_log(DI_LOG_LEVEL_INFO, "falling back to suite %s", PREFERRED_DISTRIBUTION);
				debconf_set(debconf, DEBCONF_BASE "suite", PREFERRED_DISTRIBUTION);
			}
			debconf_get(debconf, DEBCONF_BASE "suite");
			di_log(DI_LOG_LEVEL_INFO, "falling back to codename %s", debconf->value);
			debconf_set(debconf, DEBCONF_BASE "codename", debconf->value);
			exit(0);
		}

		valid = find_suite();
	}
	else {
		/* check to see if the entered data is basically ok */
		int ok = 1;
		debconf_get(debconf, host);
		if (debconf->value == NULL || strcmp(debconf->value, "") == 0 || strchr(debconf->value, '/') != NULL) {
			ok = 0;
		}
		debconf_get(debconf, dir);
		if (debconf->value == NULL || strcmp(debconf->value, "") == 0) {
			ok = 0;
		}

		if (ok) {
			valid = find_suite();
		}
		else {
			valid = 0;
		}
	}

	free(mir);
	free(host);
	free(dir);

	if (valid) {
		return 0;
	}
	else {
		debconf_input(debconf, "critical", DEBCONF_BASE "bad");
		if (debconf_go(debconf) == 30)
			exit(10); /* back up to menu */
		else
			return 1; /* back to beginning of questions */
	}
}