Add locking to installed-chrome.txt updates. Bug #55174
This commit is contained in:
Родитель
2212c0ad2f
Коммит
475af3188d
|
@ -1,6 +1,11 @@
|
|||
#!/perl
|
||||
|
||||
use File::Path;
|
||||
use Fcntl qw(:DEFAULT :flock);
|
||||
use Getopt::Std;
|
||||
use IO::File;
|
||||
|
||||
getopts("l");
|
||||
|
||||
my $installedChromeFile = $ARGV[0];
|
||||
my $disableJarPackaging = $ARGV[1];
|
||||
|
@ -10,6 +15,11 @@ my $jarFileName = $ARGV[4];
|
|||
|
||||
#print "add-chrome $installedChromeFile $disableJarPackaging $chromeType $pkgName $jarFileName\n";
|
||||
|
||||
my $nofilelocks = 0;
|
||||
if (defined($::opt_l)) {
|
||||
$nofilelocks = 1;
|
||||
}
|
||||
|
||||
if ($jarFileName =~ /(.*)\.jar/) {
|
||||
$jarFileName = $1;
|
||||
}
|
||||
|
@ -22,6 +32,15 @@ else {
|
|||
$line = "$chromeType,install,url,jar:resource:/chrome/$jarFileName.jar!/$chromeType/$pkgName/";
|
||||
}
|
||||
|
||||
my $lockfile = "$installedChromeFile.lck";
|
||||
my $lockhandle = new IO::File;
|
||||
|
||||
if (!$nofilelocks) {
|
||||
open($lockhandle,">$lockfile") ||
|
||||
die("WARNING: Could not create lockfile for $lockfile. Exiting.\n");
|
||||
flock($lockhandle, LOCK_EX);
|
||||
}
|
||||
|
||||
if (open(FILE, "<$installedChromeFile")) {
|
||||
while (<FILE>) {
|
||||
chomp;
|
||||
|
@ -29,6 +48,10 @@ if (open(FILE, "<$installedChromeFile")) {
|
|||
# line already appears in installed-chrome.txt file
|
||||
# just update the mod date
|
||||
close(FILE) || die "error: can't close $installedChromeFile: $!";
|
||||
if (!$nofilelocks) {
|
||||
unlink($lockfile);
|
||||
flock($lockhandle, LOCK_UN);
|
||||
}
|
||||
my $now = time;
|
||||
utime($now, $now, $installedChromeFile) || die "couldn't touch $installedChromeFile";
|
||||
print "+++ updating chrome $installedChromeFile\n+++\t$line\n";
|
||||
|
@ -37,6 +60,10 @@ if (open(FILE, "<$installedChromeFile")) {
|
|||
}
|
||||
close(FILE) || die "error: can't close $installedChromeFile: $!";
|
||||
}
|
||||
if (!$nofilelocks) {
|
||||
unlink($lockfile);
|
||||
flock($lockhandle, LOCK_UN);
|
||||
}
|
||||
|
||||
my $dir = $installedChromeFile;
|
||||
if ("$dir" =~ /([\w\d.\-\\\/]+)[\\\/]([\w\d.\-]+)/) {
|
||||
|
@ -44,7 +71,17 @@ if ("$dir" =~ /([\w\d.\-\\\/]+)[\\\/]([\w\d.\-]+)/) {
|
|||
}
|
||||
mkpath($dir, 0, 0755);
|
||||
|
||||
if (!$nofilelocks) {
|
||||
open($lockhandle,">$lockfile") ||
|
||||
die("WARNING: Could not create lockfile for $lockfile. Exiting.\n");
|
||||
flock($lockhandle, LOCK_EX);
|
||||
}
|
||||
open(FILE, ">>$installedChromeFile") || die "can't open $installedChromeFile: $!";
|
||||
print FILE "$line\n";
|
||||
close(FILE) || die "error: can't close $installedChromeFile: $!";
|
||||
if (!$nofilelocks) {
|
||||
unlink($lockfile);
|
||||
flock($lockhandle, LOCK_UN);
|
||||
}
|
||||
print "+++ adding chrome $installedChromeFile\n+++\t$line\n";
|
||||
|
||||
|
|
|
@ -599,18 +599,20 @@ _JAR_FLAT_FILES_ONLY=
|
|||
_JAR_REGCHROME_JAR=0
|
||||
!endif
|
||||
|
||||
REGCHROME = @perl $(DEPTH)\config\add-chrome.pl $(DIST)\bin\chrome\installed-chrome.txt $(_JAR_REGCHROME_JAR)
|
||||
!if "$(OS_TARGET)" == "WIN95"
|
||||
_NO_FLOCK=-l
|
||||
!else
|
||||
_NO_FLOCK=
|
||||
!endif
|
||||
|
||||
REGCHROME = @perl $(DEPTH)\config\add-chrome.pl $(_NO_FLOCK) $(DIST)\bin\chrome\installed-chrome.txt $(_JAR_REGCHROME_JAR)
|
||||
|
||||
!ifndef MOZ_OLD_JAR_PACKAGING
|
||||
|
||||
!if exist($(JAR_MANIFEST))
|
||||
|
||||
chrome:: $(CHROME_DEPS)
|
||||
!if "$(OS_TARGET)"=="WIN95"
|
||||
$(PERL) $(DEPTH)\config\make-jars.pl $(_JAR_FLAT_FILES_ONLY) -l -d $(DIST)\bin\chrome < $(JAR_MANIFEST)
|
||||
!else
|
||||
$(PERL) $(DEPTH)\config\make-jars.pl $(_JAR_FLAT_FILES_ONLY) -d $(DIST)\bin\chrome < $(JAR_MANIFEST)
|
||||
!endif
|
||||
$(PERL) $(DEPTH)\config\make-jars.pl $(_JAR_FLAT_FILES_ONLY) $(_NO_FLOCK) -d $(DIST)\bin\chrome < $(JAR_MANIFEST)
|
||||
!endif
|
||||
|
||||
regchrome:
|
||||
|
|
Загрузка…
Ссылка в новой задаче