diff --git a/ropam/CMakeLists.txt b/ropam/CMakeLists.txt index b8eb512..b161705 100644 --- a/ropam/CMakeLists.txt +++ b/ropam/CMakeLists.txt @@ -1,4 +1,6 @@ file(GLOB_RECURSE sources *.c *.h) add_executable(ropam ${sources}) -target_link_libraries(ropam Bluelib::Core Bluelib::Object Bluelib::Io Bluelib::Term Bluelib::Cmd) +target_link_libraries(ropam + libropkg + Bluelib::Core Bluelib::Object Bluelib::Io Bluelib::Term Bluelib::Cmd) diff --git a/ropam/bootstrap.c b/ropam/bootstrap.c new file mode 100644 index 0000000..6c8f4ac --- /dev/null +++ b/ropam/bootstrap.c @@ -0,0 +1,60 @@ +#include "commands.h" + +#include +#include + +enum { + ARG_PATH, +}; + +static int bootstrap( + const b_command *self, + const b_arglist *opt, + const b_array *args) +{ + const char *root_path = NULL; + b_status status = b_arglist_get_string( + opt, + B_COMMAND_INVALID_ID, + ARG_PATH, + 0, + &root_path); + if (!B_OK(status)) { + b_arglist_report_missing_args( + opt, + B_COMMAND_INVALID_ID, + ARG_PATH, + 0); + return -1; + } + + struct ropkg_instance *inst; + b_result result = ropkg_instance_bootstrap(root_path, &inst); + if (b_result_is_error(result)) { + b_throw(result); + return -1; + } + + return 0; +} + +B_COMMAND(CMD_BOOTSTRAP, CMD_ROOT) +{ + B_COMMAND_NAME("bootstrap"); + B_COMMAND_DESC( + "initialise a new Rosetta package manager instance. use this " + "command to prepare a sysroot for the installation of Rosetta " + "packages."); + B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); + B_COMMAND_FUNCTION(bootstrap); + + B_COMMAND_ARG(ARG_PATH) + { + B_ARG_NAME("sysroot"); + B_ARG_DESC( + "the path to the system root directory to initialise."); + B_ARG_NR_VALUES(1); + } + + B_COMMAND_HELP_OPTION(); +} diff --git a/ropam/commands.h b/ropam/commands.h index b26a2f9..840265d 100644 --- a/ropam/commands.h +++ b/ropam/commands.h @@ -6,6 +6,7 @@ enum { CMD_SYNC, CMD_REMOVE, CMD_QUERY, + CMD_BOOTSTRAP, CMD_REPO, CMD_REPO_ADD, diff --git a/ropam/main.c b/ropam/main.c index ad971db..fc036e5 100644 --- a/ropam/main.c +++ b/ropam/main.c @@ -1,6 +1,8 @@ #include "commands.h" #include +#include +#include B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID) { @@ -28,5 +30,8 @@ B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID) int main(int argc, const char **argv) { + b_set_error_report_function( + b_enhanced_error_reporter, + B_ERROR_REPORT_ALL); return b_command_dispatch(CMD_ROOT, argc, argv); }