starting the process of moving manifest mgmt to a dedicated subcommand
parent
172bc2e9c8
commit
2623bcf2b3
|
@ -91,6 +91,9 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
|
||||||
case CMD_HELP:
|
case CMD_HELP:
|
||||||
return cmd_help(argc, argv);
|
return cmd_help(argc, argv);
|
||||||
|
|
||||||
|
case CMD_MANIFEST:
|
||||||
|
return cmd_manifest(argc, argv);
|
||||||
|
|
||||||
case CMD_UNKNOWN:
|
case CMD_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
return cmd_unknown(command, argc, argv);
|
return cmd_unknown(command, argc, argv);
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
* @brief Enumeration of supported commands for the build module
|
* @brief Enumeration of supported commands for the build module
|
||||||
*/
|
*/
|
||||||
enum Command {
|
enum Command {
|
||||||
CMD_UNKNOWN, /**< Unknown or unsupported command */
|
CMD_UNKNOWN, /**< Unknown or unsupported command */
|
||||||
CMD_HELP, /**< Display help information */
|
CMD_HELP, /**< Display help information */
|
||||||
CMD_STAGE /**< Stage a new DPM package */
|
CMD_STAGE, /**< Stage a new DPM package */
|
||||||
|
CMD_MANIFEST, /**< Regenerate a stage manifest */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,17 @@
|
||||||
*/
|
*/
|
||||||
int cmd_stage(int argc, char** argv);
|
int cmd_stage(int argc, char** argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handler for the manifest command
|
||||||
|
*
|
||||||
|
* Generates or refreshes package manifest.
|
||||||
|
*
|
||||||
|
* @param argc Number of arguments
|
||||||
|
* @param argv Array of arguments
|
||||||
|
* @return 0 on success, non-zero on failure
|
||||||
|
*/
|
||||||
|
int cmd_manifest(int argc, char** argv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handler for the help command
|
* @brief Handler for the help command
|
||||||
*
|
*
|
||||||
|
@ -39,6 +50,16 @@ int cmd_help(int argc, char** argv);
|
||||||
*/
|
*/
|
||||||
int cmd_stage_help(int argc, char** argv);
|
int cmd_stage_help(int argc, char** argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handler for the manifest help command
|
||||||
|
*
|
||||||
|
* Displays information about manifest command options.
|
||||||
|
*
|
||||||
|
* @param argc Number of arguments
|
||||||
|
* @param argv Array of arguments
|
||||||
|
* @return 0 on success, non-zero on failure
|
||||||
|
*/
|
||||||
|
int cmd_manifest_help(int argc, char** argv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handler for unknown commands
|
* @brief Handler for unknown commands
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "checksums.hpp"
|
#include "checksums.hpp"
|
||||||
|
|
||||||
|
|
||||||
std::string get_configured_hash_algorithm()
|
std::string get_configured_hash_algorithm()
|
||||||
{
|
{
|
||||||
const char* algorithm = dpm_get_config("cryptography", "checksum_algorithm");
|
const char* algorithm = dpm_get_config("cryptography", "checksum_algorithm");
|
||||||
|
@ -169,4 +168,4 @@ std::string generate_file_checksum(const std::filesystem::path& file_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,6 +237,11 @@ Command parse_command(const char* cmd_str) {
|
||||||
return CMD_STAGE;
|
return CMD_STAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for stage command, including when it has additional arguments
|
||||||
|
if (strncmp(cmd_str, "manifest", 8) == 0) {
|
||||||
|
return CMD_MANIFEST;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if cmd_str is a help option
|
// Check if cmd_str is a help option
|
||||||
if (strcmp(cmd_str, "-h") == 0 || strcmp(cmd_str, "--help") == 0) {
|
if (strcmp(cmd_str, "-h") == 0 || strcmp(cmd_str, "--help") == 0) {
|
||||||
return CMD_HELP;
|
return CMD_HELP;
|
||||||
|
|
|
@ -1,5 +1,73 @@
|
||||||
#include "commands.hpp"
|
#include "commands.hpp"
|
||||||
|
|
||||||
|
static int refresh_package_manifest(const std::string& stage_dir, bool force) {
|
||||||
|
dpm_log(LOG_INFO, ("Refreshing package manifest for: " + stage_dir).c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int generate_package_manifest(const std::string& stage_dir, bool force) {
|
||||||
|
dpm_log(LOG_INFO, ("Generating package manifest for: " + stage_dir).c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmd_manifest(int argc, char** argv) {
|
||||||
|
// Parse command line options
|
||||||
|
bool force = false;
|
||||||
|
bool refresh_only = false;
|
||||||
|
bool verbose = false;
|
||||||
|
bool show_help = false;
|
||||||
|
std::string stage_dir = "";
|
||||||
|
|
||||||
|
// Process command-line arguments
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
std::string arg = argv[i];
|
||||||
|
|
||||||
|
if (arg == "-f" || arg == "--force") {
|
||||||
|
force = true;
|
||||||
|
} else if (arg == "-r" || arg == "--refresh-only") {
|
||||||
|
refresh_only = true;
|
||||||
|
} else if (arg == "-v" || arg == "--verbose") {
|
||||||
|
verbose = true;
|
||||||
|
} else if (arg == "-h" || arg == "--help" || "help" ) {
|
||||||
|
show_help = true;
|
||||||
|
} else if ((arg == "-s" || arg == "--stage") && i + 1 < argc) {
|
||||||
|
stage_dir = argv[i + 1];
|
||||||
|
i++; // Skip the next argument
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If help was requested, show it and return
|
||||||
|
if (show_help) {
|
||||||
|
return cmd_manifest_help(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate that stage directory is provided
|
||||||
|
if (stage_dir.empty()) {
|
||||||
|
dpm_log(LOG_ERROR, "Stage directory is required (--stage/-s)");
|
||||||
|
return cmd_manifest_help(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expand path if needed
|
||||||
|
stage_dir = expand_path(stage_dir);
|
||||||
|
|
||||||
|
// Check if stage directory exists
|
||||||
|
if (!std::filesystem::exists(stage_dir)) {
|
||||||
|
dpm_log(LOG_ERROR, ("Stage directory does not exist: " + stage_dir).c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set verbose logging if requested
|
||||||
|
if (verbose) {
|
||||||
|
dpm_set_logging_level(LOG_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log the operation being performed
|
||||||
|
if (refresh_only) {
|
||||||
|
return refresh_package_manifest(stage_dir, force);
|
||||||
|
} else {
|
||||||
|
return generate_package_manifest(stage_dir, force);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int cmd_stage(int argc, char** argv) {
|
int cmd_stage(int argc, char** argv) {
|
||||||
// Announce that the stage step is being executed (debug level)
|
// Announce that the stage step is being executed (debug level)
|
||||||
|
@ -81,6 +149,7 @@ int cmd_help(int argc, char** argv) {
|
||||||
dpm_log(LOG_INFO, "");
|
dpm_log(LOG_INFO, "");
|
||||||
dpm_log(LOG_INFO, "Available commands:");
|
dpm_log(LOG_INFO, "Available commands:");
|
||||||
dpm_log(LOG_INFO, " stage - Stage a new DPM package directory");
|
dpm_log(LOG_INFO, " stage - Stage a new DPM package directory");
|
||||||
|
dpm_log(LOG_INFO, " manifest - Generate or refresh package manifest");
|
||||||
dpm_log(LOG_INFO, " help - Display this help message");
|
dpm_log(LOG_INFO, " help - Display this help message");
|
||||||
dpm_log(LOG_INFO, "");
|
dpm_log(LOG_INFO, "");
|
||||||
dpm_log(LOG_INFO, "Usage: dpm build <command>");
|
dpm_log(LOG_INFO, "Usage: dpm build <command>");
|
||||||
|
@ -114,4 +183,17 @@ int cmd_stage_help(int argc, char** argv) {
|
||||||
dpm_log(LOG_INFO, " -v, --verbose Enable verbose output");
|
dpm_log(LOG_INFO, " -v, --verbose Enable verbose output");
|
||||||
dpm_log(LOG_INFO, " -h, --help Display this help message");
|
dpm_log(LOG_INFO, " -h, --help Display this help message");
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmd_manifest_help(int argc, char** argv) {
|
||||||
|
dpm_log(LOG_INFO, "Usage: dpm build manifest [options]");
|
||||||
|
dpm_log(LOG_INFO, "");
|
||||||
|
dpm_log(LOG_INFO, "Options:");
|
||||||
|
dpm_log(LOG_INFO, " -s, --stage DIR Stage directory path (required)");
|
||||||
|
dpm_log(LOG_INFO, " -r, --refresh-only Refresh existing manifest instead of generating a new one");
|
||||||
|
dpm_log(LOG_INFO, " -f, --force Force manifest operation even if warnings occur");
|
||||||
|
dpm_log(LOG_INFO, " -v, --verbose Enable verbose output");
|
||||||
|
dpm_log(LOG_INFO, " -h, --help Display this help message");
|
||||||
|
dpm_log(LOG_INFO, "");
|
||||||
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue