Skip to content

Commit fe6f7dc

Browse files
InterLinked1kharwell
authored andcommitted
menuselect: Don't erroneously recompile modules.
A bug in menuselect can cause modules that are disabled by default to be recompiled every time a recompilation occurs. This occurs for module categories that are NOT positive output, as for these categories, the modules contained in the makeopts file indicate modules which should NOT be selected. The existing procedure of iterating through these modules to mark modules as present is thus insufficient. This has led to modules with a default_enabled tag of "no" to get deleted and recompiled every time, even when they haven't changed. To fix this, we now modify the mark as present behavior for module categories that are not positive output. For these, we start by iterating through the module tree and marking all modules as present, then go back and mark anything contained in the makeopts file as not present. This ensures that makeopt selections are actually used properly, regardless of whether a module category uses positive output or not. ASTERISK-29728 #close Change-Id: Idf2974c4ed8d0ba3738a92f08a6082b234277b95
1 parent b90650d commit fe6f7dc

File tree

1 file changed

+59
-11
lines changed

1 file changed

+59
-11
lines changed

menuselect/menuselect.c

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,8 +1130,7 @@ static int build_member_list(void)
11301130
return res;
11311131
}
11321132

1133-
/*! \brief Given the string representation of a member and category, mark it as present in a given input file */
1134-
static void mark_as_present(const char *member, const char *category)
1133+
static void mark_as_present_helper(const char *member, const char *category, int present)
11351134
{
11361135
struct category *cat;
11371136
struct member *mem;
@@ -1142,31 +1141,44 @@ static void mark_as_present(const char *member, const char *category)
11421141
negate = 1;
11431142
}
11441143

1145-
print_debug("Marking %s of %s as present\n", member, category);
1144+
print_debug("Marking %s of %s as %s\n", member, category, present ? "present" : "not present");
11461145

11471146
AST_LIST_TRAVERSE(&categories, cat, list) {
1148-
if (strcmp(category, cat->name))
1147+
if (strcmp(category, cat->name)) {
11491148
continue;
1149+
}
11501150
AST_LIST_TRAVERSE(&cat->members, mem, list) {
11511151
if (mem->is_separator) {
11521152
continue;
11531153
}
11541154

11551155
if (!strcmp(member, mem->name)) {
1156-
mem->was_enabled = mem->enabled = (negate ? !cat->positive_output : cat->positive_output);
1156+
if (present) {
1157+
mem->was_enabled = mem->enabled = (negate ? !cat->positive_output : cat->positive_output);
1158+
} else {
1159+
mem->was_enabled = mem->enabled = 0;
1160+
}
11571161
print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);
11581162
break;
11591163
}
11601164
}
1161-
if (!mem)
1165+
if (!mem) {
11621166
fprintf(stderr, "member '%s' in category '%s' not found, ignoring.\n", member, category);
1167+
}
11631168
break;
11641169
}
11651170

1166-
if (!cat)
1171+
if (!cat) {
11671172
fprintf(stderr, "category '%s' not found! Can't mark '%s' as disabled.\n", category, member);
1173+
}
11681174
}
11691175

1176+
/*! \brief Given the string representation of a member and category, mark it as present in a given input file */
1177+
#define mark_as_present(member, category) mark_as_present_helper(member, category, 1)
1178+
1179+
/*! \brief Given the string representation of a member and category, mark it as not present in a given input file */
1180+
#define mark_as_not_present(member, category) mark_as_present_helper(member, category, 0)
1181+
11701182
unsigned int enable_member(struct member *mem)
11711183
{
11721184
struct reference *dep;
@@ -1380,6 +1392,9 @@ static int parse_existing_config(const char *infile)
13801392
}
13811393

13821394
while (fgets(buf, PARSE_BUF_SIZE, f)) {
1395+
struct category *cat;
1396+
struct member *mem;
1397+
13831398
lineno++;
13841399

13851400
if (strlen_zero(buf))
@@ -1414,11 +1429,44 @@ static int parse_existing_config(const char *infile)
14141429
continue;
14151430
}
14161431

1417-
while ((member = strsep(&parse, " \n"))) {
1418-
member = skip_blanks(member);
1419-
if (strlen_zero(member))
1432+
AST_LIST_TRAVERSE(&categories, cat, list) {
1433+
if (strcmp(category, cat->name)) {
14201434
continue;
1421-
mark_as_present(member, category);
1435+
}
1436+
if (!cat->positive_output) {
1437+
print_debug("Category %s is NOT positive output\n", cat->name);
1438+
/* if NOT positive_output, then if listed in makeopts, it's disabled! */
1439+
/* this means that what's listed in menuselect.makeopts is a list of modules
1440+
* that are NOT selected, so we can't use that to mark things as present.
1441+
* In fact, we need to mark everything as present, UNLESS it's listed
1442+
* in menuselect.makeopts */
1443+
AST_LIST_TRAVERSE(&cat->members, mem, list) {
1444+
if (mem->is_separator) {
1445+
continue;
1446+
}
1447+
mem->was_enabled = 1;
1448+
print_debug("Just set %s enabled to %d\n", mem->name, mem->enabled);
1449+
}
1450+
/* okay, now go ahead, and mark anything listed in makeopts as NOT present */
1451+
while ((member = strsep(&parse, " \n"))) {
1452+
member = skip_blanks(member);
1453+
if (strlen_zero(member)) {
1454+
continue;
1455+
}
1456+
mark_as_not_present(member, category);
1457+
}
1458+
} else {
1459+
print_debug("Category %s is positive output\n", cat->name);
1460+
/* if present, it was enabled (e.g. MENUSELECT_CFLAGS, MENUSELECT_UTILS, MENUSELECT_MOH, etc. */
1461+
while ((member = strsep(&parse, " \n"))) {
1462+
member = skip_blanks(member);
1463+
if (strlen_zero(member)) {
1464+
continue;
1465+
}
1466+
mark_as_present(member, category);
1467+
}
1468+
}
1469+
break;
14221470
}
14231471
}
14241472

0 commit comments

Comments
 (0)