1#! /bin/sh 2# 3# $Id: rcs-to-cvs.sh,v 1.1.1.1 1995/12/19 09:21:40 deraadt Exp $ 4# Based on the CVS 1.0 checkin csh script. 5# Contributed by Per Cederqvist <ceder@signum.se>. 6# Rewritten in sh by David MacKenzie <djm@cygnus.com>. 7# 8# Copyright (c) 1989, Brian Berliner 9# 10# You may distribute under the terms of the GNU General Public License. 11# 12############################################################################# 13# 14# Check in sources that previously were under RCS or no source control system. 15# 16# The repository is the directory where the sources should be deposited. 17# 18# Traverses the current directory, ensuring that an 19# identical directory structure exists in the repository directory. It 20# then checks the files in in the following manner: 21# 22# 1) If the file doesn't yet exist, check it in as revision 1.1 23# 24# The script also is somewhat verbose in letting the user know what is 25# going on. It prints a diagnostic when it creates a new file, or updates 26# a file that has been modified on the trunk. 27# 28# Bugs: doesn't put the files in branch 1.1.1 29# doesn't put in release and vendor tags 30# 31############################################################################# 32 33usage="Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository" 34vbose=0 35message="" 36message_file=/usr/tmp/checkin.$$ 37got_one=0 38 39if [ $# -lt 1 ]; then 40 echo "$usage" >&2 41 exit 1 42fi 43 44while [ $# -ne 0 ]; do 45 case "$1" in 46 -v) 47 vbose=1 48 ;; 49 -m) 50 shift 51 echo $1 > $message_file 52 got_one=1 53 ;; 54 -f) 55 shift 56 message_file=$1 57 got_one=2 58 ;; 59 *) 60 break 61 esac 62 shift 63done 64 65if [ $# -lt 1 ]; then 66 echo "$usage" >&2 67 exit 1 68fi 69 70repository=$1 71shift 72 73if [ -z "$CVSROOT" ]; then 74 echo "Please the environmental variable CVSROOT to the root" >&2 75 echo " of the tree you wish to update" >&2 76 exit 1 77fi 78 79if [ $got_one -eq 0 ]; then 80 echo "Please Edit this file to contain the RCS log information" >$message_file 81 echo "to be associated with this directory (please remove these lines)">>$message_file 82 ${EDITOR-/usr/ucb/vi} $message_file 83 got_one=1 84fi 85 86# Ya gotta share. 87umask 0 88 89update_dir=${CVSROOT}/${repository} 90[ ! -d ${update_dir} ] && mkdir $update_dir 91 92if [ -d SCCS ]; then 93 echo SCCS files detected! >&2 94 exit 1 95fi 96if [ -d RCS ]; then 97 co RCS/* 98fi 99 100for name in * .[a-zA-Z0-9]* 101do 102 case "$name" in 103 RCS | *~ | \* | .\[a-zA-Z0-9\]\* ) continue ;; 104 esac 105 echo $name 106 if [ $vbose -ne 0 ]; then 107 echo "Updating ${repository}/${name}" 108 fi 109 if [ -d "$name" ]; then 110 if [ ! -d "${update_dir}/${name}" ]; then 111 echo "WARNING: Creating new directory ${repository}/${name}" 112 mkdir "${update_dir}/${name}" 113 if [ $? -ne 0 ]; then 114 echo "ERROR: mkdir failed - aborting" >&2 115 exit 1 116 fi 117 fi 118 cd "$name" 119 if [ $? -ne 0 ]; then 120 echo "ERROR: Couldn\'t cd to $name - aborting" >&2 121 exit 1 122 fi 123 if [ $vbose -ne 0 ]; then 124 $0 -v -f $message_file "${repository}/${name}" 125 else 126 $0 -f $message_file "${repository}/${name}" 127 fi 128 if [ $? -ne 0 ]; then 129 exit 1 130 fi 131 cd .. 132 else # if not directory 133 if [ ! -f "$name" ]; then 134 echo "WARNING: $name is neither a regular file" 135 echo " nor a directory - ignored" 136 continue 137 fi 138 file="${update_dir}/${name},v" 139 comment="" 140 if grep -s '\$Log.*\$' "${name}"; then # If $Log keyword 141 myext=`echo $name | sed 's,.*\.,,'` 142 [ "$myext" = "$name" ] && myext= 143 case "$myext" in 144 c | csh | e | f | h | l | mac | me | mm | ms | p | r | red | s | sh | sl | cl | ml | el | tex | y | ye | yr | "" ) 145 ;; 146 147 * ) 148 echo "For file ${file}:" 149 grep '\$Log.*\$' "${name}" 150 echo -n "Please insert a comment leader for file ${name} > " 151 read comment 152 ;; 153 esac 154 fi 155 if [ ! -f "$file" ]; then # If not exists in repository 156 if [ ! -f "${update_dir}/Attic/${name},v" ]; then 157 echo "WARNING: Creating new file ${repository}/${name}" 158 if [ -f RCS/"${name}",v ]; then 159 echo "MSG: Copying old rcs file." 160 cp RCS/"${name}",v "$file" 161 else 162 if [ -n "${comment}" ]; then 163 rcs -q -i -c"${comment}" -t${message_file} -m'.' "$file" 164 fi 165 ci -q -u1.1 -t${message_file} -m'.' "$file" 166 if [ $? -ne 0 ]; then 167 echo "ERROR: Initial check-in of $file failed - aborting" >&2 168 exit 1 169 fi 170 fi 171 else 172 file="${update_dir}/Attic/${name},v" 173 echo "WARNING: IGNORED: ${repository}/Attic/${name}" 174 continue 175 fi 176 else # File existed 177 echo "ERROR: File exists in repository: Ignored: $file" 178 continue 179 fi 180 fi 181done 182 183[ $got_one -eq 1 ] && rm -f $message_file 184 185exit 0 186