ropam: add sub-command to initialise a sysroot

This commit is contained in:
2025-08-06 22:14:27 +01:00
parent ece47803c4
commit fd26924773
4 changed files with 69 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
file(GLOB_RECURSE sources *.c *.h) file(GLOB_RECURSE sources *.c *.h)
add_executable(ropam ${sources}) 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)

60
ropam/bootstrap.c Normal file
View File

@@ -0,0 +1,60 @@
#include "commands.h"
#include <blue/cmd.h>
#include <ropkg/instance.h>
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();
}

View File

@@ -6,6 +6,7 @@ enum {
CMD_SYNC, CMD_SYNC,
CMD_REMOVE, CMD_REMOVE,
CMD_QUERY, CMD_QUERY,
CMD_BOOTSTRAP,
CMD_REPO, CMD_REPO,
CMD_REPO_ADD, CMD_REPO_ADD,

View File

@@ -1,6 +1,8 @@
#include "commands.h" #include "commands.h"
#include <blue/cmd.h> #include <blue/cmd.h>
#include <blue/core/error.h>
#include <blue/term/print.h>
B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID) 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) 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); return b_command_dispatch(CMD_ROOT, argc, argv);
} }