1 |
#!/usr/bin/perl -w |
2 |
|
3 |
# script for synchronizing your CVS working directory with the CVS JSOC module (new tree) |
4 |
|
5 |
# must run from root of JSOC tree (not necessarily from $JSOCROOT) |
6 |
|
7 |
# run this on each machine to be used. |
8 |
# n02 - for linux_X86_64 machines |
9 |
# n00 - for linux4 machines such as n00, phil, etc. |
10 |
# |
11 |
# n12 formerly used for AMD x86-64 can also be used instead of n02 |
12 |
# lws Itaniam processors no longer supported for JSOC |
13 |
|
14 |
# This just in: |
15 |
# The cvs update "-d" flag will cause files outside of the CVS module |
16 |
# originally checked out to be downloaded. This is bad, because |
17 |
# if a user checks out DRMS, then does a 'cvs update -d .', the |
18 |
# user then has the JSOC-module files in their working directory. |
19 |
# BUT, as long as the "-d" flag is not used, cvs update respects |
20 |
# boundaries of the module originally checked out: so 'cvs checkout DRMS' |
21 |
# followed by 'cvs update DRMS' will not result in any new files being |
22 |
# downloaded that are outside of the DRMS module. But new files |
23 |
# within the DRMS module WILL be downloaded. |
24 |
# |
25 |
# So, this script should use 'cvs update' not 'cvs checkout'. checkout |
26 |
# doesn't know how to remove files from the working directory that |
27 |
# have been deleted from the repository. Since this script uses |
28 |
# 'cvs update', there is no need to look at the 'modulespec.txt' file. |
29 |
# |
30 |
# This just in. If a cvs user adds a new directory to the repository, |
31 |
# then the only way to get that new directory is to use the "-d" flag. |
32 |
# But we can't use the "-d" flag because this causes files outside of the |
33 |
# CVS module to be downloaded. To work around the preposterous lameness of CVS |
34 |
# first call cvs update (no "-d" flag), then call cvs checkout. The first call |
35 |
# will add/remove/update all files that are already in the user's |
36 |
# working directory. The second call will add files WITHIN THE CORRECT CVS |
37 |
# MODULE that the user doesn't have. |
38 |
|
39 |
$LATESTREL = "Ver_LATEST"; |
40 |
$CVSLOG = "cvsupdate.log"; |
41 |
|
42 |
my($aidx) = 0; |
43 |
my($arg); |
44 |
my($pos); |
45 |
my($rev) = ""; |
46 |
my($line); |
47 |
my($cvsmod); |
48 |
|
49 |
while ($arg = shift(@ARGV)) |
50 |
{ |
51 |
if ($arg eq "-R") |
52 |
{ |
53 |
$rev = "-r $LATESTREL"; |
54 |
} |
55 |
elsif (($pos = index($arg, "-l", 0)) == 0) |
56 |
{ |
57 |
$CVSLOG = substr($arg, 2); |
58 |
} |
59 |
|
60 |
$aidx++; |
61 |
} |
62 |
|
63 |
if (-e "suflag.txt") |
64 |
{ |
65 |
$cvsmod = "JSOC"; |
66 |
} |
67 |
else |
68 |
{ |
69 |
$cvsmod = "DRMS"; |
70 |
} |
71 |
|
72 |
# remove old log file |
73 |
if (-e $CVSLOG) |
74 |
{ |
75 |
unlink $CVSLOG; |
76 |
} |
77 |
|
78 |
CallCVS($rev); |
79 |
|
80 |
print "JSOC synchronization finished.\n"; |
81 |
|
82 |
sub CallCVS |
83 |
{ |
84 |
my($rev) = @_; |
85 |
my($updatecmd); |
86 |
my($checkoutcmd); |
87 |
my($date); |
88 |
|
89 |
# The following command updates the files within the user's working directory and |
90 |
# subdirectories - it doesn't add new directories that exist in the repository |
91 |
# but not in the user's working directory. |
92 |
# Can't use the -d flag to the update command, because this will cause CVS to |
93 |
# update (download) files that belong to other modules. Otherwise, the -d |
94 |
# flag will add the new directories that exist in the repository, but not in the |
95 |
# user's working directory. |
96 |
# $updatecmd = "cvs update -AP $rev \."; |
97 |
|
98 |
# The following command WILL add new directories THAT EXIST ONLY IN THE CVS |
99 |
# MODULE OF INTEREST. But of course CVS can't do anything completely right. |
100 |
# Whenever you have CVS modules, CVS will always print out spurious |
101 |
# "cvs checkout: move away <file>; it is in the way" warnings if you |
102 |
# call cvs checkout -AP JSOC, regardless if the above update command |
103 |
# was first issued or not or if performing a fresh checkout. |
104 |
# Curiously, if you remove the -P flag, you won't see these problems. |
105 |
# $checkoutcmd = "cvs checkout -AP $rev $cvsmod"; |
106 |
|
107 |
# But, there may be hope! If you run the checkout command first, without the |
108 |
# -P flag, then run the update flag with the -P flag, the update command |
109 |
# will remove the empty directories downloaded by the checkout command. |
110 |
# So, give this a go: |
111 |
$checkoutcmd = "cvs checkout -A $rev $cvsmod"; |
112 |
$updatecmd = "cvs update -AP $rev \."; |
113 |
|
114 |
#Things that didn't really work: |
115 |
#$updatecmd = "(cd ..; $updatecmd | sed 's/^/STDOUT:/') 2>&1 |"; |
116 |
#$updatecmd = "(cd $parent; $updatecmd) |"; |
117 |
|
118 |
$date = `"date"`; |
119 |
|
120 |
open(CVSLOG, ">>$CVSLOG"); |
121 |
print CVSLOG "$date\n"; |
122 |
print CVSLOG "Calling '$checkoutcmd'.\n"; |
123 |
close(CVSLOG); |
124 |
$checkoutcmd = "(cd ..; $checkoutcmd) 1>>$CVSLOG 2>&1"; |
125 |
print "Calling '$checkoutcmd'.\n"; |
126 |
system($checkoutcmd); |
127 |
|
128 |
open(CVSLOG, ">>$CVSLOG"); |
129 |
print CVSLOG "Calling '$updatecmd'.\n"; |
130 |
close(CVSLOG); |
131 |
$updatecmd = "($updatecmd) 1>>$CVSLOG 2>&1"; |
132 |
print "Calling '$updatecmd'.\n"; |
133 |
system($updatecmd); |
134 |
} |