aubrey@rpp386.cactus.org (Aubrey McIntosh) (03/05/90)
I wrote a simple shell script to read the various <directory>.crc files, extract the file names, and echo the crc of the current file, along with the correct value from the crc file, to an audit file. All the shelling, calling basename, crc, etc, makes it pretty slow. What do other people do to compare them. Surely we're not all typing a dozen commands per file... I would be glad to post what I have done, but you'd be pretty desperate to use it. -- Aubrey McIntosh "Find hungry samurai." -- The Old Man 1502 Devon Circle comp.os.minix, comp.lang.modula2 Austin, TX 78723 1-(512)-452-1540 (v)
williams@umaxc.weeg.uiowa.edu (Kent Williams) (03/05/90)
>I wrote a simple shell script to read the various <directory>.crc >files, extract the file names, and echo the crc of the current file, >along with the correct value from the crc file, to an audit file. > The following is what I used, and it didn't seem that slow (slow compared to what, after all?). It massages the 'official' crc file so that it looks like what you'd see if you ran crc in the current working directory. Then it runs crc over the current directory, and compares the two. You will always see a few differences -- figuring out which ones matter are left as an excersize to the reader. A 'perfect' run (for the mm directory, zum bespiel) would print out < 012345 2222 mm.crc < 543210 3333 mm.crc.tmp or something to that effect. --------------------------cmpcrc---------------------------------------- # find out the crc file name for the current directory. f=`pwd` f=`basename $f`.crc # temporary version of <cwd>.crc o=${f}.tmp # name of the local version. l=${f}.local # strip of the extra path gunk from the crc file, so it can be compared # to a local copy. sed 's/\/head.*\///' $f > $o # get a local crc list crc * > $l # compare local and 'official' crc's diff $o $l # clean up rm $o $l -- Kent Williams "We're One! All One! Exceptions Eternally? williams@umaxc.weeg.uiowa.edu None! Absolutely None!" - Dr. Bronner's Soap
paula@bcsaic.UUCP (Paul Allen) (03/06/90)
In article <18091@rpp386.cactus.org> aubrey@rpp386.UUCP (Aubrey McIntosh) writes: >I wrote a simple shell script to read the various <directory>.crc >files, extract the file names, and echo the crc of the current file, >along with the correct value from the crc file, to an audit file. > >All the shelling, calling basename, crc, etc, makes it pretty slow. > >What do other people do to compare them. Surely we're not all typing >a dozen commands per file... I imagine there are lots of solutions to this one out there. Here's what I do: I run a modified version of a script someone posted some time ago. It runs in the root directory of the minix sources hierarchy (i.e. the directory that contains 'src' and 'include'). It expects a crc list on stdin that has relative pathnames from the current directory. Since the crc's that Andy sends out generally have absolute paths that are specific to his Sun, there's always some hand-editing that needs to be done for each new release. Now, 1.5.3 has the crc's in the individual directories, so I just cat'ed them all together and editted the paths. This way, once I've got the crc list squared away, I can check the entire tree with one command. It would be nice if Andy would generate the crc listings to be compatible with my script, but I suppose he's got a good reason for doing it the way he does. The output of my script is a list of the files that either don't match or don't exist. I used to have a script that went through the tree looking for files that weren't in the crc list, but I can't find it now. :-) Paul Allen -- ------------------------------------------------------------------------ Paul L. Allen | pallen@atc.boeing.com Boeing Advanced Technology Center | ...!uw-beaver!bcsaic!pallen
al@escom.com (Al Donaldson) (03/08/90)
In article <21216@bcsaic.UUCP>, paula@bcsaic.UUCP (Paul Allen) writes: > In article <18091@rpp386.cactus.org> aubrey@rpp386.UUCP (Aubrey McIntosh) writes: > >What do other people do to compare them. Surely we're not all typing > >a dozen commands per file... > the crc's that Andy sends out generally have absolute paths that are > specific to his Sun, there's always some hand-editing that needs to > be done for each new release. As part of the unshar'ing, patching, and checking process, I run Andy's *.crc file through sed to pull out the absolute path, and then I save it in a file CRC.155 (for example) to indicate the release number: cat *.crc | sed 's:/home.*/::' > CRC.155 crc * > CRC diff CRC CRC.155 I find that associating the name of the CRC file with the release version is a handy way for me to keep track of what release I'm working with (for example, 153 FS and MM with 152 kernel..), and especially so if I have multiple versions of MINIX on my machine. The above is part of a csh-script I wrote on my Sun to do the unshar'ing, patching, and checking for one directory. I didn't post the whole script because it's for csh, it's ugly, it's damn ugly, and it doesn't handle unexpected conditions very well. But the fragment above handles the CRC checking very nicely -- wish I'd thought of it back at 1.4.n. :-) Al
evans@ditsyda.oz (Bruce Evans) (03/08/90)
I use the following programs (from old postings). 'checkcrc' in particular is very useful for comparing with the official CRC lists. Unfortunately the latter have some directory names (like include) inconsistent with the normal layout, and must be edited a little. The author warns that the method of 'system("crc ...")' is slow. I find it surprisingly fast given a decent sized cache (320K). Putting the shell and crc on a RAM disk should achieve similar benefits. It is fairly easy to change the system() to fork() + exec() so only crc needs to be reloaded every time, so a 50K cache might do. Or checkcrc could be merged with crc. 51458 2385 checkcrc.c 31800 217 listcrc #! /bin/sh # Contents: checkcrc.c listcrc # Wrapped by src@besplex on Thu Mar 8 07:43:50 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'checkcrc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'checkcrc.c'\" else echo shar: Extracting \"'checkcrc.c'\" \(2385 characters\) sed "s/^X//" >'checkcrc.c' <<'END_OF_FILE' X/* X * Check_crc.c -- Check the current file system against a CRC list X * Version 1.00 27 April 1989 X * X * Usage: X * check_crc [directory] <script >differences X * X * The report lists the file name, along with the official and obtained X * crcs and counts. The obtained values are printed in parenthesis. X * file crc 123 (44), count 33 (23) X * X * There are undoubtably better ways of doing this. Perhaps using the X * shell or AWK. I did it this way anyway. X * X * This program is Public Domain. Do what you want with it. X * X * Dave Regan X * regan@jacobs.cs.orst.edu X * 27 April 1989 X */ X X/* X * Notes: X * X * I tried a version of this which used "popen" instead of a temporary X * file. This wasn't any faster, and somewhat less portable. X */ X X#include <ctype.h> X#include <stdio.h> X#include <stdlib.h> X#include <string.h> X X#define LINESIZE 100 X Xmain(argc, argv) X int argc; X char *argv[]; X { X char cmd[50]; X long cor_count; X long cor_crc; X char *cptr; X long cur_count; X long cur_crc; X FILE *fd; X char *file; X char line[LINESIZE+1]; X char line2[LINESIZE+1]; X X if (argc < 1 || argc > 2) X { X fprintf(stderr, "Usage: check_crc [directory] <script >differences\n"); X exit(1); X } X if (argc == 2) X chdir(argv[1]); X X while (fgets(line, LINESIZE, stdin) != NULL) X { X if ((cptr = strchr(line, '\n')) != NULL) X *cptr = '\0'; X if (line[0] == '\0' || line[0] == '#') X continue; X for (cptr = line; isdigit(*cptr); cptr++) X ; X while (isspace(*cptr)) X cptr++; X while (isdigit(*cptr)) X cptr++; X while (isspace(*cptr)) X cptr++; X file = cptr; X X if (access(file, 0) < 0) X { X printf("%-40sDoes not exist\n", file); X continue; X } X X sprintf(cmd, "crc %s >/tmp/crc%05d", file, getpid()); X system(cmd); X sprintf(cmd, "/tmp/crc%05d", getpid()); X if ((fd = fopen(cmd, "r")) != NULL) X { X fgets(line2, LINESIZE, fd); X fclose(fd); X if ((cptr = strchr(line2, '\n')) != NULL) X *cptr = '\0'; X if (strcmp(line, line2) != 0) X { X sscanf(line, "%ld %ld", &cor_crc, &cor_count); X sscanf(line2, "%ld %ld", &cur_crc, &cur_count); X printf("%-40scrc %ld (%ld), count %ld (%ld)\n", X file, cor_crc, cur_crc, cor_count, cur_count); X } X } X } X sprintf(cmd, "/tmp/crc%05d", getpid()); X unlink(cmd); X } END_OF_FILE if test 2385 -ne `wc -c <'checkcrc.c'`; then echo shar: \"'checkcrc.c'\" unpacked with wrong size! fi # end of 'checkcrc.c' fi if test -f 'listcrc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'listcrc'\" else echo shar: Extracting \"'listcrc'\" \(217 characters\) sed "s/^X//" >'listcrc' <<'END_OF_FILE' X#! /bin/sh X# a shell script to list the crcs of the files in a list of directories, X# recursively including all ordinary files in subdirectories X X( X for i in $* X do X find "$i" -type f -print X done X) | sort | crc - END_OF_FILE if test 217 -ne `wc -c <'listcrc'`; then echo shar: \"'listcrc'\" unpacked with wrong size! fi chmod +x 'listcrc' # end of 'listcrc' fi echo shar: End of shell archive. exit 0 -- Bruce Evans evans@ditsyda.oz.au