Teach fastboot to allow required variables per product.
This is needed for products like xoom-cdma and xoom-cdma-lte. The xoom-cdma-lte product requires an lte baseband binary but it's not needed for xoom-cdma. This is implemented by allowing an optional product parameter to "required" statements. The parameter is separated from "required" by a colon so the version-baseband-2 requirment in board-info.txt for stingray becomes: require-for-product:xoom-cdma-lte version-baseband-2=ltedc_u_03.25.00|ltedc_u_03.19.00 In the above statement, only xoom-cdma-lte requires version-baseband-2 and the baseband can be lte_u_03.25.00 or lte_u_03.19.00. For other products version-baseband-2 will be ignored. Change-Id: I786bec5f5661c2243d87925b064fc6124d3cffa1
This commit is contained in:
parent
47e4ee5958
commit
b98762f782
3 changed files with 55 additions and 3 deletions
|
@ -69,6 +69,7 @@ struct Action
|
|||
Action *next;
|
||||
|
||||
char cmd[64];
|
||||
const char *prod;
|
||||
void *data;
|
||||
unsigned size;
|
||||
|
||||
|
@ -183,6 +184,16 @@ static int cb_check(Action *a, int status, char *resp, int invert)
|
|||
return status;
|
||||
}
|
||||
|
||||
if (a->prod) {
|
||||
if (strcmp(a->prod, cur_product) != 0) {
|
||||
double split = now();
|
||||
fprintf(stderr,"IGNORE, product is %s required only for %s [%7.3fs]\n",
|
||||
cur_product, a->prod, (split - a->start));
|
||||
a->start = split;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
yes = match(resp, value, count);
|
||||
if (invert) yes = !yes;
|
||||
|
||||
|
@ -214,10 +225,12 @@ static int cb_reject(Action *a, int status, char *resp)
|
|||
return cb_check(a, status, resp, 1);
|
||||
}
|
||||
|
||||
void fb_queue_require(const char *var, int invert, unsigned nvalues, const char **value)
|
||||
void fb_queue_require(const char *prod, const char *var,
|
||||
int invert, unsigned nvalues, const char **value)
|
||||
{
|
||||
Action *a;
|
||||
a = queue_action(OP_QUERY, "getvar:%s", var);
|
||||
a->prod = prod;
|
||||
a->data = value;
|
||||
a->size = nvalues;
|
||||
a->msg = mkmsg("checking %s", var);
|
||||
|
@ -244,6 +257,25 @@ void fb_queue_display(const char *var, const char *prettyname)
|
|||
a->func = cb_display;
|
||||
}
|
||||
|
||||
static int cb_save(Action *a, int status, char *resp)
|
||||
{
|
||||
if (status) {
|
||||
fprintf(stderr, "%s FAILED (%s)\n", a->cmd, resp);
|
||||
return status;
|
||||
}
|
||||
strncpy(a->data, resp, a->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fb_queue_query_save(const char *var, char *dest, unsigned dest_size)
|
||||
{
|
||||
Action *a;
|
||||
a = queue_action(OP_QUERY, "getvar:%s", var);
|
||||
a->data = (void *)dest;
|
||||
a->size = dest_size;
|
||||
a->func = cb_save;
|
||||
}
|
||||
|
||||
static int cb_do_nothing(Action *a, int status, char *resp)
|
||||
{
|
||||
fprintf(stderr,"\n");
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include "fastboot.h"
|
||||
|
||||
char cur_product[FB_RESPONSE_SZ + 1];
|
||||
|
||||
void bootimg_set_cmdline(boot_img_hdr *h, const char *cmdline);
|
||||
|
||||
boot_img_hdr *mkbootimg(void *kernel, unsigned kernel_size,
|
||||
|
@ -340,6 +342,7 @@ static int setup_requirement_line(char *name)
|
|||
{
|
||||
char *val[MAX_OPTIONS];
|
||||
const char **out;
|
||||
char *prod = NULL;
|
||||
unsigned n, count;
|
||||
char *x;
|
||||
int invert = 0;
|
||||
|
@ -350,6 +353,14 @@ static int setup_requirement_line(char *name)
|
|||
} else if (!strncmp(name, "require ", 8)) {
|
||||
name += 8;
|
||||
invert = 0;
|
||||
} else if (!strncmp(name, "require-for-product:", 20)) {
|
||||
// Get the product and point name past it
|
||||
prod = name + 20;
|
||||
name = strchr(name, ' ');
|
||||
if (!name) return -1;
|
||||
*name = 0;
|
||||
name += 1;
|
||||
invert = 0;
|
||||
}
|
||||
|
||||
x = strchr(name, '=');
|
||||
|
@ -381,7 +392,7 @@ static int setup_requirement_line(char *name)
|
|||
if (out[n] == 0) return -1;
|
||||
}
|
||||
|
||||
fb_queue_require(name, invert, n, out);
|
||||
fb_queue_require(prod, name, invert, n, out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -432,6 +443,8 @@ void do_update(char *fn)
|
|||
|
||||
queue_info_dump();
|
||||
|
||||
fb_queue_query_save("product", cur_product, sizeof(cur_product));
|
||||
|
||||
zdata = load_file(fn, &zsize);
|
||||
if (zdata == 0) die("failed to load '%s'", fn);
|
||||
|
||||
|
@ -498,6 +511,8 @@ void do_flashall(void)
|
|||
|
||||
queue_info_dump();
|
||||
|
||||
fb_queue_query_save("product", cur_product, sizeof(cur_product));
|
||||
|
||||
fname = find_item("info", product);
|
||||
if (fname == 0) die("cannot find android-info.txt");
|
||||
data = load_file(fname, &sz);
|
||||
|
|
|
@ -43,8 +43,10 @@ char *fb_get_error(void);
|
|||
/* engine.c - high level command queue engine */
|
||||
void fb_queue_flash(const char *ptn, void *data, unsigned sz);;
|
||||
void fb_queue_erase(const char *ptn);
|
||||
void fb_queue_require(const char *var, int invert, unsigned nvalues, const char **value);
|
||||
void fb_queue_require(const char *prod, const char *var, int invert,
|
||||
unsigned nvalues, const char **value);
|
||||
void fb_queue_display(const char *var, const char *prettyname);
|
||||
void fb_queue_query_save(const char *var, char *dest, unsigned dest_size);
|
||||
void fb_queue_reboot(void);
|
||||
void fb_queue_command(const char *cmd, const char *msg);
|
||||
void fb_queue_download(const char *name, void *data, unsigned size);
|
||||
|
@ -54,4 +56,7 @@ int fb_execute_queue(usb_handle *usb);
|
|||
/* util stuff */
|
||||
void die(const char *fmt, ...);
|
||||
|
||||
/* Current product */
|
||||
extern char cur_product[FB_RESPONSE_SZ + 1];
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue