2000-09-14 12:31:59 +04:00
|
|
|
#!/perl
|
2012-05-21 15:12:37 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2000-09-14 12:31:59 +04:00
|
|
|
|
2000-09-21 05:47:19 +04:00
|
|
|
use File::Path;
|
2001-01-27 04:40:15 +03:00
|
|
|
use Getopt::Std;
|
|
|
|
use IO::File;
|
2001-05-14 15:13:51 +04:00
|
|
|
use mozLock;
|
2001-01-27 04:40:15 +03:00
|
|
|
|
2004-02-21 01:14:14 +03:00
|
|
|
getopts("lxo:");
|
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
|
|
|
|
2005-06-01 18:20:35 +04:00
|
|
|
my $win32 = ($^O =~ /((MS)?win32)|msys|cygwin|os2/i) ? 1 : 0;
|
2002-10-08 10:17:19 +04:00
|
|
|
my $macos = ($^O =~ /MacOS|darwin/i) ? 1 : 0;
|
|
|
|
my $unix = !($win32 || $macos) ? 1 : 0;
|
|
|
|
|
|
|
|
sub foreignPlatformFile
|
|
|
|
{
|
|
|
|
my ($jarfile) = @_;
|
|
|
|
|
|
|
|
if (!$win32 && index($jarfile, "-win") != -1) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$unix && index($jarfile, "-unix") != -1) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$macos && index($jarfile, "-mac") != -1) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-08 15:49:47 +04:00
|
|
|
sub foreignPlatformPath
|
|
|
|
{
|
|
|
|
my ($jarpath) = @_;
|
|
|
|
|
|
|
|
if (!$win32 && index($jarpath, "-platform/win") != -1) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$unix && index($jarpath, "-platform/unix") != -1) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$macos && index($jarpath, "-platform/mac") != -1) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-03-04 06:56:03 +03:00
|
|
|
if (defined($::opt_x)) {
|
|
|
|
$win32 = 0;
|
|
|
|
$macos = 0;
|
|
|
|
$unix = 1;
|
|
|
|
}
|
|
|
|
|
2004-02-21 01:14:14 +03:00
|
|
|
my $force_os;
|
|
|
|
if (defined($::opt_o)) {
|
|
|
|
$force_os = $::opt_o;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined($force_os)) {
|
|
|
|
$win32 = 0;
|
|
|
|
$macos = 0;
|
|
|
|
$unix = 0;
|
|
|
|
if ($force_os eq "WINNT") {
|
|
|
|
$win32 = 1;
|
|
|
|
} elsif ($force_os eq "OS2") {
|
|
|
|
$win32 = 1;
|
|
|
|
} elsif ($force_os eq "Darwin") {
|
|
|
|
$macos = 1;
|
|
|
|
} else {
|
|
|
|
$unix = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-20 23:35:24 +04:00
|
|
|
if ($jarFileName =~ /(.*)\.jar/) {
|
|
|
|
$jarFileName = $1;
|
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
|
2006-04-08 15:49:47 +04:00
|
|
|
if (!foreignPlatformFile($jarFileName) && !foreignPlatformPath($pkgName)) {
|
2002-10-08 10:17:19 +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";
|
2001-05-14 15:13:51 +04:00
|
|
|
my $err;
|
2001-01-27 04:40:15 +03:00
|
|
|
|
2001-05-14 15:13:51 +04:00
|
|
|
mozLock($lockfile) if (!$nofilelocks);
|
|
|
|
$err = 0;
|
2000-09-14 12:31:59 +04:00
|
|
|
if (open(FILE, "<$installedChromeFile")) {
|
|
|
|
while (<FILE>) {
|
|
|
|
chomp;
|
2002-06-25 01:48:24 +04:00
|
|
|
if ($_ eq $line) {
|
2000-09-14 12:31:59 +04:00
|
|
|
# line already appears in installed-chrome.txt file
|
|
|
|
# just update the mod date
|
2001-05-14 15:13:51 +04:00
|
|
|
close(FILE) or $err = 1;
|
|
|
|
if ($err) {
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
die "error: can't close $installedChromeFile: $!";
|
2001-01-27 04:40:15 +03:00
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
my $now = time;
|
2001-05-14 15:13:51 +04:00
|
|
|
utime($now, $now, $installedChromeFile) or $err = 1;
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
if ($err) {
|
|
|
|
die "couldn't touch $installedChromeFile";
|
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
print "+++ updating chrome $installedChromeFile\n+++\t$line\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2001-05-14 15:13:51 +04:00
|
|
|
close(FILE) or $err = 1;
|
|
|
|
if ($err) {
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
die "error: can't close $installedChromeFile: $!";
|
|
|
|
}
|
2001-01-27 04:40:15 +03:00
|
|
|
}
|
2001-05-14 15:13:51 +04:00
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
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-05-14 15:13:51 +04:00
|
|
|
mozLock($lockfile) if (!$nofilelocks);
|
|
|
|
$err = 0;
|
|
|
|
open(FILE, ">>$installedChromeFile") or $err = 1;
|
|
|
|
if ($err) {
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
die "can't open $installedChromeFile: $!";
|
2001-01-27 04:40:15 +03:00
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
print FILE "$line\n";
|
2001-05-14 15:13:51 +04:00
|
|
|
close(FILE) or $err = 1;
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
if ($err) {
|
|
|
|
die "error: can't close $installedChromeFile: $!";
|
2001-01-27 04:40:15 +03:00
|
|
|
}
|
2000-09-14 12:31:59 +04:00
|
|
|
print "+++ adding chrome $installedChromeFile\n+++\t$line\n";
|
2002-10-08 10:17:19 +04:00
|
|
|
}
|
2001-01-27 04:40:15 +03:00
|
|
|
|