new: full implementation of remove and install functions

This commit is contained in:
ngn
2024-07-10 16:39:05 +03:00
parent d0dce209fa
commit f886bc08e4
30 changed files with 129 additions and 72 deletions

View File

@ -6,9 +6,10 @@
#include <string.h>
int main(int argc, char *argv[]) {
int ret = EXIT_FAILURE;
lm_pkg_t *pkg = NULL;
lm_ctx_t ctx;
lm_ctx_resolve_list_t *list = NULL;
lm_pkg_t *pkg = NULL, *cur = NULL;
lm_ctx_t ctx;
int ret = EXIT_FAILURE;
if (argc != 4) {
printf("usage: %s <package name> <pool name> <pool url>\n", argv[0]);
@ -50,23 +51,33 @@ int main(int argc, char *argv[]) {
goto end;
}
printf("downloading package: %s (%s)...\n", pkg->name, pkg->version);
printf("resolving package: %s (%s)...\n", pkg->name, pkg->version);
if (!lm_ctx_download(&ctx, pkg, NULL, NULL)) {
printf("failed to download package: %s (%d)\n", lm_strerror(), lm_error());
if ((list = lm_ctx_resolve(&ctx, pkg)) == NULL) {
printf("failed to resolve package: %s (%d)\n", lm_strerror(), lm_error());
goto end;
}
printf("installing package: %s (%s)...\n", pkg->name, pkg->version);
while ((cur = lm_ctx_resolve_next(list)) != NULL) {
printf("downloading package: %s (%s)...\n", cur->name, cur->version);
if (!lm_ctx_download(&ctx, cur, NULL, NULL)) {
printf("failed to download package: %s (%d)\n", lm_strerror(), lm_error());
goto end;
}
}
if (!lm_ctx_install(&ctx, pkg, NULL, NULL)) {
printf("failed to install the package: %s (%d)\n", lm_strerror(), lm_error());
goto end;
while ((cur = lm_ctx_resolve_next(list)) != NULL) {
printf("installing package: %s (%s)...\n", cur->name, cur->version);
if (!lm_ctx_install(&ctx, cur, NULL, NULL)) {
printf("failed to install the package: %s (%d)\n", lm_strerror(), lm_error());
goto end;
}
}
ret = EXIT_SUCCESS;
end:
lm_ctx_resolve_free(list);
lm_ctx_free(&ctx);
return ret;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
[base]
size = 314121
[test]
size = 3936
maintainer = ngn
pubkey = F9E70878C2FB389AEC2BA34CA3654DF5AD9F641D

BIN
examples/pools/test/LIST Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
goto end;
}
if (lm_ctx_pool_add(&ctx, "base", "mptp://127.0.0.1:5858") == NULL) {
if (lm_ctx_pool_add(&ctx, "test", "mptp://127.0.0.1:5858") == NULL) {
printf("failed to add pool: %s (%d)\n", lm_strerror(), lm_error());
goto end;
}