home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- # find packages-names sourcefile-names and versions for all installed files
- # in the dpkg system of the given Knoppix Env filesystem
- #
- #
- # This script generates output of the form:
- #
- # [DPKG-NAME] SRCPKG-NAME=VERSION
- #
- # where DPKG-NAME is the name of the installed debian package for which this
- # line of output names the sources. It is only gioven if the pacage name
- # differs from the name of the source-package. This is allways omitted when
- # the -s option is used.
- #
- # SRCPKG-NAME=VERSION denotes the actual source-package name and version in
- # the syntax the apt-get understands.
- #
- # $Id: knoppixFreedom.findsrc,v 1.3 2005/01/26 08:15:54 wilde Exp $
-
- usage() {
- cat >&2 <<EOF
- Usage: $0 [OPTIONS] BASENAME
-
- Generate list of source-packages for debian-packages in the Knoppix
- Environement Filsystem corresponding to BASENAME.
-
- -s, --sources-only list only the sourcepackage names,
- not the name of the installed package.
- -u, --uniq print output sorted and every entry only once.
-
- EOF
- }
-
- AWKPRG='/Package/{print line; line = $2 } ;
- /Source/{line = line " " $2} ;
- /Version/{line = line "=" $2}'
-
- POSTPROCESS='cat'
-
- while [ ! x$1 = x ] ; do
- case $1 in
- -*)
- case $1 in
- "-s"|"--sources-only")
- AWKPRG='/Package/{ print line; line = $2 } ;
- /Source/{ line = $2 } ;
- /Version/{ line = line "=" $2 }'
- shift
- ;;
- "-u"|"--uniq")
- POSTPROCESS='sort | uniq'
- shift
- ;;
- *)
- usage
- exit 23
- ;;
- esac
- ;;
- *)
- BASE="$1"
- shift
- ;;
- esac
- done
-
- if [ ! x$BASE = x ] ; then
- dpkg-awk -f "$BASE"_env/var/lib/dpkg/status "Status:.*install ok installed*." \
- -- "Package" "Source" "Version" | \
- awk "$AWKPRG" | \
- grep -v '^$' | eval $POSTPROCESS
- else
- usage
- exit 23
- fi