2024-06-20 00:34:32 +00:00
|
|
|
#include "../../include/all.h"
|
2024-08-03 19:23:32 +00:00
|
|
|
#include "../common.h"
|
2024-06-27 20:05:39 +00:00
|
|
|
|
2024-06-20 00:34:32 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2024-07-06 00:48:23 +00:00
|
|
|
#include <string.h>
|
2024-06-20 00:34:32 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2024-07-31 18:16:19 +00:00
|
|
|
int ret = EXIT_FAILURE;
|
|
|
|
lm_entry_t entry;
|
|
|
|
lm_ctx_t ctx;
|
2024-06-20 00:34:32 +00:00
|
|
|
|
2024-07-31 18:16:19 +00:00
|
|
|
lm_entry_init(&entry);
|
2024-07-08 09:49:22 +00:00
|
|
|
|
2024-06-20 22:36:56 +00:00
|
|
|
if (argc != 2) {
|
2024-07-08 04:24:39 +00:00
|
|
|
printf("usage: %s <package name>\n", argv[0]);
|
2024-06-20 00:34:32 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-08-04 13:00:18 +00:00
|
|
|
if (!lm_ctx_new(&ctx, ROOT_DIR, TEMP_DIR, DATA_DIR)) {
|
2024-08-03 19:23:32 +00:00
|
|
|
printf("failed to init the ctx: %s (%d)\n", lm_strerror(), lm_error());
|
2024-07-06 00:48:23 +00:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2024-07-31 18:16:19 +00:00
|
|
|
if (!lm_ctx_database_find(&ctx, &entry, argv[1], NULL)) {
|
2024-07-06 00:48:23 +00:00
|
|
|
printf("failed to find package: %s (%d)\n", lm_strerror(), lm_error());
|
2024-07-05 13:27:11 +00:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2024-07-31 18:16:19 +00:00
|
|
|
if (!lm_ctx_removeable(&ctx, &entry)) {
|
|
|
|
printf("cannot remove package: %s (%d)\n", lm_strerror(), lm_error());
|
2024-07-17 18:31:25 +00:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2024-07-31 18:16:19 +00:00
|
|
|
printf("removing package: %s (%s)...\n", entry.name, entry.version);
|
2024-07-08 10:08:45 +00:00
|
|
|
|
2024-07-31 18:16:19 +00:00
|
|
|
if (!lm_ctx_remove(&ctx, &entry, NULL, NULL)) {
|
2024-07-08 04:24:39 +00:00
|
|
|
printf("failed to remove package: %s (%d)\n", lm_strerror(), lm_error());
|
2024-07-02 01:44:07 +00:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2024-06-20 00:34:32 +00:00
|
|
|
ret = EXIT_SUCCESS;
|
|
|
|
|
|
|
|
end:
|
2024-07-31 18:16:19 +00:00
|
|
|
lm_entry_free(&entry);
|
2024-06-20 00:34:32 +00:00
|
|
|
lm_ctx_free(&ctx);
|
|
|
|
return ret;
|
|
|
|
}
|