Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   Signed-off-by: Chirantan Ekbote (http://www.linux-archive.org/archlinux-pacman-development/704902-signed-off-chirantan-ekbote-chirantan-ekbote-gmail-com.html)

Chirantan Ekbote 09-17-2012 11:14 PM

Signed-off-by: Chirantan Ekbote
 
Added code that lists if an optional dependency of a package is installed
locally and additonally prints the version number of the installed dependency.
Patch for FS#13035 in the pacman bug tracker.
---
src/pacman/util.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 7f7f6a7..5c0d7f4 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -701,16 +701,31 @@ void list_display_linebreak(const char *title, const alpm_list_t *list,
printf("%s
", _("None"));
} else {
const alpm_list_t *i;
+ alpm_db_t *db_local = alpm_get_localdb(config->handle);
+
/* Print the first element */
- indentprint((const char *)list->data, len, maxcols);
+ char *pkgname = (char *)list->data;
+ alpm_pkg_t *lpkg = alpm_db_get_pkg(db_local, (const char *)pkgname);
+ indentprint((const char *)pkgname, len, maxcols);
+
+ /* Print the version number if the package is installed locally */
+ if(lpkg != NULL) {
+ printf(" [%s: %s]", _("installed"), alpm_pkg_get_version(lpkg));
+ }
printf("
");
+
/* Print the rest */
for(i = alpm_list_next(list); i; i = alpm_list_next(i)) {
size_t j;
for(j = 1; j <= len; j++) {
printf(" ");
}
- indentprint((const char *)i->data, len, maxcols);
+ pkgname = (char *)i->data;
+ lpkg = alpm_db_get_pkg(db_local, (const char *)pkgname);
+ indentprint((const char *)pkgname, len, maxcols);
+ if(lpkg != NULL) {
+ printf(" [%s: %s]", _("installed"), alpm_pkg_get_version(lpkg));
+ }
printf("
");
}
}
--
1.7.12

Allan McRae 09-17-2012 11:28 PM

Signed-off-by: Chirantan Ekbote
 
On 18/09/12 09:14, Chirantan Ekbote wrote:
> Added code that lists if an optional dependency of a package is installed
> locally and additonally prints the version number of the installed dependency.
> Patch for FS#13035 in the pacman bug tracker.
> ---

Here is a version that prints [installed] when a package is installed or
[pending] if it is going to be installed later:
https://patchwork.archlinux.org/patch/402/


Allan

Allan McRae 09-18-2012 01:48 AM

Signed-off-by: Chirantan Ekbote
 
On 18/09/12 09:28, Allan McRae wrote:
> On 18/09/12 09:14, Chirantan Ekbote wrote:
>> Added code that lists if an optional dependency of a package is installed
>> locally and additonally prints the version number of the installed dependency.
>> Patch for FS#13035 in the pacman bug tracker.
>> ---
>
> Here is a version that prints [installed] when a package is installed or
> [pending] if it is going to be installed later:
> https://patchwork.archlinux.org/patch/402/

Oops... your patch was for the -Qi output. Here is the correct link to
the patch queue:

https://patchwork.archlinux.org/patch/386/

Allan

Chirantan Ekbote 09-18-2012 04:56 AM

Signed-off-by: Chirantan Ekbote
 
Actually my patch (unintentionally) handles both the -Qi output and
FS#13035. The -Qi output uses

static void optdeplist_display(alpm_pkg_t *pkg, unsigned short cols)


and the output for optional dependencies during package installation uses

void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg)


or

void display_optdepends(alpm_pkg_t *pkg)


All three of these methods call

void list_display_linebreak(const char *title, const alpm_list_t *list,
> unsigned short maxcols)


to actually print the output. Since my patch modifies this method, any
method that calls it will automatically get the installation status of the
packages in the provided list. Including a [pending] status would also only
take a few extra lines of code. Additionally, it seems that the only
methods that do call list_display_linebreak are ones that deal with
optional dependencies. If some other method were to start calling it, we
would have a problem.
It might also be worth considering merging some of these methods since they
seem to be doing the same thing.

Of course, this conflicts with both
https://patchwork.archlinux.org/patch/402/ and
https://patchwork.archlinux.org/patch/386/. I'm just an arch newbie though
so its very likely I missed something.

I figured I would be safe trying to contribute by patching a relatively
simple feature request that no one seemed to have touched in the last three
years. It would be just my luck that someone patched it a couple of weeks
before I did (~_~;)

Best
-Chirantan

On Mon, Sep 17, 2012 at 9:48 PM, Allan McRae <allan@archlinux.org> wrote:

> On 18/09/12 09:28, Allan McRae wrote:
> > On 18/09/12 09:14, Chirantan Ekbote wrote:
> >> Added code that lists if an optional dependency of a package is
> installed
> >> locally and additonally prints the version number of the installed
> dependency.
> >> Patch for FS#13035 in the pacman bug tracker.
> >> ---
> >
> > Here is a version that prints [installed] when a package is installed or
> > [pending] if it is going to be installed later:
> > https://patchwork.archlinux.org/patch/402/
>
> Oops... your patch was for the -Qi output. Here is the correct link to
> the patch queue:
>
> https://patchwork.archlinux.org/patch/386/
>
> Allan
>
>
>
>


All times are GMT. The time now is 05:36 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.