meta: add build system and stub tool source code

This commit is contained in:
2025-07-07 13:56:20 +01:00
parent 2bc7a0d900
commit ba40290eea
27 changed files with 990 additions and 0 deletions

4
ropam/CMakeLists.txt Normal file
View File

@@ -0,0 +1,4 @@
file(GLOB_RECURSE sources *.c *.h)
add_executable(ropam ${sources})
target_link_libraries(ropam Bluelib::Core Bluelib::Object Bluelib::Io Bluelib::Term Bluelib::Cmd)

40
ropam/commands.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef COMMANDS_H_
#define COMMANDS_H_
enum {
CMD_ROOT,
CMD_SYNC,
CMD_REMOVE,
CMD_QUERY,
CMD_VENDOR,
CMD_VENDOR_ADD,
CMD_VENDOR_REMOVE,
CMD_VENDOR_LIST,
};
enum {
OPT_SYSROOT = 0x1000,
OPT_SYSROOT_PATH,
};
#define SYSROOT_OPTION \
B_COMMAND_OPTION(OPT_SYSROOT) \
{ \
B_OPTION_SHORT_NAME('s'); \
B_OPTION_LONG_NAME("sysroot"); \
B_OPTION_DESC( \
"the system directory to use. if no " \
"sysroot is specified, the root directory is used. " \
"alternatively, the ROSETTA_SYSROOT environment " \
"variable can be used to specify the system root " \
"directory"); \
\
B_OPTION_ARG(OPT_SYSROOT_PATH) \
{ \
B_ARG_NAME("path"); \
B_ARG_NR_VALUES(1); \
} \
}
#endif

32
ropam/main.c Normal file
View File

@@ -0,0 +1,32 @@
#include "commands.h"
#include <blue/cmd.h>
B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID)
{
B_COMMAND_NAME("ropam");
B_COMMAND_DESC(
"Rosetta package manager. This tool is used to (un)install, "
"upgrade, and otherwise manage packages on a system via a set "
"of package vendors.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_HELP_OPTION();
SYSROOT_OPTION;
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_COMMAND_PLACEHOLDER();
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_OPT(OPT_SYSROOT);
B_COMMAND_USAGE_COMMAND_PLACEHOLDER();
}
}
int main(int argc, const char **argv)
{
return b_command_dispatch(CMD_ROOT, argc, argv);
}

22
ropam/query.c Normal file
View File

@@ -0,0 +1,22 @@
#include "commands.h"
#include <blue/cmd.h>
static int query(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_QUERY, CMD_ROOT)
{
B_COMMAND_NAME("query");
B_COMMAND_SHORT_NAME('Q');
B_COMMAND_DESC("query information about installed packages.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(query);
B_COMMAND_HELP_OPTION();
}

42
ropam/remove.c Normal file
View File

@@ -0,0 +1,42 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
ARG_PACKAGE,
};
static int remove(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_REMOVE, CMD_ROOT)
{
B_COMMAND_NAME("remove");
B_COMMAND_SHORT_NAME('R');
B_COMMAND_DESC(
"remove a set of Rosetta packages by name. any "
"automatically installed dependencies will not be removed "
"unless they are explicitly named in the list of packages to "
"remove.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(remove);
B_COMMAND_HELP_OPTION();
B_COMMAND_ARG(ARG_PACKAGE)
{
B_ARG_NAME("package-name");
B_ARG_DESC("the names of the packages to remove.");
B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES);
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_ARG(ARG_PACKAGE);
}
}

72
ropam/sync.c Normal file
View File

@@ -0,0 +1,72 @@
#include "commands.h"
#include <blue/cmd.h>
enum {
OPT_SYNC_DB,
OPT_SYNC_ALL,
ARG_PACKAGE,
};
static int sync(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_SYNC, CMD_ROOT)
{
B_COMMAND_NAME("sync");
B_COMMAND_SHORT_NAME('S');
B_COMMAND_DESC(
"synchronise your machine with the your registered package "
"vendor(s). this command can be used to synchronise packages, "
"installing them or updating them to the latest available "
"version. all installed packages can be synchronised to update "
"the whole system, or the package database itself can be "
"synchronised to gain access to new and updated packages.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(sync);
B_COMMAND_HELP_OPTION();
B_COMMAND_OPTION(OPT_SYNC_DB)
{
B_OPTION_SHORT_NAME('y');
B_OPTION_LONG_NAME("database");
B_OPTION_DESC(
"synchronise the package database before synchronising "
"any packages. this option can be specified without "
"any package names to synchronise the package database "
"on its own.");
}
B_COMMAND_OPTION(OPT_SYNC_ALL)
{
B_OPTION_SHORT_NAME('u');
B_OPTION_LONG_NAME("synchronise-all");
B_OPTION_DESC(
"synchronise all packages currently installed on the "
"system, updating them to the latest available "
"version.");
}
B_COMMAND_ARG(ARG_PACKAGE)
{
B_ARG_NAME("package-name");
B_ARG_DESC(
"the names of the packages to synchronise. if a named "
"package is not installed, the latest version will be "
"installed. otherwise, the already-installed package "
"will be updated to the latest version.");
B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES);
}
B_COMMAND_USAGE()
{
B_COMMAND_USAGE_ARG(ARG_PACKAGE);
}
}

22
ropam/vendor/add.c vendored Normal file
View File

@@ -0,0 +1,22 @@
#include "../commands.h"
#include <blue/cmd.h>
static int vendor_add(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_VENDOR_ADD, CMD_VENDOR)
{
B_COMMAND_NAME("add");
B_COMMAND_SHORT_NAME('A');
B_COMMAND_DESC("add a new package vendor to the system.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(vendor_add);
B_COMMAND_HELP_OPTION();
}

22
ropam/vendor/list.c vendored Normal file
View File

@@ -0,0 +1,22 @@
#include "../commands.h"
#include <blue/cmd.h>
static int vendor_list(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_VENDOR_LIST, CMD_VENDOR)
{
B_COMMAND_NAME("list");
B_COMMAND_SHORT_NAME('L');
B_COMMAND_DESC("list all registered package vendors.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(vendor_list);
B_COMMAND_HELP_OPTION();
}

22
ropam/vendor/remove.c vendored Normal file
View File

@@ -0,0 +1,22 @@
#include "../commands.h"
#include <blue/cmd.h>
static int vendor_remove(
const b_command *self,
const b_arglist *opt,
const b_array *args)
{
return 0;
}
B_COMMAND(CMD_VENDOR_REMOVE, CMD_VENDOR)
{
B_COMMAND_NAME("remove");
B_COMMAND_SHORT_NAME('R');
B_COMMAND_DESC("remove a package vendor from the system.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(vendor_remove);
B_COMMAND_HELP_OPTION();
}

13
ropam/vendor/vendor.c vendored Normal file
View File

@@ -0,0 +1,13 @@
#include "../commands.h"
#include <blue/cmd.h>
B_COMMAND(CMD_VENDOR, CMD_ROOT)
{
B_COMMAND_NAME("vendor");
B_COMMAND_SHORT_NAME('V');
B_COMMAND_DESC("package vendor management commands.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_HELP_OPTION();
}