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

Re: nifty scripts

On Tue, 7 Oct 1997, Jim Pick wrote:

[ some dpkg related scripts ]

Thanks for these scripts.  very useful.  much faster than 'dpkg -S'.

here's a slight improvement for you. wrap the dupdatedb script in a
Makefile, so it only changes the dlocatedb if you've changed any of the
/var/lib/dpkg/info/*.list files (i.e. upgraded, installed, or removed a

---cut here--- /usr/lib/dlocate/Makefile --- cut here ---
#! /usr/bin/make -f

/var/lib/dlocate/dlocatedb: /var/lib/dpkg/info/*.list
---cut here--- /usr/lib/dlocate/Makefile --- cut here ---

note: that's a tab, not a space at start of the dupdatedb line...this
      is a Makefile

> chmod +x these and also create a /var/lib/dlocate dir.  
> I added the following line to my /etc/crontab to update the database 
> nightly:  
> 42 3 * * * root /usr/lib/dlocate/dupdatedb

and the crontab entry becomes:

42 3    * * *   root    make -f /usr/lib/dlocate/Makefile

> I've got a few other quickie scripts that other people might find
> helpful.  Does anyone else have some useful little scripts like this
> that they use all the time but they aren't really big enough to package?

i've written some stuff using sgrep which makes it easy to extract info
from the /var/lib/dpkg/{status,available} or from a Packages file. e.g.
find all packages which depend on another package.

i got macro definitions for dpkg information included in the
/etc/sgreprc which comes with the sgrep package. they make it easy to
write scripts like:

here's an example script which uses the debian sgrep macros.

---cut here --- gamesearch.sh --- cut here ---
#! /bin/sh
# construct a list of non-X games to use as the basis for making a selection
# set for the recently proposed front-end to dselect.
# command line args:
# -v  verbose
# -vv very verbose

# easy to read search list
XLIB_PACKAGES="xlib6 xlib6g elf-x11r6lib"

# convert XLIB_PACKAGES into a format suitable for use with sgrep
          sed -e 's/\([^ ]*\)/"\1" or/g' \
	      -e 's/or"" //g' \
	      -e 's/or$//g'`

if [ "$1" = "-v" ] ; then 
    OUTPUT='Package: \|Depends: \|Recommends: \|Suggests: \|Conflicts: \|^$' ;
    OUTPUT='Package: ' ;

if [ "$1" = "-vv" ] ; then 
    OUTPUT='.*' ;


	sgrep 'DEB_PKG containing (DEB_SECTION containing "games")' | \
    sgrep "DEB_PKG not containing ((DEB_DEPENDS containing ($XLIB)) or (DEB_RECOMMENDS containing ($XLIB)) or (DEB_SUGGESTS containing ($XLIB)))" |\
    grep "$OUTPUT"

---cut here --- gamesearch.sh --- cut here ---

This example produces output like:

$ ./gamesearch
Package: an
Package: bsdgames
Package: filters
Package: fortune-mod
Package: fortunes
Package: gnuchess
Package: gnuchess-book
Package: gnugo
Package: gnushogi
Package: gravitywars
Package: infocom
Package: luxman
Package: mgt
Package: tf
Package: wordplay
Package: xblast-sound
Package: xconq-doc

I've also written a script called dpkg-man which lists all the manpages
assocated with a package.

$ dpkg-man dpkg
8 update-rc.d
8 start-stop-daemon
8 update-alternatives
8 install-info
8 dselect
8 dpkg
8 dpkg-split
1 md5sum
1 dpkg-deb

you can use it like so:  "man `dpkg-man dpkg`" to view all of dpkg's man

---cut here--- /usr/local/bin/dpkg-man --- cut here ---
#! /bin/sh

# lists all the man pages contained within installed debian packages.

# usage:
#        dpkg-man <package>...

for i in $@ ; do
    dpkg -L $i | \
      sed -n -e 's/\.gz$//' \
             -e '/man.*\/.*[0-9]/s/^.*\/\([^\/]*\)\.\(.*\)/\2 \1/p'
---cut here--- /usr/local/bin/dpkg-man --- cut here ---

both of these scripts are public domain.

craig sanders
networking consultant                  Available for casual or contract
temporary autonomous zone              system administration tasks.

Reply to: