Skip to content

Commit

Permalink
WIP: Additional package roles
Browse files Browse the repository at this point in the history
Resolves #213
  • Loading branch information
mgrabovsky committed Jul 1, 2021
1 parent 8843c07 commit 24c07b9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/rpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ enum sr_package_role
/* The packages contains the executable or script the execution of which
* caused the problem to manifest.
*/
SR_ROLE_AFFECTED
SR_ROLE_AFFECTED,
SR_ROLE_IN_CRASH,
SR_ROLE_OTHER
};

struct sr_rpm_consistency
Expand Down
3 changes: 3 additions & 0 deletions lib/abrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ rpm_interpreter_from_dir(struct sr_rpm_package *packages,

g_free(interpreter_str);
if (success)
{
interpreter_package->role = SR_ROLE_IN_CRASH;
packages = sr_rpm_package_append(packages, interpreter_package);
}
else
sr_rpm_package_free(interpreter_package, true);
}
Expand Down
23 changes: 19 additions & 4 deletions lib/rpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ sr_rpm_package_to_json(struct sr_rpm_package *package,
case SR_ROLE_AFFECTED:
role = "affected";
break;
case SR_ROLE_IN_CRASH:
role = "in_crash";
break;
case SR_ROLE_OTHER:
role = "other";
break;
default:
assert(0 && "Invalid role");
break;
Expand Down Expand Up @@ -596,19 +602,28 @@ single_rpm_package_from_json(json_object *root, char **error_message)
if (!json_check_type(role_json, json_type_string, "package_role", error_message))
goto fail;

/* We only know "affected" so far. */
const char *role;

role = json_object_get_string(role_json);

if (0 != strcmp(role, "affected"))
if (0 == strcmp(role, "affected"))
{
package->role = SR_ROLE_AFFECTED;
}
else if (0 == strcmp(role, "in_crash"))
{
package->role = SR_ROLE_IN_CRASH;
}
else if (0 == strcmp(role, "other"))
{
package->role = SR_ROLE_OTHER;
}
else
{
if (error_message)
*error_message = g_strdup_printf("Invalid package role %s", role);
goto fail;
}

package->role = SR_ROLE_AFFECTED;
}

return package;
Expand Down
2 changes: 2 additions & 0 deletions python/py_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ MOD_INIT

PyModule_AddIntConstant(module, "ROLE_UNKNOWN", SR_ROLE_UNKNOWN);
PyModule_AddIntConstant(module, "ROLE_AFFECTED", SR_ROLE_AFFECTED);
PyModule_AddIntConstant(module, "ROLE_IN_CRASH", SR_ROLE_IN_CRASH);
PyModule_AddIntConstant(module, "ROLE_OTHER", SR_ROLE_OTHER);

return MOD_SUCCESS_VAL(module);
}

0 comments on commit 24c07b9

Please sign in to comment.