Source: debian-goodies
Severity: wishlist
Tags: patch

Hi Javier and Axel,

Attached is a tiny tool which I use to find out enhacements of a
given package(s), by default all installed packages. I don't actually
care about the name, so change as you find fit. Please, include it in
debian-goodies if you find it helpful.

To give you an impression:

# ./check-enhancements apt git bzr 

Package <<apt>> could be Enhanced by:
netselect-apt:    Installed: (none)       Candidate: 0.3.ds1-25

Package <<git>> could be Enhanced by:
git-ftp:          Installed: (none)       Candidate: 0.7.4+git20120528-1
git2cl:   Installed: (none)       Candidate: 2.0+git200808271242-1

Package <<bzr>> could be Enhanced by:
bzr-cvsps-import:         Installed: (none)       Candidate:
0.0.1~bzr71-1
bzr-email:        Installed: 0.0.1~bzr57-2        Candidate:
0.0.1~bzr57-2
bzr-explorer:     Installed: (none)       Candidate: 1.3.0~bzr556-1
bzr-fastimport:   Installed: (none)       Candidate: 0.13.0-2
bzr-grep:         Installed: (none)       Candidate: 0.4.0+bzr147-1
bzr-gtk:          Installed: (none)       Candidate: 0.103.0+bzr792-3
bzr-loom:         Installed: (none)       Candidate: 2.2.0-2
bzr-pipeline:     Installed: (none)       Candidate: 1.4-3
bzr-rewrite:      Installed: (none)       Candidate: 0.6.3+bzr256-1
bzr-search:       Installed: (none)       Candidate: 1.7.0~bzr94-1
bzr-stats:        Installed: (none)       Candidate: 0.1.0+bzr48-2
bzr-upload:       Installed: (none)       Candidate: 1.1.0-2
bzr-xmloutput:    Installed: (none)       Candidate: 0.8.8+bzr162-3
loggerhead:       Installed: (none)       Candidate: 1.19~bzr461-1
qbzr:     Installed: (none)       Candidate: 0.22.2-1
wikkid:   Installed: (none)       Candidate: 0.1+bzr69-1
#!/bin/bash

# Copyright (C) 2012 George Danchev <danc...@spnet.net>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

SELF=$(basename "$0")

print_help() {
cat << HLP
 ${SELF} show enhancement(s) of a given package,
 by default of all installed packages.
 Usage:
 ${SELF}
 ${SELF} pkg1 pkgN
HLP
}

pkgs_enhancing_pkg_status() {
    # Figure out package Enhances:'ing installed package
    EN=`grep-dctrl -n -s Package -F Enhances -X "${1}" /var/lib/apt/lists/*Packages`
    case $? in
       0) echo -e "\nPackage <<$1>> could be Enhanced by:" ;;
       1) continue ;;
       *) echo "Error" && exit 1 ;;
    esac
    for e in `echo "${EN}" | sort | uniq | xargs` # now sort and unify
    do
          # Figure out whether those enhancements are installed
	  apt-cache policy ${e} | head -3 | paste -s
    done
}

# main
case $1 in
  
  -h|-help|--help) print_help && exit 0
    ;;

  "") # Get all installed packages
    for installed in `grep-status -FStatus "install ok installed" -n -s Package | sort | uniq | xargs`
    do
       pkgs_enhancing_pkg_status $installed
    done
    ;;

   *) # Process packages given on cmdline
    for arg in $@
    do 
      pkgs_enhancing_pkg_status $arg
    done
    ;;

esac

Reply via email to