home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2005 September / NessusLiveCD.iso / KNOPPIX / src_freedom / knoppixFreedom.findsrc < prev    next >
Encoding:
Text File  |  2005-05-10  |  1.8 KB  |  75 lines

  1. #!/bin/bash
  2. # find packages-names sourcefile-names and versions for all installed files
  3. # in the dpkg system of the given Knoppix Env filesystem
  4. #
  5. #
  6. # This script generates output of the form:
  7. #
  8. # [DPKG-NAME] SRCPKG-NAME=VERSION
  9. #
  10. # where DPKG-NAME is the name of the installed debian package for which this
  11. # line of output names the sources.  It is only gioven if the pacage name
  12. # differs from the name of the source-package.  This is allways omitted when
  13. # the -s option is used.
  14. #
  15. # SRCPKG-NAME=VERSION denotes the actual source-package name and version in
  16. # the syntax the apt-get understands.
  17. #
  18. # $Id: knoppixFreedom.findsrc,v 1.3 2005/01/26 08:15:54 wilde Exp $
  19.  
  20. usage() {
  21.     cat >&2 <<EOF 
  22. Usage: $0 [OPTIONS] BASENAME
  23.  
  24. Generate list of source-packages for debian-packages in the Knoppix
  25. Environement Filsystem corresponding to BASENAME.
  26.  
  27.   -s, --sources-only  list only the sourcepackage names, 
  28.                       not the name of the installed package.
  29.   -u, --uniq          print output sorted and every entry only once.
  30.  
  31. EOF
  32. }
  33.  
  34. AWKPRG='/Package/{print line; line = $2 } ;
  35.         /Source/{line = line " " $2} ;
  36.         /Version/{line = line "=" $2}'
  37.  
  38. POSTPROCESS='cat'
  39.  
  40. while [ ! x$1 = x ] ; do
  41.     case $1 in 
  42.     -*)     
  43.         case $1 in
  44.         "-s"|"--sources-only")
  45.             AWKPRG='/Package/{ print line; line = $2 } ;
  46.                             /Source/{ line = $2 } ;
  47.                             /Version/{ line = line "=" $2 }'
  48.             shift
  49.             ;;
  50.         "-u"|"--uniq")
  51.             POSTPROCESS='sort | uniq'
  52.             shift
  53.             ;;
  54.         *)    
  55.             usage
  56.             exit 23
  57.             ;;
  58.         esac
  59.     ;;
  60.     *)    
  61.         BASE="$1"
  62.         shift
  63.     ;;
  64.     esac
  65. done
  66.  
  67. if [ ! x$BASE = x ] ; then
  68.     dpkg-awk -f "$BASE"_env/var/lib/dpkg/status "Status:.*install ok installed*." \
  69.     -- "Package" "Source" "Version" | \
  70.     awk "$AWKPRG" | \
  71.     grep -v '^$' | eval $POSTPROCESS
  72. else
  73.     usage
  74.     exit 23
  75. fi