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

Re: Which installed pkg belongs to which release?



On Fri, 2003-04-25 at 04:58, Thomas Gebhardt wrote:
> Hi,
> 
> starting from a "clean" installation, after applying security patches,
> and installing "unofficial" .debs, backports and self-compiled packages,
> the set of installed packages can get rather messy.
> 
> Is there an easy and recommended way to scan the list of installed
> packages against an apt-get source.list and get a comprehensive
> list of all installed packages, each assigned to (at least) an
> apt-get source or marked as "unavailable"?
> 

This seemed like an interesting exercise, so here you go, the output
should be suitable for import into your favorite spreadsheet :-)

(sorry for the attachment, evolution wanted to do strange things to the
spaces)

COLUMN DESCRIPTION:
1: Package name
2: Installed version
3: Candidate version or CURRENT if current
4: if current, source of current version, if not current, source of
candidate, or unknown if no source is found

Hope that helps you,

-Mark
#!/bin/sh

for i in `dpkg --get-selections | grep "install$" | awk '{print $1}'`
do
    Installed=`apt-cache policy $i | grep "Installed:" | sed 's/.*Installed: //'`
    echo -ne $i \\t $Installed
    Candidate=`apt-cache policy $i | grep "Candidate:" | sed 's/.*Candidate: //'`
    if [ "$Installed" = "$Candidate" ]
    then
        echo -en \\tCURRENT
        SOURCE=`apt-cache policy $i | egrep -v '(Installed|Candidate)' | grep $Installed -A 5 | egrep 'Packages$' | head -n1`
        if [ -z "$SOURCE" ] 
        then
            echo -en \\tUNKNOWN
        else
            echo -en \\t`echo $SOURCE | awk '{print $3}'`
        fi
    else 
        echo -en \\t$Candidate
        SOURCE=`apt-cache policy $i | egrep -v '(Installed|Candidate)' | grep $Candidate -A 5 | egrep 'Packages$' | head -n1`
        if [ -z "$SOURCE" ]
        then 
            echo -en \\tUNKNOWN
        else 
            echo -en \\t`echo $SOURCE | awk '{print $3}'`
        fi
    fi
    echo
done

Reply to: