Compare commits
No commits in common. "7ba75dc28456565b938cdabfabc52132ec1fe675" and "4434b742c565852b621d3c76e62f7e4ba6c5e56d" have entirely different histories.
7ba75dc284
...
4434b742c5
2
Makefile
2
Makefile
@ -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.04
|
||||
VERSION = 24.02
|
||||
|
||||
all: dist dist/matt $(PO_OUTS)
|
||||
|
||||
|
@ -8,20 +8,20 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-08-25 22:43+0300\n"
|
||||
"POT-Creation-Date: 2024-08-16 03:44+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"
|
||||
"Language: \n"
|
||||
"Language: tr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: src/callback.c:39 src/callback.c:56
|
||||
#: src/callback.c:34 src/callback.c:49
|
||||
msgid "Failed to sync "
|
||||
msgstr "Failed to sync "
|
||||
|
||||
#: src/callback.c:50 src/cmd/sync.c:46
|
||||
#: src/callback.c:43 src/cmd/sync.c:32
|
||||
msgid "Synced "
|
||||
msgstr "Synced "
|
||||
|
||||
@ -31,8 +31,9 @@ msgid "Unknown configuration option: %s/%s"
|
||||
msgstr "Unknown configuration option: %s/%s"
|
||||
|
||||
#: src/config.c:79
|
||||
#, fuzzy
|
||||
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
|
||||
msgid "Failed to parse the configuration"
|
||||
@ -76,115 +77,85 @@ msgstr "%s [y/N] "
|
||||
msgid "Please answer with y/n"
|
||||
msgstr "Please answer with y/n"
|
||||
|
||||
#: src/main.c:49
|
||||
#: src/main.c:48
|
||||
msgid "Received a segfault"
|
||||
msgstr "Received a segfault"
|
||||
|
||||
#: src/main.c:64
|
||||
#, 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?"
|
||||
msgstr "Failed to access the root directory, are you running as root?"
|
||||
|
||||
#: src/main.c:123
|
||||
msgid "Failed to access the data directory ("
|
||||
msgstr "Failed to access the data directory ("
|
||||
|
||||
#: src/main.c:127
|
||||
msgid "Failed to access the temp directory ("
|
||||
msgstr "Failed to access the temp directory ("
|
||||
|
||||
#: src/main.c:131
|
||||
#, c-format
|
||||
msgid "Failed to initialize libmp context: %s"
|
||||
msgstr "Failed to initialize libmp context: %s"
|
||||
|
||||
#: src/main.c:142
|
||||
msgid "Failed to create the pools directory ("
|
||||
msgstr "Failed to create the pools directory ("
|
||||
|
||||
#: src/main.c:152
|
||||
msgid "Failed to add pool "
|
||||
msgstr "Failed to add pool "
|
||||
|
||||
#: src/main.c:166
|
||||
#: src/main.c:102
|
||||
msgid "Failed to lock, matt is already running"
|
||||
msgstr "Failed to lock, matt is already running"
|
||||
|
||||
#: src/main.c:170
|
||||
#: src/main.c:106
|
||||
msgid "Failed to lock, are you root?"
|
||||
msgstr "Failed to lock, are you root?"
|
||||
|
||||
#: src/main.c:183
|
||||
#: src/main.c:130
|
||||
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:134
|
||||
#, fuzzy
|
||||
msgid "Failed to access the data directory ("
|
||||
msgstr "Failed to access the configuration file: %s"
|
||||
|
||||
#: src/main.c:138
|
||||
#, fuzzy
|
||||
msgid "Failed to access the temp directory ("
|
||||
msgstr "Failed to open the editor: %s"
|
||||
|
||||
#: src/main.c:142
|
||||
#, fuzzy, c-format
|
||||
msgid "Failed to initialize libmp context: %s"
|
||||
msgstr "Failed to install "
|
||||
|
||||
#: src/main.c:153
|
||||
#, fuzzy
|
||||
msgid "Failed to create the pools directory ("
|
||||
msgstr "Failed to open the editor: %s"
|
||||
|
||||
#: src/main.c:163
|
||||
msgid "Failed to add pool "
|
||||
msgstr "Failed to add pool "
|
||||
|
||||
#: src/main.c:177
|
||||
msgid "Command not found: "
|
||||
msgstr "Command not found: "
|
||||
|
||||
#: src/main.c:184
|
||||
#: src/main.c:178
|
||||
msgid "Displaying help information"
|
||||
msgstr "Displaying help information"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:187
|
||||
#, c-format
|
||||
#: src/main.c:181
|
||||
#, fuzzy, c-format
|
||||
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/cmd/remove.c:27 src/cmd/search.c:197 src/cmd/sync.c:23
|
||||
#: src/cmd/update.c:22
|
||||
#: src/main.c:182
|
||||
msgid "Usage: "
|
||||
msgstr "Usage: "
|
||||
|
||||
#: src/main.c:190
|
||||
#: src/main.c:184
|
||||
msgid "Here is a list of available commands:"
|
||||
msgstr "Here is a list of available commands:"
|
||||
|
||||
#: src/main.c:196
|
||||
#: src/main.c:190
|
||||
msgid "To list different options, use commands with "
|
||||
msgstr "To list different options, use commands with "
|
||||
|
||||
#: src/main.c:197
|
||||
#: src/main.c:191
|
||||
msgid "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/cmd/info.c:50 src/cmd/info.c:51 src/cmd/install.c:35
|
||||
#: src/main.c:194 src/main.c:195 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/install.c:39 src/cmd/list.c:25 src/cmd/list.c:26 src/cmd/remove.c:29
|
||||
#: 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
|
||||
#: 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:204
|
||||
#: src/main.c:197
|
||||
msgid ""
|
||||
"Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information"
|
||||
msgstr ""
|
||||
@ -204,75 +175,70 @@ 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: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:91 src/cmd/remove.c:52
|
||||
msgid "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/search.c:192 src/cmd/sync.c:18 src/cmd/update.c:17
|
||||
#: 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 "Unknown argument: "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/info.c:48 src/cmd/list.c:24 src/cmd/search.c:198 src/cmd/sync.c:24
|
||||
#: src/cmd/info.c:53 src/cmd/list.c:23
|
||||
msgid "Listing options for the list command:"
|
||||
msgstr "Listing options for the list command:"
|
||||
|
||||
#: src/cmd/info.c:72
|
||||
#: src/cmd/info.c:76
|
||||
msgid "Please specify only a single package name"
|
||||
msgstr "Please specify only a single package name"
|
||||
|
||||
#: src/cmd/info.c:79
|
||||
#: src/cmd/info.c:83
|
||||
msgid "Please specify a single package"
|
||||
msgstr "Please specify a single package"
|
||||
|
||||
#: src/cmd/info.c:94
|
||||
#: src/cmd/info.c:98
|
||||
msgid "Failed to get the changes file for "
|
||||
msgstr "Failed to get the changes file for "
|
||||
|
||||
#: src/cmd/info.c:100
|
||||
#: src/cmd/info.c:104
|
||||
msgid "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:111
|
||||
msgid "Failed to get the depends list for "
|
||||
msgstr "Failed to get the depends list for "
|
||||
|
||||
#: src/cmd/info.c:135
|
||||
#: src/cmd/info.c:138
|
||||
#, c-format
|
||||
msgid "Name "
|
||||
msgstr "Name "
|
||||
|
||||
#: src/cmd/info.c:136
|
||||
#: src/cmd/info.c:139
|
||||
#, c-format
|
||||
msgid "Version "
|
||||
msgstr "Version "
|
||||
|
||||
#: src/cmd/info.c:137
|
||||
#: src/cmd/info.c:140
|
||||
#, c-format
|
||||
msgid "Desc "
|
||||
msgstr "Desc "
|
||||
|
||||
#: src/cmd/info.c:138
|
||||
#: src/cmd/info.c:141
|
||||
#, c-format
|
||||
msgid "Size "
|
||||
msgstr "Size "
|
||||
|
||||
#: src/cmd/info.c:141
|
||||
#: src/cmd/info.c:144
|
||||
#, c-format
|
||||
msgid "Depends "
|
||||
msgstr "Depends "
|
||||
|
||||
#: src/cmd/info.c:144
|
||||
#: src/cmd/info.c:147
|
||||
#, c-format
|
||||
msgid "Changes "
|
||||
msgstr "Changes "
|
||||
|
||||
#: src/cmd/info.c:147
|
||||
#, fuzzy, c-format
|
||||
msgid "Pool "
|
||||
msgstr " "
|
||||
|
||||
#: src/cmd/info.c:150 src/cmd/info.c:151
|
||||
#: src/cmd/info.c:151 src/cmd/info.c:152
|
||||
#, c-format
|
||||
msgid "Installed "
|
||||
msgstr "Installed "
|
||||
@ -282,162 +248,149 @@ msgstr "Installed "
|
||||
msgid "Up-to-date "
|
||||
msgstr "Up-to-date "
|
||||
|
||||
#: src/cmd/install.c:34
|
||||
#: src/cmd/install.c:33
|
||||
msgid "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: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:63
|
||||
#: src/cmd/install.c:62
|
||||
msgid "Specified "
|
||||
msgstr "Specified "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/install.c:76
|
||||
#: src/cmd/install.c:72
|
||||
#, fuzzy
|
||||
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:82 src/cmd/remove.c:54
|
||||
msgid "Failed to find "
|
||||
msgstr "Failed to find "
|
||||
|
||||
#: src/cmd/install.c:103
|
||||
#: src/cmd/install.c:100
|
||||
msgid "Failed to resolve "
|
||||
msgstr "Failed to resolve "
|
||||
|
||||
#: src/cmd/install.c:112
|
||||
#: 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:121 src/cmd/install.c:123 src/cmd/remove.c:75
|
||||
#: src/cmd/remove.c:77 src/cmd/update.c:50 src/cmd/update.c:52
|
||||
#: 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:129 src/cmd/remove.c:84
|
||||
#: src/cmd/install.c:126 src/cmd/remove.c:83
|
||||
msgid "Total of "
|
||||
msgstr "Total of "
|
||||
|
||||
#: src/cmd/install.c:132 src/cmd/update.c:59
|
||||
#: 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:134 src/cmd/remove.c:85 src/cmd/update.c:61
|
||||
#: src/cmd/install.c:131 src/cmd/remove.c:84 src/cmd/update.c:60
|
||||
msgid "Continue?"
|
||||
msgstr "Continue?"
|
||||
|
||||
#: src/cmd/install.c:135 src/cmd/remove.c:86 src/cmd/update.c:62
|
||||
#: 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:151 src/cmd/install.c:155 src/cmd/install.c:175
|
||||
#: src/cmd/install.c:191 src/cmd/remove.c:93 src/cmd/update.c:72
|
||||
#: src/cmd/update.c:83 src/cmd/update.c:94
|
||||
#: 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:161 src/cmd/update.c:78
|
||||
#: src/cmd/install.c:158 src/cmd/update.c:77
|
||||
msgid "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: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:198 src/cmd/update.c:100
|
||||
#: src/cmd/install.c:195 src/cmd/update.c:99
|
||||
msgid "Failed to install "
|
||||
msgstr "Failed to install "
|
||||
|
||||
#: src/cmd/install.c:205
|
||||
#: src/cmd/install.c:202
|
||||
msgid "Installed "
|
||||
msgstr "Installed "
|
||||
|
||||
#: src/cmd/install.c:205
|
||||
#: src/cmd/install.c:202
|
||||
msgid "Installed all of the "
|
||||
msgstr "Installed all of the "
|
||||
|
||||
#: src/cmd/list.c:39
|
||||
#, fuzzy
|
||||
msgid "There are no installed packages"
|
||||
#: src/cmd/list.c:38
|
||||
msgid "There no installed packages"
|
||||
msgstr "There no installed packages"
|
||||
|
||||
#: src/cmd/list.c:44
|
||||
#: src/cmd/list.c:43
|
||||
msgid "Listing "
|
||||
msgstr "Listing "
|
||||
|
||||
#: src/cmd/remove.c:28
|
||||
#: src/cmd/remove.c:27
|
||||
msgid "Listing options for the remove command:"
|
||||
msgstr "Listing options for the remove command:"
|
||||
|
||||
#: src/cmd/remove.c:60
|
||||
#, fuzzy
|
||||
msgid "Cannot remove "
|
||||
msgstr "Failed to remove "
|
||||
|
||||
#: src/cmd/remove.c:68
|
||||
#: 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:107
|
||||
#: src/cmd/remove.c:106
|
||||
msgid "Removed "
|
||||
msgstr "Removed "
|
||||
|
||||
#: src/cmd/remove.c:107
|
||||
#: src/cmd/remove.c:106
|
||||
msgid "Removed all of the "
|
||||
msgstr "Removed all of the "
|
||||
|
||||
#: src/cmd/search.c:72 src/cmd/search.c:149
|
||||
msgid "No results, maybe you forgot to sync?"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/search.c:77 src/cmd/search.c:154
|
||||
msgid "Found "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/search.c:113
|
||||
#, 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
|
||||
#: 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:39
|
||||
#: src/cmd/sync.c:28
|
||||
#, c-format
|
||||
msgid "Failed to sync pools: %s"
|
||||
msgstr "Failed to sync pools: %s"
|
||||
|
||||
#: src/cmd/update.c:23
|
||||
#: src/cmd/update.c:22
|
||||
msgid "Listing options for the update command:"
|
||||
msgstr "Listing options for the update command:"
|
||||
|
||||
#: src/cmd/update.c:40
|
||||
#: 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:45
|
||||
#: src/cmd/update.c:44
|
||||
msgid "All packages are up-to-date"
|
||||
msgstr "All packages are up-to-date"
|
||||
|
||||
#: src/cmd/update.c:68
|
||||
#: src/cmd/update.c:67
|
||||
msgid "Failed to update "
|
||||
msgstr "Failed to update "
|
||||
|
||||
#~ msgid "Cannot remove "
|
||||
#~ msgstr "Cannot remove "
|
||||
|
||||
#, 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"
|
||||
|
@ -3,10 +3,7 @@
|
||||
#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();
|
||||
bar(current, total);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -23,8 +20,6 @@ bool callback_remove(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current,
|
||||
|
||||
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);
|
||||
@ -37,8 +32,6 @@ bool callback_sync(
|
||||
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:
|
||||
@ -54,8 +47,6 @@ bool callback_sync(
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ typedef struct cmd {
|
||||
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_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_remove(lm_ctx_t *ctx, config_t *config, args_t *args);
|
||||
bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args);
|
||||
|
@ -1,20 +1,26 @@
|
||||
#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 <stdlib.h>
|
||||
|
||||
#include "../util.h"
|
||||
#include "../intl.h"
|
||||
#include "../cmd.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){
|
||||
if((*pkgp = lm_ctx_pool_find(ctx, name, NULL)) == NULL){
|
||||
lm_pkg_data_t *cmd_info_from_pool(lm_ctx_t *ctx, args_t *args, char *name){
|
||||
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())
|
||||
error(_("Package "FG_BOLD"%s"FG_RESET" not found"), name);
|
||||
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){
|
||||
@ -44,7 +50,6 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "info <options> [package name]"));
|
||||
info(_("Listing options for the list command:"));
|
||||
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"));
|
||||
@ -57,7 +62,6 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
|
||||
char *name = NULL, *depends = NULL, *changes = NULL;
|
||||
lm_pkg_data_t *data = NULL;
|
||||
lm_pkg_t *pkg = NULL;
|
||||
lm_entry_t ent;
|
||||
|
||||
for(size_t i = 1; i < args->count; i++){
|
||||
@ -86,7 +90,7 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -121,7 +125,6 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
printf("CHANGES:%s\n", changes);
|
||||
|
||||
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("UPTODATE:%d\n", lm_ctx_database_is_installed(ctx, data->name, data->version));
|
||||
}
|
||||
@ -144,12 +147,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);
|
||||
|
||||
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) ?
|
||||
_(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"));
|
||||
|
||||
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_RED"no"FG_RESET"\n"));
|
||||
|
@ -30,7 +30,6 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "install <options> [package name(s)]"));
|
||||
info(_("Listing options for the install command:"));
|
||||
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"));
|
||||
@ -47,7 +46,7 @@ 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;
|
||||
lm_pkg_t *pkg = NULL, **locals = NULL;
|
||||
lm_pkg_t *pkg = NULL, *locals = NULL;
|
||||
lm_ctx_resolve_list_t *list = NULL;
|
||||
lm_entry_t older;
|
||||
char ssize[LONGSTR_MAX+3];
|
||||
@ -57,7 +56,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))
|
||||
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(access(name, R_OK) != 0){
|
||||
error(_("Specified "FG_BOLD"%s"FG_RESET" archive does not have read access"), name);
|
||||
@ -65,18 +64,16 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(NULL == locals)
|
||||
locals = malloc(sizeof(lm_pkg_t*));
|
||||
locals = malloc(sizeof(lm_pkg_t));
|
||||
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));
|
||||
locals[li] = pkg;
|
||||
|
||||
if(!lm_ctx_package_from(ctx, pkg, name)){
|
||||
if(!lm_ctx_package_from(ctx, &locals[li], name)){
|
||||
error(_("Failed to load "FG_BOLD"%s"FG_RESET": %s"), name, lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
||||
pkg = &locals[li];
|
||||
goto resolve;
|
||||
}
|
||||
|
||||
@ -141,7 +138,7 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
is_local = false;
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
@ -210,7 +207,7 @@ end:
|
||||
bar_free();
|
||||
|
||||
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);
|
||||
|
||||
lm_ctx_resolve_free(list);
|
||||
|
@ -20,7 +20,6 @@ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "list <options>"));
|
||||
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 descriptions\n"));
|
||||
@ -36,7 +35,7 @@ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
|
||||
if(count <= 0){
|
||||
if(!args_get_bool(args, "grep"))
|
||||
info(_("There are no installed packages"));
|
||||
info(_("There no installed packages"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -53,11 +52,9 @@ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "desc"))
|
||||
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s\n",
|
||||
ent.name, ent.version, ent.desc);
|
||||
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s\n", ent.name, ent.version, ent.desc);
|
||||
else
|
||||
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET"\n",
|
||||
ent.name, ent.version);
|
||||
printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET"\n", ent.name, ent.version);
|
||||
}
|
||||
|
||||
lm_ctx_database_next_free(ctx, &ent);
|
||||
|
@ -24,7 +24,6 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "remove <options> [package name(s)]"));
|
||||
info(_("Listing options for the remove command:"));
|
||||
printf(_(" "FG_BOLD"--break"FG_RESET":\tbreak other package depends\n"));
|
||||
printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n"));
|
||||
@ -56,12 +55,12 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(!args_get_bool(args, "break") && !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());
|
||||
if(!lm_ctx_removeable(ctx, &pkgs[count-1])){
|
||||
error(_("Failed to 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;
|
||||
}
|
||||
|
||||
size += pkgs[count-1].size;
|
||||
size += pkgs[count].size;
|
||||
}
|
||||
|
||||
if(NULL == pkgs){
|
||||
|
240
src/cmd/search.c
240
src/cmd/search.c
@ -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);
|
||||
}
|
||||
|
@ -7,43 +7,29 @@
|
||||
#include "../log.h"
|
||||
|
||||
bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
bool ret = false, fail = false;
|
||||
ssize_t synced = 0;
|
||||
size_t sycned = 0;
|
||||
bool ret = false;
|
||||
char *arg = NULL;
|
||||
|
||||
args_split(args, "fail");
|
||||
args_register(args, "fail");
|
||||
|
||||
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 "sync <options>"));
|
||||
info(_("Listing options for the list command:"));
|
||||
printf(_(" "FG_BOLD"--fail"FG_RESET":\tquit on a single pool sync failure\n"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(config->pool_count == 0){
|
||||
error(_("There are no pools specified in the configuration"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
fail = args_get_bool(args, "fail");
|
||||
synced = lm_ctx_sync(ctx, true, callback_sync, &fail);
|
||||
sycned = lm_ctx_sync(ctx, true, callback_sync, NULL);
|
||||
bar_free();
|
||||
|
||||
if(synced < 0 && !fail){
|
||||
if(sycned < 0){
|
||||
error(_("Failed to sync pools: %s"), lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
||||
else if(synced < 0 && fail)
|
||||
goto end;
|
||||
|
||||
info(_("Synced "FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET" pools"), synced, config->pool_count);
|
||||
info(_("Synced "FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET" pools"), sycned, config->pool_count);
|
||||
ret = true;
|
||||
|
||||
end:
|
||||
|
@ -19,7 +19,6 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "update <options>"));
|
||||
info(_("Listing options for the update command:"));
|
||||
printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n"));
|
||||
return true;
|
||||
|
69
src/main.c
69
src/main.c
@ -30,7 +30,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "args.h"
|
||||
#include "cmd.h"
|
||||
@ -61,18 +60,17 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
textdomain("matt");
|
||||
|
||||
cmd_t commands[] = {
|
||||
{.name = "info", .desc = _("show information about a single package"), .root = false, .func = cmd_info },
|
||||
{.name = "list", .desc = _("list all the installed packages"), .root = false, .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"), .root = true, .func = cmd_sync },
|
||||
{.name = "install", .desc = _("install package(s) from remote pools"), .root = true, .func = cmd_install},
|
||||
{.name = "remove", .desc = _("remove installed package(s)"), .root = true, .func = cmd_remove },
|
||||
{.name = "update", .desc = _("update installed package(s)"), .root = true, .func = cmd_update },
|
||||
{.name = "info", .desc = "show information about a single package", .root = false, .func = cmd_info },
|
||||
{.name = "list", .desc = "list all the installed packages", .root = false, .func = cmd_list },
|
||||
{.name = "sync", .desc = "update the pool info and package lists", .root = true, .func = cmd_sync },
|
||||
{.name = "install", .desc = "install package(s) from remote pools", .root = true, .func = cmd_install},
|
||||
{.name = "remove", .desc = "remove installed package(s)", .root = true, .func = cmd_remove },
|
||||
{.name = "update", .desc = "update installed package(s)", .root = true, .func = cmd_update },
|
||||
};
|
||||
|
||||
char *full_datadir = NULL, *full_tmpdir = NULL, *full_pooldir = NULL;
|
||||
char *config_file = NULL, *root_dir = NULL, *real_tmpdir = NULL;
|
||||
bool ret = false, r = false, use_root = false;
|
||||
char *config_file = NULL, *root_dir = NULL;
|
||||
cmd_func_t cmd = NULL;
|
||||
args_t *args = NULL;
|
||||
config_t config;
|
||||
@ -90,30 +88,43 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
if (!config_load(&ctx, &config, config_file))
|
||||
goto end;
|
||||
|
||||
if (args->count <= 0 || args->list[0].name != NULL)
|
||||
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;
|
||||
|
||||
if (!use_root)
|
||||
goto skip_lock;
|
||||
|
||||
switch (lock(&ctx)) {
|
||||
case ALREADY_LOCKED:
|
||||
error(_("Failed to lock, matt is already running"));
|
||||
goto end;
|
||||
|
||||
case LOCK_ERROR:
|
||||
error(_("Failed to lock, are you root?"));
|
||||
goto end;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
skip_lock:
|
||||
cmd = commands[i].func;
|
||||
break;
|
||||
}
|
||||
|
||||
if (args->count <= 0 || args->list[0].name != NULL)
|
||||
goto help;
|
||||
|
||||
if ((root_dir = args_get_string(args, "root")) == NULL)
|
||||
root_dir = "/";
|
||||
|
||||
full_datadir = join_alloc(root_dir, config.datadir);
|
||||
full_tmpdir = join_alloc(root_dir, config.tmpdir);
|
||||
|
||||
if (!use_root && access(full_tmpdir, W_OK) != 0)
|
||||
real_tmpdir = "/tmp/.matt";
|
||||
else
|
||||
real_tmpdir = full_tmpdir;
|
||||
|
||||
if (!lm_ctx_new(&ctx, use_root ? root_dir : NULL, real_tmpdir, full_datadir)) {
|
||||
if (!lm_ctx_new(&ctx, use_root ? root_dir : NULL, full_tmpdir, full_datadir)) {
|
||||
switch (lm_error()) {
|
||||
case LM_ERR_CtxRootFail:
|
||||
error(_("Failed to access the root directory, are you running as root?"));
|
||||
@ -158,23 +169,6 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
}
|
||||
|
||||
if (NULL != cmd) {
|
||||
if (!use_root)
|
||||
goto skip_lock;
|
||||
|
||||
switch (lock(&ctx)) {
|
||||
case ALREADY_LOCKED:
|
||||
error(_("Failed to lock, matt is already running"));
|
||||
goto end;
|
||||
|
||||
case LOCK_ERROR:
|
||||
error(_("Failed to lock, are you root?"));
|
||||
goto end;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
skip_lock:
|
||||
ret = cmd(&ctx, &config, args);
|
||||
unlock(&ctx);
|
||||
goto end;
|
||||
@ -198,8 +192,7 @@ help:
|
||||
|
||||
printf(
|
||||
_(" " 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 "--help" FG_RESET ":\t list avaliable options/commands\n\n"));
|
||||
printf(_(" " FG_BOLD "--root" FG_RESET ":\t specify a custom root directory (default is /)\n\n"));
|
||||
|
||||
info(_("Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user