Subject: Re: CVS & import scripts
To: VaX#n8 <vax@ccwf.cc.utexas.edu>
From: Simon J. Gerraty <sjg@zen.void.oz.au>
List: current-users
Date: 06/17/1995 20:01:12
> Can anyone send me or post their scripts which import/commit CVS stuff
> after a sup. I'd like to make local changes that propogate, with minimal
> effort.
To repay Chris for helping me get cvs cooking nicely for this very
purpose (my own experiments with import a few years ago produced
confusing results - but that was me miss-reading the docs), I wrote up
a quick little example of what I now use. I'll append it below in the
hope that others find it useful...
I'll append the scripts I use, but be warned, they may bite you if you
are careless...
> Also, any CVS wisdom on how to deal with software which uses ./configure?
> Do you commit the source after configuring for the local system, or not?
The main reason I use cvs import is to handle updates from the ``vendor''.
The best way I've found is to import _exactly_ what was shipped. This
means unconfigured. And I put config.h etc in .cvsignore.
If I have to modify configure.in then obviously I commit them :-)
#!/bin/sh
# This is a shell archive.
# remove everything above the "#!/bin/sh" line
# and feed to /bin/sh
# Use -c option to overwrite existing files
#
# Contents:
# README.import
# import.sh
# prune.sh
#
# packed by: <sjg@zen.void.oz.au> on Sat Jun 17 20:00:34 EST 1995
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README.import -a x$1 != x-c ; then
echo shar: Will not over-write existing file \"README.import\"
else
echo shar: Extracting \"README.import\" \(2902 characters\)
sed 's/^X//' >README.import << '!EOF'
XThe following may be of use to others wanting to use CVS to merge
XNetBSD sources with local changes but are not confident that they have
Xinterpreted the documentation accurately.
X
XMuch thanks to Chris Demetriou (cgd) for taking the time to spell out
Xthe steps he used when merging NetBSD sources without which I might
Xnot have taken the plunge myself :-) The following is based on Chris'
Xtips, though of course any errors are mine.
X
XOk. My NetBSD sources are kept in usr.src, if NetBSD is all
Xyou use CVS for you might want to simply call it src.
X
XI unpack tar files and/or sup into a directory /d2/current.
X
XTo import the entire tree I:
X
Xcd /d2/current/src
X
Xcvs import "-I! " -m "from netbsd-current as of 950508" usr.src NetBSD \
XNetBSD-950508 > /tmp/cvs.out 2>&1
X
XWhere:
Xusr.src is the repository where the imported data goes (so set it
X according to your own needs),
XNetBSD is a vendor tag.
XNetBSD-950508 is a release tag (there can be multiple release tags given).
X
XI use "-I! " as otherise some files that you need (like
Xbin/csh/USD.doc/csh.a) will be ignored.. The space after the ! is
Xneeded.
X
XIt takes quite a while. It is a good idea to save the output to a file.
X
XAt the end you may well get a message like:
X
X cvs checkout -jNetBSD:yesterday -jNetBSD usr.src
X
XThis means there were some conflicts between your local sources and
Xthe import. So I do what it says - but not in my working tree.
X
Xcd /d2/tmp
Xcvs checkout -jNetBSD:yesterday -jNetBSD usr.src > /tmp/merge.out 2>&1
X
XYou can then go find all the files with conflicts.
XEither grep '^C' /tmp/merge.out or find usr.src -name '.#*' -print
XGo edit them to resolce the conflicts. This is usually obvious.
X
XWhen happy.
X
Xcd /d2/tmp/usr.src
Xcvs commit -m"merged local changes with NetBSD-950508"
Xcd ..
Xrm -rf usr.src
X
XOk. Now if you are brave you can:
X
Xcd /usr.src (or whereever your working sources are)
Xcvs update
X
XFinally, you should occasionally make sure you remove old files.
X
XI use a script to do this. It does a diff between files on the NetBSD
Xbranch looking for the latest release tag (eg. NetBSD-950508).
XIf cvs diff remports that a file does not have that tag, it is because
Xit was not present in the import (ie removed).
X
XThe command sequence is:
X
Xcvs diff -s -r NetBSD -r NetBSD-950508 > /tmp/prune.out 2>&1
X
X# check that all went well...
Xcat /tmp/prune.out | awk '/Diffing/ { dir=$NF }
X/NetBSD-/ { file=$NF; print dir "/" file }' > /tmp/pruned
X
Xcat /tmp/pruned | xargs cvs tag -d NetBSD
Xcat /tmp/pruned | xargs rm -f
Xcat /tmp/pruned | xargs cvs delete
X
XNote that this is a slow process on a 486DX33! So don't plan on
Xmerging everything very often. Folk who mainly hack the kernel can do
Xsrc/sys more frequently. The sequence is analogous eg.
X
Xcd /d2/current/src/sys
X
Xcvs import "-I! " -m "from netbsd-current as of 950508" usr.src/sys NetBSD \
XNetBSD-950508 > /tmp/cvs.out 2>&1
X
Xetc.
X
XHope this helps.
X
X--sjg
!EOF
if test 2902 -ne `wc -c < README.import`; then
echo shar: \"README.import\" unpacked with wrong size!
fi
fi
if test -f import.sh -a x$1 != x-c ; then
echo shar: Will not over-write existing file \"import.sh\"
else
echo shar: Extracting \"import.sh\" \(290 characters\)
sed 's/^X//' >import.sh << '!EOF'
X:
Xtoday=`date '+%y%m%d'`
X
Xrep=${1:-usr.src}
X
X# -I! doesn't work, it needs a space after the !
Xcvs import "-I! " -m "from netbsd-current as of $today" $rep NetBSD NetBSD-$today
X
X# cd somewhere
X# cvs checkout -jNetBSD:yesterday -jNetBSD usr.src > /tmp/cvs.out 2>&1
X# merge changes and commit
!EOF
if test 290 -ne `wc -c < import.sh`; then
echo shar: \"import.sh\" unpacked with wrong size!
fi
chmod +x import.sh
fi
if test -f prune.sh -a x$1 != x-c ; then
echo shar: Will not over-write existing file \"prune.sh\"
else
echo shar: Extracting \"prune.sh\" \(491 characters\)
sed 's/^X//' >prune.sh << '!EOF'
X:
Xthen=${1:-`date '+%y%m%d'`}
XTF=/tmp/prune.$$
XTF2=/tmp/prune2.$$
X#S=-s
XS=
X
Xcase `echo -n .` in -n*) N=; C="\c";; *) N=-n; C=;; esac
X
Xask () { echo $N "${2:-$1?} "$C; read $1; }
X
Xcvs diff $S -r NetBSD -r NetBSD-$then > $TF 2>&1 || cat $TF >&2
X
Xcat $TF | awk '/Diffing/ { dir=$NF } /NetBSD-/ { file=$NF; print dir "/" file }' > $TF2
X
Xcat $TF2
Xask proceed
Xcase "$proceed" in
X[yY]*)
Xcat $TF2 | xargs cvs tag -d NetBSD
Xcat $TF2 | xargs rm -f
Xcat $TF2 | xargs cvs delete
X;;
Xesac
Xrm -f $TF $TF2
!EOF
if test 491 -ne `wc -c < prune.sh`; then
echo shar: \"prune.sh\" unpacked with wrong size!
fi
chmod +x prune.sh
fi
exit 0