Compare commits

..

No commits in common. "main" and "24.00" have entirely different histories.
main ... 24.00

16 changed files with 259 additions and 732 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 CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
LIBS = -linih -lmp LIBS = -linih -lmp
VERSION = 24.04 VERSION = 24.00
all: dist dist/matt $(PO_OUTS) all: dist dist/matt $(PO_OUTS)

View File

@ -1,5 +1,5 @@
# default package manager configuration, please see the wiki page for more information # default package manager configuration, please see the wiki page for more information
# https://matterlinux.xyz/wiki/matt # https://matterlinux.xyz/wiki/package_manager
tmpdir = /var/lib/matt/temp tmpdir = /var/lib/matt/temp
datadir = /var/lib/matt/data datadir = /var/lib/matt/data

View File

@ -8,31 +8,24 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-25 22:43+0300\n" "POT-Creation-Date: 2024-08-11 01:49+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n" "Language: tr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: src/callback.c:39 src/callback.c:56
msgid "Failed to sync "
msgstr "Failed to sync "
#: src/callback.c:50 src/cmd/sync.c:46
msgid "Synced "
msgstr "Synced "
#: src/config.c:71 #: src/config.c:71
#, c-format #, c-format
msgid "Unknown configuration option: %s/%s" msgid "Unknown configuration option: %s/%s"
msgstr "Unknown configuration option: %s/%s" msgstr "Unknown configuration option: %s/%s"
#: src/config.c:79 #: src/config.c:79
#, fuzzy
msgid "Failed to access the configuration file: " msgid "Failed to access the configuration file: "
msgstr "Failed to access the configuration file: " msgstr "Failed to access the configuration file: %s"
#: src/config.c:84 #: src/config.c:84
msgid "Failed to parse the configuration" msgid "Failed to parse the configuration"
@ -76,115 +69,80 @@ msgstr "%s [y/N] "
msgid "Please answer with y/n" msgid "Please answer with y/n"
msgstr "Please answer with y/n" msgstr "Please answer with y/n"
#: src/main.c:49 #: src/main.c:48
msgid "Received a segfault" msgid "Received a segfault"
msgstr "Received a segfault" msgstr "Received a segfault"
#: src/main.c:64 #: src/main.c:97
#, fuzzy
msgid "show information about a single package"
msgstr "show information about a single package"
#: src/main.c:65
msgid "list all the installed packages"
msgstr "list all the installed packages"
#: src/main.c:66
msgid "search for packages by name/desc/version"
msgstr ""
#: src/main.c:67
msgid "update the pool info and package lists"
msgstr "update the pool info and package lists"
#: src/main.c:68
msgid "install package(s) from remote pools"
msgstr "install package(s) from remote pools"
#: src/main.c:69
msgid "remove installed package(s)"
msgstr "remove installed package(s)"
#: src/main.c:70
msgid "update installed package(s)"
msgstr "update installed package(s)"
#: src/main.c:119
msgid "Failed to access the root directory, are you running as root?" msgid "Failed to access the root directory, are you running as root?"
msgstr "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:123 #: src/main.c:101
#, fuzzy
msgid "Failed to access the data directory (" msgid "Failed to access the data directory ("
msgstr "Failed to access the data directory (" msgstr "Failed to access the configuration file: %s"
#: src/main.c:127 #: src/main.c:105
#, fuzzy
msgid "Failed to access the temp directory (" msgid "Failed to access the temp directory ("
msgstr "Failed to access the temp directory (" msgstr "Failed to open the editor: %s"
#: src/main.c:131 #: src/main.c:109
#, c-format #, fuzzy, c-format
msgid "Failed to initialize libmp context: %s" msgid "Failed to initialize libmp context: %s"
msgstr "Failed to initialize libmp context: %s" msgstr "Failed to install "
#: src/main.c:142 #: src/main.c:120
#, fuzzy
msgid "Failed to create the pools directory (" msgid "Failed to create the pools directory ("
msgstr "Failed to create the pools directory (" msgstr "Failed to open the editor: %s"
#: src/main.c:152 #: src/main.c:130
msgid "Failed to add pool " msgid "Failed to add pool "
msgstr "Failed to add pool " msgstr "Failed to add pool "
#: src/main.c:166 #: src/main.c:144
msgid "Failed to lock, matt is already running" msgid "Failed to lock, matt is already running"
msgstr "Failed to lock, matt is already running" msgstr "Failed to lock, matt is already running"
#: src/main.c:170 #: src/main.c:148
msgid "Failed to lock, are you root?" msgid "Failed to lock, are you root?"
msgstr "Failed to lock, are you root?" msgstr "Failed to lock, are you root?"
#: src/main.c:183 #: src/main.c:159
msgid "Command not found: " msgid "Command not found: "
msgstr "Command not found: " msgstr "Command not found: "
#: src/main.c:184 #: src/main.c:161
msgid "Displaying help information" #, fuzzy, c-format
msgstr "Displaying help information"
#: src/main.c:187
#, c-format
msgid "MatterLinux package manager %s (libmp %s)" msgid "MatterLinux package manager %s (libmp %s)"
msgstr "MatterLinux package manager %s (libmp %s)" msgstr "MatterLinux package manager (version %s)"
#: src/main.c:188 src/cmd/info.c:47 src/cmd/install.c:33 src/cmd/list.c:23 #: src/main.c:162
#: src/cmd/remove.c:27 src/cmd/search.c:197 src/cmd/sync.c:23
#: src/cmd/update.c:22
msgid "Usage: " msgid "Usage: "
msgstr "Usage: " msgstr "Usage: "
#: src/main.c:190 #: src/main.c:164
msgid "Here is a list of available commands:" msgid "Here is a list of available commands:"
msgstr "Here is a list of available commands:" msgstr "Here is a list of available commands:"
#: src/main.c:196 #: src/main.c:170
msgid "To list different options, use commands with " msgid "To list different options, use commands with "
msgstr "To list different options, use commands with " msgstr "To list different options, use commands with "
#: src/main.c:197 #: src/main.c:171
msgid "Here is a list of available global options:" msgid "Here is a list of available global options:"
msgstr "Here is a list of available global options:" msgstr "Here is a list of available global options:"
#: src/main.c:200 src/main.c:201 src/main.c:202 src/cmd/info.c:49 #: src/main.c:174 src/main.c:175 src/cmd/info.c:43 src/cmd/info.c:44
#: src/cmd/info.c:50 src/cmd/info.c:51 src/cmd/install.c:35 #: src/cmd/info.c:45 src/cmd/install.c:32 src/cmd/install.c:33
#: src/cmd/install.c:36 src/cmd/install.c:37 src/cmd/install.c:38 #: src/cmd/install.c:34 src/cmd/list.c:14 src/cmd/list.c:15 src/cmd/remove.c:21
#: src/cmd/install.c:39 src/cmd/list.c:25 src/cmd/list.c:26 src/cmd/remove.c:29 #: src/cmd/remove.c:22 src/cmd/update.c:30
#: src/cmd/remove.c:30 src/cmd/search.c:199 src/cmd/search.c:200
#: src/cmd/search.c:201 src/cmd/search.c:202 src/cmd/sync.c:25
#: src/cmd/update.c:24
#, c-format #, c-format
msgid " " msgid " "
msgstr " " msgstr " "
#: src/main.c:204 #: src/main.c:177
msgid "" msgid ""
"Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information" "Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information"
msgstr "" msgstr ""
@ -204,240 +162,225 @@ msgstr "Failed to run the editor: %s"
msgid "Failed to open the editor: %s" msgid "Failed to open the editor: %s"
msgstr "Failed to open the editor: %s" msgstr "Failed to open the editor: %s"
#: src/cmd/info.c:13 src/cmd/info.c:23 src/cmd/install.c:94 src/cmd/remove.c:53 #: src/cmd/info.c:19 src/cmd/info.c:29 src/cmd/install.c:87 src/cmd/remove.c:43
msgid "Package " msgid "Package "
msgstr "Package " msgstr "Package "
#: src/cmd/info.c:42 src/cmd/install.c:28 src/cmd/list.c:18 src/cmd/remove.c:22 #: src/cmd/info.c:42 src/cmd/list.c:13
#: src/cmd/search.c:192 src/cmd/sync.c:18 src/cmd/update.c:17
msgid "Unknown argument: "
msgstr "Unknown argument: "
#: src/cmd/info.c:48 src/cmd/list.c:24 src/cmd/search.c:198 src/cmd/sync.c:24
msgid "Listing options for the list command:" msgid "Listing options for the list command:"
msgstr "Listing options for the list command:" msgstr "Listing options for the list command:"
#: src/cmd/info.c:72 #: src/cmd/info.c:65
msgid "Please specify only a single package name" msgid "Please specify only a single package name"
msgstr "Please specify only a single package name" msgstr "Please specify only a single package name"
#: src/cmd/info.c:79 #: src/cmd/info.c:72
msgid "Please specify a single package" msgid "Please specify a single package"
msgstr "Please specify a single package" msgstr "Please specify a single package"
#: src/cmd/info.c:94 #: src/cmd/info.c:87
msgid "Failed to get the changes file for " msgid "Failed to get the changes file for "
msgstr "Failed to get the changes file for " msgstr "Failed to get the changes file for "
#: src/cmd/info.c:100 #: src/cmd/info.c:93
msgid "Failed to access the changes file, is the package installed?" msgid "Failed to access the changes file, is the package installed?"
msgstr "Failed to access the changes file, is the package installed?" msgstr "Failed to access the changes file, is the package installed?"
#: src/cmd/info.c:107 #: src/cmd/info.c:100
msgid "Failed to get the depends list for " msgid "Failed to get the depends list for "
msgstr "Failed to get the depends list for " msgstr "Failed to get the depends list for "
#: src/cmd/info.c:135 #: src/cmd/info.c:127
#, c-format #, c-format
msgid "Name " msgid "Name "
msgstr "Name " msgstr "Name "
#: src/cmd/info.c:136 #: src/cmd/info.c:128
#, c-format #, c-format
msgid "Version " msgid "Version "
msgstr "Version " msgstr "Version "
#: src/cmd/info.c:137 #: src/cmd/info.c:129
#, c-format #, c-format
msgid "Desc " msgid "Desc "
msgstr "Desc " msgstr "Desc "
#: src/cmd/info.c:138 #: src/cmd/info.c:130
#, c-format #, c-format
msgid "Size " msgid "Size "
msgstr "Size " msgstr "Size "
#: src/cmd/info.c:141 #: src/cmd/info.c:133
#, c-format #, c-format
msgid "Depends " msgid "Depends "
msgstr "Depends " msgstr "Depends "
#: src/cmd/info.c:144 #: src/cmd/info.c:136
#, c-format #, c-format
msgid "Changes " msgid "Changes "
msgstr "Changes " msgstr "Changes "
#: src/cmd/info.c:147 #: src/cmd/info.c:140 src/cmd/info.c:141
#, fuzzy, c-format
msgid "Pool "
msgstr " "
#: src/cmd/info.c:150 src/cmd/info.c:151
#, c-format #, c-format
msgid "Installed " msgid "Installed "
msgstr "Installed " msgstr "Installed "
#: src/cmd/info.c:154 src/cmd/info.c:155 #: src/cmd/info.c:143 src/cmd/info.c:144
#, c-format #, c-format
msgid "Up-to-date " msgid "Up-to-date "
msgstr "Up-to-date " msgstr "Up-to-date "
#: src/cmd/install.c:34 #: src/cmd/install.c:31
msgid "Listing options for the install command:" msgid "Listing options for the install command:"
msgstr "Listing options for the install command:" msgstr "Listing options for the install command:"
#: src/cmd/install.c:44 src/cmd/update.c:29 #: src/cmd/install.c:39 src/cmd/update.c:35
msgid "There are no avaliable pools, have you synced yet?" msgid "There are no avaliable pools, have you synced yet?"
msgstr "There are no avaliable pools, have you synced yet?" msgstr "There are no avaliable pools, have you synced yet?"
#: src/cmd/install.c:63 #: src/cmd/install.c:58
msgid "Specified " msgid "Specified "
msgstr "Specified " msgstr ""
#: src/cmd/install.c:76 #: src/cmd/install.c:68
#, fuzzy
msgid "Failed to load " msgid "Failed to load "
msgstr "Failed to load " msgstr "Failed to download "
#: src/cmd/install.c:85 src/cmd/remove.c:55 #: src/cmd/install.c:78 src/cmd/remove.c:45
msgid "Failed to find " msgid "Failed to find "
msgstr "Failed to find " msgstr "Failed to find "
#: src/cmd/install.c:103 #: src/cmd/install.c:93
msgid "Failed to resolve " msgid "Failed to resolve "
msgstr "Failed to resolve " msgstr "Failed to resolve "
#: src/cmd/install.c:112 #: src/cmd/install.c:99
msgid "Nothing to do (no packages to install)" msgid "Nothing to do (no packages to install)"
msgstr "Nothing to do (no packages to install)" msgstr "Nothing to do (no packages to install)"
#: src/cmd/install.c:121 src/cmd/install.c:123 src/cmd/remove.c:75 #: src/cmd/install.c:108 src/cmd/install.c:110 src/cmd/remove.c:65
#: src/cmd/remove.c:77 src/cmd/update.c:50 src/cmd/update.c:52 #: src/cmd/remove.c:67 src/cmd/update.c:56 src/cmd/update.c:58
msgid "Following " msgid "Following "
msgstr "Following " msgstr "Following "
#: src/cmd/install.c:129 src/cmd/remove.c:84 #: src/cmd/install.c:116 src/cmd/remove.c:74
msgid "Total of " msgid "Total of "
msgstr "Total of " msgstr "Total of "
#: src/cmd/install.c:132 src/cmd/update.c:59 #: src/cmd/install.c:119 src/cmd/update.c:65
#, c-format #, c-format
msgid "Root directory is modified, install scripts will be saved in %s" msgid "Root directory is modified, install scripts will be saved in %s"
msgstr "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:134 src/cmd/remove.c:85 src/cmd/update.c:61 #: src/cmd/install.c:121 src/cmd/remove.c:75 src/cmd/update.c:67
msgid "Continue?" msgid "Continue?"
msgstr "Continue?" msgstr "Continue?"
#: src/cmd/install.c:135 src/cmd/remove.c:86 src/cmd/update.c:62 #: src/cmd/install.c:122 src/cmd/remove.c:76 src/cmd/update.c:68
msgid "Operation cancelled" msgid "Operation cancelled"
msgstr "Operation cancelled" msgstr "Operation cancelled"
#: src/cmd/install.c:151 src/cmd/install.c:155 src/cmd/install.c:175 #: src/cmd/install.c:138 src/cmd/install.c:142 src/cmd/install.c:157
#: src/cmd/install.c:191 src/cmd/remove.c:93 src/cmd/update.c:72 #: src/cmd/remove.c:83 src/cmd/update.c:78 src/cmd/update.c:87
#: src/cmd/update.c:83 src/cmd/update.c:94 #: src/cmd/update.c:96
msgid "(" msgid "("
msgstr "(" msgstr "("
#: src/cmd/install.c:161 src/cmd/update.c:78 #: src/cmd/install.c:148 src/cmd/update.c:83
msgid "Failed to download " msgid "Failed to download "
msgstr "Failed to download " msgstr "Failed to download "
#: src/cmd/install.c:182 src/cmd/remove.c:100 src/cmd/update.c:89 #: src/cmd/install.c:163 src/cmd/update.c:101
msgid "Failed to remove "
msgstr "Failed to remove "
#: src/cmd/install.c:198 src/cmd/update.c:100
msgid "Failed to install " msgid "Failed to install "
msgstr "Failed to install " msgstr "Failed to install "
#: src/cmd/install.c:205 #: src/cmd/install.c:169
msgid "Installed " msgid "Installed "
msgstr "Installed " msgstr "Installed "
#: src/cmd/install.c:205 #: src/cmd/install.c:169
msgid "Installed all of the " msgid "Installed all of the "
msgstr "Installed all of the " msgstr "Installed all of the "
#: src/cmd/list.c:39 #: src/cmd/list.c:28
#, fuzzy msgid "There no installed packages"
msgid "There are no installed packages"
msgstr "There no installed packages" msgstr "There no installed packages"
#: src/cmd/list.c:44 #: src/cmd/list.c:33
msgid "Listing " msgid "Listing "
msgstr "Listing " msgstr "Listing "
#: src/cmd/remove.c:28 #: src/cmd/remove.c:20
msgid "Listing options for the remove command:" msgid "Listing options for the remove command:"
msgstr "Listing options for the remove command:" msgstr "Listing options for the remove command:"
#: src/cmd/remove.c:60 #: src/cmd/remove.c:50
#, fuzzy
msgid "Cannot remove " msgid "Cannot remove "
msgstr "Failed to remove " msgstr "Cannot remove "
#: src/cmd/remove.c:68 #: src/cmd/remove.c:58
msgid "Nothing to do (no packages to remove)" msgid "Nothing to do (no packages to remove)"
msgstr "Nothing to do (no packages to remove)" msgstr "Nothing to do (no packages to remove)"
#: src/cmd/remove.c:107 #: src/cmd/remove.c:89 src/cmd/update.c:92
msgid "Failed to remove "
msgstr "Failed to remove "
#: src/cmd/remove.c:95
msgid "Removed " msgid "Removed "
msgstr "Removed " msgstr "Removed "
#: src/cmd/remove.c:107 #: src/cmd/remove.c:95
msgid "Removed all of the " msgid "Removed all of the "
msgstr "Removed all of the " msgstr "Removed all of the "
#: src/cmd/search.c:72 src/cmd/search.c:149 #: src/cmd/sync.c:20 src/cmd/sync.c:35
msgid "No results, maybe you forgot to sync?" msgid "Failed to sync "
msgstr "" msgstr "Failed to sync "
#: src/cmd/search.c:77 src/cmd/search.c:154 #: src/cmd/sync.c:29 src/cmd/sync.c:59
msgid "Found " msgid "Synced "
msgstr "" msgstr "Synced "
#: src/cmd/search.c:113 #: src/cmd/sync.c:47
#, fuzzy, c-format
msgid "Failed to load package pools: %s"
msgstr "Failed to get the package update list: %s"
#: src/cmd/search.c:119
#, fuzzy, c-format
msgid "Failed to get package list: %s"
msgstr "Failed to get the package update list: %s"
#: src/cmd/search.c:218
#, fuzzy
msgid "Please specify only a single query for searching"
msgstr "Please specify only a single package name"
#: src/cmd/search.c:225
#, fuzzy
msgid "Please specify a query for searching"
msgstr "Please specify a single package"
#: src/cmd/sync.c:30
msgid "There are no pools specified in the configuration" msgid "There are no pools specified in the configuration"
msgstr "There are no pools specified in the configuration" msgstr "There are no pools specified in the configuration"
#: src/cmd/sync.c:39 #: src/cmd/sync.c:55
#, c-format #, c-format
msgid "Failed to sync pools: %s" msgid "Failed to sync pools: %s"
msgstr "Failed to sync pools: %s" msgstr "Failed to sync pools: %s"
#: src/cmd/update.c:23 #: src/cmd/update.c:29
msgid "Listing options for the update command:" msgid "Listing options for the update command:"
msgstr "Listing options for the update command:" msgstr "Listing options for the update command:"
#: src/cmd/update.c:40 #: src/cmd/update.c:46
#, c-format #, c-format
msgid "Failed to get the package update list: %s" msgid "Failed to get the package update list: %s"
msgstr "Failed to get the package update list: %s" msgstr "Failed to get the package update list: %s"
#: src/cmd/update.c:45 #: src/cmd/update.c:51
msgid "All packages are up-to-date" msgid "All packages are up-to-date"
msgstr "All packages are up-to-date" msgstr "All packages are up-to-date"
#: src/cmd/update.c:68 #: src/cmd/update.c:74
msgid "Failed to update " msgid "Failed to update "
msgstr "Failed to update " msgstr "Failed to update "
#, c-format
#~ msgid "Failed to sync %s: %s"
#~ msgstr "Failed to sync %s: %s"
#, c-format
#~ msgid "Bad root directory (%s): %s"
#~ msgstr "Bad root directory (%s): %s"
#, c-format
#~ msgid "Bad datadir (%s): %s"
#~ msgstr "Bad datadir (%s): %s"
#, c-format
#~ msgid "Bad tmpdir (%s): %s"
#~ msgstr "Bad tmpdir (%s): %s"

View File

@ -7,29 +7,14 @@
#include "args.h" #include "args.h"
#include "util.h" #include "util.h"
void args_register(args_t *args, char *name) {
for (int i = 0; i < args->count; i++) {
if (args->list[i].name != NULL && eq(args->list[i].name, name))
args->list[i].registered = true;
}
}
char *args_register_check(args_t *args) {
for (int i = 0; i < args->count; i++)
if (!args->list[i].registered)
return args->list[i].name;
return NULL;
}
void args_add_name(args_t *args, char *name) { void args_add_name(args_t *args, char *name) {
if (NULL == args->list) if (NULL == args->list)
args->list = malloc(sizeof(arg_t) * (args->count + 1)); args->list = malloc(sizeof(arg_t) * (args->count + 1));
else else
args->list = realloc(args->list, sizeof(arg_t) * (args->count + 1)); args->list = realloc(args->list, sizeof(arg_t) * (args->count + 1));
args->list[args->count].name = name; args->list[args->count].name = name;
args->list[args->count].registered = false; args->list[args->count++].value = NULL;
args->list[args->count++].value = NULL;
} }
void args_add_value(args_t *args, char *value) { void args_add_value(args_t *args, char *value) {
@ -38,9 +23,8 @@ void args_add_value(args_t *args, char *value) {
else else
args->list = realloc(args->list, sizeof(arg_t) * (args->count + 1)); args->list = realloc(args->list, sizeof(arg_t) * (args->count + 1));
args->list[args->count].name = NULL; args->list[args->count].name = NULL;
args->list[args->count].registered = true; args->list[args->count++].value = value;
args->list[args->count++].value = value;
} }
void args_set_value(args_t *args, char *value) { void args_set_value(args_t *args, char *value) {

View File

@ -4,7 +4,6 @@
typedef struct arg { typedef struct arg {
char *name; char *name;
char *value; char *value;
bool registered;
} arg_t; } arg_t;
typedef struct args { typedef struct args {
@ -12,8 +11,6 @@ typedef struct args {
size_t count; size_t count;
} args_t; } args_t;
void args_register(args_t *args, char *name);
char *args_register_check(args_t *args);
args_t *args_parse(int argc, char *argv[]); args_t *args_parse(int argc, char *argv[]);
char *args_get_string(args_t *args, char *name); char *args_get_string(args_t *args, char *name);
bool args_get_bool(args_t *args, char *name); bool args_get_bool(args_t *args, char *name);

View File

@ -1,63 +0,0 @@
#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) {
if (current < total)
bar(current, total);
else
bar_free();
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) {
bool fail = *(bool *)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());
if (fail)
return false;
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());
if (fail)
return false;
break;
}
return true;
}

View File

@ -1,8 +0,0 @@
#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

@ -10,14 +10,12 @@ typedef bool (*cmd_func_t)(lm_ctx_t *ctx, config_t *config, args_t *args);
typedef struct cmd { typedef struct cmd {
char *name; char *name;
char *desc; char *desc;
bool root;
cmd_func_t func; cmd_func_t func;
} cmd_t; } cmd_t;
bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args); bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args);
bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args); bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args);
bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args); bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args);
bool cmd_search(lm_ctx_t *ctx, config_t *config, args_t *args);
bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args); bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args);
bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args); bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args);
bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args); bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args);

View File

@ -1,20 +1,26 @@
#include <libmp/all.h> #include <libmp/all.h>
#include <stdlib.h> #include <libmp/ctx.h>
#include <libmp/database.h>
#include <libmp/error.h>
#include <libmp/package.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "../util.h" #include "../util.h"
#include "../intl.h" #include "../intl.h"
#include "../cmd.h" #include "../cmd.h"
#include "../log.h" #include "../log.h"
lm_pkg_data_t *cmd_info_from_pool(lm_ctx_t *ctx, lm_pkg_t **pkgp, args_t *args, char *name){ lm_pkg_data_t *cmd_info_from_pool(lm_ctx_t *ctx, args_t *args, char *name){
if((*pkgp = lm_ctx_pool_find(ctx, name, NULL)) == NULL){ lm_pkg_t *pkg = NULL;
if((pkg = lm_ctx_pool_find(ctx, name, NULL)) == NULL){
if(!args_get_bool(args, "grep") && LM_ERR_PkgNotFound == lm_error()) if(!args_get_bool(args, "grep") && LM_ERR_PkgNotFound == lm_error())
error(_("Package "FG_BOLD"%s"FG_RESET" not found"), name); error(_("Package "FG_BOLD"%s"FG_RESET" not found"), name);
return NULL; return NULL;
} }
return &(*pkgp)->data; return &pkg->data;
} }
lm_pkg_data_t *cmd_info_from_database(lm_ctx_t *ctx, lm_entry_t *entry, args_t *args, char *name){ lm_pkg_data_t *cmd_info_from_database(lm_ctx_t *ctx, lm_entry_t *entry, args_t *args, char *name){
@ -28,23 +34,11 @@ lm_pkg_data_t *cmd_info_from_database(lm_ctx_t *ctx, lm_entry_t *entry, args_t *
} }
bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
char *arg = NULL;
args_split(args, "grep"); args_split(args, "grep");
args_split(args, "changes"); args_split(args, "changes");
args_split(args, "database"); args_split(args, "database");
args_register(args, "grep");
args_register(args, "changes");
args_register(args, "database");
if((arg = args_register_check(args)) != NULL){
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg);
return false;
}
if(args_get_bool(args, "help")){ if(args_get_bool(args, "help")){
info(_("Usage: " FG_BOLD "info <options> [package name]"));
info(_("Listing options for the list command:")); info(_("Listing options for the list command:"));
printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n")); printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n"));
printf(_(" "FG_BOLD"--changes"FG_RESET":\topen the changes file for the package\n")); printf(_(" "FG_BOLD"--changes"FG_RESET":\topen the changes file for the package\n"));
@ -57,7 +51,6 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
char *name = NULL, *depends = NULL, *changes = NULL; char *name = NULL, *depends = NULL, *changes = NULL;
lm_pkg_data_t *data = NULL; lm_pkg_data_t *data = NULL;
lm_pkg_t *pkg = NULL;
lm_entry_t ent; lm_entry_t ent;
for(size_t i = 1; i < args->count; i++){ for(size_t i = 1; i < args->count; i++){
@ -86,7 +79,7 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
} }
else if(!args_get_bool(args, "database")){ else if(!args_get_bool(args, "database")){
if((data = cmd_info_from_pool(ctx, &pkg, args, name)) == NULL) if((data = cmd_info_from_pool(ctx, args, name)) == NULL)
return false; return false;
} }
@ -121,7 +114,6 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
printf("CHANGES:%s\n", changes); printf("CHANGES:%s\n", changes);
if(!args_get_bool(args, "database")){ if(!args_get_bool(args, "database")){
printf("POOL:%s\n", pkg->pool->name);
printf("INSTALLED:%d\n", lm_ctx_database_is_installed(ctx, data->name, NULL)); printf("INSTALLED:%d\n", lm_ctx_database_is_installed(ctx, data->name, NULL));
printf("UPTODATE:%d\n", lm_ctx_database_is_installed(ctx, data->name, data->version)); printf("UPTODATE:%d\n", lm_ctx_database_is_installed(ctx, data->name, data->version));
} }
@ -144,12 +136,9 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
printf(_(FG_BOLD"Changes "FG_BLUE"=>"FG_RESET" %s\n"), changes); printf(_(FG_BOLD"Changes "FG_BLUE"=>"FG_RESET" %s\n"), changes);
if(!args_get_bool(args, "database")){ if(!args_get_bool(args, "database")){
printf(_(FG_BOLD"Pool "FG_BLUE"=>"FG_RESET" %s\n"), pkg->pool->name);
printf(lm_ctx_database_is_installed(ctx, data->name, NULL) ? printf(lm_ctx_database_is_installed(ctx, data->name, NULL) ?
_(FG_BOLD"Installed "FG_BLUE"=>"FG_RESET" "FG_GREEN"yes"FG_RESET"\n") : _(FG_BOLD"Installed "FG_BLUE"=>"FG_RESET" "FG_GREEN"yes"FG_RESET"\n") :
_(FG_BOLD"Installed "FG_BLUE"=>"FG_RESET" "FG_RED"no"FG_RESET"\n")); _(FG_BOLD"Installed "FG_BLUE"=>"FG_RESET" "FG_RED"no"FG_RESET"\n"));
printf(lm_ctx_database_is_installed(ctx, data->name, data->version) ? printf(lm_ctx_database_is_installed(ctx, data->name, data->version) ?
_(FG_BOLD"Up-to-date "FG_BLUE"=>"FG_RESET" "FG_GREEN"yes"FG_RESET"\n") : _(FG_BOLD"Up-to-date "FG_BLUE"=>"FG_RESET" "FG_GREEN"yes"FG_RESET"\n") :
_(FG_BOLD"Up-to-date "FG_BLUE"=>"FG_RESET" "FG_RED"no"FG_RESET"\n")); _(FG_BOLD"Up-to-date "FG_BLUE"=>"FG_RESET" "FG_RED"no"FG_RESET"\n"));

View File

@ -1,41 +1,36 @@
#include <libmp/all.h> #include <libmp/all.h>
#include <libmp/ctx.h>
#include <libmp/error.h>
#include <libmp/package.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include "../callback.h"
#include "../util.h" #include "../util.h"
#include "../intl.h" #include "../intl.h"
#include "../cmd.h" #include "../cmd.h"
#include "../log.h" #include "../log.h"
bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){ bool cmd_install_callback(lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data){
char *arg = NULL; 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){
args_split(args, "ignore-depends"); args_split(args, "ignore-depends");
args_split(args, "ignore-none");
args_split(args, "continue"); args_split(args, "continue");
args_split(args, "skip");
args_split(args, "yes"); args_split(args, "yes");
args_register(args, "ignore-depends");
args_register(args, "ignore-none");
args_register(args, "continue");
args_register(args, "skip");
args_register(args, "yes");
if((arg = args_register_check(args)) != NULL){
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg);
return false;
}
if(args_get_bool(args, "help")){ if(args_get_bool(args, "help")){
info(_("Usage: " FG_BOLD "install <options> [package name(s)]"));
info(_("Listing options for the install command:")); info(_("Listing options for the install command:"));
printf(_(" "FG_BOLD"--ignore-depends"FG_RESET":\tignore package dependencies\n")); printf(_(" "FG_BOLD"--ignore-depends"FG_RESET":\tignore package dependencies\n"));
printf(_(" "FG_BOLD"--ignore-none"FG_RESET":\tignore if there is nothing do\n"));
printf(_(" "FG_BOLD"--continue"FG_RESET":\t\tcontinue even if package is not found\n")); printf(_(" "FG_BOLD"--continue"FG_RESET":\t\tcontinue even if package is not found\n"));
printf(_(" "FG_BOLD"--skip"FG_RESET":\t\tskip if a package is already installed\n"));
printf(_(" "FG_BOLD"--yes"FG_RESET":\t\tdon't ask for confirmation\n")); printf(_(" "FG_BOLD"--yes"FG_RESET":\t\tdon't ask for confirmation\n"));
return true; return true;
} }
@ -47,9 +42,9 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
ssize_t current = 0, size = 0, save = 0, li = 0; ssize_t current = 0, size = 0, save = 0, li = 0;
bool ret = false, r = false, is_local = false; bool ret = false, r = false, is_local = false;
lm_pkg_t *pkg = NULL, **locals = NULL; bool resolve_depends = !args_get_bool(args, "ignore-depends");
lm_pkg_t *pkg = NULL, *locals = NULL;
lm_ctx_resolve_list_t *list = NULL; lm_ctx_resolve_list_t *list = NULL;
lm_entry_t older;
char ssize[LONGSTR_MAX+3]; char ssize[LONGSTR_MAX+3];
char *name = NULL; char *name = NULL;
@ -57,7 +52,7 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
if(NULL != args->list[i].name || NULL == (name = args->list[i].value)) if(NULL != args->list[i].name || NULL == (name = args->list[i].value))
continue; continue;
// if this is a local archive, load it // if thiş is a local archive, load it
if(endswith(name, ".mpf") && access(name, F_OK) == 0){ if(endswith(name, ".mpf") && access(name, F_OK) == 0){
if(access(name, R_OK) != 0){ if(access(name, R_OK) != 0){
error(_("Specified "FG_BOLD"%s"FG_RESET" archive does not have read access"), name); error(_("Specified "FG_BOLD"%s"FG_RESET" archive does not have read access"), name);
@ -65,18 +60,16 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
} }
if(NULL == locals) if(NULL == locals)
locals = malloc(sizeof(lm_pkg_t*)); locals = malloc(sizeof(lm_pkg_t));
else else
locals = realloc(locals, sizeof(lm_pkg_t*)*((++li)+1)); locals = realloc(locals, sizeof(lm_pkg_t)*((++li)+1));
pkg = malloc(sizeof(lm_pkg_t)); if(!lm_ctx_package_from(ctx, &locals[li], name)){
locals[li] = pkg;
if(!lm_ctx_package_from(ctx, pkg, name)){
error(_("Failed to load "FG_BOLD"%s"FG_RESET": %s"), name, lm_strerror()); error(_("Failed to load "FG_BOLD"%s"FG_RESET": %s"), name, lm_strerror());
goto end; goto end;
} }
pkg = &locals[li];
goto resolve; goto resolve;
} }
@ -92,24 +85,18 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
resolve: resolve:
if(lm_ctx_database_is_installed(ctx, pkg->data.name, pkg->data.version)){ if(lm_ctx_database_is_installed(ctx, pkg->data.name, pkg->data.version)){
error(_("Package "FG_BOLD"%s"FG_RESET"_"FG_GREEN"%s"FG_RESET" is already installed"), name, pkg->data.version); error(_("Package "FG_BOLD"%s"FG_RESET"_"FG_GREEN"%s"FG_RESET" is already installed"), name, pkg->data.version);
if(args_get_bool(args, "skip")) goto end;
continue;
else
goto end;
} }
// resolve the package and depends // resolve the package and depends
if((list = lm_ctx_resolve(ctx, pkg, !args_get_bool(args, "ignore-depends"), list)) == NULL){ if((list = lm_ctx_resolve(ctx, pkg, resolve_depends, list)) == NULL){
error(_("Failed to resolve "FG_BOLD"%s"FG_RESET": %s"), name, lm_strerror()); error(_("Failed to resolve "FG_BOLD"%s"FG_RESET": %s"), name, lm_strerror());
goto end; goto end;
} }
} }
if(NULL == list){ if(NULL == list){
if(args_get_bool(args, "ignore-none")) error(_("Nothing to do (no packages to install)"));
ret = true;
else
error(_("Nothing to do (no packages to install)"));
goto end; goto end;
} }
@ -141,7 +128,7 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
is_local = false; is_local = false;
for(size_t i = 0; i < (li+1) && NULL != locals; i++){ for(size_t i = 0; i < (li+1) && NULL != locals; i++){
if(lm_package_is_same(locals[i], pkg)){ if(lm_package_is_same(&locals[i], pkg)){
is_local = true; is_local = true;
break; break;
} }
@ -154,7 +141,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); 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, callback_download, NULL); r = lm_ctx_download(ctx, pkg, cmd_download_callback, NULL);
bar_free(); bar_free();
if(!r){ if(!r){
@ -167,36 +154,13 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
// install resolved packages // install resolved packages
while((pkg = lm_ctx_resolve_next(list)) != NULL){ while((pkg = lm_ctx_resolve_next(list)) != NULL){
lm_entry_init(&older); 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);
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_remove(ctx, &older, callback_remove, NULL); r = lm_ctx_install(ctx, pkg, can_run_install(ctx), cmd_install_callback, 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(); bar_free();
if(!r){ if(!r){
error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), 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());
pkg->data.name, pkg->data.version, lm_strerror());
goto end; goto end;
} }
} }
@ -210,7 +174,7 @@ end:
bar_free(); bar_free();
for(size_t i = 0; i < (li+1) && NULL != locals; i++) for(size_t i = 0; i < (li+1) && NULL != locals; i++)
lm_ctx_package_from_free(locals[li]); lm_ctx_package_from_free(&locals[li]);
free(locals); free(locals);
lm_ctx_resolve_free(list); lm_ctx_resolve_free(list);

View File

@ -6,21 +6,10 @@
#include "../log.h" #include "../log.h"
bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){
char *arg = NULL;
args_split(args, "grep"); args_split(args, "grep");
args_split(args, "desc"); args_split(args, "desc");
args_register(args, "grep");
args_register(args, "desc");
if((arg = args_register_check(args)) != NULL){
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg);
return false;
}
if(args_get_bool(args, "help")){ if(args_get_bool(args, "help")){
info(_("Usage: " FG_BOLD "list <options>"));
info(_("Listing options for the list command:")); info(_("Listing options for the list command:"));
printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n")); printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n"));
printf(_(" "FG_BOLD"--desc"FG_RESET":\tshow package descriptions\n")); printf(_(" "FG_BOLD"--desc"FG_RESET":\tshow package descriptions\n"));
@ -36,7 +25,7 @@ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){
if(count <= 0){ if(count <= 0){
if(!args_get_bool(args, "grep")) if(!args_get_bool(args, "grep"))
info(_("There are no installed packages")); info(_("There no installed packages"));
return true; return true;
} }
@ -53,11 +42,9 @@ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){
} }
if(args_get_bool(args, "desc")) if(args_get_bool(args, "desc"))
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s\n", printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s\n", ent.name, ent.version, ent.desc);
ent.name, ent.version, ent.desc);
else else
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET"\n", printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET"\n", ent.name, ent.version);
ent.name, ent.version);
} }
lm_ctx_database_next_free(ctx, &ent); lm_ctx_database_next_free(ctx, &ent);

View File

@ -1,30 +1,22 @@
#include <libmp/all.h> #include <libmp/all.h>
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "../callback.h"
#include "../util.h" #include "../util.h"
#include "../intl.h" #include "../intl.h"
#include "../cmd.h" #include "../cmd.h"
#include "../log.h" #include "../log.h"
bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){ bool cmd_remove_callback(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current, size_t total, void *data){
char *arg = NULL; bar(current, total);
return true;
}
bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
args_split(args, "break"); args_split(args, "break");
args_split(args, "yes"); args_split(args, "yes");
args_register(args, "break");
args_register(args, "yes");
if((arg = args_register_check(args)) != NULL){
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg);
return false;
}
if(args_get_bool(args, "help")){ if(args_get_bool(args, "help")){
info(_("Usage: " FG_BOLD "remove <options> [package name(s)]"));
info(_("Listing options for the remove command:")); info(_("Listing options for the remove command:"));
printf(_(" "FG_BOLD"--break"FG_RESET":\tbreak other package depends\n")); printf(_(" "FG_BOLD"--break"FG_RESET":\tbreak other package depends\n"));
printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n")); printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n"));
@ -42,11 +34,9 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
continue; continue;
if(NULL == pkgs) if(NULL == pkgs)
pkgs = malloc(sizeof(lm_entry_t)); pkgs = malloc(sizeof(lm_pkg_t));
else else
pkgs = realloc(pkgs, sizeof(lm_entry_t)*(count+1)); pkgs = realloc(pkgs, sizeof(lm_pkg_t)*(count+1));
lm_entry_init(&pkgs[count]);
if(!lm_ctx_database_find(ctx, &pkgs[count++], name, NULL)){ if(!lm_ctx_database_find(ctx, &pkgs[count++], name, NULL)){
if(lm_error() == LM_ERR_DbSqlNotFound) if(lm_error() == LM_ERR_DbSqlNotFound)
@ -56,12 +46,12 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
goto end; goto end;
} }
if(!args_get_bool(args, "break") && !lm_ctx_removeable(ctx, &pkgs[count-1])){ if(!lm_ctx_removeable(ctx, &pkgs[count-1])){
error(_("Cannot remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), pkgs[count-1].name, pkgs[count-1].version, lm_strerror()); error(_("Cannot remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), pkgs[count-1].name, pkgs[count-1].version, lm_strerror());
goto end; goto end;
} }
size += pkgs[count-1].size; size += pkgs[count].size;
} }
if(NULL == pkgs){ if(NULL == pkgs){
@ -90,15 +80,13 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
for(int i = 0; i < count; i++){ for(int i = 0; i < count; i++){
lm_entry_t *cur = &pkgs[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), 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);
++current, count, cur->name, cur->version);
r = lm_ctx_remove(ctx, cur, callback_remove, NULL); r = lm_ctx_remove(ctx, cur, cmd_remove_callback, NULL);
bar_free(); bar_free();
if(!r){ if(!r){
error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), cur->name, cur->version, lm_strerror());
cur->name, cur->version, lm_strerror());
goto end; goto end;
} }
} }

View File

@ -1,240 +0,0 @@
#include <libmp/all.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "../util.h"
#include "../intl.h"
#include "../cmd.h"
#include "../log.h"
enum field {
FIELD_NAME = 0,
FIELD_DESC = 1,
FIELD_VERSION = 2,
};
bool contains(char *string, char *search){
if(NULL == string || NULL == search)
return false;
size_t string_size = strlen(string);
size_t search_size = strlen(search);
size_t i = 0;
char string_lower[string_size+1];
char search_lower[search_size+1];
for(i = 0; i < string_size; i++)
string_lower[i] = tolower(string[i]);
string_lower[i] = 0;
for(i = 0; i < search_size; i++)
search_lower[i] = tolower(search[i]);
search_lower[i] = 0;
return strstr(string_lower, search_lower) != NULL;
}
bool cmd_search_database(lm_ctx_t *ctx, args_t *args, char *query, enum field field) {
lm_entry_t *list = malloc(sizeof(lm_entry_t));
char *selected = NULL;
size_t indx = 0, i = 0;
bool ret = false;
while(lm_ctx_database_next(ctx, &list[indx])){
selected = NULL;
switch (field) {
case FIELD_NAME:
selected = list[indx].name;
break;
case FIELD_DESC:
selected = list[indx].desc;
break;
case FIELD_VERSION:
selected = list[indx].version;
break;
}
if(!contains(selected, query))
continue;
list = realloc(list, sizeof(lm_entry_t)*((++indx)+1));
lm_entry_init(&list[indx]);
}
if(indx <= 0){
if(!args_get_bool(args, "grep"))
info(_("No results, maybe you forgot to sync?"));
goto end;
}
if(!args_get_bool(args, "grep"))
info(indx > 1 ? _("Found "FG_BOLD"%d"FG_RESET" results") : _("Found "FG_BOLD"%d"FG_RESET" result"), indx);
for(i = 0; i < indx; i++){
if(args_get_bool(args, "grep")){
if(args_get_bool(args, "desc"))
printf("%s:%s:%s\n", list[i].name, list[i].version, list[i].desc);
else
printf("%s:%s\n", list[i].name, list[i].version);
continue;
}
if(args_get_bool(args, "desc"))
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s\n", list[i].name, list[i].version, list[i].desc);
else
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET"\n", list[i].name, list[i].version);
}
ret = true;
end:
for(i = 0; i < (indx+1); i++)
lm_ctx_database_next_free(ctx, &list[indx]);
free(list);
return ret;
}
bool cmd_search_pools(lm_ctx_t *ctx, args_t *args, char *query, enum field field) {
lm_pkg_t **list = malloc(sizeof(lm_pkg_t*));
char *selected = NULL;
size_t indx = 0, i = 0;
lm_ctx_list_t plist;
bool ret = false;
list[indx] = NULL;
if(!lm_ctx_sync(ctx, false, NULL, NULL)){
if(!args_get_bool(args, "grep"))
info(_("Failed to load package pools: %s"), lm_strerror());
goto end;
}
if(!lm_ctx_list(ctx, &plist)){
if(!args_get_bool(args, "grep"))
info(_("Failed to get package list: %s"), lm_strerror());
goto end;
}
while((list[indx] = lm_ctx_list_next(&plist)) != NULL){
selected = NULL;
switch (field) {
case FIELD_NAME:
selected = list[indx]->data.name;
break;
case FIELD_DESC:
selected = list[indx]->data.desc;
break;
case FIELD_VERSION:
selected = list[indx]->data.version;
break;
}
if(!contains(selected, query))
continue;
list = realloc(list, sizeof(lm_pkg_t*)*((++indx)+1));
list[indx] = NULL;
}
if(indx <= 0){
if(!args_get_bool(args, "grep"))
info(_("No results, maybe you forgot to sync?"));
goto end;
}
if(!args_get_bool(args, "grep"))
info(indx > 1 ? _("Found "FG_BOLD"%d"FG_RESET" results") : _("Found "FG_BOLD"%d"FG_RESET" result"), indx);
for(i = 0; i < indx; i++){
if(args_get_bool(args, "grep")){
if(args_get_bool(args, "desc"))
printf("%s:%s:%s\n", list[i]->data.name, list[i]->data.version, list[i]->data.desc);
else
printf("%s:%s\n", list[i]->data.name, list[i]->data.version);
continue;
}
if(args_get_bool(args, "desc"))
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s\n",
list[i]->data.name, list[i]->data.version, list[i]->data.desc);
else
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET"\n",
list[i]->data.name, list[i]->data.version);
}
end:
lm_ctx_list_free(&plist);
free(list);
return ret;
}
bool cmd_search(lm_ctx_t *ctx, config_t *config, args_t *args){
char *arg = NULL;
args_split(args, "grep");
args_split(args, "desc");
args_split(args, "database");
args_register(args, "grep");
args_register(args, "desc");
args_register(args, "field");
args_register(args, "database");
if((arg = args_register_check(args)) != NULL){
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg);
return false;
}
if(args_get_bool(args, "help")){
info(_("Usage: " FG_BOLD "search <options> [query]"));
info(_("Listing options for the list command:"));
printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n"));
printf(_(" "FG_BOLD"--desc"FG_RESET":\tshow package description of the results\n"));
printf(_(" "FG_BOLD"--field"FG_RESET":\tpackage field to search by (\"name\", \"desc\" or \"version\")\n"));
printf(_(" "FG_BOLD"--database"FG_RESET":\tsearch the database instead of the pools\n"));
return true;
}
enum field field = FIELD_NAME;
char *query = NULL, *field_val = NULL;
for(size_t i = 1; i < args->count; i++){
if(NULL != args->list[i].name)
continue;
if(NULL == query && NULL != (query = args->list[i].value))
continue;
else if(NULL != query && NULL != (query = args->list[i].value)){
if(!args_get_bool(args, "grep"))
error(_("Please specify only a single query for searching"));
return false;
}
}
if(NULL == query){
if(!args_get_bool(args, "grep"))
error(_("Please specify a query for searching"));
return false;
}
if(NULL == (field_val = args_get_string(args, "field")))
field = FIELD_NAME;
else if(eq(field_val, "desc"))
field = FIELD_DESC;
else if(eq(field_val, "version"))
field = FIELD_VERSION;
if(args_get_bool(args, "database"))
return cmd_search_database(ctx, args, query, field);
return cmd_search_pools(ctx, args, query, field);
}

View File

@ -1,49 +1,62 @@
#include <libmp/all.h> #include <libmp/all.h>
#include <stdio.h> #include <stdio.h>
#include "../callback.h"
#include "../intl.h" #include "../intl.h"
#include "../cmd.h" #include "../cmd.h"
#include "../log.h" #include "../log.h"
bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args){ 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){
bool ret = false, fail = false; switch (state) {
ssize_t synced = 0; case SYNC_DOWNLOADING_INFO:
char *arg = NULL; bar(current, total);
break;
args_split(args, "fail");
args_register(args, "fail"); case SYNC_INFO_SUCCESS:
bar_free();
if((arg = args_register_check(args)) != NULL){ break;
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg);
return false; 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;
} }
if(args_get_bool(args, "help")){ return true;
info(_("Usage: " FG_BOLD "sync <options>")); }
info(_("Listing options for the list command:"));
printf(_(" "FG_BOLD"--fail"FG_RESET":\tquit on a single pool sync failure\n")); bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args){
return true; size_t sycned = 0;
} bool ret = false;
if(config->pool_count == 0){ if(config->pool_count == 0){
error(_("There are no pools specified in the configuration")); error(_("There are no pools specified in the configuration"));
goto end; goto end;
} }
fail = args_get_bool(args, "fail"); sycned = lm_ctx_sync(ctx, true, cmd_sync_callback, NULL);
synced = lm_ctx_sync(ctx, true, callback_sync, &fail);
bar_free(); bar_free();
if(synced < 0 && !fail){ if(sycned < 0){
error(_("Failed to sync pools: %s"), lm_strerror()); error(_("Failed to sync pools: %s"), lm_strerror());
goto end; goto end;
} }
else if(synced < 0 && fail) info(_("Synced "FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET" pools"), sycned, config->pool_count);
goto end;
info(_("Synced "FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET" pools"), synced, config->pool_count);
ret = true; ret = true;
end: end:

View File

@ -1,25 +1,31 @@
#include <libmp/all.h> #include <libmp/all.h>
#include <stdio.h> #include <stdio.h>
#include "../callback.h"
#include "../util.h" #include "../util.h"
#include "../intl.h" #include "../intl.h"
#include "../cmd.h" #include "../cmd.h"
#include "../log.h" #include "../log.h"
bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){ bool cmd_update_remove_callback(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current, size_t total, void *data){
char *arg = NULL; bar(current, total);
return true;
args_split(args, "yes"); }
args_register(args, "yes");
if((arg = args_register_check(args)) != NULL){ bool cmd_update_install_callback(lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data){
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg); bar(current, total);
return false; 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){
args_split(args, "yes");
if(args_get_bool(args, "help")){ if(args_get_bool(args, "help")){
info(_("Usage: " FG_BOLD "update <options>"));
info(_("Listing options for the update command:")); info(_("Listing options for the update command:"));
printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n")); printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n"));
return true; return true;
@ -69,36 +75,30 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){
goto end; goto end;
} }
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Downloading "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), 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);
++current, list->count, new->data.name, new->data.version); r = lm_ctx_download(ctx, new, cmd_update_download_callback, NULL);
r = lm_ctx_download(ctx, new, callback_download, NULL);
bar_free(); bar_free();
if(!r){ if(!r){
error(_("Failed to download "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), 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());
new->data.name, new->data.version, lm_strerror());
goto end; goto end;
} }
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), 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);
current, list->count, old->name, old->version); r = lm_ctx_remove(ctx, old, cmd_update_remove_callback, NULL);
r = lm_ctx_remove(ctx, old, callback_remove, NULL);
bar_free(); bar_free();
if(!r){ if(!r){
error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), old->name, old->version, lm_strerror());
old->name, old->version, lm_strerror());
goto end; goto end;
} }
info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Installing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), 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);
current, list->count, new->data.name, new->data.version); r = lm_ctx_install(ctx, new, can_run_install(ctx), cmd_update_install_callback, NULL);
r = lm_ctx_install(ctx, new, can_run_install(ctx), callback_install, NULL);
bar_free(); bar_free();
if(!r){ if(!r){
error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), 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());
new->data.name, new->data.version, lm_strerror());
goto end; goto end;
} }
} }

View File

@ -30,7 +30,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>
#include "args.h" #include "args.h"
#include "cmd.h" #include "cmd.h"
@ -44,11 +43,9 @@ lm_ctx_t ctx;
void handler(int sig) { void handler(int sig) {
unlock(&ctx); unlock(&ctx);
printf("\e[?25h"); printf("\e[?25h\n");
if (SIGSEGV == sig) if (SIGSEGV == sig)
error(_("Received a segfault")); error(_("Received a segfault"));
else
printf("\n"); // print a newline to not the break shell prompt on SIGINT
exit(1); exit(1);
} }
@ -61,28 +58,23 @@ int main(int argc, char *argv[], char *envp[]) {
textdomain("matt"); textdomain("matt");
cmd_t commands[] = { cmd_t commands[] = {
{.name = "info", .desc = _("show information about a single package"), .root = false, .func = cmd_info }, {.name = "info", .desc = "show information about a single package", .func = cmd_info },
{.name = "list", .desc = _("list all the installed packages"), .root = false, .func = cmd_list }, {.name = "list", .desc = "list all the installed packages", .func = cmd_list },
{.name = "search", .desc = _("search for packages by name/desc/version"), .root = false, .func = cmd_search }, {.name = "sync", .desc = "update the pool info and package lists", .func = cmd_sync },
{.name = "sync", .desc = _("update the pool info and package lists"), .root = true, .func = cmd_sync }, {.name = "install", .desc = "install package(s) from remote pools", .func = cmd_install},
{.name = "install", .desc = _("install package(s) from remote pools"), .root = true, .func = cmd_install}, {.name = "remove", .desc = "remove installed package(s)", .func = cmd_remove },
{.name = "remove", .desc = _("remove installed package(s)"), .root = true, .func = cmd_remove }, {.name = "update", .desc = "update installed package(s)", .func = cmd_update },
{.name = "update", .desc = _("update installed package(s)"), .root = true, .func = cmd_update },
}; };
char *full_datadir = NULL, *full_tmpdir = NULL, *full_pooldir = NULL; char *full_datadir = NULL, *full_tmpdir = NULL, *full_pooldir = NULL;
char *config_file = NULL, *root_dir = NULL, *real_tmpdir = NULL; char *config_file = NULL, *root_dir = NULL;
bool ret = false, r = false, use_root = false; bool ret = false, r = false;
cmd_func_t cmd = NULL; args_t *args = NULL;
args_t *args = NULL; config_t config;
config_t config;
set_env(envp); set_env(envp);
lm_ctx_init(&ctx); lm_ctx_init(&ctx);
args = args_parse(argc, argv); args = args_parse(argc, argv);
args_register(args, "config");
args_register(args, "root");
args_register(args, "help");
if ((config_file = args_get_string(args, "config")) == NULL) if ((config_file = args_get_string(args, "config")) == NULL)
config_file = "/etc/matt/config.ini"; config_file = "/etc/matt/config.ini";
@ -93,27 +85,13 @@ int main(int argc, char *argv[], char *envp[]) {
if (args->count <= 0 || args->list[0].name != NULL) if (args->count <= 0 || args->list[0].name != NULL)
goto help; goto help;
for (int i = 0; i < sizeof(commands) / sizeof(cmd_t); i++) {
if (!eq(commands[i].name, args->list[0].value))
continue;
use_root = commands[i].root;
cmd = commands[i].func;
break;
}
if ((root_dir = args_get_string(args, "root")) == NULL) if ((root_dir = args_get_string(args, "root")) == NULL)
root_dir = "/"; root_dir = "/";
full_datadir = join_alloc(root_dir, config.datadir); full_datadir = join_alloc(root_dir, config.datadir);
full_tmpdir = join_alloc(root_dir, config.tmpdir); full_tmpdir = join_alloc(root_dir, config.tmpdir);
if (!use_root && access(full_tmpdir, W_OK) != 0) if (!lm_ctx_new(&ctx, root_dir, full_tmpdir, full_datadir)) {
real_tmpdir = "/tmp/.matt";
else
real_tmpdir = full_tmpdir;
if (!lm_ctx_new(&ctx, use_root ? root_dir : NULL, real_tmpdir, full_datadir)) {
switch (lm_error()) { switch (lm_error()) {
case LM_ERR_CtxRootFail: case LM_ERR_CtxRootFail:
error(_("Failed to access the root directory, are you running as root?")); error(_("Failed to access the root directory, are you running as root?"));
@ -157,9 +135,9 @@ int main(int argc, char *argv[], char *envp[]) {
pool = pool->next; pool = pool->next;
} }
if (NULL != cmd) { for (int i = 0; i < sizeof(commands) / sizeof(cmd_t); i++) {
if (!use_root) if (!eq(commands[i].name, args->list[0].value))
goto skip_lock; continue;
switch (lock(&ctx)) { switch (lock(&ctx)) {
case ALREADY_LOCKED: case ALREADY_LOCKED:
@ -174,15 +152,11 @@ int main(int argc, char *argv[], char *envp[]) {
break; break;
} }
skip_lock: ret = commands[i].func(&ctx, &config, args);
ret = cmd(&ctx, &config, args);
unlock(&ctx);
goto end; goto end;
} }
error(_("Command not found: " FG_BOLD "%s"), args->list[0].value); error(_("Command not found: " FG_BOLD "%s"), args->list[0].value);
info(_("Displaying help information"));
help: help:
info(_("MatterLinux package manager %s (libmp %s)"), VERSION, LM_VERSION); info(_("MatterLinux package manager %s (libmp %s)"), VERSION, LM_VERSION);
info(_("Usage: " FG_BOLD "%s [command] <options> <arguments>"), argv[0]); info(_("Usage: " FG_BOLD "%s [command] <options> <arguments>"), argv[0]);
@ -198,8 +172,7 @@ help:
printf( printf(
_(" " FG_BOLD "--config" FG_RESET ":\t specify the configuration file (default is /etc/matt/config.ini)\n")); _(" " FG_BOLD "--config" FG_RESET ":\t specify the configuration file (default is /etc/matt/config.ini)\n"));
printf(_(" " FG_BOLD "--root" FG_RESET ":\t specify a custom root directory (default is /)\n")); printf(_(" " FG_BOLD "--root" FG_RESET ":\t specify a custom root directory (default is /)\n\n"));
printf(_(" " FG_BOLD "--help" FG_RESET ":\t list avaliable options/commands\n\n"));
info(_("Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information")); info(_("Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information"));
@ -207,6 +180,8 @@ help:
goto end; goto end;
end: end:
unlock(&ctx);
free(full_pooldir); free(full_pooldir);
free(full_datadir); free(full_datadir);
free(full_tmpdir); free(full_tmpdir);