2000-06-09 10:33:25 +04:00
|
|
|
#!/perl
|
|
|
|
|
2005-07-28 20:17:15 +04:00
|
|
|
# make-jars [-f] [-v] [-l] [-x] [-a] [-e] [-d <chromeDir>] [-s <srcdir>] [-t <topsrcdir>] [-c <localedir>] [-j <jarDir>] [-z zipprog] [-o operating-system] < <jar.mn>
|
2000-09-21 02:45:45 +04:00
|
|
|
|
2003-04-02 10:22:59 +04:00
|
|
|
my $cygwin_mountprefix = "";
|
|
|
|
if ($^O eq "cygwin") {
|
2004-07-02 04:53:36 +04:00
|
|
|
$cygwin_mountprefix = $ENV{CYGDRIVE_MOUNT};
|
|
|
|
if ($cygwin_mountprefix eq "") {
|
|
|
|
$cygwin_mountprefix = `mount -p | awk '{ if (/^\\//) { print \$1; exit } }'`;
|
|
|
|
if ($cygwin_mountprefix eq "") {
|
|
|
|
print "Cannot determine cygwin mount points. Exiting.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2004-03-02 00:12:29 +03:00
|
|
|
chomp($cygwin_mountprefix);
|
|
|
|
# Remove extra ^M caused by using dos-mode line-endings
|
|
|
|
chop $cygwin_mountprefix if (substr($cygwin_mountprefix, -1, 1) eq "\r");
|
2003-04-02 10:22:59 +04:00
|
|
|
} else {
|
2004-03-02 00:12:29 +03:00
|
|
|
# we'll be pulling in some stuff from the script directory
|
|
|
|
require FindBin;
|
|
|
|
import FindBin;
|
|
|
|
push @INC, $FindBin::Bin;
|
2002-06-17 21:09:57 +04:00
|
|
|
}
|
2002-04-01 08:43:40 +04:00
|
|
|
|
2000-09-21 02:45:45 +04:00
|
|
|
use strict;
|
2000-06-09 10:33:25 +04:00
|
|
|
|
2000-07-28 09:08:08 +04:00
|
|
|
use Getopt::Std;
|
|
|
|
use Cwd;
|
2000-08-11 09:16:15 +04:00
|
|
|
use File::stat;
|
|
|
|
use Time::localtime;
|
2000-09-21 02:45:45 +04:00
|
|
|
use File::Copy;
|
|
|
|
use File::Path;
|
2003-10-30 12:24:40 +03:00
|
|
|
use File::Spec;
|
2005-04-15 16:31:49 +04:00
|
|
|
use File::Basename;
|
2001-01-22 07:20:55 +03:00
|
|
|
use IO::File;
|
2002-12-12 03:08:59 +03:00
|
|
|
use Config;
|
2002-04-01 08:43:40 +04:00
|
|
|
require mozLock;
|
|
|
|
import mozLock;
|
2000-09-21 02:45:45 +04:00
|
|
|
|
|
|
|
my $objdir = getcwd;
|
2000-07-28 09:08:08 +04:00
|
|
|
|
2004-04-23 00:52:34 +04:00
|
|
|
# if there's a "--", everything after it goes into $defines. We don't do
|
|
|
|
# this with the remaining args in @ARGV after the getopts call because
|
|
|
|
# old versions of Getopt::Std don't understand "--".
|
|
|
|
my $ddindex = 0;
|
|
|
|
foreach my $arg (@ARGV) {
|
|
|
|
++$ddindex;
|
|
|
|
last if ($arg eq "--");
|
|
|
|
}
|
2004-04-23 04:44:52 +04:00
|
|
|
my $defines = join(' ', @ARGV[ $ddindex .. $#ARGV ]);
|
2004-04-23 00:52:34 +04:00
|
|
|
|
2005-09-28 19:48:07 +04:00
|
|
|
getopts("d:s:t:c:j:f:avlD:o:p:xz:e");
|
2000-09-21 02:45:45 +04:00
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
my $baseFilesDir = ".";
|
2000-09-21 02:45:45 +04:00
|
|
|
if (defined($::opt_s)) {
|
2000-09-21 11:14:35 +04:00
|
|
|
$baseFilesDir = $::opt_s;
|
2000-09-21 02:45:45 +04:00
|
|
|
}
|
2000-08-05 00:25:42 +04:00
|
|
|
|
2004-10-02 05:39:39 +04:00
|
|
|
my $topSrcDir;
|
|
|
|
if (defined($::opt_t)) {
|
|
|
|
$topSrcDir = $::opt_t;
|
|
|
|
}
|
|
|
|
|
2004-11-30 02:14:13 +03:00
|
|
|
my $localeDir;
|
|
|
|
if (defined($::opt_c)) {
|
|
|
|
$localeDir = $::opt_c;
|
|
|
|
}
|
|
|
|
|
2002-12-12 03:08:59 +03:00
|
|
|
my $maxCmdline = 4000;
|
|
|
|
if ($Config{'archname'} =~ /VMS/) {
|
|
|
|
$maxCmdline = 200;
|
|
|
|
}
|
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
my $chromeDir = ".";
|
2000-09-21 02:45:45 +04:00
|
|
|
if (defined($::opt_d)) {
|
2000-09-21 11:14:35 +04:00
|
|
|
$chromeDir = $::opt_d;
|
2000-09-12 09:10:48 +04:00
|
|
|
}
|
|
|
|
|
2005-07-28 20:17:15 +04:00
|
|
|
my $jarDir = $chromeDir;
|
|
|
|
if (defined($::opt_j)) {
|
|
|
|
$jarDir = $::opt_j;
|
|
|
|
}
|
|
|
|
|
2000-09-21 02:45:45 +04:00
|
|
|
my $verbose = 0;
|
|
|
|
if (defined($::opt_v)) {
|
|
|
|
$verbose = 1;
|
2000-09-12 09:10:48 +04:00
|
|
|
}
|
|
|
|
|
2001-03-24 14:07:15 +03:00
|
|
|
my $fileformat = "jar";
|
2000-09-21 10:22:06 +04:00
|
|
|
if (defined($::opt_f)) {
|
2001-03-24 14:07:15 +03:00
|
|
|
($fileformat = $::opt_f) =~ tr/A-Z/a-z/;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("$fileformat" ne "jar" &&
|
|
|
|
"$fileformat" ne "flat" &&
|
2003-10-30 12:24:40 +03:00
|
|
|
"$fileformat" ne "symlink" &&
|
2001-03-24 14:07:15 +03:00
|
|
|
"$fileformat" ne "both") {
|
2003-10-30 12:24:40 +03:00
|
|
|
print "File format specified by -f option must be one of: jar, flat, both, or symlink.\n";
|
2001-03-24 14:07:15 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $zipmoveopt = "";
|
|
|
|
if ("$fileformat" eq "jar") {
|
2003-04-17 12:09:44 +04:00
|
|
|
$zipmoveopt = "-m -0";
|
|
|
|
}
|
|
|
|
if ("$fileformat" eq "both") {
|
|
|
|
$zipmoveopt = "-0";
|
2000-09-21 10:22:06 +04:00
|
|
|
}
|
|
|
|
|
2001-01-22 10:36:25 +03:00
|
|
|
my $nofilelocks = 0;
|
|
|
|
if (defined($::opt_l)) {
|
|
|
|
$nofilelocks = 1;
|
|
|
|
}
|
|
|
|
|
2002-03-14 08:03:04 +03:00
|
|
|
my $autoreg = 1;
|
|
|
|
if (defined($::opt_a)) {
|
|
|
|
$autoreg = 0;
|
|
|
|
}
|
|
|
|
|
2005-06-01 15:59:09 +04:00
|
|
|
my $useExtensionManifest = 0;
|
|
|
|
if (defined($::opt_e)) {
|
|
|
|
$useExtensionManifest = 1;
|
|
|
|
}
|
|
|
|
|
2002-10-10 07:11:27 +04:00
|
|
|
my $preprocessor = "";
|
|
|
|
if (defined($::opt_p)) {
|
|
|
|
$preprocessor = $::opt_p;
|
|
|
|
}
|
|
|
|
|
2003-03-04 06:56:03 +03:00
|
|
|
my $force_x11 = 0;
|
|
|
|
if (defined($::opt_x)) {
|
|
|
|
$force_x11 = 1;
|
|
|
|
}
|
|
|
|
|
2003-04-13 09:20:20 +04:00
|
|
|
my $zipprog = $ENV{ZIP};
|
|
|
|
if (defined($::opt_z)) {
|
|
|
|
$zipprog = $::opt_z;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($zipprog eq "") {
|
|
|
|
print "A valid zip program must be given via the -z option or the ZIP environment variable. Exiting.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2004-02-21 01:14:14 +03:00
|
|
|
my $force_os;
|
|
|
|
if (defined($::opt_o)) {
|
|
|
|
$force_os = $::opt_o;
|
|
|
|
}
|
|
|
|
|
2000-09-21 02:45:45 +04:00
|
|
|
if ($verbose) {
|
2000-09-20 23:35:24 +04:00
|
|
|
print "make-jars "
|
2000-09-21 11:14:35 +04:00
|
|
|
. "-v -d $chromeDir "
|
2005-07-28 20:17:15 +04:00
|
|
|
. "-j $jarDir "
|
2004-03-02 00:12:29 +03:00
|
|
|
. "-z $zipprog "
|
2001-03-24 16:44:41 +03:00
|
|
|
. ($fileformat ? "-f $fileformat " : "")
|
2001-01-22 10:36:25 +03:00
|
|
|
. ($nofilelocks ? "-l " : "")
|
2000-09-21 11:14:35 +04:00
|
|
|
. ($baseFilesDir ? "-s $baseFilesDir " : "")
|
|
|
|
. "\n";
|
2000-08-04 00:58:31 +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;
|
2003-01-22 07:16:58 +03:00
|
|
|
my $vms = ($^O =~ /VMS/i) ? 1 : 0;
|
2002-10-08 10:17:19 +04:00
|
|
|
|
2003-03-04 06:56:03 +03:00
|
|
|
if ($force_x11) {
|
|
|
|
$win32 = 0;
|
|
|
|
$macos = 0;
|
|
|
|
$unix = 1;
|
|
|
|
}
|
|
|
|
|
2004-02-21 01:14:14 +03:00
|
|
|
if (defined($force_os)) {
|
|
|
|
$win32 = 0;
|
|
|
|
$macos = 0;
|
|
|
|
$unix = 0;
|
|
|
|
if ($force_os eq "WINNT") {
|
2004-03-02 00:12:29 +03:00
|
|
|
$win32 = 1;
|
2004-02-21 01:14:14 +03:00
|
|
|
} elsif ($force_os eq "OS2") {
|
2004-03-02 00:12:29 +03:00
|
|
|
$win32 = 1;
|
2004-02-21 01:14:14 +03:00
|
|
|
} elsif ($force_os eq "Darwin") {
|
2004-03-02 00:12:29 +03:00
|
|
|
$macos = 1;
|
2004-02-21 01:14:14 +03:00
|
|
|
} else {
|
2004-03-02 00:12:29 +03:00
|
|
|
$unix = 1;
|
2004-02-21 01:14:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-08 10:17:19 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-05-14 15:13:51 +04:00
|
|
|
sub zipErrorCheck($$)
|
2000-09-21 02:45:45 +04:00
|
|
|
{
|
2001-05-14 15:13:51 +04:00
|
|
|
my ($err,$lockfile) = @_;
|
2000-09-21 02:45:45 +04:00
|
|
|
return if ($err == 0 || $err == 12);
|
2001-05-14 15:13:51 +04:00
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
2000-09-22 04:31:58 +04:00
|
|
|
die ("Error invoking zip: $err");
|
2000-09-21 02:45:45 +04:00
|
|
|
}
|
|
|
|
|
2000-06-09 10:33:25 +04:00
|
|
|
sub JarIt
|
|
|
|
{
|
2005-07-28 20:17:15 +04:00
|
|
|
my ($destPath, $jarPath, $jarfile, $args, $overrides) = @_;
|
2001-03-24 14:07:15 +03:00
|
|
|
my $oldDir = cwd();
|
2005-08-25 23:18:05 +04:00
|
|
|
my $jarchive = _moz_abs2rel("$jarPath/$jarfile.jar", "$destPath/$jarfile", 1);
|
2001-03-24 14:07:15 +03:00
|
|
|
chdir("$destPath/$jarfile");
|
2000-09-12 09:10:48 +04:00
|
|
|
|
2003-10-30 12:24:40 +03:00
|
|
|
if ("$fileformat" eq "flat" || "$fileformat" eq "symlink") {
|
2005-07-28 20:17:15 +04:00
|
|
|
unlink($jarchive) if ( -e $jarchive);
|
|
|
|
chdir($oldDir);
|
2000-09-21 11:14:35 +04:00
|
|
|
return 0;
|
2000-09-12 09:10:48 +04:00
|
|
|
}
|
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
#print "cd $destPath/$jarfile\n";
|
2001-01-22 10:36:25 +03:00
|
|
|
|
2001-01-22 07:20:55 +03:00
|
|
|
my $lockfile = "../$jarfile.lck";
|
2001-05-14 15:13:51 +04:00
|
|
|
|
|
|
|
mozLock($lockfile) if (!$nofilelocks);
|
2000-09-21 11:14:35 +04:00
|
|
|
|
|
|
|
if (!($args eq "")) {
|
2004-03-02 00:12:29 +03:00
|
|
|
my $err = 0;
|
2001-01-22 07:20:55 +03:00
|
|
|
|
2005-07-28 20:17:15 +04:00
|
|
|
#print "$zipprog $zipmoveopt -uX $jarchive $args\n";
|
2000-09-25 04:36:12 +04:00
|
|
|
|
2004-03-02 00:12:29 +03:00
|
|
|
# Handle posix cmdline limits
|
|
|
|
while (length($args) > $maxCmdline) {
|
|
|
|
#print "Exceeding POSIX cmdline limit: " . length($args) . "\n";
|
|
|
|
my $subargs = substr($args, 0, $maxCmdline-1);
|
|
|
|
my $pos = rindex($subargs, " ");
|
|
|
|
$subargs = substr($args, 0, $pos);
|
|
|
|
$args = substr($args, $pos);
|
|
|
|
|
2005-07-28 20:17:15 +04:00
|
|
|
#print "$zipprog $zipmoveopt -uX $jarchive $subargs\n";
|
2004-03-02 00:12:29 +03:00
|
|
|
#print "Length of subargs: " . length($subargs) . "\n";
|
2005-07-28 20:17:15 +04:00
|
|
|
system("$zipprog $zipmoveopt -uX $jarchive $subargs") == 0 or
|
2004-03-02 00:12:29 +03:00
|
|
|
$err = $? >> 8;
|
|
|
|
zipErrorCheck($err,$lockfile);
|
|
|
|
}
|
|
|
|
#print "Length of args: " . length($args) . "\n";
|
2005-07-28 20:17:15 +04:00
|
|
|
#print "$zipprog $zipmoveopt -uX $jarchive $args\n";
|
|
|
|
system("$zipprog $zipmoveopt -uX $jarchive $args") == 0 or
|
2004-03-02 00:12:29 +03:00
|
|
|
$err = $? >> 8;
|
|
|
|
zipErrorCheck($err,$lockfile);
|
2000-09-12 03:08:41 +04:00
|
|
|
}
|
2000-09-25 04:36:12 +04:00
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
if (!($overrides eq "")) {
|
2004-03-02 00:12:29 +03:00
|
|
|
my $err = 0;
|
2000-09-21 11:14:35 +04:00
|
|
|
print "+++ overriding $overrides\n";
|
2003-01-19 22:14:05 +03:00
|
|
|
|
2004-03-02 00:12:29 +03:00
|
|
|
while (length($overrides) > $maxCmdline) {
|
|
|
|
#print "Exceeding POSIX cmdline limit: " . length($overrides) . "\n";
|
|
|
|
my $subargs = substr($overrides, 0, $maxCmdline-1);
|
|
|
|
my $pos = rindex($subargs, " ");
|
|
|
|
$subargs = substr($overrides, 0, $pos);
|
|
|
|
$overrides = substr($overrides, $pos);
|
|
|
|
|
2005-07-28 20:17:15 +04:00
|
|
|
#print "$zipprog $zipmoveopt -X $jarchive $subargs\n";
|
2004-03-02 00:12:29 +03:00
|
|
|
#print "Length of subargs: " . length($subargs) . "\n";
|
2005-07-28 20:17:15 +04:00
|
|
|
system("$zipprog $zipmoveopt -X $jarchive $subargs") == 0 or
|
2004-03-02 00:12:29 +03:00
|
|
|
$err = $? >> 8;
|
|
|
|
zipErrorCheck($err,$lockfile);
|
|
|
|
}
|
|
|
|
#print "Length of args: " . length($overrides) . "\n";
|
2005-07-28 20:17:15 +04:00
|
|
|
#print "$zipprog $zipmoveopt -X $jarchive $overrides\n";
|
|
|
|
system("$zipprog $zipmoveopt -X $jarchive $overrides\n") == 0 or
|
2004-03-02 00:12:29 +03:00
|
|
|
$err = $? >> 8;
|
|
|
|
zipErrorCheck($err,$lockfile);
|
2001-01-22 10:36:25 +03:00
|
|
|
}
|
2001-05-14 15:13:51 +04:00
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
2000-09-21 11:14:35 +04:00
|
|
|
chdir($oldDir);
|
|
|
|
#print "cd $oldDir\n";
|
2000-06-09 10:33:25 +04:00
|
|
|
}
|
|
|
|
|
2003-10-30 12:24:40 +03:00
|
|
|
sub _moz_rel2abs
|
|
|
|
{
|
2005-08-25 23:18:05 +04:00
|
|
|
my ($path, $isdir) = @_;
|
|
|
|
$path = File::Spec->catfile(getcwd, $path)
|
|
|
|
unless File::Spec->file_name_is_absolute($path);
|
|
|
|
$path = File::Spec->canonpath($path);
|
|
|
|
$path =~ s|\\|/|g if $path =~ s/^([A-Z]:\\)/\L$1/;
|
|
|
|
my (@dirs) = reverse split(m:/:, $path);
|
|
|
|
shift @dirs unless $isdir;
|
2003-10-30 12:24:40 +03:00
|
|
|
my ($up) = File::Spec->updir();
|
|
|
|
foreach (reverse 0 .. $#dirs) {
|
2005-08-25 23:18:05 +04:00
|
|
|
splice(@dirs, $_, 2) if ($dirs[$_] eq $up);
|
2003-10-30 12:24:40 +03:00
|
|
|
}
|
2005-08-25 23:18:05 +04:00
|
|
|
return reverse @dirs;
|
2003-10-30 12:24:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sub _moz_abs2rel
|
|
|
|
{
|
2005-08-25 23:18:05 +04:00
|
|
|
my ($target, $basedir, $isdir) = @_;
|
|
|
|
my (@target) = _moz_rel2abs($target, 1);
|
|
|
|
my (@basedir) = _moz_rel2abs($basedir, $isdir);
|
|
|
|
shift @target, shift @basedir
|
|
|
|
while @target && @basedir && $target[0] eq $basedir[0];
|
|
|
|
return File::Spec->catfile((File::Spec->updir()) x @basedir, @target);
|
2003-10-30 12:24:40 +03:00
|
|
|
}
|
2002-03-14 08:03:04 +03:00
|
|
|
|
2005-04-15 16:31:49 +04:00
|
|
|
sub UniqIt
|
|
|
|
{
|
|
|
|
my $manifest = shift;
|
|
|
|
|
|
|
|
return if (scalar(@_) == 0); # no entries, don't bother
|
|
|
|
|
|
|
|
my %lines = map { $_ => 1 } @_;
|
|
|
|
|
|
|
|
my $lockfile = "$manifest.lck";
|
|
|
|
print "+++ updating chrome $manifest\n";
|
|
|
|
|
|
|
|
my $dir = dirname($manifest);
|
|
|
|
mkpath($dir, 0, 0755);
|
|
|
|
|
|
|
|
mozLock($lockfile) if (!$nofilelocks);
|
|
|
|
if (-f $manifest) {
|
|
|
|
unless (open(FILE, "<$manifest")) {
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
die "error: can't open $manifest: $!";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Read through the file: if the lines already exist, no need to write
|
|
|
|
# them again.
|
|
|
|
while (defined($_ = <FILE>)) {
|
|
|
|
chomp;
|
|
|
|
delete $lines{$_};
|
|
|
|
}
|
2005-06-01 15:59:09 +04:00
|
|
|
close(FILE);
|
2005-04-15 16:31:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
unless (open(FILE, ">>$manifest")) {
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
die "error: can't open $manifest: $!";
|
|
|
|
};
|
|
|
|
|
|
|
|
print FILE map("$_\n", keys(%lines));
|
|
|
|
close(FILE) or my $err = 1;
|
|
|
|
mozUnlock($lockfile) if (!$nofilelocks);
|
|
|
|
|
|
|
|
if ($err) {
|
|
|
|
die "error: can't close $manifest: $!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-14 08:03:04 +03:00
|
|
|
sub RegIt
|
|
|
|
{
|
|
|
|
my ($chromeDir, $jarFileName, $chromeType, $pkgName) = @_;\
|
|
|
|
chop($pkgName) if ($pkgName =~ m/\/$/);
|
2002-04-01 08:43:40 +04:00
|
|
|
#print "RegIt: $chromeDir, $jarFileName, $chromeType, $pkgName\n";
|
2002-03-14 08:03:04 +03:00
|
|
|
|
|
|
|
my $line;
|
2003-10-30 12:24:40 +03:00
|
|
|
if ($fileformat eq "flat" || $fileformat eq "symlink") {
|
2004-03-02 00:12:29 +03:00
|
|
|
$line = "$chromeType,install,url,resource:/chrome/$jarFileName/$chromeType/$pkgName/";
|
2002-03-14 08:03:04 +03:00
|
|
|
} else {
|
2004-03-02 00:12:29 +03:00
|
|
|
$line = "$chromeType,install,url,jar:resource:/chrome/$jarFileName.jar!/$chromeType/$pkgName/";
|
2002-03-14 08:03:04 +03:00
|
|
|
}
|
2005-07-28 20:17:15 +04:00
|
|
|
my $installedChromeFile = "$jarDir/installed-chrome.txt";
|
2005-04-15 16:31:49 +04:00
|
|
|
UniqIt($installedChromeFile, $line);
|
2002-03-14 08:03:04 +03:00
|
|
|
}
|
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
sub EnsureFileInDir
|
2000-06-09 10:33:25 +04:00
|
|
|
{
|
2002-10-10 07:11:27 +04:00
|
|
|
my ($destPath, $srcPath, $destFile, $srcFile, $override, $preproc) = @_;
|
2002-11-09 02:04:01 +03:00
|
|
|
my $objPath;
|
2000-09-21 08:29:59 +04:00
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
#print "EnsureFileInDir($destPath, $srcPath, $destFile, $srcFile, $override)\n";
|
2000-09-21 08:29:59 +04:00
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
my $src = $srcFile;
|
|
|
|
if (defined($src)) {
|
2004-10-02 05:39:39 +04:00
|
|
|
if ($src =~ m|^/|) {
|
|
|
|
# "absolute" patch from topSrcDir
|
2004-11-30 02:14:13 +03:00
|
|
|
defined($topSrcDir) || die("Command-line option -t <topsrcdir> missing.");
|
2004-10-02 05:39:39 +04:00
|
|
|
$src = $topSrcDir.$srcFile;
|
2004-11-30 02:14:13 +03:00
|
|
|
} elsif ($srcFile =~ s|^\%|/|) {
|
|
|
|
defined($localeDir) || die("Command-line option -c <localedir> missing.");
|
|
|
|
$src = $localeDir.$srcFile;
|
2004-10-02 05:39:39 +04:00
|
|
|
} elsif (! -e $src ) {
|
2004-03-02 00:12:29 +03:00
|
|
|
$src = "$srcPath/$srcFile";
|
|
|
|
}
|
2000-06-09 10:33:25 +04:00
|
|
|
}
|
2000-09-21 11:14:35 +04:00
|
|
|
else {
|
|
|
|
$src = "$srcPath/$destFile";
|
|
|
|
# check for the complete jar path in the dest dir
|
|
|
|
if (!-e $src) {
|
|
|
|
#else check for just the file name in the dest dir
|
|
|
|
my $dir = "";
|
|
|
|
my $file;
|
2002-04-24 22:08:47 +04:00
|
|
|
if ($destFile =~ /([\w\d.\-\_\\\/\+]+)[\\\/]([\w\d.\-\_]+)/) {
|
2000-09-21 11:14:35 +04:00
|
|
|
$dir = $1;
|
|
|
|
$file = $2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
die "file not found: $srcPath/$destFile";
|
|
|
|
}
|
|
|
|
$src = "$srcPath/$file";
|
|
|
|
if (!-e $src) {
|
|
|
|
die "file not found: $srcPath/$destFile";
|
|
|
|
}
|
|
|
|
}
|
2000-09-12 09:10:48 +04:00
|
|
|
}
|
2000-08-11 09:16:15 +04:00
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
$srcPath = $src;
|
|
|
|
$destPath = "$destPath/$destFile";
|
2000-08-11 09:16:15 +04:00
|
|
|
|
2000-09-21 11:14:35 +04:00
|
|
|
my $srcStat = stat($srcPath);
|
|
|
|
my $srcMtime = $srcStat ? $srcStat->mtime : 0;
|
2000-07-11 10:40:09 +04:00
|
|
|
|
2000-09-20 23:35:24 +04:00
|
|
|
my $destStat = stat($destPath);
|
|
|
|
my $destMtime = $destStat ? $destStat->mtime : 0;
|
|
|
|
#print "destMtime = $destMtime, srcMtime = $srcMtime\n";
|
2000-09-21 11:14:35 +04:00
|
|
|
|
2000-09-21 02:45:45 +04:00
|
|
|
if (!-e $destPath || $destMtime < $srcMtime || $override) {
|
2000-09-20 23:35:24 +04:00
|
|
|
#print "copying $destPath, from $srcPath\n";
|
2000-07-12 11:50:37 +04:00
|
|
|
my $dir = "";
|
|
|
|
my $file;
|
2002-04-24 22:08:47 +04:00
|
|
|
if ($destPath =~ /([\w\d.\-\_\\\/\+]+)[\\\/]([\w\d.\-\_]+)/) {
|
2000-07-12 11:50:37 +04:00
|
|
|
$dir = $1;
|
|
|
|
$file = $2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$file = $destPath;
|
|
|
|
}
|
2000-07-11 10:40:09 +04:00
|
|
|
|
|
|
|
if ($srcPath) {
|
|
|
|
$file = $srcPath;
|
|
|
|
}
|
2002-11-09 02:04:01 +03:00
|
|
|
$objPath = "$objdir/$destFile";
|
2000-07-11 10:40:09 +04:00
|
|
|
|
2000-06-09 10:33:25 +04:00
|
|
|
if (!-e $file) {
|
2002-11-09 02:04:01 +03:00
|
|
|
if (!-e $objPath) {
|
|
|
|
die "error: file '$file' doesn't exist";
|
|
|
|
} else {
|
|
|
|
$file = "$objPath";
|
|
|
|
}
|
2000-09-21 11:14:35 +04:00
|
|
|
}
|
|
|
|
if (!-e $dir) {
|
2000-09-22 04:31:58 +04:00
|
|
|
mkpath($dir, 0, 0775) || die "can't mkpath $dir: $!";
|
2000-06-09 10:33:25 +04:00
|
|
|
}
|
2000-09-21 21:23:29 +04:00
|
|
|
unlink $destPath; # in case we had a symlink on unix
|
2002-10-10 07:11:27 +04:00
|
|
|
if ($preproc) {
|
2005-08-26 16:49:37 +04:00
|
|
|
my $preproc_flags = '';
|
|
|
|
if ($srcFile =~ /\.css$/o) {
|
|
|
|
$preproc_flags = '--marker=%';
|
|
|
|
}
|
|
|
|
|
2004-03-02 00:12:29 +03:00
|
|
|
my $preproc_file = $file;
|
|
|
|
if ($^O eq 'cygwin' && $file =~ /^[a-zA-Z]:/) {
|
|
|
|
# convert to a cygwin path
|
|
|
|
$preproc_file =~ s|^([a-zA-Z]):|$cygwin_mountprefix/\1|;
|
|
|
|
}
|
|
|
|
if ($vms) {
|
|
|
|
# use a temporary file otherwise cmd is too long for system()
|
|
|
|
my $tmpFile = "$destPath.tmp";
|
|
|
|
open(TMP, ">$tmpFile") || die("$tmpFile: $!");
|
2005-08-26 16:49:37 +04:00
|
|
|
print(TMP "$^X $preprocessor $preproc_flags $defines $preproc_file > $destPath");
|
2004-03-02 00:12:29 +03:00
|
|
|
close(TMP);
|
|
|
|
print "+++ preprocessing $preproc_file > $destPath\n";
|
|
|
|
if (system("bash \"$tmpFile\"") != 0) {
|
2003-01-22 07:16:58 +03:00
|
|
|
die "Preprocessing of $file failed (VMS): ".($? >> 8);
|
2004-03-02 00:12:29 +03:00
|
|
|
}
|
|
|
|
unlink("$tmpFile") || die("$tmpFile: $!");
|
|
|
|
} else {
|
2005-08-26 16:49:37 +04:00
|
|
|
if (system("$^X $preprocessor $preproc_flags $defines $preproc_file > $destPath") != 0) {
|
2004-03-02 00:12:29 +03:00
|
|
|
die "Preprocessing of $file failed: ".($? >> 8);
|
|
|
|
}
|
|
|
|
}
|
2003-10-30 12:24:40 +03:00
|
|
|
} elsif ("$fileformat" eq "symlink") {
|
|
|
|
$file = _moz_abs2rel($file, $destPath);
|
|
|
|
symlink($file, $destPath) || die "symlink($file, $destPath) failed: $!";
|
|
|
|
return 1;
|
2002-10-10 07:11:27 +04:00
|
|
|
} else {
|
|
|
|
copy($file, $destPath) || die "copy($file, $destPath) failed: $!";
|
|
|
|
}
|
2000-09-21 11:14:35 +04:00
|
|
|
|
|
|
|
# fix the mod date so we don't jar everything (is this faster than just jarring everything?)
|
|
|
|
my $mtime = stat($file)->mtime || die $!;
|
2002-04-12 10:01:39 +04:00
|
|
|
my $atime = stat($file)->atime;
|
|
|
|
$atime = $mtime if !defined($atime);
|
2000-09-21 11:14:35 +04:00
|
|
|
utime($atime, $mtime, $destPath);
|
|
|
|
|
2000-06-09 10:33:25 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-21 22:17:15 +04:00
|
|
|
my @gLines = <STDIN>;
|
|
|
|
|
|
|
|
while (defined($_ = shift @gLines)) {
|
2000-06-09 10:33:25 +04:00
|
|
|
chomp;
|
2004-03-02 00:12:29 +03:00
|
|
|
|
|
|
|
start:
|
2000-09-21 11:14:35 +04:00
|
|
|
if (/^([\w\d.\-\_\\\/]+).jar\:\s*$/) {
|
2000-09-12 03:08:41 +04:00
|
|
|
my $jarfile = $1;
|
2000-06-09 10:33:25 +04:00
|
|
|
my $args = "";
|
2000-09-12 03:08:41 +04:00
|
|
|
my $overrides = "";
|
2004-03-02 00:12:29 +03:00
|
|
|
my $cwd = cwd();
|
2005-04-15 16:31:49 +04:00
|
|
|
my @manifestLines;
|
|
|
|
|
2005-07-28 20:17:15 +04:00
|
|
|
print "+++ making chrome $cwd => $jarDir/$jarfile.jar\n";
|
2004-07-21 22:17:15 +04:00
|
|
|
while (defined($_ = shift @gLines)) {
|
2004-11-30 02:14:13 +03:00
|
|
|
if (/^\s+([\w\d.\-\_\\\/\+]+)\s*(\(\%?[\w\d.\-\_\\\/]+\))?$\s*/) {
|
2000-08-04 00:58:31 +04:00
|
|
|
my $dest = $1;
|
2000-09-21 11:14:35 +04:00
|
|
|
my $srcPath = defined($2) ? substr($2, 1, -1) : $2;
|
2004-03-02 00:12:29 +03:00
|
|
|
EnsureFileInDir("$chromeDir/$jarfile", $baseFilesDir, $dest, $srcPath, 0, 0);
|
2000-07-11 10:40:09 +04:00
|
|
|
$args = "$args$dest ";
|
2006-04-08 15:49:47 +04:00
|
|
|
if (!foreignPlatformFile($jarfile) && !foreignPlatformPath($dest) && $autoreg &&
|
2004-03-02 00:12:29 +03:00
|
|
|
$dest =~ /([\w\d.\-\_\+]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
|
|
|
|
{
|
|
|
|
my $chrome_type = $1;
|
|
|
|
my $pkg_name = $2;
|
|
|
|
RegIt($chromeDir, $jarfile, $chrome_type, $pkg_name);
|
|
|
|
}
|
2004-11-30 02:14:13 +03:00
|
|
|
} elsif (/^\+\s+([\w\d.\-\_\\\/\+]+)\s*(\(\%?[\w\d.\-\_\\\/]+\))?$\s*/) {
|
2000-09-12 03:08:41 +04:00
|
|
|
my $dest = $1;
|
2000-09-21 11:14:35 +04:00
|
|
|
my $srcPath = defined($2) ? substr($2, 1, -1) : $2;
|
2002-10-10 07:11:27 +04:00
|
|
|
EnsureFileInDir("$chromeDir/$jarfile", $baseFilesDir, $dest, $srcPath, 1, 0);
|
2000-09-12 03:08:41 +04:00
|
|
|
$overrides = "$overrides$dest ";
|
2006-04-08 15:49:47 +04:00
|
|
|
if (!foreignPlatformFile($jarfile) && !foreignPlatformPath($dest) && $autoreg &&
|
|
|
|
$dest =~ /([\w\d.\-\_\+]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
|
2004-03-02 00:12:29 +03:00
|
|
|
{
|
|
|
|
my $chrome_type = $1;
|
|
|
|
my $pkg_name = $2;
|
|
|
|
RegIt($chromeDir, $jarfile, $chrome_type, $pkg_name);
|
|
|
|
}
|
2004-11-30 02:14:13 +03:00
|
|
|
} elsif (/^\*\+?\s+([\w\d.\-\_\\\/\+]+)\s*(\(\%?[\w\d.\-\_\\\/]+\))?$\s*/) {
|
2004-03-02 00:12:29 +03:00
|
|
|
# preprocessed (always override)
|
|
|
|
my $dest = $1;
|
|
|
|
my $srcPath = defined($2) ? substr($2, 1, -1) : $2;
|
|
|
|
EnsureFileInDir("$chromeDir/$jarfile", $baseFilesDir, $dest, $srcPath, 1, 1);
|
2004-03-02 05:59:28 +03:00
|
|
|
$overrides = "$overrides$dest ";
|
2006-04-08 15:49:47 +04:00
|
|
|
if (!foreignPlatformFile($jarfile) && !foreignPlatformPath($dest) && $autoreg &&
|
|
|
|
$dest =~ /([\w\d.\-\_\+]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
|
2004-03-02 00:12:29 +03:00
|
|
|
{
|
|
|
|
my $chrome_type = $1;
|
|
|
|
my $pkg_name = $2;
|
|
|
|
RegIt($chromeDir, $jarfile, $chrome_type, $pkg_name);
|
|
|
|
}
|
2005-04-15 16:31:49 +04:00
|
|
|
} elsif (/^\%\s+(.*)$/) {
|
|
|
|
my $path = $1;
|
|
|
|
|
2005-06-01 15:59:09 +04:00
|
|
|
my $jarpath = $jarfile;
|
|
|
|
$jarpath = "chrome/".$jarfile if $useExtensionManifest;
|
|
|
|
|
2005-04-15 16:31:49 +04:00
|
|
|
if ($fileformat eq "flat" || $fileformat eq "symlink") {
|
2005-06-01 15:59:09 +04:00
|
|
|
$path =~ s|\%|$jarpath/$1|;
|
2005-04-15 16:31:49 +04:00
|
|
|
} else {
|
2005-06-01 15:59:09 +04:00
|
|
|
$path =~ s|\%|jar:$jarpath.jar!/$1|;
|
2005-04-15 16:31:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
push @manifestLines, $path;
|
2005-04-14 21:36:55 +04:00
|
|
|
} elsif (/^\s*$/) {
|
|
|
|
# end with blank line
|
|
|
|
last;
|
|
|
|
} else {
|
2005-07-28 20:17:15 +04:00
|
|
|
my $manifest = "$jarDir/$jarfile.manifest";
|
|
|
|
my $manifest = "$jarDir/../chrome.manifest" if $useExtensionManifest;
|
2005-06-01 15:59:09 +04:00
|
|
|
UniqIt($manifest, @manifestLines);
|
2005-07-28 20:17:15 +04:00
|
|
|
JarIt($chromeDir, $jarDir, $jarfile, $args, $overrides);
|
2000-06-09 10:33:25 +04:00
|
|
|
goto start;
|
|
|
|
}
|
|
|
|
}
|
2005-07-28 20:17:15 +04:00
|
|
|
my $manifest = "$jarDir/$jarfile.manifest";
|
|
|
|
$manifest = "$jarDir/../chrome.manifest" if $useExtensionManifest;
|
2005-06-01 15:59:09 +04:00
|
|
|
UniqIt($manifest, @manifestLines);
|
2005-07-28 20:17:15 +04:00
|
|
|
JarIt($chromeDir, $jarDir, $jarfile, $args, $overrides);
|
2000-08-11 09:16:15 +04:00
|
|
|
|
2000-06-09 10:33:25 +04:00
|
|
|
} elsif (/^\s*\#.*$/) {
|
|
|
|
# skip comments
|
|
|
|
} elsif (/^\s*$/) {
|
|
|
|
# skip blank lines
|
|
|
|
} else {
|
|
|
|
close;
|
|
|
|
die "bad jar rule head at: $_";
|
|
|
|
}
|
2000-08-11 09:16:15 +04:00
|
|
|
}
|