summaryrefslogtreecommitdiff
path: root/lib/sbin/checkout.pl
blob: d271715d2bf5cc9f09703ff5414611c19031b62f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# /usr/bin/perl -s

$sbin_dir = "lib/sbin";

require "$sbin_dir/MakeUtils.pl";

print "\n";

print "Type \"help\" at any prompt for a description on how\nto use this script\n\n";

print "Developmental thorns/arrangements are labelled (dev)\n\n";

print "________________________________________________________________________\n\n";

print "Checkout applications, arrangements or thorns? [arrangements] : ";
    
$which = <STDIN>;

if ($which =~ /^h/i)
{
    &print_help();
}
elsif ($which =~ /^t/i)
{
    &get_thorns();
}
elsif ($which =~ /^ap/i)
{
    &get_applications();
}
else
{ 
    &get_arrangements();
}

print "\nQuit or checkout more applications, arrangements or thorns [quit] : ";
$dowhat = <STDIN>;
if ($dowhat !~ /^[tpah]/i )
{
    print "All done!\n";
    exit;
}

$doit = 1;
while ()
{
    if ($dowhat =~ /^h/i)
    {
	&print_help();
    }
    elsif ($dowhat =~ /^t/i)
    {
	&get_thorns();
    }
    elsif ($dowhat =~ /^ap/i)
    {
	&get_applications();
    }
    else
    { 
	&get_arrangements();
    }

    print "\nQuit or checkout more applications, arrangements or thorns [quit] : ";

    $dowhat = <STDIN>;
    if ($dowhat !~ /^[thpa]/)
    {
	print "All done!\n";
	exit;
    }    
}

sub get_arrangements
{   
    local(%info);
    local($arrangement);
    print "\nYou already have arrangements: \n\n";

    %info = &buildthorns("arrangements/","arrangements");
    
    foreach $arrangement (sort keys %info)
    {
      print "$arrangement\n";
    }

    print "\nAvailable arrangements: \n";

    open(MODULES,"cvs co -s | ");
    
    $count = 0;
    while(<MODULES>)
    {
	if (/(\w*)\s*ARRANGEMENT(.*)?/)
	{
	  $count++;
	  $name{$count} = "$1";
	  $devlev{$count} = "$2";
	}
    }
    
    
    for ($i=1; $i<$count+1;$i++)
    {
        $extra = "";
        if ($devlev{$i} == 2) 
	{
	  $extra = "(dev)";
	}
	print "  [$i] $name{$i} $extra\n";
    }
    
    print "\n";
    
    print "Checkout arrangements [1-$count] : ";
    
    # Goto target arrangement directory 
    chdir arrangements || die "Could not find arrangements directory";

    $range = <STDIN>;
    if ($range =~ /^h/i)
    {
	&print_help();
    }
    elsif ($range =~ /^\s*$/)
    {
	$range = "1-$count";
    }

    while ($range =~/^([0-9]+(?:-[0-9]+)?),?/)
    {
	$range = $';
	$1 =~ /^([0-9]*)(-[0-9]*)?$/;
	$first = $1;
	if (!$2) 
	{$last=$1}
	else
        {$2=~/-([0-9]*)/; $last=$1}

	for ($i=$first; $i<$last+1; $i++)
	{
	    system("cvs -q checkout $name{$i}");
	}	
    }

    chdir("..") || die "Could not go back to Cactus home directory\n";

}



sub get_thorns
{
    local(%info);
    local($thorn);

    print "\nYou already have thorns: \n\n";
    
    %info = &buildthorns("arrangements/","thorns");
    
    foreach $thorn (sort keys %info)
    {
      print "$thorn\n";
    }

    print "\nAvailable thorns: \n";

    open(MODULES,"cvs -q co -s | ");
    
    $count = 0;
    while(<MODULES>)
    {
	if (/(\w*\/?\w*)\s*THORN([^\s])\s/)
	{
	    $count++;
	    $name{$count} = "$1";
	    $devlev{$count} = "$2";
	}
    }


    for ($i=1; $i<$count+1;$i++)
    {
        $extra = "";
        if ($devlev{$i} == "2") 
	{
	  $extra = "(dev)";
	}
	print "  [$i] $name{$i} $extra\n";
    }
    
    print "\n";
    
    print "Checkout thorns [1-$count] : ";
    
    # Goto target arrangement directory 
    chdir arrangements || die "Could not find arrangements directory\n";

    $range = <STDIN>;
    if ($range =~ /^h/i)
    {
	&print_help();
    }
    elsif ($range =~ /^\s*$/)
    {
	$range = "1-$count";
    }

    while ($range =~/^([0-9]+(?:-[0-9]+)?),?/)
    {
	$range = $';
	$1 =~ /^([0-9]*)(-[0-9]*)?$/;
	$first = $1;
	if (!$2) 
	{$last=$1}
	else
        {$2=~/-([0-9]*)/; $last=$1}
	
	for ($i=$first; $i<$last+1; $i++)
	{
	    system("cvs -q checkout $name{$i}");
	}
    }

    chdir ("..") || die "Could not return to Cactus home directory\n";
}




sub get_applications
{
  print "\nAvailable applications: \n";
  print "  [1] Example F90 wave equation evolver\n";
  print "  [2] Example F77 wave equation evolver\n";
  print "  [3] Example C   wave equation evolver\n";
  print "  [4] Benchmark (ADM)\n";
  print "\n";
    
  # Put number of applications here
  $count = 3;

  print "Checkout applications [1-$count] : ";
    
    # Goto target arrangement directory 
    chdir arrangements || die "Could not find arrangements directory\n";

    $range = <STDIN>;
    if ($range =~ /^h/i)
    {
	&print_help();
    }
    elsif ($range =~ /^\s*$/)
    {
	$range = "1-$count";
    }

    while ($range =~/^([0-9]+(?:-[0-9]+)?),?/)
    {
	$range = $';
	$1 =~ /^([0-9]*)(-[0-9]*)?$/;
	$first = $1;
	if (!$2) 
	{$last=$1}
	else
        {$2=~/-([0-9]*)/; $last=$1}
	
	 
	for ($i=$first; $i<$last+1; $i++)
	{
	  if ($i == 1)
	  {
	    # Checkout F90 WaveToy
	    print("\n");
	    print("Checking out WaveToyF90\n");
	    &CheckOut("CactusWave/WaveToyF90");
	    &CheckOut("CactusWave/IDScalarWave");
	    &CheckOut("CactusBase/Boundary");
	    &CheckOut("CactusBase/CartGrid3D");
	    &CheckOut("CactusBase/IOUtil");
	    &CheckOut("CactusBase/IOBasic");
	    &CheckOut("CactusBase/Time");
	    &CheckOut("CactusPUGHIO/IOASCII");
	    &CheckOut("CactusPUGH/PUGH");
	    print("Completed checkout of application Wave F90\n");
	  }
	  elsif ($i == 2)
	  {
	    # Checkout F77 WaveToy
	    print("\n");
	    print("Checking out WaveToyF77\n");
	    &CheckOut("CactusWave/WaveToyF77");
	    &CheckOut("CactusWave/IDScalarWave");
	    &CheckOut("CactusBase/Boundary");
	    &CheckOut("CactusBase/CartGrid3D");
	    &CheckOut("CactusBase/IOUtil");
	    &CheckOut("CactusBase/IOBasic");
	    &CheckOut("CactusBase/Time");
	    &CheckOut("CactusPUGHIO/IOASCII");
	    &CheckOut("CactusPUGH/PUGH");
	    print("Completed checkout of application Wave F77\n");
	  }	  
	  elsif ($i == 3)
	  {
	    # Checkout C WaveToy
	    print("\n");
	    print("Checking out WaveToyC\n");
	    &CheckOut("CactusWave/WaveToyC");
	    &CheckOut("CactusWave/IDScalarWave");
	    &CheckOut("CactusBase/Boundary");
	    &CheckOut("CactusBase/CartGrid3D");
	    &CheckOut("CactusBase/IOUtil");
	    &CheckOut("CactusBase/IOBasic");
	    &CheckOut("CactusBase/Time");
	    &CheckOut("CactusPUGHIO/IOASCII");
	    &CheckOut("CactusPUGH/PUGH");
	    print("Completed checkout of application Wave C\n");
	  }	  
          elsif ($i == 4)
          {
            # Checkout ADM Benchmark
	    print("\n");
	    print("Checking out ADM\n");
	    system("cvs -q checkout CactusEinstein/ADM");
	    print("Checking out Einstein\n");
	    system("cvs -q checkout CactusEinstein/Einstein");
	    print("Checking out \n");
	    system("cvs -q checkout CactusBase/CartGrid3D");
	    print("Checking out IOUtil\n");
	    system("cvs -q checkout CactusBase/IOUtil");
	    print("Checking out IOASCII\n");
	    system("cvs -q checkout CactusPUGHIO/IOASCII");
	    print("Checking out PUGH\n");
	    system("cvs -q checkout CactusPUGH/PUGH");
	    print("Completed checkout of application Benchmark (ADM)\n");
          }
     
	}
    }

    chdir ("..") || die "Could not return to Cactus home directory\n";
}

sub print_help
{ 

    print "\nTo select arrangements or thorns for checking out from CVS, give\n";
    print "a comma separated list with the numbers of the thorns/arrangements.\n";
    print "Ranges can also be given, using a hyphen.\n";
    print "For example, to checkout thorns/arrangements 1,2,4,6,7,9 use:\n\n";
    print "   1-2,4,6-7,9\n\n";
}

sub CheckOut
{
  local($file) = @_;

  print("Checking out $file\n");
  system("cvs -z9 -q checkout $file");
}