[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: mashup "apt-cache search <SearchTerm>" & "dpkg -l" - HowTo? ; jor



Thanks Aaron & Tom - 
That's progress, but not there yet. ;)  
Further suggestion? Thanks :)

On Sat, 26 Jun 2010 19:00:20 -0600, "Aaron Toponce" <aaron.toponce@gmail.com> said:
> On 6/26/2010 6:58 PM, Aaron Toponce wrote:
> > On 6/26/2010 6:55 PM, Aaron Toponce wrote:
> >> On 6/26/2010 5:57 PM, giovanni_re wrote:
> >>> Is there a way to mashup "apt-cache search <SearchTerm>" & "dpkg -l" 
> >>> - so that given a SearchTerm, 
> >>> it would find all the related package names in the cache, 
> >>> then do a "dpkg -l" on those package names?
> >>
> >> dpkg -l $(apt-search iceweasel|grep ^i|awk '{print $2}'|tr '\n' ' ')
> > 
> > Actually, looking at that command, I'm sure I could combine the grep,
> > awk and tr in a single awk command. This was just "quick and dirty". Of
> > course, replace 'iceweasel' with the package(s) you are searching for.
> 
> And, I just noticed I used one of my apt aliases.
> 
> alias apt-search="aptitude search"


: The good result here is that this shows the dpkg -l, which can show uninstalled or failed match packages.
: But it doesn't yet get all the packages.


One key point is that the output should include every package returned by 
"apt-cache search <SearchTerm>"
& show whether or not they are installed.


=====  Example showing the concept, using package "parted":

1)  First, here are all the packages apt-cache returns:

# apt-cache search parted | sort
drobo-utils - manage data robotics storage units (drobos)
fatresize - FAT16/FAT32 filesystem resizer
gnu-fdisk - Linux fdisk replacement based on libparted
gparted - GNOME partition editor
kvpm - LVM frontend for KDE
libparted0debian1-dbg - The GNU Parted disk partitioning library debug development files
libparted0debian1 - The GNU Parted disk partitioning shared library
libparted0-dev - The GNU Parted disk partitioning library development files
libparted0-i18n - The GNU Parted disk partitioning library i18n support
libparted0 - The GNU Parted disk partitioning shared library (old name)
parted-doc - The GNU Parted disk partition resizing program documentation
parted - The GNU Parted disk partition resizing program
partitionmanager - A partition management utility
python-parted-dbg - Python interface for libparted - Debugging symbols
python-parted - Python interface for libparted



2)  But "dpkg -l"  only shows some of them:

dpkg -l | grep parted
ii  gparted                              0.5.1-1ubuntu2                                  GNOME partition editor
ii  libparted0                           2.2-5ubuntu5                                    The GNU Parted disk partitioning shared libr
ii  libparted0debian1                    2.2-5ubuntu5                                    The GNU Parted disk partitioning shared libr
ii  parted                               2.2-5ubuntu5                                    The GNU Parted disk partition resizing progr


{  For reference, here are 2 more dpkg -l searches:

dpkg -l parted
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                               Version                            Description
+++-==================================-==================================-====================================================================================
ii  parted                             2.2-5ubuntu5                       The GNU Parted disk partition resizing program

dpkg -l '*parted*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                               Version                            Description
+++-==================================-==================================-====================================================================================
ii  gparted                            0.5.1-1ubuntu2                     GNOME partition editor
un  libparted                          <none>                             (no description available)
ii  libparted0                         2.2-5ubuntu5                       The GNU Parted disk partitioning shared library (old name)
un  libparted0-dev                     <none>                             (no description available)
un  libparted0-i18n                    <none>                             (no description available)
ii  libparted0debian1                  2.2-5ubuntu5                       The GNU Parted disk partitioning shared library
un  libparted1                         <none>                             (no description available)
un  libparted1.4                       <none>                             (no description available)
un  libparted2                         <none>                             (no description available)
un  nparted                            <none>                             (no description available)
ii  parted                             2.2-5ubuntu5                       The GNU Parted disk partition resizing program
un  parted-doc                         <none>                             (no description available)
un  parted1.6                          <none>                             (no description available)

}


3a)  I'd like to get an output list including all the packages from step 1 above,
3b)  Showing the package name, & its installed status (ii, un, etc) like from step 2.

Note:  One way might be to:
1) Do the apt-cache search <packagename>
2) For each line
2a) Pull out the package name
2b) Write an apt-cache search for that name only to a temp file
3) Do the dpkg -l 's from the file
3b) & remove from the output all the dpkg heading info, leaving only the package status lines.

Can you get that mashup?  Thanks :)



==========   RESULTS SO FAR:  ==========
=====  From tomh0665
# aptitude -F "%c%a %p %v %d" search '?narrow(?installed,parted)'
i  gparted                                                               0.5.1-1ubu GNOME partition editor                                                         
i  libparted0                                                            2.2-5ubunt The GNU Parted disk partitioning shared library (old name)                     
i  libparted0debian1                                                     2.2-5ubunt The GNU Parted disk partitioning shared library                                
i  parted                                                                2.2-5ubunt The GNU Parted disk partition resizing program                                 

:  The good thing here is this shows the package installed status.
:  But it is missing many of the packages shown by "apt-cache search parted", many of which are probably not installed.


=====  From  aaron.toponce
alias apt-search="aptitude search"

# dpkg -l $(apt-search parted |grep ^i|awk '{print $2}'|tr '\n' ' ')
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                               Version                            Description
+++-==================================-==================================-====================================================================================
ii  gparted                            0.5.1-1ubuntu2                     GNOME partition editor
ii  parted                             2.2-5ubuntu5                       The GNU Parted disk partition resizing program
No packages found matching A.
No packages found matching A.


: The good result here is that this shows the dpkg -l, which can show uninstalled or failed match packages.
: But it doesn't yet get all the packages.


==
Aaron & Tom - can you mash this up a little better?  Thanks  :)


Reply to: