2000-09-14 12:31:59 +04:00
|
|
|
#!/perl
|
|
|
|
|
2000-09-21 05:47:19 +04:00
|
|
|
use File::Path;
|
2001-01-27 04:40:15 +03:00
|
|
|
use Fcntl qw(:DEFAULT :flock);
|
|
|
|
use Getopt::Std;
|
|
|
|
use IO::File;
|
|
|
|
|
|
|
|
getopts("l");
|
2000-09-21 05:47:19 +04:00
|
|
|
|
2000-09-15 12:08:11 +04:00
|
|
|
my $installedChromeFile = $ARGV[0];
|
2000-09-21 05:47:19 +04:00
|
|
|
my $disableJarPackaging = $ARGV[1];
|
|
|
|
my $chromeType = $ARGV[2];
|
|
|
|
my $pkgName = $ARGV[3];
|
|
|
|
my $jarFileName = $ARGV[4];
|
2000-09-14 12:31:59 +04:00
|
|
|
|
2000-09-21 05:47:19 +04:00
|
|
|
#print "add-chrome $installedChromeFile $disableJarPackaging $chromeType $pkgName $jarFileName\n";
|
2000-09-20 23:35:24 +04:00
|
|
|
|
2001-01-27 04:40:15 +03:00
|
|
|
my $nofilelocks = 0;
|
|
|
|
if (defined($::opt_l)) {
|
|
|
|
$nofilelocks = 1;
|
|
|
|
}
|
|
|
|
|
2000-09-20 23:35:24 +04:00
|
|
|
if ($jarFileName =~ /(.*)\.jar/) {
|
|
|
|
$jarFileName = $1;
|
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
|
2000-09-15 12:08:11 +04:00
|
|
|
my $line;
|
|
|
|
if ($disableJarPackaging) {
|
2000-09-20 23:35:24 +04:00
|
|
|
$line = "$chromeType,install,url,resource:/chrome/$jarFileName/$chromeType/$pkgName/";
|
2000-09-15 12:08:11 +04:00
|
|
|
}
|
|
|
|
else {
|
2000-09-20 23:35:24 +04:00
|
|
|
$line = "$chromeType,install,url,jar:resource:/chrome/$jarFileName.jar!/$chromeType/$pkgName/";
|
2000-09-15 12:08:11 +04:00
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
|
2001-01-27 04:40:15 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2000-09-14 12:31:59 +04:00
|
|
|
if (open(FILE, "<$installedChromeFile")) {
|
|
|
|
while (<FILE>) {
|
|
|
|
chomp;
|
|
|
|
if ($_ =~ $line) {
|
|
|
|
# line already appears in installed-chrome.txt file
|
|
|
|
# just update the mod date
|
2000-09-22 04:31:58 +04:00
|
|
|
close(FILE) || die "error: can't close $installedChromeFile: $!";
|
2001-01-27 04:40:15 +03:00
|
|
|
if (!$nofilelocks) {
|
|
|
|
unlink($lockfile);
|
|
|
|
flock($lockhandle, LOCK_UN);
|
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
my $now = time;
|
|
|
|
utime($now, $now, $installedChromeFile) || die "couldn't touch $installedChromeFile";
|
|
|
|
print "+++ updating chrome $installedChromeFile\n+++\t$line\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(FILE) || die "error: can't close $installedChromeFile: $!";
|
|
|
|
}
|
2001-01-27 04:40:15 +03:00
|
|
|
if (!$nofilelocks) {
|
|
|
|
unlink($lockfile);
|
|
|
|
flock($lockhandle, LOCK_UN);
|
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
|
2000-09-21 05:47:19 +04:00
|
|
|
my $dir = $installedChromeFile;
|
|
|
|
if ("$dir" =~ /([\w\d.\-\\\/]+)[\\\/]([\w\d.\-]+)/) {
|
|
|
|
$dir = $1;
|
|
|
|
}
|
|
|
|
mkpath($dir, 0, 0755);
|
|
|
|
|
2001-01-27 04:40:15 +03:00
|
|
|
if (!$nofilelocks) {
|
|
|
|
open($lockhandle,">$lockfile") ||
|
|
|
|
die("WARNING: Could not create lockfile for $lockfile. Exiting.\n");
|
|
|
|
flock($lockhandle, LOCK_EX);
|
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
open(FILE, ">>$installedChromeFile") || die "can't open $installedChromeFile: $!";
|
|
|
|
print FILE "$line\n";
|
|
|
|
close(FILE) || die "error: can't close $installedChromeFile: $!";
|
2001-01-27 04:40:15 +03:00
|
|
|
if (!$nofilelocks) {
|
|
|
|
unlink($lockfile);
|
|
|
|
flock($lockhandle, LOCK_UN);
|
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
print "+++ adding chrome $installedChromeFile\n+++\t$line\n";
|
2001-01-27 04:40:15 +03:00
|
|
|
|