diff options
author | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-11-10 09:16:18 +0000 |
---|---|---|
committer | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-11-10 09:16:18 +0000 |
commit | 05916c33065527e0724e25ef2a0061236a88251f (patch) | |
tree | 749f29cdc31e4d8da26d8453905ad2336cf23f8d /lib | |
parent | edc48203ca8c6da1a991338f8b2eab67c6da9af7 (diff) |
New improved copy par files, that adds the configuration directory and
checks that all the thorns are compiled ... so in principle all par files
should work.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@1149 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sbin/CopyParFiles.pl | 93 |
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); + +} |