Bug 780561 - Remove now unused bits of the packaging scripts. r=ted

This commit is contained in:
Mike Hommey 2013-01-23 11:23:15 +01:00
Родитель 5ad44af9bd
Коммит 2434030c1f
17 изменённых файлов: 3 добавлений и 1647 удалений

Просмотреть файл

@ -28,12 +28,7 @@ DEFINES += \
-DPREF_DIR=$(PREF_DIR) \
$(NULL)
ifeq ($(MOZ_CHROME_FILE_FORMAT),jar)
JAREXT=.jar
else
JAREXT=
endif
DEFINES += -DJAREXT=$(JAREXT)
DEFINES += -DJAREXT=
include $(topsrcdir)/ipc/app/defs.mk
DEFINES += -DMOZ_CHILD_PROCESS_NAME=$(MOZ_CHILD_PROCESS_NAME)

Просмотреть файл

@ -60,11 +60,7 @@ ifdef _MSC_VER
DEFINES += -D_MSC_VER=$(_MSC_VER)
endif
ifeq ($(MOZ_CHROME_FILE_FORMAT),jar)
DEFINES += -DJAREXT=.jar
else
DEFINES += -DJAREXT=
endif
ifdef MOZ_ANGLE_RENDERER
DEFINES += -DMOZ_ANGLE_RENDERER=$(MOZ_ANGLE_RENDERER)

Просмотреть файл

@ -178,86 +178,6 @@ libs:: $(topsrcdir)/tools/rb/fix_stack_using_bpsyms.py
ifeq ($(OS_ARCH),Darwin)
libs:: $(topsrcdir)/tools/rb/fix_macosx_stack.py
$(INSTALL) $< $(DIST)/bin
# Basic unit tests for some stuff in the unify script
check::
# build x64/i386 binaries, and unify them
rm -f unify-test-x64 unify-test-i386 unify-test-universal
$(HOST_CC) -arch x86_64 $(srcdir)/unify-test.c -o unify-test-x64
$(HOST_CC) -arch i386 $(srcdir)/unify-test.c -o unify-test-i386
@if ! $(srcdir)/macosx/universal/unify ./unify-test-x64 ./unify-test-i386 \
./unify-test-universal; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary!"; \
false; \
fi
@if test ! -f ./unify-test-universal; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary!"; \
false; \
fi
@if ! file -b ./unify-test-universal | head -n1 | grep -q "^Mach-O universal binary"; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary!"; \
false; \
else \
echo "TEST-PASS | build/ | unify produced a universal binary!"; \
fi
# try building an x86-64 binary. if that succeeds, try unifying it
# with an i386 binary
rm -f unify-test-x86_64 unify-test-universal-64
-$(HOST_CC) -arch x86_64 $(srcdir)/unify-test.c -o unify-test-x86_64
@if test -f ./unify-test-x86_64; then \
if ! $(srcdir)/macosx/universal/unify ./unify-test-x86_64 ./unify-test-i386 \
./unify-test-universal-64; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \
false; \
fi; \
if test ! -f ./unify-test-universal-64; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \
false; \
fi; \
if ! file -b ./unify-test-universal-64 | head -n1 | grep -q "^Mach-O universal binary"; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \
false; \
else \
echo "TEST-PASS | build/ | unify produced a universal binary with a 64-bit input!"; \
fi \
fi
# try unifying two identical Java class files
rm -f unifytesta.class unifytestb.class unifytestc.class
cp $(srcdir)/unifytest.class ./unifytesta.class
cp $(srcdir)/unifytest.class ./unifytestb.class
@if ! $(srcdir)/macosx/universal/unify ./unifytesta.class ./unifytestb.class \
./unifytestc.class; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify a Java class file!"; \
false; \
fi
@if test ! -f ./unifytestc.class; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify a Java class file!"; \
false; \
fi
@if ! diff -q ./unifytesta.class ./unifytestc.class; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify a Java class file!"; \
false; \
else \
echo "TEST-PASS | build/ | unify unified a Java class file!"; \
fi
# try unifying some files that differ only in line ordering
rm -rf unify-sort-test
mkdir unify-sort-test unify-sort-test/a unify-sort-test/b
printf "lmn\nabc\nxyz\n" > unify-sort-test/a/file.foo
printf "xyz\nlmn\nabc" > unify-sort-test/b/file.foo
printf "lmn\nabc\nxyz\n" > unify-sort-test/expected-result
@if ! $(srcdir)/macosx/universal/unify --unify-with-sort "\.foo$$" \
./unify-sort-test/a ./unify-sort-test/b \
./unify-sort-test/c; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify files with differing line ordering!"; \
false; \
fi
@if ! diff -q ./unify-sort-test/expected-result ./unify-sort-test/c/file.foo; then \
echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify files with differing line ordering!"; \
false; \
else \
echo "TEST-PASS | build/ | unify unified files with differing line ordering!"; \
fi
endif
ifeq ($(OS_ARCH),Linux)

Просмотреть файл

@ -1,144 +0,0 @@
#!/usr/bin/perl
# 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/.
use strict;
use warnings;
use Archive::Zip(':ERROR_CODES');
my ($BUILDCONFIG);
sub fixBuildconfig($$$);
$BUILDCONFIG = 'content/global/buildconfig.html';
if (scalar(@ARGV) != 3) {
print STDERR ("usage: fix-buildconfig <jar|file> <file1> <file2>\n");
exit(1);
}
if (!fixBuildconfig($ARGV[0], $ARGV[1], $ARGV[2])) {
exit(1);
}
exit(0);
sub fixBuildconfig($$$) {
my ($mode, $path1, $path2);
($mode, $path1, $path2) = @_;
if ($mode ne 'jar' && $mode ne 'file') {
print STDERR ($0.': must specify jar or file\n');
return 0;
}
my ($contents1, $contents2);
my ($ze, $zip1, $zip2);
if ($mode eq 'jar') {
$zip1 = Archive::Zip->new();
if (($ze = $zip1->read($path1)) != AZ_OK) {
print STDERR ($0.': could not read "'.$path1.'": error '.$ze."\n");
return 0;
}
$zip2 = Archive::Zip->new();
if (($ze = $zip2->read($path2)) != AZ_OK) {
print STDERR ($0.': could not read "'.$path2.'": error '.$ze."\n");
return 0;
}
$contents1 = $zip1->contents($BUILDCONFIG);
$contents2 = $zip2->contents($BUILDCONFIG);
} elsif ($mode eq 'file') {
local($/);
my ($file1, $file2);
open($file1, '<'.$path1.$BUILDCONFIG) or return 0;
open($file2, '<'.$path2.$BUILDCONFIG) or return 0;
$contents1 = <$file1>;
$contents2 = <$file2>;
close($file1);
close($file2);
}
if (!defined($contents1)) {
print STDERR ($0.': could not get "'.$BUILDCONFIG.'" from "'.$path1.'"'.
"\n");
return 0;
}
if (!defined($contents2)) {
print STDERR ($0.': could not get "'.$BUILDCONFIG.'" from "'.$path2.'"'.
"\n");
return 0;
}
my (@lines1, @lines2);
@lines1 = split(/\n/, $contents1);
@lines2 = split(/\n/, $contents2);
my ($line, @linesNew);
@linesNew = ();
# Copy everything from the first file up to the end of its <body>.
while ($line = shift(@lines1)) {
if ($line eq '</body>') {
last;
}
push(@linesNew, $line);
}
# Insert a <hr> between the two files.
push (@linesNew, '<hr> </hr>');
# Copy the second file's content beginning after its leading <h1>.
while ($line = shift(@lines2)) {
if ($line eq '<h1>about:buildconfig</h1>') {
last;
}
}
while ($line = shift(@lines2)) {
push(@linesNew, $line);
}
my ($contentsNew);
$contentsNew = join("\n", @linesNew);
if ($mode eq 'jar') {
if (!defined($zip1->contents($BUILDCONFIG, $contentsNew))) {
print STDERR ($0.': could not set "'.$BUILDCONFIG.'" to "'.$path1.'"'.
"\n");
return 0;
}
if (!defined($zip2->contents($BUILDCONFIG, $contentsNew))) {
print STDERR ($0.': could not set "'.$BUILDCONFIG.'" to "'.$path2.'"'.
"\n");
return 0;
}
if (($ze = $zip1->overwrite()) != AZ_OK) {
print STDERR ($0.': could not write "'.$path1.'": error '.$ze."\n");
return 0;
}
if (($ze = $zip2->overwrite()) != AZ_OK) {
print STDERR ($0.': could not write "'.$path2.'": error '.$ze."\n");
return 0;
}
} elsif ($mode eq 'file') {
my ($file1, $file2);
open($file1, '>'.$path1.$BUILDCONFIG) or return 0;
open($file2, '>'.$path2.$BUILDCONFIG) or return 0;
print $file1 ($contentsNew);
print $file2 ($contentsNew);
close($file1);
close($file2);
}
return 1;
}

Просмотреть файл

@ -751,8 +751,6 @@ DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
endif
OPTIMIZE_JARS_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/optimizejars.py)
CREATE_PRECOMPLETE_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/createprecomplete.py)
# MDDEPDIR is the subdirectory where dependency files are stored

Просмотреть файл

@ -1,341 +0,0 @@
# 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/.
import sys, os, subprocess, struct, re
local_file_header = [
("signature", "uint32"),
("min_version", "uint16"),
("general_flag", "uint16"),
("compression", "uint16"),
("lastmod_time", "uint16"),
("lastmod_date", "uint16"),
("crc32", "uint32"),
("compressed_size", "uint32"),
("uncompressed_size", "uint32"),
("filename_size", "uint16"),
("extra_field_size", "uint16"),
("filename", "filename_size"),
("extra_field", "extra_field_size"),
("data", "compressed_size")
]
cdir_entry = [
("signature", "uint32"),
("creator_version", "uint16"),
("min_version", "uint16"),
("general_flag", "uint16"),
("compression", "uint16"),
("lastmod_time", "uint16"),
("lastmod_date", "uint16"),
("crc32", "uint32"),
("compressed_size", "uint32"),
("uncompressed_size", "uint32"),
("filename_size", "uint16"),
("extrafield_size", "uint16"),
("filecomment_size", "uint16"),
("disknum", "uint16"),
("internal_attr", "uint16"),
("external_attr", "uint32"),
("offset", "uint32"),
("filename", "filename_size"),
("extrafield", "extrafield_size"),
("filecomment", "filecomment_size"),
]
cdir_end = [
("signature", "uint32"),
("disk_num", "uint16"),
("cdir_disk", "uint16"),
("disk_entries", "uint16"),
("cdir_entries", "uint16"),
("cdir_size", "uint32"),
("cdir_offset", "uint32"),
("comment_size", "uint16"),
]
type_mapping = { "uint32":"I", "uint16":"H"}
def format_struct (format):
string_fields = {}
fmt = "<"
for (name,value) in iter(format):
try:
fmt += type_mapping[value][0]
except KeyError:
string_fields[name] = value
return (fmt, string_fields)
def size_of(format):
return struct.calcsize(format_struct(format)[0])
class MyStruct:
def __init__(self, format, string_fields):
self.__dict__["struct_members"] = {}
self.__dict__["format"] = format
self.__dict__["string_fields"] = string_fields
def addMember(self, name, value):
self.__dict__["struct_members"][name] = value
def __getattr__(self, item):
try:
return self.__dict__["struct_members"][item]
except:
pass
print("no %s" %item)
print(self.__dict__["struct_members"])
raise AttributeError
def __setattr__(self, item, value):
if item in self.__dict__["struct_members"]:
self.__dict__["struct_members"][item] = value
else:
raise AttributeError
def pack(self):
extra_data = ""
values = []
string_fields = self.__dict__["string_fields"]
struct_members = self.__dict__["struct_members"]
format = self.__dict__["format"]
for (name,_) in format:
if name in string_fields:
extra_data = extra_data + struct_members[name]
else:
values.append(struct_members[name]);
return struct.pack(format_struct(format)[0], *values) + extra_data
ENDSIG = 0x06054b50
def assert_true(cond, msg):
if not cond:
raise Exception(msg)
exit(1)
class BinaryBlob:
def __init__(self, f):
self.data = open(f, "rb").read()
self.offset = 0
self.length = len(self.data)
def readAt(self, pos, length):
self.offset = pos + length
return self.data[pos:self.offset]
def read_struct (self, format, offset = None):
if offset == None:
offset = self.offset
(fstr, string_fields) = format_struct(format)
size = struct.calcsize(fstr)
data = self.readAt(offset, size)
ret = struct.unpack(fstr, data)
retstruct = MyStruct(format, string_fields)
i = 0
for (name,_) in iter(format):
member_desc = None
if not name in string_fields:
member_data = ret[i]
i = i + 1
else:
# zip has data fields which are described by other struct fields, this does
# additional reads to fill em in
member_desc = string_fields[name]
member_data = self.readAt(self.offset, retstruct.__getattr__(member_desc))
retstruct.addMember(name, member_data)
# sanity check serialization code
data = self.readAt(offset, self.offset - offset)
out_data = retstruct.pack()
assert_true(out_data == data, "Serialization fail %d !=%d"% (len(out_data), len(data)))
return retstruct
def optimizejar(jar, outjar, inlog = None):
if inlog is not None:
inlog = open(inlog).read().rstrip()
# in the case of an empty log still move the index forward
if len(inlog) == 0:
inlog = []
else:
inlog = inlog.split("\n")
outlog = []
jarblob = BinaryBlob(jar)
dirend = jarblob.read_struct(cdir_end, jarblob.length - size_of(cdir_end))
assert_true(dirend.signature == ENDSIG, "no signature in the end");
cdir_offset = dirend.cdir_offset
readahead = 0
if inlog is None and cdir_offset == 4:
readahead = struct.unpack("<I", jarblob.readAt(0, 4))[0]
print("%s: startup data ends at byte %d" % (outjar, readahead));
total_stripped = 0;
jarblob.offset = cdir_offset
central_directory = []
for i in range(0, dirend.cdir_entries):
entry = jarblob.read_struct(cdir_entry)
if entry.filename[-1:] == "/":
total_stripped += len(entry.pack())
else:
total_stripped += entry.extrafield_size
central_directory.append(entry)
reordered_count = 0
if inlog is not None:
dup_guard = set()
for ordered_name in inlog:
if ordered_name in dup_guard:
continue
else:
dup_guard.add(ordered_name)
found = False
for i in range(reordered_count, len(central_directory)):
if central_directory[i].filename == ordered_name:
# swap the cdir entries
tmp = central_directory[i]
central_directory[i] = central_directory[reordered_count]
central_directory[reordered_count] = tmp
reordered_count = reordered_count + 1
found = True
break
if not found:
print( "Can't find '%s' in %s" % (ordered_name, jar))
outfd = open(outjar, "wb")
out_offset = 0
if inlog is not None:
# have to put central directory at offset 4 cos 0 confuses some tools.
# This also lets us specify how many entries should be preread
dirend.cdir_offset = 4
# make room for central dir + end of dir + 4 extra bytes at front
out_offset = dirend.cdir_offset + dirend.cdir_size + size_of(cdir_end) - total_stripped
outfd.seek(out_offset)
cdir_data = ""
written_count = 0
crc_mapping = {}
dups_found = 0
dupe_bytes = 0
# store number of bytes suggested for readahead
for entry in central_directory:
# read in the header twice..first for comparison, second time for convenience when writing out
jarfile = jarblob.read_struct(local_file_header, entry.offset)
assert_true(jarfile.filename == entry.filename, "Directory/Localheader mismatch")
# drop directory entries
if entry.filename[-1:] == "/":
total_stripped += len(jarfile.pack())
dirend.cdir_entries -= 1
continue
# drop extra field data
else:
total_stripped += jarfile.extra_field_size;
entry.extrafield = jarfile.extra_field = ""
entry.extrafield_size = jarfile.extra_field_size = 0
# January 1st, 2010
entry.lastmod_date = jarfile.lastmod_date = ((2010 - 1980) << 9) | (1 << 5) | 1
entry.lastmod_time = jarfile.lastmod_time = 0
data = jarfile.pack()
outfd.write(data)
old_entry_offset = entry.offset
entry.offset = out_offset
out_offset = out_offset + len(data)
entry_data = entry.pack()
cdir_data += entry_data
expected_len = entry.filename_size + entry.extrafield_size + entry.filecomment_size
assert_true(len(entry_data) != expected_len,
"%s entry size - expected:%d got:%d" % (entry.filename, len(entry_data), expected_len))
written_count += 1
if entry.crc32 in crc_mapping:
dups_found += 1
dupe_bytes += entry.compressed_size + len(data) + len(entry_data)
print("%s\n\tis a duplicate of\n%s\n---"%(entry.filename, crc_mapping[entry.crc32]))
else:
crc_mapping[entry.crc32] = entry.filename;
if inlog is not None:
if written_count == reordered_count:
readahead = out_offset
print("%s: startup data ends at byte %d"%( outjar, readahead));
elif written_count < reordered_count:
pass
#print("%s @ %d" % (entry.filename, out_offset))
elif readahead >= old_entry_offset + len(data):
outlog.append(entry.filename)
reordered_count += 1
if inlog is None:
dirend.cdir_offset = out_offset
if dups_found > 0:
print("WARNING: Found %d duplicate files taking %d bytes"%(dups_found, dupe_bytes))
dirend.cdir_size = len(cdir_data)
dirend.disk_entries = dirend.cdir_entries
dirend_data = dirend.pack()
assert_true(size_of(cdir_end) == len(dirend_data), "Failed to serialize directory end correctly. Serialized size;%d, expected:%d"%(len(dirend_data), size_of(cdir_end)));
outfd.seek(dirend.cdir_offset)
outfd.write(cdir_data)
outfd.write(dirend_data)
# for ordered jars the central directory is written in the begining of the file, so a second central-directory
# entry has to be written in the end of the file
if inlog is not None:
outfd.seek(0)
outfd.write(struct.pack("<I", readahead));
outfd.seek(out_offset)
outfd.write(dirend_data)
print "Stripped %d bytes" % total_stripped
print "%s %d/%d in %s" % (("Ordered" if inlog is not None else "Deoptimized"),
reordered_count, len(central_directory), outjar)
outfd.close()
return outlog
if len(sys.argv) != 5:
print "Usage: --optimize|--deoptimize %s JAR_LOG_DIR IN_JAR_DIR OUT_JAR_DIR" % sys.argv[0]
exit(1)
jar_regex = re.compile("\\.jar?$")
def optimize(JAR_LOG_DIR, IN_JAR_DIR, OUT_JAR_DIR):
ls = os.listdir(IN_JAR_DIR)
for jarfile in ls:
if not re.search(jar_regex, jarfile):
continue
injarfile = os.path.join(IN_JAR_DIR, jarfile)
outjarfile = os.path.join(OUT_JAR_DIR, jarfile)
logfile = os.path.join(JAR_LOG_DIR, jarfile + ".log")
if not os.path.isfile(logfile):
logfile = None
optimizejar(injarfile, outjarfile, logfile)
def deoptimize(JAR_LOG_DIR, IN_JAR_DIR, OUT_JAR_DIR):
if not os.path.exists(JAR_LOG_DIR):
os.makedirs(JAR_LOG_DIR)
ls = os.listdir(IN_JAR_DIR)
for jarfile in ls:
if not re.search(jar_regex, jarfile):
continue
injarfile = os.path.join(IN_JAR_DIR, jarfile)
outjarfile = os.path.join(OUT_JAR_DIR, jarfile)
logfile = os.path.join(JAR_LOG_DIR, jarfile + ".log")
log = optimizejar(injarfile, outjarfile, None)
open(logfile, "wb").write("\n".join(log))
def main():
MODE = sys.argv[1]
JAR_LOG_DIR = sys.argv[2]
IN_JAR_DIR = sys.argv[3]
OUT_JAR_DIR = sys.argv[4]
if MODE == "--optimize":
optimize(JAR_LOG_DIR, IN_JAR_DIR, OUT_JAR_DIR)
elif MODE == "--deoptimize":
deoptimize(JAR_LOG_DIR, IN_JAR_DIR, OUT_JAR_DIR)
else:
print("Unknown mode %s" % MODE)
exit(1)
if __name__ == '__main__':
main()

Просмотреть файл

@ -751,8 +751,6 @@ DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
endif
OPTIMIZE_JARS_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/optimizejars.py)
CREATE_PRECOMPLETE_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/createprecomplete.py)
# MDDEPDIR is the subdirectory where dependency files are stored

Просмотреть файл

@ -34,12 +34,7 @@ DEFINES += \
-DPREF_DIR=$(PREF_DIR) \
$(NULL)
ifeq ($(MOZ_CHROME_FILE_FORMAT),jar)
JAREXT=.jar
else
JAREXT=
endif
DEFINES += -DJAREXT=$(JAREXT)
DEFINES += -DJAREXT=
include $(topsrcdir)/ipc/app/defs.mk
DEFINES += -DMOZ_CHILD_PROCESS_NAME=$(MOZ_CHILD_PROCESS_NAME)

Просмотреть файл

@ -34,12 +34,7 @@ DEFINES += \
-DPREF_DIR=$(PREF_DIR) \
$(NULL)
ifeq ($(MOZ_CHROME_FILE_FORMAT),jar)
JAREXT=.jar
else
JAREXT=
endif
DEFINES += -DJAREXT=$(JAREXT)
DEFINES += -DJAREXT=
include $(topsrcdir)/ipc/app/defs.mk
DEFINES += -DMOZ_CHILD_PROCESS_NAME=$(MOZ_CHILD_PROCESS_NAME)

Просмотреть файл

@ -1,647 +0,0 @@
#!perl -w
# 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/.
package Packager;
require 5.004;
use strict;
use File::stat;
use Cwd;
use File::Basename;
use File::Copy;
use File::Find;
use File::Path;
use File::stat;
require Exporter;
use vars qw(@ISA @EXPORT);
# Package that generates a jar manifest from an input file
@ISA = qw(Exporter);
@EXPORT = qw(
Copy
);
# initialize variables
my($saved_cwd) = cwd();
my($component) = ""; # current component being copied
my(@components) = (); # list of components to copy
my($components) = ""; # string version of @components
my($altdest) = ""; # alternate file destination
my($line) = ""; # line being processed
my($srcdir) = ""; # root directory being copied from
my($destdir) = ""; # root directory being copied to
my($package) = ""; # file listing files to copy
my($os) = ""; # os type (MSDOS, Unix)
my($lineno) = 0; # line # of package file for error text
my($debug) = 0; # controls amount of debug output
my($dirflag) = 0; # flag: are we copying a directory?
my($help) = 0; # flag: if set, print usage
my($fatal_warnings) = 0; # flag: whether package warnings (missing files or invalid entries) are fatal
my($flat) = 0; # copy everything into the package dir, not into separate
# component dirs
my($delayed_error) = 0; # flag: whether an error was found while reading the manifest but we still
# chose to finish reading it
#
# Copy
#
# Loop over each line in the specified manifest, copying into $destdir
#
sub Copy {
($srcdir, $destdir, $package, $os, $flat, $fatal_warnings, $help, $debug, @components) = @_;
check_arguments();
if ($os eq "MSDOS") {
$srcdir =~ s|\\|/|;
$destdir =~ s|\\|/|;
}
open (MANIFEST,"<$package") ||
die "Error: couldn't open file $package for reading: $!. Exiting...\n";
LINE: while (<MANIFEST>) {
$line = "";
$altdest = "";
$lineno++;
s/\\/\//g if ($os eq "MSDOS"); # Convert to posix path
s/\;.*//; # it's a comment, kill it.
s/^\s+//; # nuke leading whitespace
s/\s+$//; # nuke trailing whitespace
($debug >= 2) && print "\n";
($debug >= 8) && print "line $lineno:$_\n";
# it's a blank line, skip it.
/^$/ && do {
($debug >= 10) && print "blank line.\n";
next LINE;
};
# it's a new component
/^\[/ && do {
($debug >= 10) && print "component.\n";
$component = $_;
do_component();
next LINE;
};
# if we find a file before we have a component and we are in flat mode,
# copy it - allows for flat only files (installed-chrome.txt)
if (( $component eq "" ) && ($components eq "" ) && (!$flat)) {
next LINE;
}
# skip line if we're only copying specific components and outside
# those components
if (( $component eq "" ) && ($components ne "" )) {
($debug >= 10) && print "Not in specifed component. Skipping $_\n";
next LINE;
}
if ($line eq "") {
$line = $_; # if $line not set, set it.
}
if ($os ne "MSDOS") { # hack - need to fix for dos
$line =~ s|^/||; # strip any leading path delimiter
}
# delete the file or directory following the '-'
/^-/ && do {
$line =~ s/^-//; # strip leading '-'
($debug >= 10) && print "delete: $destdir/$component/$line\n";
do_delete ("$destdir", "$component", "$line");
next LINE;
};
# file/directory being copied to different target location
/\,/ && do {
/.*\,.*\,.*/ &&
die "Error: multiple commas not allowed ($package, $lineno): $_.\n";
($line, $altdest) = split (/\s*\,\s*/, $line, 2);
$line =~ s|/*$||; # strip any trailing path delimiters
$altdest =~ s|/*$||; # strip any trailing delimiter
($debug >= 10) && print "relocate: $line => $altdest.\n";
};
# if it has wildcards, do recursive copy.
/(?:\*|\?)/ && do {
($debug >= 10) && print "wildcard copy.\n";
do_wildcard ("$srcdir/$line");
next LINE;
};
# if it's a single file, copy it.
( -f "$srcdir/$line" ) && do {
($debug >= 10) && print "file copy.\n";
do_copyfile ();
next LINE;
};
# if it's a directory, do recursive copy.
(-d "$srcdir/$line") && do {
($debug >= 10) && print "directory copy.\n";
do_copydir ("$srcdir/$line");
next LINE;
};
# if we hit this, it's either a file in the package file that is
# not in the src directory, or it is not a valid entry.
delayed_die_or_warn("package error or possible missing or unnecessary file: $line ($package, $lineno).");
} # LINE
close (MANIFEST);
chdir ($saved_cwd);
if ($delayed_error) {
die "Error: found error(s) while packaging, see above for details.\n"
}
}
#
# Delete the given file or directory
#
sub do_delete
{
my ($targetpath) = $_[0];
my ($targetcomp) = $_[1];
my ($targetfile) = $_[2];
my ($target) = ($flat) ? "$targetpath/$targetfile" : "$targetpath/$targetcomp/$targetfile";
($debug >= 2) && print "do_delete():\n";
($debug >= 1) && print "-$targetfile\n";
if ( -f $target ) {
(! -w $target ) &&
die "Error: delete failed: $target not writeable ($package, $component, $lineno). Exiting...\n";
($debug >= 4) && print " unlink($target)\n";
unlink ($target) ||
die "Error: unlink() failed: $!. Exiting...\n";
} elsif ( -d $target ) {
(! -w $target ) &&
die "Error: delete failed: $target not writeable ($package, $component, $lineno). Exiting...\n";
($debug >= 4) && print " rmtree($target)\n";
rmtree ($target, 0, 0) ||
die "Error: rmtree() failed: $!. Exiting...\n";
} else {
warn "Warning: delete failed: $target is not a file or directory ($package, $component, $lineno).\n";
}
}
#
# Copy an individual file from the srcdir to the destdir.
#
# This is called by both the individual and batch/recursive copy routines,
# using $dirflag to check if called from do_copydir. Batch copy can pass in
# directories, so be sure to check first and break if it isn't a file.
#
sub do_copyfile
{
my ($destpath) = ""; # destination directory path
my ($destpathcomp) = ""; # ditto, but possibly including component dir
my ($destname) = ""; # destination file name
my ($destsuffix) = ""; # destination file name suffix
my ($altpath) = ""; # alternate destination directory path
my ($altname) = ""; # alternate destination file name
my ($altsuffix) = ""; # alternate destination file name suffix
my ($srcpath) = ""; # source file directory path
my ($srcname) = ""; # source file name
my ($srcsuffix) = ""; # source file name suffix
($debug >= 2) && print "do_copyfile():\n";
($debug >= 10) && print " cwd: " . getcwd() . "\n";
# set srcname correctly depending on how called
if ( $dirflag ) {
($srcname, $srcpath, $srcsuffix) = fileparse("$File::Find::name", '\..*?$');
} else {
($srcname, $srcpath, $srcsuffix) = fileparse("$srcdir/$line", '\..*?$');
}
($debug >= 4) && print " fileparse(src): '$srcpath $srcname $srcsuffix'\n";
# return if srcname is a directory from do_copydir
if ( -d "$srcpath$srcname$srcsuffix" ) {
($debug >= 10) && print " return: '$srcpath$srcname$srcsuffix' is a directory\n";
return;
}
else {
($debug >= 10) && print " '$srcpath$srcname$srcsuffix' is not a directory\n";
}
# set the destination path, if alternate destination given, use it.
if ($flat) {
# WebappRuntime has manifests that shouldn't be flattened, even though it
# gets packaged with Firefox, which does get flattened, so special-case it.
if ($srcsuffix eq ".manifest" && $srcpath =~ m'/(chrome|components)/$' &&
$component ne "WebappRuntime") {
my $subdir = $1;
if ($component eq "") {
die ("Manifest file was not part of a component.");
}
$destpathcomp = "$srcdir/manifests/$component/$subdir";
$altdest = "$srcname$srcsuffix";
}
elsif ($srcsuffix eq ".xpt" && $srcpath =~ m|/components/$|) {
if ($component eq "") {
die ("XPT file was not part of a component.");
}
$destpathcomp = "$srcdir/xpt/$component/components";
$altdest = "$srcname$srcsuffix";
}
else {
$destpathcomp = "$destdir";
}
} else {
if ( $component ne "" ) {
$destpathcomp = "$destdir/$component";
}
else {
$destpathcomp = "$destdir";
}
}
if ( $altdest ne "" ) {
if ( $dirflag ) { # directory copy to altdest
($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$altdest/$File::Find::name", '\..*?$');
# Todo: add MSDOS hack
$destpath =~ s|\Q$srcdir\E/$line/||; # rm info added by find
($debug >= 5) &&
print " dir copy to altdest: $destpath $destname $destsuffix\n";
} else { # single file copy to altdest
($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$altdest", '\..*?$');
($debug >= 5) &&
print " file copy to altdest: $destpath $destname $destsuffix\n";
}
} else {
if ( $dirflag ) { # directory copy, no altdest
my $destfile = $File::Find::name;
if ($os eq "MSDOS") {
$destfile =~ s|\\|/|;
}
$destfile =~ s|\Q$srcdir\E/||;
($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$destfile", '\..*?$');
($debug >= 5) &&
print " dir copy w/o altdest: $destpath $destname $destsuffix\n";
} else { # single file copy, no altdest
($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$line", '\..*?$');
($debug >= 5) &&
print " file copy w/o altdest: $destpath $destname $destsuffix\n";
}
}
# Translate: */../../*/bin/*
# into: */../../*/*
# (where the *'s are interpreted using shell-notation and
# it matches not only forward slashes but also backslashes.)
# $1 = */../../*/
# $2 = bin/
# $3 = *
if ($flat) {
$destpath =~ s|(.*[/\\]\.\.[/\\]\.\.[/\\].+[/\\])(bin[/\\])(.*)|$1$3|;
}
# create the destination path if it doesn't exist
if (! -d "$destpath" ) {
($debug >= 5) && print " mkpath($destpath)\n";
# For OS/2 - remove trailing '/'
chop($destpath);
mkpath ($destpath, 0, 0755) ||
die "Error: mkpath() failed: $!. Exiting...\n";
# Put delimiter back for copying...
$destpath = "$destpath/";
}
# path exists, source and destination known, time to copy
if ((-f "$srcpath$srcname$srcsuffix") && (-r "$srcpath$srcname$srcsuffix")) {
if ( $debug >= 1 ) {
if ( $dirflag ) {
print "$destname$destsuffix\n"; # from unglob
} else {
print "$line\n"; # from single file
}
if ( $debug >= 3 ) {
print " copy\t$srcpath$srcname$srcsuffix =>\n\t\t$destpath$destname$destsuffix\n";
}
}
if (stat("$destpath$destname$destsuffix") &&
stat("$srcpath$srcname$srcsuffix")->mtime < stat("$destpath$destname$destsuffix")->mtime) {
if ( $debug >= 3 ) {
print "source file older than destination, do not copy\n";
}
return;
}
unlink("$destpath$destname$destsuffix") if ( -e "$destpath$destname$destsuffix");
# If source is a symbolic link pointing in the same directory, create a
# symbolic link
if ((-l "$srcpath$srcname$srcsuffix") && (readlink("$srcpath$srcname$srcsuffix") !~ /\//)) {
symlink(readlink("$srcpath$srcname$srcsuffix"), "$destpath$destname$destsuffix") ||
die "Error: copy of symbolic link $srcpath$srcname$srcsuffix failed ($package, $component, $lineno): $!. Exiting...\n";
return;
}
copy ("$srcpath$srcname$srcsuffix", "$destpath$destname$destsuffix") ||
die "Error: copy of file $srcpath$srcname$srcsuffix failed ($package, $component, $lineno): $!. Exiting...\n";
# if this is unix, set the dest file permissions
# read permissions
my($st) = stat("$srcpath$srcname$srcsuffix") ||
die "Error: can't stat $srcpath$srcname$srcsuffix: $! Exiting...\n";
# set permissions
($debug >= 2) && print " chmod ".$st->mode." $destpath$destname$destsuffix\n";
chmod ($st->mode, "$destpath$destname$destsuffix") ||
warn "Warning: chmod of $destpath$destname$destsuffix failed: $!. Exiting...\n";
} else {
warn "Error: file $srcpath$srcname$srcsuffix is not a file or is not readable ($package, $component, $lineno).\n";
}
}
#
# Expand any wildcards and copy files and/or directories
#
# todo: pass individual files to do_copyfile, not do_copydir
#
sub do_wildcard
{
my ($entry) = $_[0];
my (@list) = ();
my ($item) = "";
($debug >= 2) && print "do_wildcard():\n";
if ( $entry =~ /(?:\*|\?)/ ) { # it's a wildcard,
@list = glob($entry); # expand it
($debug >= 4) && print " glob: $entry => @list\n";
foreach $item ( @list ) { # now copy each item in list
if ( -f $item ) {
($debug >= 10) && print " do_copyfile: $item\n";
# glob adds full path to item like find() in copydir so
# take advantage of existing code in copyfile by using
# $dirflag and $File::Find::name.
$File::Find::name = $item;
$dirflag = 1;
do_copyfile();
$dirflag = 0;
$File::Find::name = "";
} elsif ( -d $item ) {
($debug >= 10) && print " do_copydir($item)\n";
do_copydir ($item);
} else {
warn "Warning: $item is not a file or directory ($package, $component, $lineno). Skipped...\n";
}
}
}
}
#
# Recursively copy directories specified.
#
sub do_copydir
{
my ($entry) = $_[0];
$dirflag = 1; # flag indicating directory copy in progress
($debug >= 2) && print "do_copydir():\n";
if (! -d "$entry" ) {
warn "Warning: $entry is not a directory ($package, $component, $lineno). Skipped...\n";
}
($debug >= 4) && print " find($entry)\n";
find (\&do_copyfile, $entry);
$dirflag = 0;
}
#
# Handle new component
#
sub do_component
{
($debug >= 2) && print "do_component():\n";
( $component =~ /^\[.*(?:\s|\[|\])+.*\]/ ) && # no brackets or ws
die "Error: malformed component $component. Exiting...\n";
$component =~ s/^\[(.*)\]/$1/; # strip []
if ( $components ne "") {
if ( $components =~ /$component/ ) {
($debug >= 10) && print "Component $component is in $components.\n";
} else {
($debug >= 10) && print "Component $component not in $components.\n";
$component = "";
return; # named specific components and this isn't it
}
}
if ($debug >= 1) {
print "[$component]\n";
}
# create component directory
if (!$flat) {
if ( -d "$destdir/$component" ) {
warn "Warning: component directory \"$component\" already exists in \"$destdir\".\n";
} else {
($debug >= 4) && print " mkdir $destdir/$component\n";
mkdir ("$destdir/$component", 0755) ||
die "Error: couldn't create component directory \"$component\": $!. Exiting...\n";
}
}
}
#
# Print error (and die later) or warn, based on whether $fatal_warnings is set.
#
sub delayed_die_or_warn
{
my ($msg) = $_[0];
if ($fatal_warnings) {
warn "Error: $msg\n";
$delayed_error = 1;
} else {
warn "Warning: $msg\n";
}
}
#
# Check that arguments to script are valid.
#
sub check_arguments
{
my ($exitval) = 0;
($debug >= 2) && print "check_arguments():\n";
# if --help print usage
if ($help) {
print_usage();
exit (1);
}
# make sure required variables are set:
# check source directory
if ( $srcdir eq "" ) {
print "Error: source directory (--source) not specified.\n";
$exitval += 8;
} elsif ((! -d $srcdir) || (! -r $srcdir)) {
print "Error: source directory \"$srcdir\" is not a directory or is unreadable.\n";
$exitval = 1;
}
# check destination directory
if ( $destdir eq "" ) {
print "Error: destination directory (--destination) not specified.\n";
$exitval += 8;
} elsif ((! -d $destdir) || (! -w $destdir)) {
print "Error: destination directory \"$destdir\" is not a directory or is not writeable.\n";
$exitval += 2;
}
# check destdir not a subdir of srcdir
# hack - workaround for bug 14558 that should be fixed eventually.
if (0) { # todo - write test
print "Error: destination directory must not be subdirectory of the source directory.\n";
$exitval += 32;
}
# check package file
if ( $package eq "" ) {
print "Error: package file (--file) not specified.\n";
$exitval += 8;
} elsif (!(-f $package) || !(-r $package)) {
print "Error: package file \"$package\" is not a file or is unreadable.\n";
$exitval += 4;
}
# check OS == {unix|dos}
if ($os eq "") {
print "Error: OS type (--os) not specified.\n";
$exitval += 8;
} elsif ( $os =~ /dos/i ) {
$os = "MSDOS";
fileparse_set_fstype ($os);
} elsif ( $os =~ /unix/i ) {
$os = "Unix"; # can be anything but MSDOS
fileparse_set_fstype ($os);
} else {
print "Error: OS type \"$os\" unknown.\n";
$exitval += 16;
}
# turn components array into a string for regexp
if ( @components > 0 ) {
$components = join (",",@components);
} else {
$components = "";
}
if ($debug > 4) {
print ("source dir:\t$srcdir\ndest dir:\t$destdir\npackage:\t$package\nOS:\t$os\ncomponents:\t$components\n");
}
if ($exitval) {
print "See \'$0 --help\' for more information.\n";
print "Exiting...\n";
exit ($exitval);
}
}
#
# display usage information
#
sub print_usage
{
($debug >= 2) && print "print_usage():\n";
print <<EOC
$0
Copy files from the source directory to component directories
in the destination directory as specified by the package file.
Options:
-s, --source <source directory>
Specifies the directory from which to copy the files
specified in the file passed via --file.
Required.
-d, --destination <destination directory>
Specifies the directory in which to create the component
directories and copy the files specified in the file passed
via --file.
Required.
NOTE: Source and destination directories must be absolute paths.
Relative paths will NOT work. Also, the destination directory
must NOT be a subdirectory of the source directory.
-f, --file <package file>
Specifies the file listing the components to be created in
the destination directory and the files to copy from the
source directory to each component directory in the
destination directory.
Required.
-o, --os [dos|unix]
Specifies which type of system this is. Used for parsing
file specifications from the package file.
Required.
-c, --component <component name>
Specifies a specific component in the package file to copy
rather than copying all the components in the package file.
Can be used more than once for multiple components (e.g.
"-c browser -c mail" to copy mail and news only).
Optional.
-l, --flat
Suppresses creation of components dirs, but stuffes everything
directly into the package destination dir. This is useful
for creating tarballs.
-h, --help
Prints this information.
Optional.
--debug [1-10]
Controls verbosity of debugging output, 10 being most verbose.
1 : same as --verbose.
2 : includes function calls.
3 : includes source and destination for each copy.
Optional.
-v, --verbose
Print component names and files copied/deleted.
Optional.
e.g.
$0 --os unix --source /builds/mozilla/dist --destination /h/lithium/install --file packages-win --os unix --verbose
Note: options can be specified by either a leading '--' or '-'.
EOC
}

Просмотреть файл

@ -1,24 +0,0 @@
# 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/.
import sys, os
outmanifest = sys.argv[1]
manifestdirs = sys.argv[2:]
outfd = open(outmanifest, 'w')
for manifestdir in manifestdirs:
if not os.path.isdir(manifestdir):
print >>sys.stderr, "Warning: trying to link manifests in missing directory '%s'" % manifestdir
continue
for name in os.listdir(manifestdir):
infd = open(os.path.join(manifestdir, name))
print >>outfd, "# %s" % name
outfd.write(infd.read())
print >>outfd
infd.close()
outfd.close()

Просмотреть файл

@ -1,21 +0,0 @@
REM This Source Code Form is subject to the terms of the Mozilla Public
REM License, v. 2.0. If a copy of the MPL was not distributed with this
REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
/* An adapted version of sign.cmd from NSS */
PARSE ARG dist filename
dist=forwardtoback(dist);
'@echo 'dist
'set BEGINLIBPATH='dist'\bin;%BEGINLIBPATH%'
'set LIBPATHSTRICT=T'
dist'\bin\shlibsign -v -i 'filename
exit
forwardtoback: procedure
arg pathname
parse var pathname pathname'/'rest
do while (rest <> "")
pathname = pathname'\'rest
parse var pathname pathname'/'rest
end
return pathname

Просмотреть файл

@ -1,10 +0,0 @@
REM This Source Code Form is subject to the terms of the Mozilla Public
REM License, v. 2.0. If a copy of the MPL was not distributed with this
REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
@rem compress binaries for optimum performance without disturbing chkdll32
@rem yes to: abort if in use, delete debug & extra data, leave non-resident names;
@rem align no-bounday/page-shift; no backup; use stdio; discard existing exe/dll settings;
@rem normal priority; packing: LZ, medium run lth, medium fixup; recursive search;
@rem unpack before pack; pack files; leave stub, remove debug & extra data;
lxlite *.exe *.dll /yua /ydd /yxd /ynl /anp /b- /cs+ /d /i- /ml1 /mr2 /mf2 /r+ /u+ /x- /zs:0 /zx /zd

Просмотреть файл

@ -1,13 +0,0 @@
# 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/.
import os, sys
filename = sys.argv[1]
with open(filename, 'r') as f:
for l in f.readlines():
l = l.strip()
if not l.startswith("bin/"):
continue
print l[4:]

Просмотреть файл

@ -595,9 +595,6 @@ stage-package: $(MOZ_PKG_MANIFEST)
$(addprefix --unify ,$(UNIFY_DIST)) \
$(MOZ_PKG_MANIFEST) $(DIST) $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/find-dupes.py $(DIST)/$(MOZ_PKG_DIR)
ifdef MOZ_POST_STAGING_CMD
cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(MOZ_POST_STAGING_CMD)
endif # MOZ_POST_STAGING_CMD
ifndef LIBXUL_SDK
ifdef MOZ_PACKAGE_JSSHELL
# Package JavaScript Shell

Просмотреть файл

@ -1,91 +0,0 @@
#!/usr/bin/perl -w
#
# 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/.
# pkgcp.pl -
#
# Parse a package file and copy the specified files for a component
# from the given source directory into the given destination directory
# for packaging by the install builder.
#
# Todo:
# - port to MacPerl
# - change warn()s to die()s to enforce updating package files.
# - change var names to standard form
# load modules
use Getopt::Long;
use File::Basename;
use Cwd;
# initialize variables
%components = (); # list of components to copy
$srcdir = ""; # root directory being copied from
$destdir = ""; # root directory being copied to
$package = ""; # file listing files to copy
$os = ""; # os type (MacOS, MSDOS, Unix, OS/2)
$verbose = 0; # shorthand for --debug 1
$debug = 0; # controls amount of debug output
$help = 0; # flag: if set, print usage
# get command line options
$return = GetOptions(
"source|s=s", \$srcdir,
"destination|d=s", \$destdir,
"file|f=s", \$package,
"os|o=s", \$os,
"component|c=s", \@components,
"help|h", \$help,
"debug=i", \$debug,
"verbose|v", \$verbose,
"flat|l", \$flat,
"<>", \&do_badargument
);
# set debug level
if ($verbose && !($debug)) {
$debug = 1;
} elsif ($debug != 0) {
$debug = abs ($debug);
($debug >= 2) && print "debug level: $debug\n";
}
# check usage
if (! $return)
{
die "Error: couldn't parse command line options. See \'$0 --help' for options.\nExiting...\n";
}
# ensure that Packager.pm is in @INC, since we might not be called from
# mozilla/toolkit/mozapps/installer.
$top_path = $0;
if ( $os eq "dos" ) {
$top_path =~ s/\\/\//g;
}
push(@INC, dirname($top_path));
require Packager;
if ( $os eq "os2" ) {
$cwd = cwd();
if ($srcdir !~ /^.:+/) {
$srcdir = $cwd."/".$srcdir;
}
$os = "unix";
}
Packager::Copy($srcdir, $destdir, $package, $os, $flat, $help, $debug, @components);
#
# This is called by GetOptions when there are extra command line arguments
# it doesn't understand.
#
sub do_badargument
{
warn "Warning: unknown command line option specified: @_.\n";
}
# EOF

Просмотреть файл

@ -1,247 +0,0 @@
#!/usr/bin/perl -w
#
# 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/.
# xptlink.pl -
#
# traverse directories created by pkgcp.pl and merge multiple .xpt files into
# a single .xpt file to improve startup performance.
#
use Getopt::Long;
# initialize variables
$srcdir = ""; # root directory being copied from
$destdir = ""; # root directory being copied to
$finaldir = ""; # where to put the final linked XPT
$verbose = 0; # shorthand for --debug 1
$debug = 0; # controls amount of debug output
$help = 0; # flag: if set, print usage
$xptlink = ""; # path to the xpt_link binary
# get command line options
$return = GetOptions( "source|s=s", \$srcdir,
"destination|d=s", \$destdir,
"final|f=s", \$finaldir,
"help|h", \$help,
"debug=i", \$debug,
"verbose|v", \$verbose,
"xptlink|x=s", \$xptlink,
"<>", \&do_badargument
);
if ($finaldir eq "") {
die "Error: -f is required";
}
my $bindir = "";
# remove extra slashes from $destdir
$destdir =~ s:/+:/:g;
# set debug level
if ($verbose && !($debug)) {
$debug = 1;
} elsif ($debug != 0) {
$debug = abs ($debug);
($debug >= 2) && print "debug level: $debug\n";
}
# check usage
if (! $return)
{
die "Error: couldn't parse command line options. See \'$0 --help' for options.\nExiting...\n";
} else {
check_arguments();
}
$xptdirs = (); # directories in the destination directory
($debug >= 1) && print "\nLinking .xpt files...\n";
($debug >= 2) && print "do_xptlink():\n";
# get list of directories on which to run xptlink
opendir (DESTDIR, "$destdir") ||
die "Error: could not open directory $destdir. Exiting...\n";
@xptdirs = sort ( grep (!/^\./, readdir (DESTDIR) ) );
($debug >= 4) && print "xptdirs: @xptdirs\n";
closedir (DESTDIR);
foreach my $component (@xptdirs) {
($debug >= 1) && print "[$component]\n";
print ("Checking for '$destdir/$component/$bindir"."components'\n") if $debug >= 3;
if (-d "$destdir/$component/$bindir"."components") {
warn "File '$destdir/$component/$bindir"."components/$component.xpt' already exists."
if -f "$destdir/$component/$bindir"."components/$component.xpt";
# create list of .xpt files in cwd
my @xptfiles;
($debug >= 4) && print "opendir: $destdir/$component/$bindir"."components\n";
opendir (COMPDIR, "$destdir/$component/$bindir"."components") ||
die "Error: cannot open $destdir/$component/$bindir"."components. Exiting...\n";
($debug >= 3) && print "Creating list of .xpt files...\n";
my @files = sort ( grep (!/^\./, readdir (COMPDIR)));
foreach my $file (@files) {
($debug >= 6) && print "$file\n";
if ( $file =~ /\.xpt$/ ) {
push @xptfiles, "$destdir/$component/$bindir"."components/$file";
($debug >= 8) && print "xptfiles:\t@xptfiles\n";
}
}
closedir (COMPDIR);
# merge .xpt files into one if we found any in the dir
if ( scalar(@xptfiles) ) {
my ($merged, $manifest);
$merged = "$finaldir/$component.xpt";
$manifest = "$finaldir/interfaces.manifest";
my @realxptfiles;
my $realmerged;
if ($^O eq "cygwin") {
@realxptfiles = map {my $file = `cygpath -t mixed $_`;
chomp $file;
$file} @xptfiles;
$realmerged = `cygpath -t mixed $merged`;
chomp $realmerged;
}
else {
@realxptfiles = @xptfiles;
$realmerged = $merged;
}
my $cmdline = "$xptlink $realmerged @realxptfiles";
($debug >= 4) && print "$cmdline\n";
system($cmdline) == 0 || die ("'$cmdline' failed");
print "Manifest file: $manifest";
open MANIFEST, '>>', $manifest;
print MANIFEST "interfaces $component.xpt\n";
close MANIFEST;
}
}
}
($debug >= 1) && print "Linking .xpt files completed.\n";
exit (0);
#
# Check that arguments to script are valid.
#
sub check_arguments
{
my ($exitval) = 0;
($debug >= 2) && print "check_arguments():\n";
# if --help print usage
if ($help) {
print_usage();
exit (1);
}
# make sure required variables are set:
# check source directory
if ( $srcdir eq "" ) {
print "Error: source directory (--source) not specified.\n";
$exitval += 8;
} elsif ((! -d $srcdir) || (! -r $srcdir)) {
print "Error: source directory \"$srcdir\" is not a directory or is unreadable.\n";
$exitval = 1;
}
# check directory
if ( $destdir eq "" ) {
print "Error: destination directory (--destdir) not specified.\n";
$exitval += 8;
} elsif ((! -d $destdir) || (! -w $destdir)) {
print "Error: destination directory \"$destdir\" is not a directory or is not writeable.\n";
$exitval += 2;
}
if ($exitval) {
print "See \'$0 --help\' for more information.\n";
print "Exiting...\n";
exit ($exitval);
}
if ($xptlink eq "") {
$xptlink = "$srcdir/bin/xpt_link";
}
}
#
# This is called by GetOptions when there are extra command line arguments
# it doesn't understand.
#
sub do_badargument
{
warn "Warning: unknown command line option specified: @_.\n";
}
#
# display usage information
#
sub print_usage
{
($debug >= 2) && print "print_usage():\n";
print <<EOC
$0
Traverse component directory specified and merge multiple existing
.xpt files into single new .xpt files for improved startup time.
Options:
-s, --source <directory>
Specifies the directory from which the component files were
copied. Typically, this will be the same directory used by
pkgcp.pl.
Required.
-d, --destination <directory>
Specifies the directory in which the component directories are
located. Typically, this will be the same directory used by
pkgcp.pl.
Required.
-o, --os [dos|unix]
Specifies which type of system this is. Used for setting path
delimiters correctly.
Required.
-h, --help
Prints this information.
Optional.
--debug [1-10]
Controls verbosity of debugging output, 10 being most verbose.
1 : same as --verbose.
2 : includes function calls.
3 : includes source and destination for each copy.
Optional.
-v, --verbose
Print component names and files copied/deleted.
Optional.
e.g.
$0 --os unix -source /builds/mozilla/dist --destination /h/lithium/install --os unix --verbose
Note: options can be specified by either a leading '--' or '-'.
EOC
}
# EOF