FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 05-10-2008, 01:37 AM
"Dan McGee"
 
Default List packages from a given repo

On Fri, May 9, 2008 at 8:29 PM, Allan McRae <mcrae_allan@hotmail.com> wrote:
> Xavier wrote:
>> and bask in the glory and speed of perl
>>
>
> Oooo, I am, I am!
And while we are on the perl bus:
http://code.toofishes.net/gitweb.cgi?p=pacman.git;a=commitdiff;h=555e2091725 a255f2e7dbe10c7c17d0830a60e36

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.

> Now I preface this by saying I know next to nothing about perl.... but
> from what I can tell, this script looks good. Just one query, when
> adding an item to a hash, does perl not return an indicator about
> whether a new item was created or not? If so, we can probably combine
You might be right, but I think it is a bit clearer as is? I don't
think we are going to get much of a performance gain over 0.1 seconds
anyway.

Note that the hash table holds (key, value) pairs of (pkginfo, # of
times found). I didn't get this at first but it makes sense.

> 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.

-Dan

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 05-10-2008, 02:33 AM
Allan McRae
 
Default List packages from a given repo

Dan McGee wrote:
> On Fri, May 9, 2008 at 8:29 PM, Allan McRae <mcrae_allan@hotmail.com> wrote:
>
>> Xavier wrote:
>>
>>> and bask in the glory and speed of perl
>>>
>>>
>> Oooo, I am, I am!
>>
> And while we are on the perl bus:
> http://code.toofishes.net/gitweb.cgi?p=pacman.git;a=commitdiff;h=555e2091725 a255f2e7dbe10c7c17d0830a60e36
>
> 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.
>
>

Here we go:

<code>
+if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
+ print "$progname - List all packages installed from a given repo
";
+ print "Usage: $progname <pattern>
";
+ print "Example: $progname ^gnome
";
</code>

You will want to fix the description there...

Otherwise, I can follow what you are doing there and without
understanding the specific details I don't see any obvious problems.

>> Now I preface this by saying I know next to nothing about perl.... but
>> from what I can tell, this script looks good. Just one query, when
>> adding an item to a hash, does perl not return an indicator about
>> whether a new item was created or not? If so, we can probably combine
>>
> You might be right, but I think it is a bit clearer as is? I don't
> think we are going to get much of a performance gain over 0.1 seconds
> anyway.
>
>
>

Good point. Leave it.

>> 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 vote for paclist because it lists packages, not repos and it fits with
pacsearch and pacnew.





_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 05-10-2008, 12:09 PM
Xavier
 
Default List packages from a given repo

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
", 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);
}
}
}
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 04:39 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org