blob: ca51fc99368753fe23816f3d79a3f7da72b198f5 (
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
|
#!/bin/perl -s
#
# Script to copy parameter files
#
# Only copies those parameter files that used the compiled thorns
#
# Version: $Id$
$home = `pwd`;
chop($home);
$config = $ARGV[0];
open(THORNLIST,"<configs/$config/ThornList") || die "ThornList not available";
# Create thornparfiles directory if needed
if (! -d "thornparfiles")
{
mkdir("thornparfiles", 0755) || die "Unable to create thornparfiles directory";
}
# Create configuration directory if needed
if (! -d "thornparfiles/$config")
{
mkdir("thornparfiles/$config", 0755) || die "Unable to create thornparfiles/$config directory";
}
# Create an array of compiled thorns
$nthorns = 0;
while (<THORNLIST>)
{
/^(\S*)/;
$line = $1;
next if (m:^\#:);
$thorns[$nthorns] = $line;
$nthorns++;
}
close(THORNLIST);
for ($i=0;$i<$nthorns;$i++)
{
$thorn=$thorns[$i];
$thorn = "arrangements/$thorn/par";
if (-d $thorn)
{
chdir $thorn;
while ($parfile = <*.par>)
{
$gotall = 1;
@ActiveThorns = &GetActiveThorns($parfile);
$donothave = "";
for ($j=0;$j<scalar(@ActiveThorns);$j++)
{
$gotit = 0;
for ($k=0;$k<$nthorns;$k++)
{
$thorns[$k] =~ m:.*/(\w*):;
if ($ActiveThorns[$j] =~ /^$1$/i)
{
$gotit = 1;
}
}
if ($gotit == 0)
{
$donothave .= "$ActiveThorns[$j] ";
$gotall = 0;
}
}
if ($gotall == 1)
{
if (-e "$home/thornparfiles/$config/$parfile")
{
print " $parfile: Exists, no overwrite\n";
}
else
{
print " $parfile: Copying\n";
system("cp $parfile $home/thornparfiles/$config/$parfile");
}
}
else
{
print " $parfile: Missing thorns ($donothave)\n";
}
}
chdir "$home${sep}";
}
}
# Parse the active thorns from a parameter file
sub GetActiveThorns
{
my($parfile) = @_;
my $i;
my @ActiveThorns;
open(PAR,"<$parfile");
while (<PAR>)
{
if ($_ =~ /ActiveThorns\s*=\s*\"(.*)\"/)
{
@ActiveThorns = split(' ',$1);
}
}
close(PAR);
# Get rid of spaces and change to lower case
for ($i=0;$i<scalar(@ActiveThorns);$i++)
{
$ActiveThorns[$i] =~ s/\s*//g;
$ActiveThorns[$i] = lc $ActiveThorns[$i];
}
return sort(@ActiveThorns);
}
|