working out peer module loading

This commit is contained in:
Chris Punches
2025-03-27 21:51:21 -04:00
parent 49c73d1876
commit 448dc0cdfd
12 changed files with 96 additions and 9 deletions

View File

@@ -113,4 +113,5 @@ extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
// If we're building in standalone mode, include the main function
#ifdef BUILD_STANDALONE
DPM_MODULE_STANDALONE_MAIN()
#endif // BUILD_STANDALONE
#endif // BUILD_STANDALONE

View File

@@ -37,7 +37,7 @@
* @param force Whether to force the operation even if warnings occur
* @return 0 on success, non-zero on failure
*/
int seal_stage_components( const std::string& stage_dir, bool force );
extern "C" int seal_stage_components( const std::string& stage_dir, bool force );
/**
* @brief Second phase of sealing to finalize a package
@@ -50,7 +50,7 @@ int seal_stage_components( const std::string& stage_dir, bool force );
* @param force Whether to force the operation even if warnings occur
* @return 0 on success, non-zero on failure
*/
int seal_final_package(const std::string &stage_dir, const std::string &output_dir, bool force);
extern "C" int seal_final_package(const std::string &stage_dir, const std::string &output_dir, bool force);
/**
* @brief Unseals a package file back to stage format
@@ -63,7 +63,7 @@ int seal_final_package(const std::string &stage_dir, const std::string &output_d
* @param force Whether to force the operation even if warnings occur
* @return 0 on success, non-zero on failure
*/
int unseal_package(const std::string& package_path, const std::string& output_dir, bool force);
extern "C" int unseal_package(const std::string& package_path, const std::string& output_dir, bool force);
/**
* @brief Unseals component files in a stage directory
@@ -74,4 +74,4 @@ int unseal_package(const std::string& package_path, const std::string& output_di
* @param stage_dir Path to the stage directory containing components
* @return 0 on success, non-zero on failure
*/
int unseal_stage_components(const std::filesystem::path& stage_dir);
extern "C" int unseal_stage_components(const std::filesystem::path& stage_dir);

View File

@@ -432,7 +432,7 @@ bool smart_compress_component( const std::filesystem::path& stage_dir, const std
}
int seal_stage_components(const std::string& stage_dir, bool force)
extern "C" int seal_stage_components(const std::string& stage_dir, bool force)
{
dpm_con(LOG_INFO, ("Sealing package stage: " + stage_dir).c_str());
@@ -487,7 +487,7 @@ int seal_stage_components(const std::string& stage_dir, bool force)
return 0;
}
int seal_final_package(const std::string &stage_dir, const std::string &output_dir, bool force)
extern "C" int seal_final_package(const std::string &stage_dir, const std::string &output_dir, bool force)
{
int stage_seal_result = seal_stage_components( stage_dir, force );
if ( stage_seal_result != 0 ) {
@@ -525,7 +525,7 @@ int seal_final_package(const std::string &stage_dir, const std::string &output_d
return 0;
}
int unseal_package(const std::string& package_filepath, const std::string& output_dir, bool force)
extern "C" int unseal_package(const std::string& package_filepath, const std::string& output_dir, bool force)
{
dpm_log(LOG_INFO, ("Unsealing package: " + package_filepath).c_str());
@@ -657,7 +657,7 @@ bool smart_uncompress_component(const std::filesystem::path& stage_dir, const st
return true;
}
int unseal_stage_components(const std::filesystem::path& stage_dir)
extern "C" int unseal_stage_components(const std::filesystem::path& stage_dir)
{
dpm_log(LOG_INFO, ("Unsealing package components in: " + stage_dir.string()).c_str());

View File

@@ -15,6 +15,9 @@
#include <string>
#include <cstring>
#include <dpmdk/include/CommonModuleAPI.hpp>
#include <dlfcn.h>
#include <sys/stat.h>
#include <filesystem>
/**
* @enum Command

View File

@@ -12,6 +12,39 @@
#include "verify_commands.hpp"
int check_and_load_build_module(void*& module_handle) {
// Get the module path using the new direct accessor
const char* module_path = dpm_get_module_path();
if (!module_path || strlen(module_path) == 0) {
dpm_log(LOG_ERROR, "Module path not available");
return 1;
}
// Create a proper path object
std::filesystem::path modules_dir(module_path);
// Build path to the build module
std::filesystem::path build_module_path = modules_dir / "build.so";
// Check if the file exists
if (!std::filesystem::exists(build_module_path)) {
dpm_log(LOG_ERROR, ("Build module not found at: " + build_module_path.string()).c_str());
return 1;
}
// Load the module
module_handle = dlopen(build_module_path.c_str(), RTLD_LAZY);
if (!module_handle) {
dpm_log(LOG_ERROR, ("Failed to load build module: " + std::string(dlerror())).c_str());
return 1;
}
// Clear any error
dlerror();
return 0;
}
int cmd_checksum(int argc, char** argv) {
// Parse command line arguments
bool all_packages = false;