summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sbin/CopyParFiles.pl93
1 files changed, 84 insertions, 9 deletions
diff --git a/lib/sbin/CopyParFiles.pl b/lib/sbin/CopyParFiles.pl
index 6d4a9251..ca51fc99 100644
--- a/lib/sbin/CopyParFiles.pl
+++ b/lib/sbin/CopyParFiles.pl
@@ -1,6 +1,9 @@
#!/bin/perl -s
#
# Script to copy parameter files
+#
+# Only copies those parameter files that used the compiled thorns
+#
# Version: $Id$
$home = `pwd`;
@@ -10,31 +13,75 @@ $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*)/;
- next if (m:^\#:);
- $thorn=$1;
- print "Thorn $thorn\n";
+ /^(\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>)
{
- if (-e "$home/thornparfiles/$parfile")
+ $gotall = 1;
+ @ActiveThorns = &GetActiveThorns($parfile);
+ $donothave = "";
+ for ($j=0;$j<scalar(@ActiveThorns);$j++)
{
- print " $parfile exists, will not overwrite\n";
+ $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 " Copying $parfile\n";
- system("cp $parfile $home/thornparfiles/$parfile");
+ print " $parfile: Missing thorns ($donothave)\n";
}
}
@@ -42,3 +89,31 @@ while (<THORNLIST>)
}
}
+
+# 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);
+
+}