SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-02-23 05:58:15

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,990
Website

Quick package information

I use this every day, so someone might possibly find it useful...

aptitude show packagename
works well enough but on an oldish box it can be very slow. apt-cache and dpkg are much faster to show results, but apt-cache doesn't know if the package is installed on your machine or not, and dpkg only knows about stuff that is installed. Putting them together, you can do something like this (edited 2010/3/1):

#!/bin/bash
# get info about packages, installed or not

output=''
for i in "$@"
do
    package=$( dpkg -s $i 2>/dev/null )
    if grep 'Status: install ok installed' > /dev/null <<< "$package" 
    then package="$package
Commands:
$( dpkg -L $i | grep 'bin/' )"
    else package="$i: NOT INSTALLED
"
package="$package$( apt-cache show $i 2>&1 )"
    fi
output="$output$package
--------------------------------------
"
done

if [ -t 1 ]
then
    echo "$output"
else
#   echo "$output" | leafpad /dev/stdin
     leafpad <(echo "$output")
#   conky --config=$HOME/.conkyrc-message --text="$output"
fi

exit

Save this as pkg.sh or something, put it in your ~/bin folder, or, better, link to it from there with a link called "pkg" so it's in your $PATH. Now you can call it with

pkg somepackage someotherpackage

It will do several packages at once. If you call it from a terminal you'll get the results there, if you call it from gmrun for example with alt+F2 (or from some other script?) it will pop up a leafpad window with the results in.

TO DO: it would be nice to have "package search" or something in Leafpad's title bar, if anyone knows how to do that...?

Last edited by johnraff (2010-03-01 06:13:31)


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

Be excellent to each other!

#2 2010-02-24 06:04:16

illumin8
#! Junkie
From: Seattle
Registered: 2009-05-30
Posts: 407
Website

Re: Quick package information

i was so busy playing with this i forgot to tell you what a great little tool this is..
Great for charting dependencies when trying to build from a minimal ubuntu or debian install.


Website    500px     DeviantArt
God never ends anything on a negative; God always ends on a positive. -- Edwin Louis Cole --

Offline

#3 2010-03-01 06:14:37

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,990
Website

Re: Quick package information

Small tweak added to show what commands the package installed. (any files in a "bin" directory)


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo