| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# |
| 4 |
# Create all the combined configuration files |
| 5 |
# |
| 6 |
# Usage: ./combineMJ [--force] [proj-dir] |
| 7 |
# |
| 8 |
|
| 9 |
use Cwd; |
| 10 |
use FindBin; |
| 11 |
|
| 12 |
if ($ARGV[0] eq '--force') {$force = true; shift} |
| 13 |
|
| 14 |
$DIR = $FindBin::Bin; |
| 15 |
$MJX = shift || getcwd; |
| 16 |
$COMBINELIST = "$DIR/combineMJlist"; |
| 17 |
$COMBINELISTU = "$DIR/combineMJlist-unpacked"; |
| 18 |
|
| 19 |
die "Project directory must contain a config directory\n" unless -d "$MJX/config"; |
| 20 |
|
| 21 |
|
| 22 |
opendir(LISTS,"$DIR/lists") || die "Can't list $DIR/lists: $!\n"; |
| 23 |
@lists = grep {/.*\.lis/} readdir(LISTS); |
| 24 |
closedir(LISTS); |
| 25 |
|
| 26 |
foreach $list (@lists) { |
| 27 |
$file = $list; $file =~ s/\.[^.]*/.js/; |
| 28 |
$needsUpdate = 1; |
| 29 |
if (-e "$MJX/config/$file" && !$force) { |
| 30 |
$needsUpdate = 0; |
| 31 |
$date = (stat("$MJX/config/$file"))[9]; |
| 32 |
open(LIST,"<","$DIR/lists/$list") || warn "Can't read $DIR/lists/$list: $!\n"; |
| 33 |
@files = <LIST>; chomp(@files); |
| 34 |
close(LIST); |
| 35 |
foreach $name (@files) { |
| 36 |
last unless $name =~ m/\S/; |
| 37 |
if (!(-e "$MJX/$name") || (stat("$MJX/$name"))[9] > $date) { |
| 38 |
$needsUpdate = 1; |
| 39 |
last; |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
if ($needsUpdate) { |
| 44 |
print "Refreshing: config/$file\n"; |
| 45 |
system("$COMBINELIST '$MJX' '$DIR/lists/$list' > /dev/null"); |
| 46 |
system("$COMBINELISTU '$MJX' '$DIR/lists/$list' > /dev/null"); |
| 47 |
} else { |
| 48 |
print "Up to date: config/$file\n"; |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
1; |