new: update command
This commit is contained in:
parent
ba0583fdf4
commit
c92aa262a7
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-07-17 22:55+0300\n"
|
||||
"POT-Creation-Date: 2024-07-18 19:12+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -123,7 +123,7 @@ msgstr ""
|
||||
|
||||
#: src/main.c:121 src/main.c:122 src/cmd/install.c:22 src/cmd/install.c:23
|
||||
#: src/cmd/list.c:13 src/cmd/list.c:14 src/cmd/remove.c:17 src/cmd/remove.c:18
|
||||
#: src/cmd/update.c:39
|
||||
#: src/cmd/update.c:23
|
||||
#, c-format
|
||||
msgid " "
|
||||
msgstr ""
|
||||
@ -137,7 +137,7 @@ msgstr ""
|
||||
msgid "Listing options for the install command:"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:35
|
||||
#: src/cmd/install.c:28 src/cmd/update.c:28
|
||||
msgid "There are no avaliable pools, have you synced yet?"
|
||||
msgstr ""
|
||||
|
||||
@ -159,12 +159,12 @@ msgstr "Havuzları sekronize etmek başarısız oldu: %s"
|
||||
msgid "Nothing to do (no packages to install)"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:77 src/cmd/remove.c:64 src/cmd/update.c:60
|
||||
#: src/cmd/install.c:77 src/cmd/remove.c:64 src/cmd/update.c:48
|
||||
#, c-format
|
||||
msgid "Following %d package will be "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:79 src/cmd/remove.c:66 src/cmd/update.c:62
|
||||
#: src/cmd/install.c:79 src/cmd/remove.c:66 src/cmd/update.c:50
|
||||
#, c-format
|
||||
msgid "Following %d packages will be "
|
||||
msgstr ""
|
||||
@ -175,30 +175,30 @@ msgid "Total of "
|
||||
msgstr ""
|
||||
|
||||
#. list all the packages
|
||||
#: src/cmd/install.c:84 src/cmd/remove.c:71 src/cmd/update.c:66
|
||||
#: src/cmd/install.c:84 src/cmd/remove.c:71 src/cmd/update.c:54
|
||||
msgid "Continue?"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:85 src/cmd/remove.c:72 src/cmd/update.c:67
|
||||
#: src/cmd/install.c:85 src/cmd/remove.c:72 src/cmd/update.c:55
|
||||
msgid "Operation cancelled"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:91
|
||||
#: src/cmd/install.c:91 src/cmd/update.c:65
|
||||
#, c-format
|
||||
msgid "(%d/%d) Downloading "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:97
|
||||
#: src/cmd/install.c:97 src/cmd/update.c:70
|
||||
#, fuzzy
|
||||
msgid "Failed to download "
|
||||
msgstr "Havuzları sekronize etmek başarısız oldu: %s"
|
||||
|
||||
#: src/cmd/install.c:106 src/cmd/update.c:27
|
||||
#: src/cmd/install.c:106 src/cmd/update.c:83
|
||||
#, c-format
|
||||
msgid "(%d/%d) Installing "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:112
|
||||
#: src/cmd/install.c:112 src/cmd/update.c:88
|
||||
#, fuzzy
|
||||
msgid "Failed to install "
|
||||
msgstr "Havuzları sekronize etmek başarısız oldu: %s"
|
||||
@ -238,12 +238,12 @@ msgstr "Havuzları sekronize etmek başarısız oldu: %s"
|
||||
msgid "Nothing to do (no packages to remove)"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/remove.c:79 src/cmd/update.c:20
|
||||
#: src/cmd/remove.c:79 src/cmd/update.c:74
|
||||
#, c-format
|
||||
msgid "(%d/%d) Removing "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/remove.c:85
|
||||
#: src/cmd/remove.c:85 src/cmd/update.c:79
|
||||
#, fuzzy
|
||||
msgid "Failed to remove "
|
||||
msgstr "Havuzları sekronize etmek başarısız oldu: %s"
|
||||
@ -282,20 +282,20 @@ msgstr "Lütfen konfigürasyonda en az bir havuz belirtin"
|
||||
msgid "Failed to sync pools: %s"
|
||||
msgstr "Havuzları sekronize etmek başarısız oldu: %s"
|
||||
|
||||
#: src/cmd/update.c:38
|
||||
#: src/cmd/update.c:22
|
||||
msgid "Listing options for the update command:"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/update.c:50
|
||||
#: src/cmd/update.c:38
|
||||
#, fuzzy, c-format
|
||||
msgid "Failed to get the package update list: %s"
|
||||
msgstr "%s: paket listesini yüklemek başarısız oldu (%s)"
|
||||
|
||||
#: src/cmd/update.c:55
|
||||
#: src/cmd/update.c:43
|
||||
msgid "All packages are up-to-date"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/update.c:79
|
||||
#: src/cmd/update.c:61
|
||||
#, fuzzy
|
||||
msgid "Failed to update "
|
||||
msgstr "Havuzları sekronize etmek başarısız oldu: %s"
|
||||
|
@ -24,6 +24,11 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(lm_ctx_sync(ctx, false, NULL, NULL) <= 0){
|
||||
error(_("There are no avaliable pools, have you synced yet?"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
lm_ctx_resolve_list_t *list = NULL;
|
||||
bool ret = false, r = false;
|
||||
ssize_t current = 0, size = 0;
|
||||
@ -31,11 +36,6 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
lm_pkg_t *pkg = NULL;
|
||||
char *name = NULL;
|
||||
|
||||
if(lm_ctx_sync(ctx, false, NULL, NULL) <= 0){
|
||||
error(_("There are no avaliable pools, have you synced yet?"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
for(int i = 0; i < args->count; i++){
|
||||
if(NULL != args->list[i].name)
|
||||
continue;
|
||||
|
@ -6,30 +6,14 @@
|
||||
#include "../cmd.h"
|
||||
#include "../log.h"
|
||||
|
||||
struct cmd_update_data {
|
||||
ssize_t total;
|
||||
ssize_t current;
|
||||
};
|
||||
|
||||
bool cmd_update_callback(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_update_state_t state, char *file, size_t current, size_t total, void *data){
|
||||
struct cmd_update_data *cbdata = data;
|
||||
|
||||
switch (state) {
|
||||
case UPDATE_REMOVE:
|
||||
if(current == 0)
|
||||
info(_("(%d/%d) Removing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), cbdata->current, cbdata->total, pkg->name, pkg->version);
|
||||
bool cmd_update_callback(lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data){
|
||||
bar(current, total);
|
||||
break;
|
||||
|
||||
case UPDATE_INSTALL:
|
||||
if(current == 0){
|
||||
bar_free();
|
||||
info(_("(%d/%d) Installing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), cbdata->current, cbdata->total, pkg->name, pkg->version);
|
||||
}
|
||||
bar(current, total);
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cmd_update_download_callback(lm_ctx_t *ctx, lm_pkg_t *pkg, bool is_archive, size_t current, size_t total, void *data){
|
||||
if(!is_archive)
|
||||
bar(current, total);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -40,10 +24,14 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(lm_ctx_sync(ctx, false, NULL, NULL) <= 0){
|
||||
error(_("There are no avaliable pools, have you synced yet?"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
lm_pkg_t *old = NULL, *new = NULL;
|
||||
lm_ctx_update_list_t *list = NULL;
|
||||
struct cmd_update_data cbdata;
|
||||
bool ret = false, r = false;
|
||||
lm_pkg_t *pkg = NULL;
|
||||
ssize_t current = 0;
|
||||
|
||||
if((list = lm_ctx_update_list(ctx)) == NULL){
|
||||
@ -68,15 +56,36 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
goto end;
|
||||
}
|
||||
|
||||
while((pkg = lm_ctx_update_list_next(list)) != NULL){
|
||||
cbdata.current = ++current;
|
||||
cbdata.total = list->count;
|
||||
while((old = lm_ctx_update_list_next(list)) != NULL){
|
||||
if((new = lm_ctx_update(ctx, old)) == NULL){
|
||||
error(_("Failed to update "FG_BOLD"%s"FG_RESET": %s"), old->name, lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
||||
r = lm_ctx_update(ctx, pkg, cmd_update_callback, &cbdata);
|
||||
info(_("(%d/%d) Downloading "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), ++current, list->count, new->name, new->version);
|
||||
r = lm_ctx_download(ctx, new, cmd_update_download_callback, NULL);
|
||||
bar_free();
|
||||
|
||||
if(!r){
|
||||
error(_("Failed to update "FG_BOLD"%s"FG_RESET": %s"), pkg->name, lm_strerror());
|
||||
error(_("Failed to download "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s"), new->name, new->version, lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
||||
info(_("(%d/%d) Removing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), current, list->count, old->name, old->version);
|
||||
r = lm_ctx_remove(ctx, old, cmd_update_callback, NULL);
|
||||
bar_free();
|
||||
|
||||
if(!r){
|
||||
error(_("Failed to remove "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s"), old->name, old->version, lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
||||
info(_("(%d/%d) Installing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), current, list->count, new->name, new->version);
|
||||
r = lm_ctx_install(ctx, new, cmd_update_callback, NULL);
|
||||
bar_free();
|
||||
|
||||
if(!r){
|
||||
error(_("Failed to install "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s"), new->name, new->version, lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user