update: remove older packages while installing newer

This commit is contained in:
ngn 2024-08-16 03:10:07 +03:00
parent 04b3e3c8ef
commit 787d975c49
9 changed files with 191 additions and 162 deletions

View File

@ -11,7 +11,7 @@ OBJS = $(patsubst src/%.c,dist/%.o,$(SRCS))
CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
LIBS = -linih -lmp
VERSION = 24.01
VERSION = 24.02
all: dist dist/matt $(PO_OUTS)

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-15 03:57+0300\n"
"POT-Creation-Date: 2024-08-16 03:05+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"
@ -17,6 +17,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/callback.c:34 src/callback.c:49
msgid "Failed to sync "
msgstr "Failed to sync "
#: src/callback.c:43 src/cmd/sync.c:32
msgid "Synced "
msgstr "Synced "
#: src/config.c:71
#, c-format
msgid "Unknown configuration option: %s/%s"
@ -73,77 +81,77 @@ msgstr "Please answer with y/n"
msgid "Received a segfault"
msgstr "Received a segfault"
#: src/main.c:100
#: src/main.c:102
msgid "Failed to access the root directory, are you running as root?"
msgstr "Failed to access the root directory, are you running as root?"
#: src/main.c:104
#: src/main.c:106
#, fuzzy
msgid "Failed to access the data directory ("
msgstr "Failed to access the configuration file: %s"
#: src/main.c:108
#: src/main.c:110
#, fuzzy
msgid "Failed to access the temp directory ("
msgstr "Failed to open the editor: %s"
#: src/main.c:112
#: src/main.c:114
#, fuzzy, c-format
msgid "Failed to initialize libmp context: %s"
msgstr "Failed to install "
#: src/main.c:123
#: src/main.c:125
#, fuzzy
msgid "Failed to create the pools directory ("
msgstr "Failed to open the editor: %s"
#: src/main.c:133
#: src/main.c:135
msgid "Failed to add pool "
msgstr "Failed to add pool "
#: src/main.c:147
#: src/main.c:149
msgid "Failed to lock, matt is already running"
msgstr "Failed to lock, matt is already running"
#: src/main.c:151
#: src/main.c:153
msgid "Failed to lock, are you root?"
msgstr "Failed to lock, are you root?"
#: src/main.c:162
#: src/main.c:165
msgid "Command not found: "
msgstr "Command not found: "
#: src/main.c:164
#: src/main.c:167
#, fuzzy, c-format
msgid "MatterLinux package manager %s (libmp %s)"
msgstr "MatterLinux package manager (version %s)"
#: src/main.c:165
#: src/main.c:168
msgid "Usage: "
msgstr "Usage: "
#: src/main.c:167
#: src/main.c:170
msgid "Here is a list of available commands:"
msgstr "Here is a list of available commands:"
#: src/main.c:173
#: src/main.c:176
msgid "To list different options, use commands with "
msgstr "To list different options, use commands with "
#: src/main.c:174
#: src/main.c:177
msgid "Here is a list of available global options:"
msgstr "Here is a list of available global options:"
#: src/main.c:177 src/main.c:178 src/cmd/info.c:54 src/cmd/info.c:55
#: src/cmd/info.c:56 src/cmd/install.c:47 src/cmd/install.c:48
#: src/cmd/install.c:49 src/cmd/install.c:50 src/cmd/install.c:51
#: src/cmd/list.c:24 src/cmd/list.c:25 src/cmd/remove.c:32 src/cmd/remove.c:33
#: src/cmd/update.c:38
#: src/main.c:180 src/main.c:181 src/cmd/info.c:54 src/cmd/info.c:55
#: src/cmd/info.c:56 src/cmd/install.c:34 src/cmd/install.c:35
#: src/cmd/install.c:36 src/cmd/install.c:37 src/cmd/install.c:38
#: src/cmd/list.c:24 src/cmd/list.c:25 src/cmd/remove.c:28 src/cmd/remove.c:29
#: src/cmd/update.c:23
#, c-format
msgid " "
msgstr " "
#: src/main.c:180
#: src/main.c:183
msgid ""
"Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information"
msgstr ""
@ -163,13 +171,12 @@ msgstr "Failed to run the editor: %s"
msgid "Failed to open the editor: %s"
msgstr "Failed to open the editor: %s"
#: src/cmd/info.c:19 src/cmd/info.c:29 src/cmd/install.c:104
#: src/cmd/remove.c:56
#: src/cmd/info.c:19 src/cmd/info.c:29 src/cmd/install.c:91 src/cmd/remove.c:52
msgid "Package "
msgstr "Package "
#: src/cmd/info.c:48 src/cmd/install.c:41 src/cmd/list.c:18 src/cmd/remove.c:26
#: src/cmd/sync.c:48 src/cmd/update.c:32
#: src/cmd/info.c:48 src/cmd/install.c:28 src/cmd/list.c:18 src/cmd/remove.c:22
#: src/cmd/sync.c:15 src/cmd/update.c:17
msgid "Unknown argument: "
msgstr ""
@ -237,76 +244,81 @@ msgstr "Installed "
msgid "Up-to-date "
msgstr "Up-to-date "
#: src/cmd/install.c:46
#: src/cmd/install.c:33
msgid "Listing options for the install command:"
msgstr "Listing options for the install command:"
#: src/cmd/install.c:56 src/cmd/update.c:43
#: src/cmd/install.c:43 src/cmd/update.c:28
msgid "There are no avaliable pools, have you synced yet?"
msgstr "There are no avaliable pools, have you synced yet?"
#: src/cmd/install.c:75
#: src/cmd/install.c:62
msgid "Specified "
msgstr ""
#: src/cmd/install.c:85
#: src/cmd/install.c:72
#, fuzzy
msgid "Failed to load "
msgstr "Failed to download "
#: src/cmd/install.c:95 src/cmd/remove.c:58
#: src/cmd/install.c:82 src/cmd/remove.c:54
msgid "Failed to find "
msgstr "Failed to find "
#: src/cmd/install.c:113
#: src/cmd/install.c:100
msgid "Failed to resolve "
msgstr "Failed to resolve "
#: src/cmd/install.c:122
#: src/cmd/install.c:109
msgid "Nothing to do (no packages to install)"
msgstr "Nothing to do (no packages to install)"
#: src/cmd/install.c:131 src/cmd/install.c:133 src/cmd/remove.c:78
#: src/cmd/remove.c:80 src/cmd/update.c:64 src/cmd/update.c:66
#: src/cmd/install.c:118 src/cmd/install.c:120 src/cmd/remove.c:74
#: src/cmd/remove.c:76 src/cmd/update.c:49 src/cmd/update.c:51
msgid "Following "
msgstr "Following "
#: src/cmd/install.c:139 src/cmd/remove.c:87
#: src/cmd/install.c:126 src/cmd/remove.c:83
msgid "Total of "
msgstr "Total of "
#: src/cmd/install.c:142 src/cmd/update.c:73
#: src/cmd/install.c:129 src/cmd/update.c:58
#, c-format
msgid "Root directory is modified, install scripts will be saved in %s"
msgstr "Root directory is modified, install scripts will be saved in %s"
#: src/cmd/install.c:144 src/cmd/remove.c:88 src/cmd/update.c:75
#: src/cmd/install.c:131 src/cmd/remove.c:84 src/cmd/update.c:60
msgid "Continue?"
msgstr "Continue?"
#: src/cmd/install.c:145 src/cmd/remove.c:89 src/cmd/update.c:76
#: src/cmd/install.c:132 src/cmd/remove.c:85 src/cmd/update.c:61
msgid "Operation cancelled"
msgstr "Operation cancelled"
#: src/cmd/install.c:161 src/cmd/install.c:165 src/cmd/install.c:180
#: src/cmd/remove.c:96 src/cmd/update.c:86 src/cmd/update.c:95
#: src/cmd/update.c:104
#: src/cmd/install.c:148 src/cmd/install.c:152 src/cmd/install.c:172
#: src/cmd/install.c:188 src/cmd/remove.c:92 src/cmd/update.c:71
#: src/cmd/update.c:82 src/cmd/update.c:93
msgid "("
msgstr "("
#: src/cmd/install.c:171 src/cmd/update.c:91
#: src/cmd/install.c:158 src/cmd/update.c:77
msgid "Failed to download "
msgstr "Failed to download "
#: src/cmd/install.c:186 src/cmd/update.c:109
#: src/cmd/install.c:179 src/cmd/remove.c:59 src/cmd/remove.c:99
#: src/cmd/update.c:88
msgid "Failed to remove "
msgstr "Failed to remove "
#: src/cmd/install.c:195 src/cmd/update.c:99
msgid "Failed to install "
msgstr "Failed to install "
#: src/cmd/install.c:192
#: src/cmd/install.c:202
msgid "Installed "
msgstr "Installed "
#: src/cmd/install.c:192
#: src/cmd/install.c:202
msgid "Installed all of the "
msgstr "Installed all of the "
@ -318,57 +330,45 @@ msgstr "There no installed packages"
msgid "Listing "
msgstr "Listing "
#: src/cmd/remove.c:31
#: src/cmd/remove.c:27
msgid "Listing options for the remove command:"
msgstr "Listing options for the remove command:"
#: src/cmd/remove.c:63 src/cmd/remove.c:102 src/cmd/update.c:100
msgid "Failed to remove "
msgstr "Failed to remove "
#: src/cmd/remove.c:71
#: src/cmd/remove.c:67
msgid "Nothing to do (no packages to remove)"
msgstr "Nothing to do (no packages to remove)"
#: src/cmd/remove.c:108
#: src/cmd/remove.c:106
msgid "Removed "
msgstr "Removed "
#: src/cmd/remove.c:108
#: src/cmd/remove.c:106
msgid "Removed all of the "
msgstr "Removed all of the "
#: src/cmd/sync.c:20 src/cmd/sync.c:35
msgid "Failed to sync "
msgstr "Failed to sync "
#: src/cmd/sync.c:29 src/cmd/sync.c:65
msgid "Synced "
msgstr "Synced "
#: src/cmd/sync.c:53
#: src/cmd/sync.c:20
msgid "There are no pools specified in the configuration"
msgstr "There are no pools specified in the configuration"
#: src/cmd/sync.c:61
#: src/cmd/sync.c:28
#, c-format
msgid "Failed to sync pools: %s"
msgstr "Failed to sync pools: %s"
#: src/cmd/update.c:37
#: src/cmd/update.c:22
msgid "Listing options for the update command:"
msgstr "Listing options for the update command:"
#: src/cmd/update.c:54
#: src/cmd/update.c:39
#, c-format
msgid "Failed to get the package update list: %s"
msgstr "Failed to get the package update list: %s"
#: src/cmd/update.c:59
#: src/cmd/update.c:44
msgid "All packages are up-to-date"
msgstr "All packages are up-to-date"
#: src/cmd/update.c:82
#: src/cmd/update.c:67
msgid "Failed to update "
msgstr "Failed to update "

54
src/callback.c Normal file
View File

@ -0,0 +1,54 @@
#include "callback.h"
#include "intl.h"
#include "log.h"
bool callback_install(lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data) {
bar(current, total);
return true;
}
bool callback_download(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;
}
bool callback_remove(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current, size_t total, void *data) {
bar(current, total);
return true;
}
bool callback_sync(
lm_ctx_t *ctx, lm_pool_t *pool, lm_ctx_sync_state_t state, size_t current, size_t total, void *data) {
switch (state) {
case SYNC_DOWNLOADING_INFO:
bar(current, total);
break;
case SYNC_INFO_SUCCESS:
bar_free();
break;
case SYNC_INFO_FAIL:
bar_free();
error(_("Failed to sync " FG_BOLD "%s" FG_RESET ": %s"), pool->name, lm_strerror());
break;
case SYNC_DOWNLOADING_LIST:
bar(current, total);
break;
case SYNC_LIST_SUCCESS:
bar_free();
success(_("Synced " FG_BOLD "%s [%s]" FG_RESET), pool->name, pool->info.pubkey);
break;
case SYNC_LIST_FAIL:
bar_free();
if (LM_ERR_InfoNotLoaded != lm_error())
error(_("Failed to sync " FG_BOLD "%s" FG_RESET ": %s"), pool->name, lm_strerror());
break;
}
return true;
}

8
src/callback.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <libmp/all.h>
#include <stdbool.h>
bool callback_install(lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data);
bool callback_download(lm_ctx_t *ctx, lm_pkg_t *pkg, bool is_archive, size_t current, size_t total, void *data);
bool callback_remove(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current, size_t total, void *data);
bool callback_sync(lm_ctx_t *ctx, lm_pool_t *pool, lm_ctx_sync_state_t state, size_t current, size_t total, void *data);

View File

@ -1,27 +1,14 @@
#include <libmp/all.h>
#include <libmp/ctx.h>
#include <libmp/error.h>
#include <libmp/package.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include "../callback.h"
#include "../util.h"
#include "../intl.h"
#include "../cmd.h"
#include "../log.h"
bool cmd_install_callback(lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data){
bar(current, total);
return true;
}
bool cmd_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;
}
bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
char *arg = NULL;
@ -59,9 +46,9 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
ssize_t current = 0, size = 0, save = 0, li = 0;
bool ret = false, r = false, is_local = false;
bool resolve_depends = !args_get_bool(args, "ignore-depends");
lm_pkg_t *pkg = NULL, *locals = NULL;
lm_ctx_resolve_list_t *list = NULL;
lm_entry_t older;
char ssize[LONGSTR_MAX+3];
char *name = NULL;
@ -109,7 +96,7 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
}
// resolve the package and depends
if((list = lm_ctx_resolve(ctx, pkg, resolve_depends, list)) == NULL){
if((list = lm_ctx_resolve(ctx, pkg, !args_get_bool(args, "ignore-depends"), list)) == NULL){
error(_("Failed to resolve "FG_BOLD"%s"FG_RESET": %s"), name, lm_strerror());
goto end;
}
@ -164,7 +151,7 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Downloading "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), ++current, list->count, pkg->data.name, pkg->data.version);
r = lm_ctx_download(ctx, pkg, cmd_download_callback, NULL);
r = lm_ctx_download(ctx, pkg, callback_download, NULL);
bar_free();
if(!r){
@ -177,13 +164,36 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
// install resolved packages
while((pkg = lm_ctx_resolve_next(list)) != NULL){
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Installing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), ++current, list->count, pkg->data.name, pkg->data.version);
lm_entry_init(&older);
current++;
// if an older version is installed, remove it first
if(lm_ctx_database_find(ctx, &older, pkg->data.name, NULL)){
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"),
current, list->count, older.name, older.version);
r = lm_ctx_install(ctx, pkg, can_run_install(ctx), cmd_install_callback, NULL);
r = lm_ctx_remove(ctx, &older, callback_remove, NULL);
bar_free();
if(!r)
error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"),
older.name, older.version, lm_strerror());
lm_entry_free(&older);
if(!r)
goto end;
}
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Installing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"),
current, list->count, pkg->data.name, pkg->data.version);
r = lm_ctx_install(ctx, pkg, can_run_install(ctx), callback_install, NULL);
bar_free();
if(!r){
error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), pkg->data.name, pkg->data.version, lm_strerror());
error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"),
pkg->data.name, pkg->data.version, lm_strerror());
goto end;
}
}

View File

@ -3,16 +3,12 @@
#include <stdlib.h>
#include <stdio.h>
#include "../callback.h"
#include "../util.h"
#include "../intl.h"
#include "../cmd.h"
#include "../log.h"
bool cmd_remove_callback(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current, size_t total, void *data){
bar(current, total);
return true;
}
bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
char *arg = NULL;
@ -45,11 +41,11 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
continue;
if(NULL == pkgs)
pkgs = malloc(sizeof(lm_pkg_t));
pkgs = malloc(sizeof(lm_entry_t));
else
pkgs = realloc(pkgs, sizeof(lm_pkg_t)*(count+1));
pkgs = realloc(pkgs, sizeof(lm_entry_t)*(count+1));
bzero(&pkgs[count], sizeof(lm_pkg_t));
lm_entry_init(&pkgs[count]);
if(!lm_ctx_database_find(ctx, &pkgs[count++], name, NULL)){
if(lm_error() == LM_ERR_DbSqlNotFound)
@ -93,13 +89,15 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
for(int i = 0; i < count; i++){
lm_entry_t *cur = &pkgs[i];
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET), ++current, count, cur->name, cur->version);
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET),
++current, count, cur->name, cur->version);
r = lm_ctx_remove(ctx, cur, cmd_remove_callback, NULL);
r = lm_ctx_remove(ctx, cur, callback_remove, NULL);
bar_free();
if(!r){
error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), cur->name, cur->version, lm_strerror());
error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"),
cur->name, cur->version, lm_strerror());
goto end;
}
}

View File

@ -1,44 +1,11 @@
#include <libmp/all.h>
#include <stdio.h>
#include "../callback.h"
#include "../intl.h"
#include "../cmd.h"
#include "../log.h"
bool cmd_sync_callback(lm_ctx_t *ctx, lm_pool_t *pool, lm_ctx_sync_state_t state, size_t current, size_t total, void *data){
switch (state) {
case SYNC_DOWNLOADING_INFO:
bar(current, total);
break;
case SYNC_INFO_SUCCESS:
bar_free();
break;
case SYNC_INFO_FAIL:
bar_free();
error(_("Failed to sync "FG_BOLD"%s"FG_RESET": %s"), pool->name, lm_strerror());
break;
case SYNC_DOWNLOADING_LIST:
bar(current, total);
break;
case SYNC_LIST_SUCCESS:
bar_free();
success(_("Synced "FG_BOLD"%s [%s]"FG_RESET), pool->name, pool->info.pubkey);
break;
case SYNC_LIST_FAIL:
bar_free();
if(LM_ERR_InfoNotLoaded != lm_error())
error(_("Failed to sync "FG_BOLD"%s"FG_RESET": %s"), pool->name, lm_strerror());
break;
}
return true;
}
bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args){
size_t sycned = 0;
bool ret = false;
@ -54,7 +21,7 @@ bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args){
goto end;
}
sycned = lm_ctx_sync(ctx, true, cmd_sync_callback, NULL);
sycned = lm_ctx_sync(ctx, true, callback_sync, NULL);
bar_free();
if(sycned < 0){

View File

@ -1,27 +1,12 @@
#include <libmp/all.h>
#include <stdio.h>
#include "../callback.h"
#include "../util.h"
#include "../intl.h"
#include "../cmd.h"
#include "../log.h"
bool cmd_update_remove_callback(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current, size_t total, void *data){
bar(current, total);
return true;
}
bool cmd_update_install_callback(lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data){
bar(current, total);
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;
}
bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){
char *arg = NULL;
@ -83,30 +68,36 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){
goto end;
}
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Downloading "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), ++current, list->count, new->data.name, new->data.version);
r = lm_ctx_download(ctx, new, cmd_update_download_callback, NULL);
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Downloading "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"),
++current, list->count, new->data.name, new->data.version);
r = lm_ctx_download(ctx, new, callback_download, NULL);
bar_free();
if(!r){
error(_("Failed to download "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), new->data.name, new->data.version, lm_strerror());
error(_("Failed to download "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"),
new->data.name, new->data.version, lm_strerror());
goto end;
}
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), current, list->count, old->name, old->version);
r = lm_ctx_remove(ctx, old, cmd_update_remove_callback, NULL);
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"),
current, list->count, old->name, old->version);
r = lm_ctx_remove(ctx, old, callback_remove, NULL);
bar_free();
if(!r){
error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), old->name, old->version, lm_strerror());
error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"),
old->name, old->version, lm_strerror());
goto end;
}
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Installing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), current, list->count, new->data.name, new->data.version);
r = lm_ctx_install(ctx, new, can_run_install(ctx), cmd_update_install_callback, NULL);
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Installing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"),
current, list->count, new->data.name, new->data.version);
r = lm_ctx_install(ctx, new, can_run_install(ctx), callback_install, NULL);
bar_free();
if(!r){
error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), new->data.name, new->data.version, lm_strerror());
error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"),
new->data.name, new->data.version, lm_strerror());
goto end;
}
}

View File

@ -43,9 +43,11 @@ lm_ctx_t ctx;
void handler(int sig) {
unlock(&ctx);
printf("\e[?25h\n");
printf("\e[?25h");
if (SIGSEGV == sig)
error(_("Received a segfault"));
else
printf("\n"); // print a newline to not the break shell prompt on SIGINT
exit(1);
}
@ -156,6 +158,7 @@ int main(int argc, char *argv[], char *envp[]) {
}
ret = commands[i].func(&ctx, &config, args);
unlock(&ctx);
goto end;
}
@ -183,8 +186,6 @@ help:
goto end;
end:
unlock(&ctx);
free(full_pooldir);
free(full_datadir);
free(full_tmpdir);