update: refactoring and small fixes
This commit is contained in:
@ -6,11 +6,11 @@
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int ret = EXIT_FAILURE;
|
||||
lm_pkg_t pkg;
|
||||
lm_ctx_t ctx;
|
||||
int ret = EXIT_FAILURE;
|
||||
lm_entry_t entry;
|
||||
lm_ctx_t ctx;
|
||||
|
||||
lm_package_init(&pkg);
|
||||
lm_entry_init(&entry);
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: %s <package name>\n", argv[0]);
|
||||
@ -34,14 +34,14 @@ int main(int argc, char *argv[]) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!lm_ctx_database_find(&ctx, &pkg, argv[1], NULL)) {
|
||||
if (!lm_ctx_database_find(&ctx, &entry, argv[1], NULL)) {
|
||||
printf("failed to find package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("checking %s (%s)...\n", pkg.name, pkg.version);
|
||||
printf("checking %s (%s)...\n", entry.name, entry.version);
|
||||
|
||||
if (!lm_ctx_check(&ctx, &pkg, NULL, NULL)) {
|
||||
if (!lm_ctx_check(&ctx, &entry, NULL, NULL)) {
|
||||
printf("failed to verify the package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
}
|
||||
@ -51,7 +51,7 @@ int main(int argc, char *argv[]) {
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
end:
|
||||
lm_package_free(&pkg);
|
||||
lm_entry_free(&entry);
|
||||
lm_ctx_free(&ctx);
|
||||
return ret;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ int main(int argc, char *argv[]) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("resolving package: %s (%s)...\n", pkg->name, pkg->version);
|
||||
printf("resolving package: %s (%s)...\n", pkg->data.name, pkg->data.version);
|
||||
|
||||
if ((list = lm_ctx_resolve(&ctx, pkg, NULL)) == NULL) {
|
||||
printf("failed to resolve package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
@ -59,7 +59,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
while ((cur = lm_ctx_resolve_next(list)) != NULL) {
|
||||
printf("downloading package: %s (%s)...\n", cur->name, cur->version);
|
||||
printf("downloading package: %s (%s)...\n", cur->data.name, cur->data.version);
|
||||
if (!lm_ctx_download(&ctx, cur, NULL, NULL)) {
|
||||
printf("failed to download package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
@ -67,8 +67,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
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("installing package: %s (%s)...\n", cur->data.name, cur->data.version);
|
||||
if (!lm_ctx_install(&ctx, cur, false, NULL, NULL)) {
|
||||
printf("failed to install the package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
}
|
||||
|
@ -6,10 +6,11 @@
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
lm_ctx_t ctx;
|
||||
lm_pkg_t pkg;
|
||||
int ret = EXIT_FAILURE;
|
||||
lm_ctx_t ctx;
|
||||
lm_entry_t entry;
|
||||
int ret = EXIT_FAILURE;
|
||||
|
||||
lm_entry_init(&entry);
|
||||
lm_ctx_init(&ctx);
|
||||
|
||||
if (!lm_ctx_set_data(&ctx, DATA_DIR)) {
|
||||
@ -19,10 +20,10 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
printf("listing installed packages:\n");
|
||||
|
||||
while (lm_ctx_database_next(&ctx, &pkg))
|
||||
printf("%s (%s)\n", pkg.name, pkg.version);
|
||||
while (lm_ctx_database_next(&ctx, &entry))
|
||||
printf("%s (%s)\n", entry.name, entry.version);
|
||||
|
||||
end:
|
||||
lm_ctx_database_next_free(&ctx, &pkg);
|
||||
lm_ctx_database_next_free(&ctx, &entry);
|
||||
return ret;
|
||||
}
|
||||
|
@ -6,11 +6,11 @@
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int ret = EXIT_FAILURE;
|
||||
lm_pkg_t pkg;
|
||||
lm_ctx_t ctx;
|
||||
int ret = EXIT_FAILURE;
|
||||
lm_entry_t entry;
|
||||
lm_ctx_t ctx;
|
||||
|
||||
lm_package_init(&pkg);
|
||||
lm_entry_init(&entry);
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: %s <package name>\n", argv[0]);
|
||||
@ -39,19 +39,19 @@ int main(int argc, char *argv[]) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!lm_ctx_database_find(&ctx, &pkg, argv[1], NULL)) {
|
||||
if (!lm_ctx_database_find(&ctx, &entry, argv[1], NULL)) {
|
||||
printf("failed to find package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!lm_ctx_removeable(&ctx, &pkg)) {
|
||||
printf("cannot remove package: %s (%d)", lm_strerror(), lm_error());
|
||||
if (!lm_ctx_removeable(&ctx, &entry)) {
|
||||
printf("cannot remove package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("removing package: %s (%s)...\n", pkg.name, pkg.version);
|
||||
printf("removing package: %s (%s)...\n", entry.name, entry.version);
|
||||
|
||||
if (!lm_ctx_remove(&ctx, &pkg, NULL, NULL)) {
|
||||
if (!lm_ctx_remove(&ctx, &entry, NULL, NULL)) {
|
||||
printf("failed to remove package: %s (%d)\n", lm_strerror(), lm_error());
|
||||
goto end;
|
||||
}
|
||||
@ -59,7 +59,7 @@ int main(int argc, char *argv[]) {
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
end:
|
||||
lm_package_free(&pkg);
|
||||
lm_entry_free(&entry);
|
||||
lm_ctx_free(&ctx);
|
||||
return ret;
|
||||
}
|
||||
|
@ -8,8 +8,9 @@
|
||||
int main(int argc, char *argv[]) {
|
||||
lm_ctx_update_list_t *list = NULL;
|
||||
int ret = EXIT_FAILURE;
|
||||
lm_pkg_t pkg, *old = NULL, *new = NULL;
|
||||
lm_ctx_t ctx;
|
||||
lm_pkg_t *new = NULL;
|
||||
lm_entry_t *old = NULL;
|
||||
lm_ctx_t ctx;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("usage: %s <pool name> <pool url>\n", argv[0]);
|
||||
@ -74,7 +75,7 @@ int main(int argc, char *argv[]) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!lm_ctx_install(&ctx, new, NULL, NULL)) {
|
||||
if (!lm_ctx_install(&ctx, new, false, NULL, NULL)) {
|
||||
printf("failed to install new package: %s", lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
Reference in New Issue
Block a user