1*a7c91847Schristos#! /bin/sh 2*a7c91847Schristos# 3*a7c91847Schristos# Copyright (C) 1995-2005 The Free Software Foundation, Inc. 4*a7c91847Schristos# 5*a7c91847Schristos# This program is free software; you can redistribute it and/or modify 6*a7c91847Schristos# it under the terms of the GNU General Public License as published by 7*a7c91847Schristos# the Free Software Foundation; either version 2, or (at your option) 8*a7c91847Schristos# any later version. 9*a7c91847Schristos# 10*a7c91847Schristos# This program is distributed in the hope that it will be useful, 11*a7c91847Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 12*a7c91847Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*a7c91847Schristos# GNU General Public License for more details. 14*a7c91847Schristos# 15*a7c91847Schristos 16*a7c91847Schristos############################################################ 17*a7c91847Schristos# Error checking 18*a7c91847Schristos# 19*a7c91847Schristosif [ ! -d SCCS ] ; then 20*a7c91847Schristos mkdir SCCS 21*a7c91847Schristosfi 22*a7c91847Schristos 23*a7c91847Schristoslogfile=/tmp/rcs2sccs_$$_log 24*a7c91847Schristosrm -f $logfile 25*a7c91847Schristostmpfile=/tmp/rcs2sccs_$$_tmp 26*a7c91847Schristosrm -f $tmpfile 27*a7c91847Schristosemptyfile=/tmp/rcs2sccs_$$_empty 28*a7c91847Schristosecho -n "" > $emptyfile 29*a7c91847Schristosinitialfile=/tmp/rcs2sccs_$$_init 30*a7c91847Schristosecho "Initial revision" > $initialfile 31*a7c91847Schristossedfile=/tmp/rcs2sccs_$$_sed 32*a7c91847Schristosrm -f $sedfile 33*a7c91847Schristosrevfile=/tmp/rcs2sccs_$$_rev 34*a7c91847Schristosrm -f $revfile 35*a7c91847Schristoscommentfile=/tmp/rcs2sccs_$$_comment 36*a7c91847Schristosrm -f $commentfile 37*a7c91847Schristos 38*a7c91847Schristos# create the sed script 39*a7c91847Schristoscat > $sedfile << EOF 40*a7c91847Schristoss,;Id;,%Z%%M% %I% %E%,g 41*a7c91847Schristoss,;SunId;,%Z%%M% %I% %E%,g 42*a7c91847Schristoss,;RCSfile;,%M%,g 43*a7c91847Schristoss,;Revision;,%I%,g 44*a7c91847Schristoss,;Date;,%E%,g 45*a7c91847Schristoss,;Id:.*;,%Z%%M% %I% %E%,g 46*a7c91847Schristoss,;SunId:.*;,%Z%%M% %I% %E%,g 47*a7c91847Schristoss,;RCSfile:.*;,%M%,g 48*a7c91847Schristoss,;Revision:.*;,%I%,g 49*a7c91847Schristoss,;Date:.*;,%E%,g 50*a7c91847SchristosEOF 51*a7c91847Schristossed -e 's/;/\\$/g' $sedfile > $tmpfile 52*a7c91847Schristoscp $tmpfile $sedfile 53*a7c91847Schristos############################################################ 54*a7c91847Schristos# Loop over every RCS file in RCS dir 55*a7c91847Schristos# 56*a7c91847Schristosif sort -k 1,1 /dev/null 2>/dev/null 57*a7c91847Schristosthen sort_each_field='-k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9' 58*a7c91847Schristoselse sort_each_field='+0 +1 +2 +3 +4 +5 +6 +7 +8' 59*a7c91847Schristosfi 60*a7c91847Schristosfor vfile in *,v; do 61*a7c91847Schristos # get rid of the ",v" at the end of the name 62*a7c91847Schristos file=`echo $vfile | sed -e 's/,v$//'` 63*a7c91847Schristos 64*a7c91847Schristos # work on each rev of that file in ascending order 65*a7c91847Schristos firsttime=1 66*a7c91847Schristos rlog $file | grep "^revision [0-9][0-9]*\." | awk '{print $2}' | sed -e 's/\./ /g' | sort -n -u $sort_each_field | sed -e 's/ /./g' > $revfile 67*a7c91847Schristos for rev in `cat $revfile`; do 68*a7c91847Schristos if [ $? != 0 ]; then 69*a7c91847Schristos echo ERROR - revision 70*a7c91847Schristos exit 71*a7c91847Schristos fi 72*a7c91847Schristos # get file into current dir and get stats 73*a7c91847Schristos date=`rlog -r$rev $file | grep "^date: " | awk '{print $2; exit}' | sed -e 's/^19\|^20//'` 74*a7c91847Schristos time=`rlog -r$rev $file | grep "^date: " | awk '{print $3; exit}' | sed -e 's/;//'` 75*a7c91847Schristos author=`rlog -r$rev $file | grep "^date: " | awk '{print $5; exit}' | sed -e 's/;//'` 76*a7c91847Schristos date="$date $time" 77*a7c91847Schristos echo "" 78*a7c91847Schristos 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 79*a7c91847Schristos echo "==> file $file, rev=$rev, date=$date, author=$author" 80*a7c91847Schristos rm -f $file 81*a7c91847Schristos co -r$rev $file >> $logfile 2>&1 82*a7c91847Schristos if [ $? != 0 ]; then 83*a7c91847Schristos echo ERROR - co 84*a7c91847Schristos exit 85*a7c91847Schristos fi 86*a7c91847Schristos echo checked out of RCS 87*a7c91847Schristos 88*a7c91847Schristos # add SCCS keywords in place of RCS keywords 89*a7c91847Schristos sed -f $sedfile $file > $tmpfile 90*a7c91847Schristos if [ $? != 0 ]; then 91*a7c91847Schristos echo ERROR - sed 92*a7c91847Schristos exit 93*a7c91847Schristos fi 94*a7c91847Schristos echo performed keyword substitutions 95*a7c91847Schristos rm -f $file 96*a7c91847Schristos cp $tmpfile $file 97*a7c91847Schristos 98*a7c91847Schristos # check file into SCCS 99*a7c91847Schristos if [ "$firsttime" = "1" ]; then 100*a7c91847Schristos firsttime=0 101*a7c91847Schristos echo about to do sccs admin 102*a7c91847Schristos echo sccs admin -n -i$file $file < $commentfile 103*a7c91847Schristos sccs admin -n -i$file $file < $commentfile >> $logfile 2>&1 104*a7c91847Schristos if [ $? != 0 ]; then 105*a7c91847Schristos echo ERROR - sccs admin 106*a7c91847Schristos exit 107*a7c91847Schristos fi 108*a7c91847Schristos echo initial rev checked into SCCS 109*a7c91847Schristos else 110*a7c91847Schristos case $rev in 111*a7c91847Schristos *.*.*.*) 112*a7c91847Schristos brev=`echo $rev | sed -e 's/\.[0-9]*$//'` 113*a7c91847Schristos sccs admin -fb $file 2>>$logfile 114*a7c91847Schristos echo sccs get -e -p -r$brev $file 115*a7c91847Schristos sccs get -e -p -r$brev $file >/dev/null 2>>$logfile 116*a7c91847Schristos ;; 117*a7c91847Schristos *) 118*a7c91847Schristos echo sccs get -e -p $file 119*a7c91847Schristos sccs get -e -p $file >/dev/null 2>> $logfile 120*a7c91847Schristos ;; 121*a7c91847Schristos esac 122*a7c91847Schristos if [ $? != 0 ]; then 123*a7c91847Schristos echo ERROR - sccs get 124*a7c91847Schristos exit 125*a7c91847Schristos fi 126*a7c91847Schristos sccs delta $file < $commentfile >> $logfile 2>&1 127*a7c91847Schristos if [ $? != 0 ]; then 128*a7c91847Schristos echo ERROR - sccs delta -r$rev $file 129*a7c91847Schristos exit 130*a7c91847Schristos fi 131*a7c91847Schristos echo checked into SCCS 132*a7c91847Schristos fi 133*a7c91847Schristos sed -e "s;^d D $rev ../../.. ..:..:.. [^ ][^ ]*;d D $rev $date $author;" SCCS/s.$file > $tmpfile 134*a7c91847Schristos rm -f SCCS/s.$file 135*a7c91847Schristos cp $tmpfile SCCS/s.$file 136*a7c91847Schristos chmod 444 SCCS/s.$file 137*a7c91847Schristos sccs admin -z $file 138*a7c91847Schristos if [ $? != 0 ]; then 139*a7c91847Schristos echo ERROR - sccs admin -z 140*a7c91847Schristos exit 141*a7c91847Schristos fi 142*a7c91847Schristos done 143*a7c91847Schristos rm -f $file 144*a7c91847Schristosdone 145*a7c91847Schristos 146*a7c91847Schristos 147*a7c91847Schristos############################################################ 148*a7c91847Schristos# Clean up 149*a7c91847Schristos# 150*a7c91847Schristosecho cleaning up... 151*a7c91847Schristosrm -f $tmpfile $emptyfile $initialfile $sedfile $commentfile 152*a7c91847Schristosecho =================================================== 153*a7c91847Schristosecho " Conversion Completed Successfully" 154*a7c91847Schristosecho =================================================== 155*a7c91847Schristos 156*a7c91847Schristosrm -f *,v 157