]> git.pld-linux.org Git - packages/poldek.git/blame - poldek-ls-source-rpm.patch
- updated to 0.30rc1
[packages/poldek.git] / poldek-ls-source-rpm.patch
CommitLineData
6ea8dbac
BZ
1diff --git a/cli/ls.c b/cli/ls.c
2index 86b755d..1fa55ba 100644
3--- a/cli/ls.c
4+++ b/cli/ls.c
5@@ -49,6 +49,7 @@ int pkg_cmp_lookup(struct pkg *lpkg, tn_array *pkgs, int compare_ver,
6 #define OPT_LS_GROUP (1 << 9)
7 #define OPT_LS_SUMMARY (1 << 10)
8 #define OPT_LS_NAMES_ONLY (1 << 11)
9+#define OPT_LS_SOURCERPM (1 << 12)
10
11
12 #define OPT_LS_ERR (1 << 16);
13@@ -67,7 +68,8 @@ static struct argp_option options[] = {
14 { NULL, 'n', 0, 0, N_("Print only package names"), 1},
15 { NULL, 'G', 0, 0, N_("Print package groups"), 1},
16 { NULL, 'O', 0, 0, N_("Print package summaries"), 1},
17-// { NULL, 'i', 0, OPTION_ALIAS, 0, 1 },
18+ { "source-rpm", 's', 0, 0,N_("Print package source rpm"), 1},
19+// { NULL, 'i', 0, OPTION_ALIAS, 0, 1 },
20 { 0, 0, 0, 0, 0, 0 },
21 };
22
23@@ -84,7 +86,7 @@ static
24 error_t parse_opt(int key, char *arg, struct argp_state *state)
25 {
26 struct cmdctx *cmdctx = state->input;
27- const char *errmsg_excl = _("ls: -l and -G are exclusive");
28+ const char *errmsg_excl = _("ls: -l,-s and -G are exclusive");
29 arg = arg;
30
31 switch (key) {
32@@ -102,14 +104,23 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
33 break;
34
35 case 'G':
36- if (cmdctx->_flags & OPT_LS_LONG) {
37+ if (cmdctx->_flags & OPT_LS_LONG || cmdctx->_flags & OPT_LS_SOURCERPM) {
38 logn(LOGERR, errmsg_excl);
39 return EINVAL;
40 }
41
42 cmdctx->_flags |= OPT_LS_GROUP;
43 break;
44-
45+
46+ case 's':
47+ if (cmdctx->_flags & OPT_LS_LONG || cmdctx->_flags & OPT_LS_GROUP) {
48+ logn(LOGERR, errmsg_excl);
49+ return EINVAL;
50+ }
51+
52+ cmdctx->_flags |= OPT_LS_SOURCERPM;
53+ break;
54+
55 case 't':
56 cmdctx->_flags |= OPT_LS_SORTBUILDTIME;
57 break;
58@@ -403,15 +414,17 @@ int do_ls(const tn_array *ents, struct cmdctx *cmdctx, const tn_array *evrs)
59
60 *hdr = '\0';
61
62- if (flags & OPT_LS_GROUP) {
63+ if (flags & OPT_LS_GROUP || flags & OPT_LS_SOURCERPM) {
64 snprintf(fmt_hdr, sizeof(fmt_hdr), "%%-%ds%%-%ds\n",
65 term_width_div2 + term_width_div2/10, (term_width/7));
66
67 snprintf(fmt_pkg, sizeof(fmt_pkg), "%%-%ds%%-%ds\n",
68 term_width_div2 + term_width_div2/10, (term_width/7));
69-
70- snprintf(hdr, sizeof(hdr), fmt_hdr, _("package"), _("group"));
71
72+ if (flags & OPT_LS_GROUP)
73+ snprintf(hdr, sizeof(hdr), fmt_hdr, _("package"), _("group"));
74+ else
75+ snprintf(hdr, sizeof(hdr), fmt_hdr, _("package"), _("source rpm"));
76 } else if (flags & OPT_LS_LONG) {
77 if ((flags & OPT_LS_UPGRADEABLE) == 0) {
78 snprintf(fmt_hdr, sizeof(fmt_hdr), "%%-%ds %%-%ds%%%ds\n",
79@@ -480,7 +493,10 @@ int do_ls(const tn_array *ents, struct cmdctx *cmdctx, const tn_array *evrs)
80 if (flags & OPT_LS_GROUP) {
81 const char *group = pkg_group(pkg);
82 cmdctx_printf(cmdctx, fmt_pkg, pkg_name, group ? group : "(unset)");
83-
84+ }
85+ else if (flags & OPT_LS_SOURCERPM) {
86+ const char *srcrpm = pkg_srcfilename_s(pkg);
87+ cmdctx_printf(cmdctx, fmt_pkg, pkg_name, srcrpm ? srcrpm : "(unset)");
88 } else if ((flags & OPT_LS_LONG) == 0) {
89 cmdctx_printf(cmdctx, "%s\n", pkg_name);
90
This page took 0.078994 seconds and 4 git commands to generate.