1999-12-11 02:44:37 +03:00
|
|
|
#!/usr/bin/perl -w
|
1999-10-19 01:44:15 +04:00
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Netscape Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/NPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is Mozilla Communicator client code, released
|
|
|
|
# March 31, 1998.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape
|
|
|
|
# Communications Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
|
|
|
# Sean Su <ssu@netscape.com>
|
1999-12-11 02:44:37 +03:00
|
|
|
# Samir Gehani <sgehani@netscape.com>
|
1999-10-19 01:44:15 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# This perl script creates .xpi files given component input name
|
|
|
|
#
|
|
|
|
# Input: component name
|
|
|
|
# - name of the component directory located in the staging path
|
|
|
|
# staging path
|
|
|
|
# - path to where the built files are staged at
|
|
|
|
# dest path
|
|
|
|
# - path to where the .xpi files are are to be created at.
|
|
|
|
# ** MUST BE AN ABSOLUTE PATH, NOT A RELATIVE PATH **
|
|
|
|
#
|
1999-12-11 02:44:37 +03:00
|
|
|
# ie: perl makexpi.pl core z:\exposed\windows\32bit\en\5.0
|
|
|
|
# d:\build\mozilla\dist\win32_o.obj\install\working
|
1999-10-19 01:44:15 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
use Cwd;
|
|
|
|
|
2001-06-28 07:10:38 +04:00
|
|
|
##
|
|
|
|
# RecursiveStrip
|
|
|
|
#
|
|
|
|
# Strips all libs by recursing into all directories and calling
|
|
|
|
# the strip utility on all *.so files.
|
|
|
|
#
|
|
|
|
# @param targetDir the directory to traverse recursively
|
|
|
|
#
|
|
|
|
sub RecursiveStrip
|
|
|
|
{
|
|
|
|
my($targetDir) = $_[0];
|
|
|
|
my(@dirEntries) = ();
|
|
|
|
my($entry) = "";
|
|
|
|
my($saveCwd) = cwd();
|
|
|
|
|
|
|
|
@dirEntries = <$targetDir/*>;
|
|
|
|
|
|
|
|
# strip all .so files in this dir
|
|
|
|
chdir($targetDir); # push targetDir
|
2003-04-05 02:22:01 +04:00
|
|
|
system("strip *.so > /dev/null 2>&1");
|
2001-06-28 07:10:38 +04:00
|
|
|
chdir($saveCwd); # pop targetDir
|
|
|
|
|
|
|
|
# iterate over all subdir entries
|
|
|
|
foreach $entry ( @dirEntries )
|
|
|
|
{
|
|
|
|
# if dir entry is dir
|
|
|
|
if (-d $entry)
|
|
|
|
{
|
|
|
|
# recurse into subdir
|
|
|
|
RecursiveStrip($entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-19 01:44:15 +04:00
|
|
|
# Make sure there are at least three arguments
|
|
|
|
if($#ARGV < 2)
|
|
|
|
{
|
|
|
|
die "usage: $0 <component name> <staging path> <dest path>
|
|
|
|
|
|
|
|
component name : name of component directory within staging path
|
|
|
|
staging path : path to where the components are staged at
|
|
|
|
dest path : path to where the .xpi files are to be created at
|
|
|
|
\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$inComponentName = $ARGV[0];
|
|
|
|
$inStagePath = $ARGV[1];
|
|
|
|
$inDestPath = $ARGV[2];
|
|
|
|
|
1999-12-11 02:44:37 +03:00
|
|
|
# check for existence of staging component path
|
1999-10-19 01:44:15 +04:00
|
|
|
if(!(-e "$inStagePath/$inComponentName"))
|
|
|
|
{
|
|
|
|
die "invalid path: $inStagePath/$inComponentName\n";
|
|
|
|
}
|
|
|
|
|
1999-12-11 02:44:37 +03:00
|
|
|
# check for existence of .js script
|
1999-10-19 01:44:15 +04:00
|
|
|
if(!(-e "$inComponentName.js"))
|
|
|
|
{
|
|
|
|
die "missing .js script: $inComponentName.js\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# delete component .xpi file
|
|
|
|
if(-e "$inDestPath/$inComponentName.xpi")
|
|
|
|
{
|
|
|
|
unlink("$inDestPath/$inComponentName.xpi");
|
|
|
|
}
|
1999-12-11 02:44:37 +03:00
|
|
|
if(-e "$inStagePath/$inComponentName/$inComponentName.xpi")
|
1999-10-19 01:44:15 +04:00
|
|
|
{
|
|
|
|
unlink("$inDestPath/$inComponentName.xpi");
|
|
|
|
}
|
|
|
|
|
|
|
|
# delete install.js
|
|
|
|
if(-e "install.js")
|
|
|
|
{
|
|
|
|
unlink("install.js");
|
|
|
|
}
|
|
|
|
|
|
|
|
# make sure inDestPath exists
|
|
|
|
if(!(-e "$inDestPath"))
|
|
|
|
{
|
|
|
|
system("mkdir $inDestPath");
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\n Making $inComponentName.xpi...\n";
|
|
|
|
|
|
|
|
$saveCwdir = cwd();
|
|
|
|
|
|
|
|
# change directory to where the files are, else zip will store
|
|
|
|
# unwanted path information.
|
|
|
|
chdir("$inStagePath/$inComponentName");
|
2000-04-05 09:06:29 +04:00
|
|
|
|
2001-06-28 07:10:38 +04:00
|
|
|
# strip libs
|
|
|
|
print "stripping libs in $inStagePath/$inComponentName...\n";
|
|
|
|
RecursiveStrip(cwd());
|
|
|
|
|
2001-09-21 03:33:23 +04:00
|
|
|
system("zip -r -y $inDestPath/$inComponentName.xpi *");
|
1999-10-19 01:44:15 +04:00
|
|
|
chdir("$saveCwdir");
|
|
|
|
|
2000-04-05 09:06:29 +04:00
|
|
|
system("cp $inComponentName.js install.js");
|
1999-10-19 01:44:15 +04:00
|
|
|
system("zip -g $inDestPath/$inComponentName.xpi install.js");
|
|
|
|
|
|
|
|
# delete install.js
|
|
|
|
if(-e "install.js")
|
|
|
|
{
|
|
|
|
unlink("install.js");
|
|
|
|
}
|
|
|
|
|
|
|
|
print " done!\n";
|
|
|
|
|
|
|
|
# end of script
|
|
|
|
exit(0);
|
|
|
|
|