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