From owner-freebsd-bugs Wed Mar 18 23:10:03 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA04489 for freebsd-bugs-outgoing; Wed, 18 Mar 1998 23:10:03 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA04459; Wed, 18 Mar 1998 23:10:02 -0800 (PST) (envelope-from gnats) Received: from dt050n33.san.rr.com (Studded@dt050n33.san.rr.com [204.210.31.51]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA03269 for ; Wed, 18 Mar 1998 23:02:19 -0800 (PST) (envelope-from dougdougdougdoug@dt050n33.san.rr.com) Received: (from dougdougdougdoug@localhost) by dt050n33.san.rr.com (8.8.8/8.8.8) id HAA17456; Thu, 19 Mar 1998 07:02:16 GMT (envelope-from dougdougdougdoug) Message-Id: <199803190702.HAA17456@dt050n33.san.rr.com> Date: Thu, 19 Mar 1998 07:02:16 GMT From: Studded@dal.net Reply-To: Studded@dal.net To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/6064: Script to update files installed by /usr/src/etc/Makefile Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 6064 >Category: bin >Synopsis: Script to update files installed by /usr/src/etc/Makefile >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Mar 18 23:10:01 PST 1998 >Last-Modified: >Originator: Doug >Organization: AAAG >Release: FreeBSD 2.2.6-BETA-0316 i386 >Environment: All FreeBSD systems >Description: Updating configuration and other files installed by /usr/src/etc/Makefile is currently left up to the user. A script to help automate the procedure has been requested for a long time, so here you go. :) >How-To-Repeat: DNA >Fix: If desired, import the following script. It grew from the example on Nik Clayton's upgrade page, http://www.nothing-going-on.demon.co.uk/FreeBSD/make-world/make-world.html however my approach is slightly different. To start, make a temporary directory somewhere, /var/tmp seems to work well. # mkdir /var/tmp/temproot # cd /usr/src/etc # make DESTDIR=/var/tmp/temproot distrib-dirs distribution # cd /var/tmp/temproot At this point you're ready to run the script. #!/bin/sh # comproot # Compare files in the temproot environment with the currently installed copy. # Studded@dal.net # Last modified 13 March 1998 # Usage: # To compare CVS revision $Id's for files that have them, and compare # diffs for files that don't, type # comproot # in the top level temp root directory. (e.g., /var/tmp/temproot) # # For a strict comparison (diff'ing every pair of files) use # comproot -s # # To use context diff's instead of unified diffs use # comproot [-s] -c PATH=/bin:/usr/bin # If user has a pager defined, use it. If not, use more. if [ "x$PAGER" = "x" ]; then PAGER='more' else echo '' echo "*** You have $PAGER defined as your pager so we'll use that" echo '' sleep 1 fi # Use unified diffs by default. Context diffs give me a headache. :) DIFF_FLAG='-u' opt-err () { echo '' echo 'Usage: comproot [-s] [-c]' echo '' echo 'Options:' echo ' -s strict comparison (diff every pair of files)' echo ' -c use context diff instead of unified diff' echo '' exit 1 } opt-case () { case "$1" in "-s") STRICT=yes ;; "-c") DIFF_FLAG='-c' ;; *) opt-err ;; esac } # Check command line options if [ "x$1" != "x" ]; then opt-case "$1" fi if [ "x$2" != "x" ]; then opt-case "$2" fi if [ "x$3" != "x" ]; then opt-err fi # Using -size +0 avoids uselessly checking the empty log files created # by /usr/src/etc/Makefile and the device entries in ./dev (but does # check the scripts in ./dev, as we'd like). for COMPFILE in `find . -type f -size +0`; do if [ ! -n "$STRICT" ]; then # Compare CVS $Id's first so if the file hasn't been modified # local changes will be ignored. IDFILE1=`grep "[$]Id:" $COMPFILE` IDFILE2=`grep "[$]Id:" ${COMPFILE#.}` # If the files have the same $Id, delete the one in temproot so the # user will have less to wade through if files are left to merge by hand. if [ -n "$IDFILE1" -a "$IDFILE1" = "$IDFILE2" ]; then echo "*** $COMPFILE has the same Id as the installed version, deleting" rm $COMPFILE fi fi # If the file is still here either because the $Id's are different, the # file doesn't have an $Id, or we're using 'STRICT' mode; look at the diff. if [ -f "$COMPFILE" ]; then # Do an absolute diff first to see if the files are actually different. diff -q "${COMPFILE#.}" "$COMPFILE" # If they're not different, delete the one in temproot. if [ $? -eq 0 ]; then echo "*** $COMPFILE is the same as installed version, deleting" rm "$COMPFILE" else # Ok, the files are different, so show the user where they differ. Use user's # choice of diff methods; and user's pager if they have one. Use more if not. echo '' diff "$DIFF_FLAG" "${COMPFILE#.}" "$COMPFILE" | "$PAGER" echo '' read -p "*** Ok to delete $COMPFILE? (y for yes) [no] " RMORNOT if [ "x$RMORNOT" = "xy" -o "x$RMORNOT" = "xY" ]; then rm "$COMPFILE" echo '' echo " *** Deleting $COMPFILE" echo '' sleep 1 fi fi fi # If the user didn't want to delete the file, give them the option to # install it, or leave it around to merge by hand. if [ -f "$COMPFILE" ]; then echo '' read -p "*** Would you like to install $COMPFILE? (y for yes) [no] " MVORNOT echo '' if [ "x$MVORNOT" = "xy" -o "x$MVORNOT" = "xY" ]; then mv "$COMPFILE" "${COMPFILE#.}" echo " *** Installing $COMPFILE" else echo " *** $COMPFILE will remain for your consideration" fi echo '' sleep 1 fi # This is for the 'do' way up there at the beginning done There are some other functions that could be added to this script like make the directories and install the files for the user, option to keep the diff around, etc. However the script already does all I want so I'm loathe to add more features if it's not going to be seriously considered for inclusion. I will also be posting discussion to -hackers if anyone's interested. I keep the most recent version of the script posted at http://home.san.rr.com/freebsd/comproot. Doug >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message