home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # test-db-files
- # copyleft (c) 2000, joseph cheek, joseph@cheek.com. released under GPL.
- #
- # test-db-files:
- # test the validity of the files $BUILDROOT/col/data/{pkgs|meta}.db. a
- # real script would build these files instead of testing them, but i
- # expect little in these files will change and i don't want to put the
- # effort into building them. this script will instead just tell you when
- # you updated an RPM and forgot to change these files, or when their
- # contents just don't jive.
- #
- # $1 = RPMDIR
- # $2 = pkgs.db pathlist
- # $3 = meta.db pathlist
- #
- # ex: ./test-db-files ../../../../col24_gold/col/install/RPMS/ ../pkgs.db \
- # ../meta.db
- #
- # these files contain a list of packages and package groups for selection
- # during a lisa install.
- #
- # each time the RPM list changes, this file needs to be checked. in
- # practice it should be checked for each build IMHO.
-
- # the pkgs.db file format is as follows [educated guess]:
- #
- # GROUP:NAME:n:DRO:INST_SIZE:CAT:RPM_SIZE:VER:: [note 2 trailing colons]
- #
- # where:
- #
- # GROUP = low-level group name, ie TEXTTOOL or SHELL or REC
- # NAME = name of the RPM, ie DEV, SysVinit, XFree86-3DLabs
- # n = dunno. always n.
- # DRO = not sure. Default, Recommended, Optional?
- # INST_SIZE = size of package once installed. from rpm.
- # CAT = one of eleven different [arbitrary?] categories.
- # currently used are:
- # basis1 = basic stuff, needs to be installed
- # develop1 = development stuff
- # doku1 = documentation stuff
- # misc1 = misc stuff
- # network1 = network stuff
- # tex1 = tex packages, not sure why it's separate
- # text1 = text processing stuff
- # xappl1 = X apps
- # xbasis1 = basic X stuff
- # xdevelo1 = X development stuff
- # xemacs1 = X [lucid?] emacs stuff, not sure why separate
- # RPM_SIZE = the size of the [uninstalled] rpm package.
- # VER = version and revision of the package, ie 3.3.6-3
- #
- # the meta.db file format is as follows [educated guess]:
- #
- # :HIGHGROUP:GROUP: [note leading colon]
- #
- # where:
- #
- # HIGHGROUP = high-level group name, ie MAIN or TEXT or X or NET
- # GROUP = low-level group name from pkgs.db, ie TEXTTOOL or SHELL or REC
-
- # pkgs.db tests:
- #
- # TEST 1: make sure each GROUP is listed in meta.db
- # TEST 2: make sure each NAMEd rpm exists in the RPM dir
- # TEST 3: make sure each rpm in the RPM dir exists as a NAME
-
- if [ "$#" != "3" ]; then
- echo -e `basename $0`: need 3 parameters\\a
- exit 1
- fi
-
- TMPFILE=/tmp/`basename $0`.$$
-
- # TEST 1: make sure each pkgs.db GROUP is listed in meta.db
- echo TEST 1: make sure each pkgs.db GROUP is listed in meta.db
-
- for a in `cut -d : -f 1 "$2" | sort | uniq`
- do
-
- grep :$a:$ "$3" > /dev/null
- if [ "$?" = "1" ]; then
- echo -e $a is not listed in $3\\a
- TEST_FAIL=1
- fi
-
- done
-
- # TEST 2: make sure each pkgs.db NAMEd rpm exists in the RPM dir
- echo TEST 2: make sure each pkgs.db NAMEd rpm exists in the RPM dir
-
- # extract RPM names and versions
- ( while read a
- do
-
- RPM_NAME=`echo $a | cut -d : -f 2`
- RPM_VERS=`echo $a | cut -d : -f 8`
-
- if [ ! -e "$1/$RPM_NAME-$RPM_VERS.i386.rpm" -a \
- ! -e "$1/$RPM_NAME-$RPM_VERS.i486.rpm" -a \
- ! -e "$1/$RPM_NAME-$RPM_VERS.i586.rpm" -a \
- ! -e "$1/$RPM_NAME-$RPM_VERS.noarch.rpm" ]
- then
- echo -e RPM $RPM_NAME-$RPM_VERS does not exist\\a
- TEST_FAIL=1
- fi
-
- done ) < "$2"
-
- # TEST 3: make sure each rpm in the RPM dir exists as a pkgs.db NAME
- echo TEST 3: make sure each rpm in the RPM dir exists as a pkgs.db NAME
-
- # generate list of rpm names
-
- for a in "$1"/*.rpm
- do
-
- RPM_NAME=`rpmextr --tag=name "$a"`
- RPM_VERS=`rpmextr --tag=version "$a"`-`rpmextr --tag=release "$a"`
-
- grep ":$RPM_NAME:.*:$RPM_VERS:" "$2" > /dev/null
- if [ "$?" = "1" ]
- then
- echo -e RPM $RPM_NAME-$RPM_VERS [from file $a] does not exist in pkgs.db\\a
- TEST_FAIL=1
- fi
-
- done
-
- if [ "$TEST_FAIL" = "1" ]
- then
- exit 1
- fi
-