Dan McGee wrote:
Comments/questions/feedback would be much appreciated there. Perl
isn't always obvious at first sight, so be sure to tell me if there
are places that need more commenting.


Looks fine to me.
But doing a step back over pacsearch / paclist, it seems like the task of adding an install marker (***) would be much easier to do in pacman itself. Then paclist would be a one liner :
pacman -Sl community | grep "^*"
And pacsearch should be much simpler as well, it would just have to worry about colors. And keeping all that color stuff in an external script seems reasonable to me.

So the main advantage of doing it directly in pacman would be an overall code reduction / simplification. But the downside is an useless loss of performance for people who don't need that feature.
-Sl before the patch is 0.085ms and after it is 0.225ms.
I believe that pacman lookups are not very efficient since they do a basic linear search. But I don't know how much we could gain here, for example by using a binary search over a sorted list, or using a hash table for the pkgcache. Otherwise, this feature of marking installed packages could be disabled by default and enabled with a flag.


Otherwise, I'm happy to bung the copyright notice on the top and
recreate the patch.
Did we decide on a name for this yet? Xavier called it repolist, you
wanted to call it paclist and/or repopkg.


I am fine with paclist, so I just changed the name and added the copyright notice, I can then put it on my git repo .
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 3c6dfd5..f6da9c4 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -296,12 +296,17 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t 
*targets)
                for(j = ret; j; j = alpm_list_next(j)) {
                        alpm_list_t *grp;
                        pmpkg_t *pkg = alpm_list_getdata(j);
-
+                       const char *pkgname = alpm_pkg_get_name(pkg);
+                       const char *pkgver = alpm_pkg_get_version(pkg);
+                       pmpkg_t *lpkg = alpm_db_get_pkg(db_local, pkgname);
+                       const char *s = "";
+                       if(lpkg && strcmp(pkgver, alpm_pkg_get_version(lpkg)) 
== 0) {
+                               s = "***";
+                       }
                        if (!config->quiet) {
-                               printf("%s/%s %s", alpm_db_get_name(db), 
alpm_pkg_get_name(pkg),
-                                                        
alpm_pkg_get_version(pkg));
+                               printf("%s%s/%s %s", s, alpm_db_get_name(db), 
pkgname, pkgver);
                        } else {
-                               printf("%s", alpm_pkg_get_name(pkg));
+                               printf("%s", pkgname);
                        }
 
                        /* print the package size with the output if ShowSize 
option set */
@@ -506,11 +511,17 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t 
*targets)
 
                for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
                        pmpkg_t *pkg = alpm_list_getdata(j);
+                       const char *pkgname = alpm_pkg_get_name(pkg);
+                       const char *pkgver = alpm_pkg_get_version(pkg);
+                       pmpkg_t *lpkg = alpm_db_get_pkg(db_local, pkgname);
+                       const char *s = "";
+                       if(lpkg && strcmp(pkgver, alpm_pkg_get_version(lpkg)) 
== 0) {
+                               s = "***";
+                       }
                        if (!config->quiet) {
-                               printf("%s %s %s\n", alpm_db_get_name(db), 
alpm_pkg_get_name(pkg),
-                                                        
alpm_pkg_get_version(pkg));
+                               printf("%s%s %s %s\n", s, alpm_db_get_name(db), 
pkgname, pkgver);
                        } else {
-                               printf("%s\n", alpm_pkg_get_name(pkg));
+                               printf("%s\n", pkgname);
                        }
                }
        }
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev

Reply via email to