10 my $installedChromeFile = $ARGV[0];
11 my $disableJarPackaging = $ARGV[1];
12 my $chromeType = $ARGV[2];
13 my $pkgName = $ARGV[3];
14 my $jarFileName = $ARGV[4];
16 my $win32 = ($^O
=~ /((MS)?win32)|msys|cygwin|os2/i) ?
1 : 0;
17 my $macos = ($^O
=~ /MacOS|darwin/i) ?
1 : 0;
18 my $unix = !($win32 || $macos) ?
1 : 0;
20 sub foreignPlatformFile
24 if (!$win32 && index($jarfile, "-win") != -1) {
28 if (!$unix && index($jarfile, "-unix") != -1) {
32 if (!$macos && index($jarfile, "-mac") != -1) {
39 sub foreignPlatformPath
43 if (!$win32 && index($jarpath, "-platform/win") != -1) {
47 if (!$unix && index($jarpath, "-platform/unix") != -1) {
51 if (!$macos && index($jarpath, "-platform/mac") != -1) {
58 #print "add-chrome $installedChromeFile $disableJarPackaging $chromeType $pkgName $jarFileName\n";
61 if (defined($::opt_l
)) {
65 if (defined($::opt_x
)) {
72 if (defined($::opt_o
)) {
76 if (defined($force_os)) {
80 if ($force_os eq "WINNT") {
82 } elsif ($force_os eq "OS2") {
84 } elsif ($force_os eq "Darwin") {
91 if ($jarFileName =~ /(.*)\.jar/) {
95 if (!foreignPlatformFile
($jarFileName) && !foreignPlatformPath
($pkgName)) {
98 if ($disableJarPackaging) {
99 $line = "$chromeType,install,url,resource:/chrome/$jarFileName/$chromeType/$pkgName/";
102 $line = "$chromeType,install,url,jar:resource:/chrome/$jarFileName.jar!/$chromeType/$pkgName/";
105 my $lockfile = "$installedChromeFile.lck";
108 mozLock
($lockfile) if (!$nofilelocks);
110 if (open(FILE
, "<$installedChromeFile")) {
114 # line already appears in installed-chrome.txt file
115 # just update the mod date
116 close(FILE
) or $err = 1;
118 mozUnlock
($lockfile) if (!$nofilelocks);
119 die "error: can't close $installedChromeFile: $!";
122 utime($now, $now, $installedChromeFile) or $err = 1;
123 mozUnlock
($lockfile) if (!$nofilelocks);
125 die "couldn't touch $installedChromeFile";
127 print "+++ updating chrome $installedChromeFile\n+++\t$line\n";
131 close(FILE
) or $err = 1;
133 mozUnlock
($lockfile) if (!$nofilelocks);
134 die "error: can't close $installedChromeFile: $!";
137 mozUnlock
($lockfile) if (!$nofilelocks);
139 my $dir = $installedChromeFile;
140 if ("$dir" =~ /([\w\d.\-\\\/]+)[\\\
/]([\w\d.\-]+)/) {
143 mkpath
($dir, 0, 0755);
145 mozLock
($lockfile) if (!$nofilelocks);
147 open(FILE
, ">>$installedChromeFile") or $err = 1;
149 mozUnlock
($lockfile) if (!$nofilelocks);
150 die "can't open $installedChromeFile: $!";
152 print FILE
"$line\n";
153 close(FILE
) or $err = 1;
154 mozUnlock
($lockfile) if (!$nofilelocks);
156 die "error: can't close $installedChromeFile: $!";
158 print "+++ adding chrome $installedChromeFile\n+++\t$line\n";