1*c26070a5Stholo#! /bin/sh 2*c26070a5Stholo# 3*c26070a5Stholo# 4*c26070a5Stholo 5*c26070a5Stholo############################################################ 6*c26070a5Stholo# Error checking 7*c26070a5Stholo# 8*c26070a5Stholoif [ ! -d SCCS ] ; then 9*c26070a5Stholo mkdir SCCS 10*c26070a5Stholofi 11*c26070a5Stholo 12*c26070a5Stholologfile=/tmp/rcs2sccs_$$_log 13*c26070a5Stholorm -f $logfile 14*c26070a5Stholotmpfile=/tmp/rcs2sccs_$$_tmp 15*c26070a5Stholorm -f $tmpfile 16*c26070a5Stholoemptyfile=/tmp/rcs2sccs_$$_empty 17*c26070a5Stholoecho -n "" > $emptyfile 18*c26070a5Stholoinitialfile=/tmp/rcs2sccs_$$_init 19*c26070a5Stholoecho "Initial revision" > $initialfile 20*c26070a5Stholosedfile=/tmp/rcs2sccs_$$_sed 21*c26070a5Stholorm -f $sedfile 22*c26070a5Stholorevfile=/tmp/rcs2sccs_$$_rev 23*c26070a5Stholorm -f $revfile 24*c26070a5Stholocommentfile=/tmp/rcs2sccs_$$_comment 25*c26070a5Stholorm -f $commentfile 26*c26070a5Stholo 27*c26070a5Stholo# create the sed script 28*c26070a5Stholocat > $sedfile << EOF 29*c26070a5Stholos,;Id;,%Z%%M% %I% %E%,g 30*c26070a5Stholos,;SunId;,%Z%%M% %I% %E%,g 31*c26070a5Stholos,;RCSfile;,%M%,g 32*c26070a5Stholos,;Revision;,%I%,g 33*c26070a5Stholos,;Date;,%E%,g 34*c26070a5Stholos,;Id:.*;,%Z%%M% %I% %E%,g 35*c26070a5Stholos,;SunId:.*;,%Z%%M% %I% %E%,g 36*c26070a5Stholos,;RCSfile:.*;,%M%,g 37*c26070a5Stholos,;Revision:.*;,%I%,g 38*c26070a5Stholos,;Date:.*;,%E%,g 39*c26070a5StholoEOF 40*c26070a5Stholosed -e 's/;/\\$/g' $sedfile > $tmpfile 41*c26070a5Stholocp $tmpfile $sedfile 42*c26070a5Stholo############################################################ 43*c26070a5Stholo# Loop over every RCS file in RCS dir 44*c26070a5Stholo# 45*c26070a5Stholofor vfile in *,v; do 46*c26070a5Stholo # get rid of the ",v" at the end of the name 47*c26070a5Stholo file=`echo $vfile | sed -e 's/,v$//'` 48*c26070a5Stholo 49*c26070a5Stholo # work on each rev of that file in ascending order 50*c26070a5Stholo firsttime=1 51*c26070a5Stholo rlog $file | grep "^revision [0-9][0-9]*\." | awk '{print $2}' | sed -e 's/\./ /g' | sort -n -u +0 +1 +2 +3 +4 +5 +6 +7 +8 | sed -e 's/ /./g' > $revfile 52*c26070a5Stholo for rev in `cat $revfile`; do 53*c26070a5Stholo if [ $? != 0 ]; then 54*c26070a5Stholo echo ERROR - revision 55*c26070a5Stholo exit 56*c26070a5Stholo fi 57*c26070a5Stholo # get file into current dir and get stats 58*c26070a5Stholo date=`rlog -r$rev $file | grep "^date: " | awk '{print $2; exit}' | sed -e 's/^19//'` 59*c26070a5Stholo time=`rlog -r$rev $file | grep "^date: " | awk '{print $3; exit}' | sed -e 's/;//'` 60*c26070a5Stholo author=`rlog -r$rev $file | grep "^date: " | awk '{print $5; exit}' | sed -e 's/;//'` 61*c26070a5Stholo date="$date $time" 62*c26070a5Stholo echo "" 63*c26070a5Stholo rlog -r$rev $file | sed -e '/^branches: /d' -e '1,/^date: /d' -e '/^===========/d' -e 's/$/\\/' | awk '{if ((total += length($0) + 1) < 510) print $0}' > $commentfile 64*c26070a5Stholo echo "==> file $file, rev=$rev, date=$date, author=$author" 65*c26070a5Stholo rm -f $file 66*c26070a5Stholo co -r$rev $file >> $logfile 2>&1 67*c26070a5Stholo if [ $? != 0 ]; then 68*c26070a5Stholo echo ERROR - co 69*c26070a5Stholo exit 70*c26070a5Stholo fi 71*c26070a5Stholo echo checked out of RCS 72*c26070a5Stholo 73*c26070a5Stholo # add SCCS keywords in place of RCS keywords 74*c26070a5Stholo sed -f $sedfile $file > $tmpfile 75*c26070a5Stholo if [ $? != 0 ]; then 76*c26070a5Stholo echo ERROR - sed 77*c26070a5Stholo exit 78*c26070a5Stholo fi 79*c26070a5Stholo echo performed keyword substitutions 80*c26070a5Stholo rm -f $file 81*c26070a5Stholo cp $tmpfile $file 82*c26070a5Stholo 83*c26070a5Stholo # check file into SCCS 84*c26070a5Stholo if [ "$firsttime" = "1" ]; then 85*c26070a5Stholo firsttime=0 86*c26070a5Stholo echo about to do sccs admin 87*c26070a5Stholo echo sccs admin -n -i$file $file < $commentfile 88*c26070a5Stholo sccs admin -n -i$file $file < $commentfile >> $logfile 2>&1 89*c26070a5Stholo if [ $? != 0 ]; then 90*c26070a5Stholo echo ERROR - sccs admin 91*c26070a5Stholo exit 92*c26070a5Stholo fi 93*c26070a5Stholo echo initial rev checked into SCCS 94*c26070a5Stholo else 95*c26070a5Stholo case $rev in 96*c26070a5Stholo *.*.*.*) 97*c26070a5Stholo brev=`echo $rev | sed -e 's/\.[0-9]*$//'` 98*c26070a5Stholo sccs admin -fb $file 2>>$logfile 99*c26070a5Stholo echo sccs get -e -p -r$brev $file 100*c26070a5Stholo sccs get -e -p -r$brev $file >/dev/null 2>>$logfile 101*c26070a5Stholo ;; 102*c26070a5Stholo *) 103*c26070a5Stholo echo sccs get -e -p $file 104*c26070a5Stholo sccs get -e -p $file >/dev/null 2>> $logfile 105*c26070a5Stholo ;; 106*c26070a5Stholo esac 107*c26070a5Stholo if [ $? != 0 ]; then 108*c26070a5Stholo echo ERROR - sccs get 109*c26070a5Stholo exit 110*c26070a5Stholo fi 111*c26070a5Stholo sccs delta $file < $commentfile >> $logfile 2>&1 112*c26070a5Stholo if [ $? != 0 ]; then 113*c26070a5Stholo echo ERROR - sccs delta -r$rev $file 114*c26070a5Stholo exit 115*c26070a5Stholo fi 116*c26070a5Stholo echo checked into SCCS 117*c26070a5Stholo fi 118*c26070a5Stholo sed -e "s;^d D $rev ../../.. ..:..:.. [^ ][^ ]*;d D $rev $date $author;" SCCS/s.$file > $tmpfile 119*c26070a5Stholo rm -f SCCS/s.$file 120*c26070a5Stholo cp $tmpfile SCCS/s.$file 121*c26070a5Stholo chmod 444 SCCS/s.$file 122*c26070a5Stholo sccs admin -z $file 123*c26070a5Stholo if [ $? != 0 ]; then 124*c26070a5Stholo echo ERROR - sccs admin -z 125*c26070a5Stholo exit 126*c26070a5Stholo fi 127*c26070a5Stholo done 128*c26070a5Stholo rm -f $file 129*c26070a5Stholodone 130*c26070a5Stholo 131*c26070a5Stholo 132*c26070a5Stholo############################################################ 133*c26070a5Stholo# Clean up 134*c26070a5Stholo# 135*c26070a5Stholoecho cleaning up... 136*c26070a5Stholorm -f $tmpfile $emptyfile $initialfile $sedfile $commentfile 137*c26070a5Stholoecho =================================================== 138*c26070a5Stholoecho " Conversion Completed Successfully" 139*c26070a5Stholoecho =================================================== 140*c26070a5Stholo 141*c26070a5Stholorm -f *,v 142