futility/updater_archive.c
/*
 * Finds the existing model_config from manifest that best matches current
 * system (as defined by model_name).
 * Returns a model_config from manifest, or NULL if not found.
 */
Finds the existing model_config from manifest that best matches current
system (as defined by model_name).
Returns a model_config from manifest, or NULL if not found.
Finds the existing model_config from manifest that best matches current system ( as defined by model_name ) . Returns a model_config from manifest or NULL if not found .
const struct model_config *manifest_find_model(const struct manifest *manifest,
					       const char *model_name)
{
	char *sys_model_name = NULL;
	const struct model_config *model = NULL;
	int i;
	if (manifest->num == 1)
		return &manifest->models[0];
	if (!model_name) {
		sys_model_name = host_shell("mosys platform model");
		VB2_DEBUG("System model name: '%s'\n", sys_model_name);
		model_name = sys_model_name;
	}
	for (i = 0; !model && i < manifest->num; i++) {
		if (strcmp(model_name, manifest->models[i].name) == 0)
			model = &manifest->models[i];
	}
	if (!model) {
		if (!*model_name)
			ERROR("Cannot get model name.\n");
		else
			ERROR("Unsupported model: '%s'.\n", model_name);
		fprintf(stderr,
			"You are probably running an image for wrong board, or "
			"a device in early stage that 'mosys' command is not "
			"ready, or image from old (or factory) branches that "
			"Unified Build config is not updated yet for 'mosys'.\n"
			"Please check command 'mosys platform model', "
			"which should output one of the supported models below:"
			"\n");
		for (i = 0; i < manifest->num; i++)
			fprintf(stderr, " %s", manifest->models[i].name);
		fprintf(stderr, "\n");
	}
	free(sys_model_name);
	return model;
}
const struct model_config * manifest_find_model ( const struct manifest * manifest , const char * model_name ) { char * sys_model_name = NULL ; const struct model_config * model = NULL ; int i ; if ( manifest -> num == 1 ) return & manifest -> models [ 0 ] ; if ( ! model_name ) { sys_model_name = host_shell ( " " ) ; VB2_DEBUG ( " \n " , sys_model_name ) ; model_name = sys_model_name ; } for ( i = 0 ; ! model && i < manifest -> num ; i ++ ) { if ( strcmp ( model_name , manifest -> models [ i ] . name ) == 0 ) model = & manifest -> models [ i ] ; } if ( ! model ) { if ( ! * model_name ) ERROR ( " \n " ) ; else ERROR ( " \n " , model_name ) ; fprintf ( stderr , " " " " " " " \n " " " " " " \n " ) ; for ( i = 0 ; i < manifest -> num ; i ++ ) fprintf ( stderr , " " , manifest -> models [ i ] . name ) ; fprintf ( stderr , " \n " ) ; } free ( sys_model_name ) ; return model ; }
Finds the existing model_config from manifest that best matches current
 system (as defined by model_name).
Finds the existing model_config from manifest that best matches current system ( as defined by model_name ) .
/*
	 * For manifest with single model defined, we should just return because
	 * there are other mechanisms like platform name check to double confirm
	 * if the firmware is valid.
	 */