Move version compatibility to the consumer; name libdpm-core explicitly
dpm_require no longer takes a minimum version and applies no version criterion of its own. A handle now means the module is valid, not that it suits the caller. dpm_module_info_of is added alongside it, reporting the name, version, description, and minimum-libdpm-core version read at load, so a consuming module can judge a dependency's version for itself. The one rule still enforced is the minimum-version handshake, where libdpm-core is the host and refuses a module that demands a newer library than the one running. dpm_module_info_of joins the version script, so the exported surface is now fourteen symbols under DPM_CORE_1.0. Separately, the bare word "core" is gone from prose everywhere. It named both the command-line tool and the library, so every use forced the reader to guess which. Text now says "the dpm binary" or "libdpm-core". Identifiers keep their spelling: libdpm-core, core.h, core.conf, the "core" configuration namespace, dpm_core_version, core_min, DPM_CORE_1.0, the dpmcore namespace, test_core, core_api. Three user-visible strings changed with it: the load-refusal message now reads "requires libdpm-core >= X, running libdpm-core is Y — update libdpm-core", and the info module's description and help text name the library. The test asserting on the refusal text was updated to match. DESIGN.md's terminology line no longer defines "DPM Core" as the CLI, which was the source of the ambiguity. OVERVIEW.md is restructured around the three layers a reader meets DPM at — user, developer, filesystem — so a code-level symbol never appears without saying whose layer it is. MODULES.md describes the bundled info module as testing and demonstrating full DPM system functionality rather than as a reference implementation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ Programs link libdpm-core to operate the package manager directly: build systems
|
||||
|
||||
## Compiling and linking
|
||||
|
||||
With core installed, include the public header and link the library:
|
||||
With libdpm-core installed, include the public header and link the library:
|
||||
|
||||
```
|
||||
#include <dpm/core.h>
|
||||
@@ -44,13 +44,22 @@ The root override is what makes chroot builds, image assembly, and sysroot manag
|
||||
|
||||
## Acquiring and using modules
|
||||
|
||||
**dpm_require** loads a module by name, on demand, with an optional minimum version:
|
||||
**dpm_require** loads a module by name, on demand:
|
||||
|
||||
```
|
||||
dpm_module* mod = dpm_require(ctx, "mymodule", "1.0.0");
|
||||
dpm_module* mod = dpm_require(ctx, "mymodule");
|
||||
```
|
||||
|
||||
Core validates the module completely at load; a handle is returned only for a fully valid module. NULL means the module is absent, invalid, or below the minimum — dpm_last_error(ctx) carries the precise reason. Modules load at most once per context; repeated calls return the same handle.
|
||||
libdpm-core validates the module completely at load; a handle is returned only for a fully valid module. NULL means the module is absent or invalid — dpm_last_error(ctx) carries the precise reason. Modules load at most once per context; repeated calls return the same handle.
|
||||
|
||||
**dpm_module_info_of** reports what libdpm-core saw in the loaded module:
|
||||
|
||||
```
|
||||
dpm_module_info info;
|
||||
dpm_module_info_of(ctx, mod, &info); /* info.name, .version, .description, .core_min */
|
||||
```
|
||||
|
||||
Deciding whether that version is too new or too old is yours. libdpm-core applies no version criterion of its own — a handle means the module is valid, not that it suits you.
|
||||
|
||||
**dpm_execute** drives a module the way the CLI does — a command name and arguments:
|
||||
|
||||
@@ -81,7 +90,8 @@ The cursor covers every valid module in the module path; invalid candidates are
|
||||
|
||||
## Services
|
||||
|
||||
- **dpm_core_version()** — core's version; callable without a context.
|
||||
- **dpm_core_version()** — the libdpm-core version; callable without a context.
|
||||
- **dpm_module_info_of(ctx, mod, out)** — the name, version, description, and minimum-libdpm-core version read from a loaded module.
|
||||
- **dpm_config_get(ctx, module, section, key)** — a value from a module's configuration namespace, or NULL if unset.
|
||||
- **dpm_log(ctx, level, message)** — writes to the context's configured log targets; levels are DPM_LOG_FATAL through DPM_LOG_DEBUG.
|
||||
- **dpm_module_path(ctx)** — the resolved module directory.
|
||||
@@ -104,7 +114,7 @@ int main(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
dpm_module* mod = dpm_require(ctx, "info", NULL);
|
||||
dpm_module* mod = dpm_require(ctx, "info");
|
||||
if (!mod) {
|
||||
fprintf(stderr, "%s\n", dpm_last_error(ctx));
|
||||
dpm_close(ctx);
|
||||
|
||||
Reference in New Issue
Block a user