From b034a3679d4326a592e0732202b1df7a757f1734 Mon Sep 17 00:00:00 2001 From: Chris Punches Date: Sat, 15 Mar 2025 05:12:18 -0400 Subject: [PATCH] fleshing out stage creation --- modules/build/CMakeLists.txt | 2 ++ modules/build/include/commands.hpp | 1 + modules/build/src/cli_parsers.cpp | 22 ++++++++++++++-------- modules/build/src/commands.cpp | 20 ++++++++++++++------ 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/modules/build/CMakeLists.txt b/modules/build/CMakeLists.txt index cc59507..4741393 100644 --- a/modules/build/CMakeLists.txt +++ b/modules/build/CMakeLists.txt @@ -16,6 +16,7 @@ add_library(build MODULE src/helpers.cpp src/cli_parsers.cpp src/commands.cpp + src/package_staging.cpp ) # Set output properties @@ -40,6 +41,7 @@ add_executable(build_standalone src/helpers.cpp src/cli_parsers.cpp src/commands.cpp + src/package_staging.cpp ) # Define the BUILD_STANDALONE macro for the standalone build diff --git a/modules/build/include/commands.hpp b/modules/build/include/commands.hpp index b7962c8..e84a268 100644 --- a/modules/build/include/commands.hpp +++ b/modules/build/include/commands.hpp @@ -3,6 +3,7 @@ #include "cli_parsers.hpp" #include #include +#include "package_staging.hpp" /** * @brief Handler for the stage command diff --git a/modules/build/src/cli_parsers.cpp b/modules/build/src/cli_parsers.cpp index ea30314..672d29b 100644 --- a/modules/build/src/cli_parsers.cpp +++ b/modules/build/src/cli_parsers.cpp @@ -41,7 +41,7 @@ int parse_create_options(int argc, char** argv, BuildOptions& options) { std::string option = arg.substr(0, equals_pos); std::string value = arg.substr(equals_pos + 1); - if (option == "--output-dir") { + if (option == "--output") { options.output_dir = value; output_dir_provided = true; } else if (option == "--contents") { @@ -82,7 +82,7 @@ int parse_create_options(int argc, char** argv, BuildOptions& options) { } static struct option long_options[] = { - {"output-dir", required_argument, 0, 'o'}, + {"output", required_argument, 0, 'o'}, {"contents", required_argument, 0, 'c'}, {"hooks", required_argument, 0, 'H'}, {"name", required_argument, 0, 'n'}, @@ -254,6 +254,18 @@ int validate_build_options(const BuildOptions& options) { return 0; } + // Check if output directory is provided + if (options.output_dir.empty()) { + dpm_log(LOG_ERROR, "Output directory is required (--output)"); + return 1; + } + + // Check if output directory exists + if (!std::filesystem::exists(options.output_dir)) { + dpm_log(LOG_ERROR, ("Output directory does not exist: " + options.output_dir).c_str()); + return 1; + } + // Check if contents directory is provided and exists if (options.contents_dir.empty()) { dpm_log(LOG_ERROR, "Contents directory is required (--contents)"); @@ -289,11 +301,5 @@ int validate_build_options(const BuildOptions& options) { return 1; } - // Check if output directory exists - if (!std::filesystem::exists(options.output_dir)) { - dpm_log(LOG_ERROR, ("Output directory does not exist: " + options.output_dir).c_str()); - return 1; - } - return 0; } \ No newline at end of file diff --git a/modules/build/src/commands.cpp b/modules/build/src/commands.cpp index cd4585a..336b5e1 100644 --- a/modules/build/src/commands.cpp +++ b/modules/build/src/commands.cpp @@ -1,5 +1,6 @@ #include "commands.hpp" + int cmd_stage(int argc, char** argv) { // Announce that the stage step is being executed (debug level) dpm_log(LOG_DEBUG, "Executing stage command"); @@ -62,11 +63,17 @@ int cmd_stage(int argc, char** argv) { dpm_log(LOG_DEBUG, " Force: Yes"); } - // Standard info logs that are always visible - dpm_log(LOG_INFO, "Package staging functionality not yet implemented"); - dpm_log(LOG_INFO, "Would stage package directory using the provided options"); - - return 0; + // Call the build_package_stage function with individual parameters + return build_package_stage( + options.output_dir, + options.contents_dir, + options.hooks_dir, + options.package_name, + options.package_version, + options.architecture, + options.os, + options.force + ); } int cmd_help(int argc, char** argv) { @@ -91,11 +98,12 @@ int cmd_unknown(const char* command, int argc, char** argv) { return 1; } + int cmd_stage_help(int argc, char** argv) { dpm_log(LOG_INFO, "Usage: dpm build stage [options]"); dpm_log(LOG_INFO, ""); dpm_log(LOG_INFO, "Options:"); - dpm_log(LOG_INFO, " -o, --output-dir DIR Directory to save the staged package (required)"); + dpm_log(LOG_INFO, " -o, --output DIR Directory to save the staged package (required)"); dpm_log(LOG_INFO, " -c, --contents DIR Directory with package contents (required)"); dpm_log(LOG_INFO, " -H, --hooks DIR Directory with package hooks (optional)"); dpm_log(LOG_INFO, " -n, --name NAME Package name (required)");