Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / admin / bin / fnrclone
1 #! /bin/sh
2
3 # This shell script runs findnewrcs on a clone tree.
4
5 # Usage
6 DoUsage()
7 {
8         cat << dernier
9 Usage: fnrclone [-OPTIONS] <source> <destination>   
10         where OPTIONS are:
11         [-c (checkout any new versions of files from RCS)]
12         [-s (create a script & log file in $HOME/fnrclone and
13             execute the script)]
14         [-n (leave actual files, not symbolic links)]
15         [-f <logfile name> (create a log file of changes)]
16         [-d (descend symbolically linked directories)]
17         [-S (do not follow symbolic links for files)
18         [-O (do not check out files, Only create symbolic links for existing files)
19         [-C (process SCCS directories[usually they are ignored])
20         [-u Usage message]
21 NOTE: the default is make symbolic links and don't check out newer
22       revisions of files, just shadow the source. If the RCS directory is 
23       accessible, check out any brand new files as real files. If the
24       RCS directory is not accessible (remote exchange), do NOT check out
25       any brand new files.
26 dernier
27 }
28                         
29                 
30 if [ $# -lt 2 ] ; then
31         DoUsage
32         exit 1
33 fi
34
35 DEF_s="L"
36 DEF_X="X"
37 LINKOPT="l"
38 ACTUAL=
39 #Parse the options
40 set -- `getopt csSCOdnuf: $*`
41 while [ $# -gt 0 ]
42 do
43         case $1 in
44                 -n) LINKOPT= ;shift;;
45                 -s) DEF_X=;shift;;
46                 -S) DEF_S=s;shift;;
47                 -c) DEF_s=;shift;;
48                 -C) DEF_C=C;shift;;
49                 -O) DEF_O=O;shift;;
50                 -u) DoUsage;shift;;
51                 -f) LOG=$2;shift 2;;
52                 -d) ACTUAL="${ACTUAL}f";shift;;
53                 --) shift;;
54                 -*) DoUsage;shift;;
55                  *) SRC=$1;DEST=$2;shift 2;;
56         esac
57 done
58
59 OPTS="${DEF_X}${DEF_s}${DEF_S}${DEF_C}${DEF_O}${ACTUAL}${LINKOPT}miA"
60
61 #
62 # get the system from uname -s
63 #
64 SYSTEM=`uname -s`
65 RELEASE=`uname -r`
66 MACHINE=`uname -m`
67
68 Findnewrcs="findnewrcs.${SYSTEM}"
69 if [ "$SYSTEM" = "HP-UX" ];then
70         # 700's
71         M700=`echo $MACHINE | fgrep '/7' 2>/dev/null` 
72         M800=`echo $MACHINE | fgrep '/8' 2>/dev/null`
73         R100=`echo $RELEASE | fgrep '10.' 2>/dev/null` 
74         R90=`echo $RELEASE | fgrep '9.' 2>/dev/null` 
75         R80=`echo $RELEASE | fgrep '8.' 2>/dev/null` 
76         R70=`echo $RELEASE | fgrep '7.' 2>/dev/null` 
77         if [ "$M700" ]; then
78                 if [ "$R100" ];then
79                         Findnewrcs="findnewrcs.700.100"
80                 elif [ "$R80" ];then
81                         Findnewrcs="findnewrcs.700.807"
82                 fi
83         elif [ "$M800" ]; then
84                 if [ "$R100" ];then
85                         Findnewrcs="findnewrcs.800.100"
86                 elif [ "$R90" ];then
87                         Findnewrcs="findnewrcs.800.90"
88                 elif [ "$R80" ];then
89                         Findnewrcs="findnewrcs.800.80"
90                 else
91                         Findnewrcs="findnewrcs.800.70"
92                 fi
93         else
94                 if [ "$R90" ];then
95                         Findnewrcs="findnewrcs.300.90"
96                 elif [ "$R80" ];then
97                         Findnewrcs="findnewrcs.300.80"
98                 fi
99         fi
100 fi
101                         
102 if [ "$SYSTEM" = "SunOS" ];then
103
104   if [ "$MACHINE" = "i86pc" ];then
105     Findnewrcs="findnewrcs.UNIX_SV"
106   elif [ "$MACHINE" = "prep" ];then
107     Findnewrcs="findnewrcs.SunOS_PPC"
108   else
109     Findnewrcs="findnewrcs.SunOS"
110   fi
111
112 fi
113
114 #
115 # make an old style script
116 #
117 FNR_BINDIR=`dirname $0`
118 if [ ! "$DEF_X" ];then
119         DATE=`date +%H%M%S`
120         FNR_DIR=/$HOME/fnrclone
121         [ ! -d $FNR_DIR ] && mkdir $FNR_DIR
122         FNR_SCRIPT=$FNR_DIR/script$DATE
123         FNR_LOG=$FNR_DIR/log$DATE
124         $FNR_BINDIR/$Findnewrcs -S${SRC} -W${DEST} -${OPTS} > $FNR_SCRIPT 2> $FNR_LOG
125         chmod 777 $FNR_SCRIPT
126         chmod 777 $FNR_LOG
127         $FNR_SCRIPT
128         echo "`basename $0`: script is in $FNR_SCRIPT, logfile is $FNR_LOG"
129         if [ "$LOG" ];then
130                 cat $FNR_LOG > $LOG
131                 echo "logfile is also in $LOG"
132         fi
133 else # execute without a script
134         if [ "$LOG" ];then
135                 $FNR_BINDIR/$Findnewrcs -S${SRC} -W${DEST} -${OPTS} 2> $LOG
136         else 
137                 $FNR_BINDIR/$Findnewrcs -S${SRC} -W${DEST} -${OPTS}
138         fi
139 fi
140