-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-config
More file actions
executable file
·55 lines (49 loc) · 1.44 KB
/
update-config
File metadata and controls
executable file
·55 lines (49 loc) · 1.44 KB
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
#! /usr/bin/perl
##
## This script checks to make sure that the list of classes in "compc-config.xml" is
## up to date. It does this by running the script "swcclasses", which generates the
## current list of classes, and comparing to the current "compc-config.xml". If there
## are any differences, this script replaces "compc-config.xml" with the new version.
## If there aren't any differences, "compc-config.xml" is left unchanged.
##
$configfile = shift; # compc-config.xml
if ($configfile eq "compc-config.xml") {
$target = "SWC";
} elsif ($configfile eq "mxmlc-config.xml") {
$target = "SWF";
} else {
die "usage: update-config { compc-config.xml | mxmlc-config.xml }\n";
}
###
### Create new version of $configfile in the /tmp directory:
###
open(IN, "<$configfile");
open(OUT, ">/tmp/$configfile");
while (<IN>) {
if (!/<class>/) {
print OUT $_;
}
if (/<include-classes>/) {
open(SRCCLASSES, "./srcclasses $target |");
while (chomp($class = <SRCCLASSES>)) {
printf(OUT " <class>%s</class>\n", $class);
}
close(SRCCLASSES);
}
}
close(OUT);
close(IN);
###
### Compare current version to new version, and if different, replace:
###
$code = system("cmp /tmp/$configfile ./$configfile > /dev/null");
if ($code) {
system("cp /tmp/$configfile ./$configfile");
printf("$configfile updated\n");
} else {
printf("$configfile unchanged\n");
}
###
### Remove new version from /tmp:
###
unlink("/tmp/$configfile");