xbps-{bin,repo}: wrap long lines for list, pkg-list and search targets.
Fixes issue #26
This commit is contained in:
parent
eb75041b25
commit
1be90e57d7
@ -41,16 +41,17 @@ struct xferstat {
|
|||||||
struct list_pkgver_cb {
|
struct list_pkgver_cb {
|
||||||
pkg_state_t state;
|
pkg_state_t state;
|
||||||
size_t pkgver_len;
|
size_t pkgver_len;
|
||||||
|
size_t maxcols;
|
||||||
bool check_state;
|
bool check_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* from transaction.c */
|
/* from transaction.c */
|
||||||
int install_new_pkg(struct xbps_handle *, const char *, bool);
|
int install_new_pkg(struct xbps_handle *, const char *, bool);
|
||||||
int update_pkg(struct xbps_handle *, const char *);
|
int update_pkg(struct xbps_handle *, const char *);
|
||||||
int remove_pkg(struct xbps_handle *, const char *, bool);
|
int remove_pkg(struct xbps_handle *, const char *, size_t, bool);
|
||||||
int remove_pkg_orphans(struct xbps_handle *, bool, bool);
|
int remove_pkg_orphans(struct xbps_handle *, size_t, bool, bool);
|
||||||
int dist_upgrade(struct xbps_handle *, bool, bool, bool);
|
int dist_upgrade(struct xbps_handle *, size_t, bool, bool, bool);
|
||||||
int exec_transaction(struct xbps_handle *, bool, bool, bool);
|
int exec_transaction(struct xbps_handle *, size_t, bool, bool, bool);
|
||||||
|
|
||||||
/* from remove.c */
|
/* from remove.c */
|
||||||
int remove_installed_pkgs(int, char **, bool, bool, bool, bool);
|
int remove_installed_pkgs(int, char **, bool, bool, bool, bool);
|
||||||
@ -117,7 +118,8 @@ int list_strings_sep_in_array(struct xbps_handle *,
|
|||||||
void *,
|
void *,
|
||||||
bool *);
|
bool *);
|
||||||
size_t find_longest_pkgver(struct xbps_handle *, prop_object_t);
|
size_t find_longest_pkgver(struct xbps_handle *, prop_object_t);
|
||||||
void print_package_line(const char *, bool);
|
void print_package_line(const char *, size_t, bool);
|
||||||
|
size_t get_maxcols(void);
|
||||||
|
|
||||||
/* from list.c */
|
/* from list.c */
|
||||||
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *);
|
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *);
|
||||||
|
@ -40,9 +40,9 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
|
|||||||
{
|
{
|
||||||
struct list_pkgver_cb *lpc = arg;
|
struct list_pkgver_cb *lpc = arg;
|
||||||
const char *pkgver, *short_desc, *arch;
|
const char *pkgver, *short_desc, *arch;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL, *out = NULL;
|
||||||
pkg_state_t curstate;
|
pkg_state_t curstate;
|
||||||
size_t i = 0;
|
size_t i, len = 0;
|
||||||
bool chkarch;
|
bool chkarch;
|
||||||
|
|
||||||
(void)xhp;
|
(void)xhp;
|
||||||
@ -78,7 +78,17 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
|
|||||||
tmp[i] = ' ';
|
tmp[i] = ' ';
|
||||||
|
|
||||||
tmp[i] = '\0';
|
tmp[i] = '\0';
|
||||||
|
len = strlen(tmp) + strlen(short_desc) + 1;
|
||||||
|
if (len > lpc->maxcols) {
|
||||||
|
out = malloc(lpc->maxcols);
|
||||||
|
assert(out);
|
||||||
|
snprintf(out, lpc->maxcols-2, "%s %s", tmp, short_desc);
|
||||||
|
strncat(out, "...", lpc->maxcols);
|
||||||
|
printf("%s\n", out);
|
||||||
|
free(out);
|
||||||
|
} else {
|
||||||
printf("%s %s\n", tmp, short_desc);
|
printf("%s %s\n", tmp, short_desc);
|
||||||
|
}
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -115,12 +115,14 @@ main(int argc, char **argv)
|
|||||||
int i, c, flags, rv;
|
int i, c, flags, rv;
|
||||||
bool rsync, yes, reqby_force, force_rm_with_deps, recursive_rm;
|
bool rsync, yes, reqby_force, force_rm_with_deps, recursive_rm;
|
||||||
bool reinstall, show_download_pkglist_url, dry_run;
|
bool reinstall, show_download_pkglist_url, dry_run;
|
||||||
|
size_t maxcols;
|
||||||
|
|
||||||
rootdir = cachedir = conffile = option = NULL;
|
rootdir = cachedir = conffile = option = NULL;
|
||||||
flags = rv = 0;
|
flags = rv = 0;
|
||||||
reqby_force = rsync = yes = dry_run = force_rm_with_deps = false;
|
reqby_force = rsync = yes = dry_run = force_rm_with_deps = false;
|
||||||
recursive_rm = reinstall = show_download_pkglist_url = false;
|
recursive_rm = reinstall = show_download_pkglist_url = false;
|
||||||
|
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "AC:c:dDFfhMno:Rr:SVvy")) != -1) {
|
while ((c = getopt(argc, argv, "AC:c:dDFfhMno:Rr:SVvy")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'A':
|
case 'A':
|
||||||
@ -228,6 +230,8 @@ main(int argc, char **argv)
|
|||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
|
|
||||||
|
maxcols = get_maxcols();
|
||||||
|
|
||||||
if (strcasecmp(argv[0], "list") == 0) {
|
if (strcasecmp(argv[0], "list") == 0) {
|
||||||
/* Lists packages currently registered in database. */
|
/* Lists packages currently registered in database. */
|
||||||
if (argc < 1 || argc > 2)
|
if (argc < 1 || argc > 2)
|
||||||
@ -258,6 +262,7 @@ main(int argc, char **argv)
|
|||||||
* Find the longest pkgver string to pretty print the output.
|
* Find the longest pkgver string to pretty print the output.
|
||||||
*/
|
*/
|
||||||
lpc.pkgver_len = find_longest_pkgver(&xh, NULL);
|
lpc.pkgver_len = find_longest_pkgver(&xh, NULL);
|
||||||
|
lpc.maxcols = maxcols;
|
||||||
rv = xbps_pkgdb_foreach_cb(&xh, list_pkgs_in_dict, &lpc);
|
rv = xbps_pkgdb_foreach_cb(&xh, list_pkgs_in_dict, &lpc);
|
||||||
if (rv == ENOENT) {
|
if (rv == ENOENT) {
|
||||||
printf("No packages currently registered.\n");
|
printf("No packages currently registered.\n");
|
||||||
@ -276,7 +281,8 @@ main(int argc, char **argv)
|
|||||||
if ((rv = install_new_pkg(&xh, argv[i], reinstall)) != 0)
|
if ((rv = install_new_pkg(&xh, argv[i], reinstall)) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rv = exec_transaction(&xh, yes, dry_run, show_download_pkglist_url);
|
rv = exec_transaction(&xh, maxcols, yes, dry_run,
|
||||||
|
show_download_pkglist_url);
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "update") == 0) {
|
} else if (strcasecmp(argv[0], "update") == 0) {
|
||||||
/* Update an installed package. */
|
/* Update an installed package. */
|
||||||
@ -290,7 +296,8 @@ main(int argc, char **argv)
|
|||||||
if ((rv = update_pkg(&xh, argv[i])) != 0)
|
if ((rv = update_pkg(&xh, argv[i])) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rv = exec_transaction(&xh, yes, dry_run, show_download_pkglist_url);
|
rv = exec_transaction(&xh, yes, maxcols, dry_run,
|
||||||
|
show_download_pkglist_url);
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "remove") == 0) {
|
} else if (strcasecmp(argv[0], "remove") == 0) {
|
||||||
/* Removes a package. */
|
/* Removes a package. */
|
||||||
@ -298,7 +305,7 @@ main(int argc, char **argv)
|
|||||||
usage(true);
|
usage(true);
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
rv = remove_pkg(&xh, argv[i], recursive_rm);
|
rv = remove_pkg(&xh, argv[i], maxcols, recursive_rm);
|
||||||
if (rv == 0)
|
if (rv == 0)
|
||||||
continue;
|
continue;
|
||||||
else if (rv != EEXIST)
|
else if (rv != EEXIST)
|
||||||
@ -310,7 +317,7 @@ main(int argc, char **argv)
|
|||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
rv = exec_transaction(&xh, yes, dry_run, false);
|
rv = exec_transaction(&xh, maxcols, yes, dry_run, false);
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||||
/* Shows info about an installed binary package. */
|
/* Shows info about an installed binary package. */
|
||||||
@ -355,7 +362,8 @@ main(int argc, char **argv)
|
|||||||
if (rsync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
if (rsync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rv = dist_upgrade(&xh, yes, dry_run, show_download_pkglist_url);
|
rv = dist_upgrade(&xh, maxcols, yes, dry_run,
|
||||||
|
show_download_pkglist_url);
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "show-orphans") == 0) {
|
} else if (strcasecmp(argv[0], "show-orphans") == 0) {
|
||||||
/*
|
/*
|
||||||
@ -377,7 +385,7 @@ main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
usage(true);
|
usage(true);
|
||||||
|
|
||||||
rv = remove_pkg_orphans(&xh, yes, dry_run);
|
rv = remove_pkg_orphans(&xh, maxcols, yes, dry_run);
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "reconfigure") == 0) {
|
} else if (strcasecmp(argv[0], "reconfigure") == 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -135,7 +135,7 @@ show_binpkgs_url(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_package_list(prop_object_iterator_t iter, const char *match)
|
show_package_list(prop_object_iterator_t iter, const char *match, size_t cols)
|
||||||
{
|
{
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
const char *pkgver, *tract;
|
const char *pkgver, *tract;
|
||||||
@ -145,14 +145,14 @@ show_package_list(prop_object_iterator_t iter, const char *match)
|
|||||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
||||||
if (strcmp(match, tract))
|
if (strcmp(match, tract))
|
||||||
continue;
|
continue;
|
||||||
print_package_line(pkgver, false);
|
print_package_line(pkgver, cols, false);
|
||||||
}
|
}
|
||||||
prop_object_iterator_reset(iter);
|
prop_object_iterator_reset(iter);
|
||||||
print_package_line(NULL, true);
|
print_package_line(NULL, cols, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
show_transaction_sizes(struct transaction *trans)
|
show_transaction_sizes(struct transaction *trans, size_t cols)
|
||||||
{
|
{
|
||||||
uint64_t dlsize = 0, instsize = 0, rmsize = 0;
|
uint64_t dlsize = 0, instsize = 0, rmsize = 0;
|
||||||
char size[8];
|
char size[8];
|
||||||
@ -164,28 +164,28 @@ show_transaction_sizes(struct transaction *trans)
|
|||||||
&trans->inst_pkgcnt)) {
|
&trans->inst_pkgcnt)) {
|
||||||
printf("%u package%s will be installed:\n",
|
printf("%u package%s will be installed:\n",
|
||||||
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
|
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "install");
|
show_package_list(trans->iter, "install", cols);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (prop_dictionary_get_uint32(trans->d, "total-update-pkgs",
|
if (prop_dictionary_get_uint32(trans->d, "total-update-pkgs",
|
||||||
&trans->up_pkgcnt)) {
|
&trans->up_pkgcnt)) {
|
||||||
printf("%u package%s will be updated:\n",
|
printf("%u package%s will be updated:\n",
|
||||||
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
|
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "update");
|
show_package_list(trans->iter, "update", cols);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (prop_dictionary_get_uint32(trans->d, "total-configure-pkgs",
|
if (prop_dictionary_get_uint32(trans->d, "total-configure-pkgs",
|
||||||
&trans->cf_pkgcnt)) {
|
&trans->cf_pkgcnt)) {
|
||||||
printf("%u package%s will be configured:\n",
|
printf("%u package%s will be configured:\n",
|
||||||
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
|
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "configure");
|
show_package_list(trans->iter, "configure", cols);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (prop_dictionary_get_uint32(trans->d, "total-remove-pkgs",
|
if (prop_dictionary_get_uint32(trans->d, "total-remove-pkgs",
|
||||||
&trans->rm_pkgcnt)) {
|
&trans->rm_pkgcnt)) {
|
||||||
printf("%u package%s will be removed:\n",
|
printf("%u package%s will be removed:\n",
|
||||||
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
|
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "remove");
|
show_package_list(trans->iter, "remove", cols);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -227,6 +227,7 @@ show_transaction_sizes(struct transaction *trans)
|
|||||||
|
|
||||||
int
|
int
|
||||||
dist_upgrade(struct xbps_handle *xhp,
|
dist_upgrade(struct xbps_handle *xhp,
|
||||||
|
size_t cols,
|
||||||
bool yes,
|
bool yes,
|
||||||
bool dry_run,
|
bool dry_run,
|
||||||
bool show_download_pkglist_url)
|
bool show_download_pkglist_url)
|
||||||
@ -254,11 +255,12 @@ dist_upgrade(struct xbps_handle *xhp,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return exec_transaction(xhp, yes, dry_run, show_download_pkglist_url);
|
return exec_transaction(xhp, cols, yes, dry_run,
|
||||||
|
show_download_pkglist_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
remove_pkg_orphans(struct xbps_handle *xhp, bool yes, bool dry_run)
|
remove_pkg_orphans(struct xbps_handle *xhp, size_t cols, bool yes, bool dry_run)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
@ -272,7 +274,7 @@ remove_pkg_orphans(struct xbps_handle *xhp, bool yes, bool dry_run)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return exec_transaction(xhp, yes, dry_run, false);
|
return exec_transaction(xhp, cols, yes, dry_run, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -323,7 +325,8 @@ update_pkg(struct xbps_handle *xhp, const char *pkgname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
|
remove_pkg(struct xbps_handle *xhp, const char *pkgname, size_t cols,
|
||||||
|
bool recursive)
|
||||||
{
|
{
|
||||||
prop_dictionary_t pkgd;
|
prop_dictionary_t pkgd;
|
||||||
prop_array_t reqby;
|
prop_array_t reqby;
|
||||||
@ -342,10 +345,10 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
|
|||||||
prop_array_count(reqby) > 1 ? "S" : "");
|
prop_array_count(reqby) > 1 ? "S" : "");
|
||||||
for (x = 0; x < prop_array_count(reqby); x++) {
|
for (x = 0; x < prop_array_count(reqby); x++) {
|
||||||
prop_array_get_cstring_nocopy(reqby, x, &pkgver);
|
prop_array_get_cstring_nocopy(reqby, x, &pkgver);
|
||||||
print_package_line(pkgver, false);
|
print_package_line(pkgver, cols, false);
|
||||||
}
|
}
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
print_package_line(NULL, true);
|
print_package_line(NULL, cols, true);
|
||||||
return rv;
|
return rv;
|
||||||
} else if (rv == ENOENT) {
|
} else if (rv == ENOENT) {
|
||||||
printf("Package `%s' is not currently installed.\n", pkgname);
|
printf("Package `%s' is not currently installed.\n", pkgname);
|
||||||
@ -361,6 +364,7 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
|
|||||||
|
|
||||||
int
|
int
|
||||||
exec_transaction(struct xbps_handle *xhp,
|
exec_transaction(struct xbps_handle *xhp,
|
||||||
|
size_t maxcols,
|
||||||
bool yes,
|
bool yes,
|
||||||
bool dry_run,
|
bool dry_run,
|
||||||
bool show_download_urls)
|
bool show_download_urls)
|
||||||
@ -419,7 +423,7 @@ exec_transaction(struct xbps_handle *xhp,
|
|||||||
/*
|
/*
|
||||||
* Show download/installed size for the transaction.
|
* Show download/installed size for the transaction.
|
||||||
*/
|
*/
|
||||||
if ((rv = show_transaction_sizes(trans)) != 0)
|
if ((rv = show_transaction_sizes(trans, maxcols)) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
/*
|
/*
|
||||||
* Ask interactively (if -y not set).
|
* Ask interactively (if -y not set).
|
||||||
|
@ -216,18 +216,22 @@ list_strings_sep_in_array(struct xbps_handle *xhp,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
get_maxcols(void)
|
||||||
|
{
|
||||||
|
struct winsize ws;
|
||||||
|
|
||||||
|
if (ioctl(1, TIOCGWINSZ, &ws) == 0)
|
||||||
|
return ws.ws_col;
|
||||||
|
|
||||||
|
return 80;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
print_package_line(const char *str, bool reset)
|
print_package_line(const char *str, size_t maxcols, bool reset)
|
||||||
{
|
{
|
||||||
static size_t cols;
|
static size_t cols;
|
||||||
static bool first;
|
static bool first;
|
||||||
struct winsize ws;
|
|
||||||
size_t maxcols;
|
|
||||||
|
|
||||||
if (ioctl(1, TIOCGWINSZ, &ws) == 0)
|
|
||||||
maxcols = ws.ws_col;
|
|
||||||
else
|
|
||||||
maxcols = 80;
|
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
cols = 0;
|
cols = 0;
|
||||||
|
@ -32,6 +32,7 @@ struct repo_search_data {
|
|||||||
int npatterns;
|
int npatterns;
|
||||||
char **patterns;
|
char **patterns;
|
||||||
size_t pkgver_len;
|
size_t pkgver_len;
|
||||||
|
size_t maxcols;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* From common.c */
|
/* From common.c */
|
||||||
|
@ -50,11 +50,10 @@ repo_pkg_list_cb(struct xbps_handle *xhp,
|
|||||||
lpc.check_state = false;
|
lpc.check_state = false;
|
||||||
lpc.state = 0;
|
lpc.state = 0;
|
||||||
lpc.pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
lpc.pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
||||||
|
lpc.maxcols = get_maxcols();
|
||||||
if (arg == NULL)
|
|
||||||
printf("From %s repository ...\n", rpi->uri);
|
|
||||||
|
|
||||||
(void)xbps_callback_array_iter(xhp, rpi->repo, list_pkgs_in_dict, &lpc);
|
(void)xbps_callback_array_iter(xhp, rpi->repo, list_pkgs_in_dict, &lpc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,9 +82,10 @@ repo_search_pkgs_cb(struct xbps_handle *xhp,
|
|||||||
struct repo_search_data *rsd = arg;
|
struct repo_search_data *rsd = arg;
|
||||||
(void)done;
|
(void)done;
|
||||||
|
|
||||||
|
rsd->maxcols = get_maxcols();
|
||||||
rsd->pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
rsd->pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
||||||
|
|
||||||
printf("From %s repository ...\n", rpi->uri);
|
|
||||||
(void)xbps_callback_array_iter(xhp, rpi->repo, show_pkg_namedesc, rsd);
|
(void)xbps_callback_array_iter(xhp, rpi->repo, show_pkg_namedesc, rsd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,9 @@ show_pkg_namedesc(struct xbps_handle *xhp,
|
|||||||
bool *loop_done)
|
bool *loop_done)
|
||||||
{
|
{
|
||||||
struct repo_search_data *rsd = arg;
|
struct repo_search_data *rsd = arg;
|
||||||
const char *pkgver, *pkgname, *desc, *arch;
|
const char *pkgver, *pkgname, *desc, *arch, *inststr;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL, *out = NULL;
|
||||||
size_t i, x;
|
size_t i, x, len;
|
||||||
|
|
||||||
(void)xhp;
|
(void)xhp;
|
||||||
(void)loop_done;
|
(void)loop_done;
|
||||||
@ -129,11 +129,22 @@ show_pkg_namedesc(struct xbps_handle *xhp,
|
|||||||
|
|
||||||
tmp[x] = '\0';
|
tmp[x] = '\0';
|
||||||
if (xbps_pkgdb_get_pkgd_by_pkgver(xhp, pkgver))
|
if (xbps_pkgdb_get_pkgd_by_pkgver(xhp, pkgver))
|
||||||
printf(" * ");
|
inststr = "[*] ";
|
||||||
else
|
else
|
||||||
printf(" ");
|
inststr = "[ ] ";
|
||||||
printf("%s %s\n", tmp, desc);
|
|
||||||
free(tmp);
|
len = strlen(inststr) + strlen(tmp) + strlen(desc) + 1;
|
||||||
|
if (len > rsd->maxcols) {
|
||||||
|
out = malloc(rsd->maxcols);
|
||||||
|
assert(out);
|
||||||
|
snprintf(out, rsd->maxcols-2, "%s%s %s",
|
||||||
|
inststr, tmp, desc);
|
||||||
|
strncat(out, "...", rsd->maxcols);
|
||||||
|
printf("%s\n", out);
|
||||||
|
free(out);
|
||||||
|
} else {
|
||||||
|
printf("%s%s %s\n", inststr, tmp, desc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user