diff --git a/config/make-jars.pl b/config/make-jars.pl index 95fac52c4608..7a46b3256721 100644 --- a/config/make-jars.pl +++ b/config/make-jars.pl @@ -80,9 +80,6 @@ my $jarDir = $chromeDir; if (defined($::opt_j)) { $jarDir = $::opt_j; } -if ($jarDir !~ /^\//) { - $jarDir = getcwd() . '/' . $jarDir; -} my $verbose = 0; if (defined($::opt_v)) { @@ -218,7 +215,10 @@ sub JarIt { my ($destPath, $jarPath, $jarfile, $args, $overrides) = @_; my $oldDir = cwd(); - my $jarchive = $jarPath . '/' . $jarfile . '.jar'; + my @destPath = _moz_splitpath("$destPath/$jarfile"); + my @jarchive = _moz_splitpath("$jarPath/$jarfile.jar"); + shift @destPath, shift @jarchive while $destPath[0] eq $jarchive[0]; + my $jarchive = "../" x @destPath . join("/", @jarchive); chdir("$destPath/$jarfile"); if ("$fileformat" eq "flat" || "$fileformat" eq "symlink") { @@ -288,6 +288,17 @@ sub JarIt #print "cd $oldDir\n"; } +sub _moz_splitpath +{ + my ($path) = @_; + my @dirs = split(m:/:, $path); + foreach (reverse 0 .. $#dirs) { + splice(@dirs, $_, 1) if $dirs[$_] eq "."; + splice(@dirs, $_, 2) if $dirs[$_] eq ".."; + } + return @dirs; +} + sub _moz_rel2abs { my ($path, $keep_file) = @_;