basic POC functionality established for peer module loading

This commit is contained in:
Chris Punches
2025-03-27 22:28:02 -04:00
parent 448dc0cdfd
commit 7b29824e40
9 changed files with 177 additions and 82 deletions

View File

@@ -27,7 +27,8 @@ enum Command {
CMD_UNKNOWN, /**< Unknown or unsupported command */
CMD_HELP, /**< Display help information */
CMD_CHECKSUM, /**< Verify package checksums */
CMD_SIGNATURE /**< Verify package signatures */
CMD_SIGNATURE, /**< Verify package signatures */
CMD_CHECK /**< Check build module integration */
};
/**
@@ -84,4 +85,16 @@ int cmd_unknown(const char* command, int argc, char** argv);
* @param cmd_str The command string to parse
* @return The corresponding Command enum value
*/
Command parse_command(const char* cmd_str);
Command parse_command(const char* cmd_str);
/**
* @brief Handler for the check command
*
* Checks if the build module can be loaded. This validates that the integration
* between the verify module and build module is working correctly.
*
* @param argc Number of arguments
* @param argv Array of arguments
* @return 0 on success, non-zero on failure
*/
int cmd_check(int argc, char** argv);

View File

@@ -196,6 +196,7 @@ int cmd_help(int argc, char** argv) {
dpm_con(LOG_INFO, "");
dpm_con(LOG_INFO, " checksum - Verify checksums of installed packages");
dpm_con(LOG_INFO, " signature - Verify signatures of installed packages");
dpm_con(LOG_INFO, " check - Check build module integration");
dpm_con(LOG_INFO, " help - Display this help message");
dpm_con(LOG_INFO, "");
dpm_con(LOG_INFO, "Usage: dpm verify <command>");
@@ -227,6 +228,30 @@ Command parse_command(const char* cmd_str) {
else if (strcmp(cmd_str, "signature") == 0) {
return CMD_SIGNATURE;
}
else if (strcmp(cmd_str, "check") == 0) {
return CMD_CHECK;
}
return CMD_UNKNOWN;
}
int cmd_check(int argc, char** argv) {
dpm_log(LOG_INFO, "Checking build module integration...");
void* module_handle = nullptr;
int result = check_and_load_build_module(module_handle);
if (result != 0) {
dpm_log(LOG_ERROR, "Failed to load build module.");
return 1;
}
dpm_log(LOG_INFO, "Successfully loaded build module.");
// Clean up
if (module_handle) {
dlclose(module_handle);
}
return 0;
}

View File

@@ -85,12 +85,15 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
case CMD_SIGNATURE:
return cmd_signature(argc, argv);
case CMD_CHECK:
return cmd_check(argc, argv);
case CMD_HELP:
return cmd_help(argc, argv);
case CMD_UNKNOWN:
default:
return cmd_unknown(command, argc, argv);
default:
return cmd_unknown(command, argc, argv);
}
}