2001-04-19 09:43:15 -05:00
|
|
|
:
|
|
|
|
eval 'exec perl -wS $0 ${1+"$@"}'
|
|
|
|
if 0;
|
|
|
|
#*************************************************************************
|
|
|
|
#
|
|
|
|
# $RCSfile: deliver.pl,v $
|
|
|
|
#
|
2004-06-16 07:46:56 -05:00
|
|
|
# $Revision: 1.71 $
|
2001-04-19 09:43:15 -05:00
|
|
|
#
|
2004-06-16 07:46:56 -05:00
|
|
|
# last change: $Author: rt $ $Date: 2004-06-16 13:46:56 $
|
2001-04-19 09:43:15 -05:00
|
|
|
#
|
|
|
|
# The Contents of this file are made available subject to the terms of
|
|
|
|
# either of the following licenses
|
|
|
|
#
|
|
|
|
# - GNU Lesser General Public License Version 2.1
|
|
|
|
# - Sun Industry Standards Source License Version 1.1
|
|
|
|
#
|
|
|
|
# Sun Microsystems Inc., October, 2000
|
|
|
|
#
|
|
|
|
# GNU Lesser General Public License Version 2.1
|
|
|
|
# =============================================
|
|
|
|
# Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
# 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License version 2.1, as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
# MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Sun Industry Standards Source License Version 1.1
|
|
|
|
# =================================================
|
|
|
|
# The contents of this file are subject to the Sun Industry Standards
|
|
|
|
# Source 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.openoffice.org/license.html.
|
|
|
|
#
|
|
|
|
# Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
# WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
|
|
|
|
# WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
# See the License for the specific provisions governing your rights and
|
|
|
|
# obligations concerning the Software.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is: Sun Microsystems, Inc..
|
|
|
|
#
|
|
|
|
# Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
#
|
|
|
|
# All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): _______________________________________
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#*************************************************************************
|
|
|
|
|
|
|
|
#
|
2001-04-25 07:26:33 -05:00
|
|
|
# deliver.pl - copy from module output tree to solver
|
2001-04-19 09:43:15 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
use Cwd;
|
|
|
|
use File::Basename;
|
|
|
|
use File::Copy;
|
|
|
|
use File::DosGlob 'glob';
|
|
|
|
use File::Path;
|
2004-05-19 06:14:44 -05:00
|
|
|
use File::Spec;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
#### script id #####
|
|
|
|
|
2001-04-19 10:20:05 -05:00
|
|
|
( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
2004-06-16 07:46:56 -05:00
|
|
|
$id_str = ' $Revision: 1.71 $ ';
|
2001-04-19 09:43:15 -05:00
|
|
|
$id_str =~ /Revision:\s+(\S+)\s+\$/
|
|
|
|
? ($script_rev = $1) : ($script_rev = "-");
|
|
|
|
|
|
|
|
print "$script_name -- version: $script_rev\n";
|
|
|
|
|
|
|
|
#### globals ####
|
|
|
|
|
|
|
|
### valid actions ###
|
|
|
|
# if you add a action 'foo', than add 'foo' to this list and
|
|
|
|
# implement 'do_foo()' in the implemented actions area
|
|
|
|
@action_list = ( # valid actions
|
|
|
|
'copy',
|
|
|
|
'dos',
|
|
|
|
'hedabu',
|
2001-06-01 06:06:26 -05:00
|
|
|
'linklib',
|
2001-04-19 09:43:15 -05:00
|
|
|
'mkdir',
|
2002-04-09 08:59:37 -05:00
|
|
|
'symlink',
|
2001-04-19 09:43:15 -05:00
|
|
|
'touch'
|
|
|
|
);
|
|
|
|
|
2002-03-08 04:45:14 -06:00
|
|
|
# copy filter: files matching these patterns won't be copied by
|
|
|
|
# the copy action
|
|
|
|
@copy_filter_patterns = (
|
|
|
|
'\/_[\w\-]+\.dll$' # Win32 debug dll's
|
|
|
|
);
|
|
|
|
|
2001-04-19 09:43:15 -05:00
|
|
|
$is_debug = 0;
|
|
|
|
|
|
|
|
$module = 0; # module name
|
|
|
|
$base_dir = 0; # path to module base directory
|
|
|
|
$dlst_file = 0; # path to d.lst
|
2004-05-26 08:12:05 -05:00
|
|
|
@ilst_file = (); # array of pathes to image lists
|
2004-06-08 10:38:00 -05:00
|
|
|
$ilst_ext = 'ilst'; # extension of image lists
|
2001-04-25 07:26:33 -05:00
|
|
|
$umask = 22; # default file/directory creation mask
|
2001-05-03 06:22:28 -05:00
|
|
|
$dest = 0; # optional destination path
|
2003-12-01 09:17:17 -06:00
|
|
|
$common_build = 0; # do we have common trees?
|
2002-11-08 03:59:58 -06:00
|
|
|
$common_dest = 0; # common tree on solver
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
@action_data = (); # LoL with all action data
|
|
|
|
@macros = (); # d.lst macros
|
2001-04-25 07:26:33 -05:00
|
|
|
@hedabu_list = (); # files which have to be filtered through hedabu
|
2001-08-02 05:03:24 -05:00
|
|
|
@zip_list = (); # files which have to be zipped
|
2002-11-08 03:59:58 -06:00
|
|
|
@common_zip_list = (); # common files which have to be zipped
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
$files_copied = 0; # statistics
|
|
|
|
$files_unchanged = 0; # statistics
|
|
|
|
|
|
|
|
$opt_force = 0; # option force copy
|
|
|
|
$opt_minor = 0; # option deliver in minor
|
|
|
|
$opt_check = 0; # do actually execute any action
|
2001-08-02 05:03:24 -05:00
|
|
|
$opt_zip = 0; # create an additional zip file
|
2003-07-02 07:42:21 -05:00
|
|
|
$opt_link = 0; # hard link files into the solver to save disk space
|
|
|
|
$opt_deloutput = 0; # delete the output tree for the project once successfully delivered
|
2001-04-19 09:43:15 -05:00
|
|
|
|
2004-05-24 01:38:39 -05:00
|
|
|
$strip = 'strip' if ($ENV{COM} ne 'MSC');
|
2004-05-19 06:14:44 -05:00
|
|
|
|
2004-04-13 10:35:48 -05:00
|
|
|
$upd = $ENV{'UPD'};
|
2004-04-13 10:55:50 -05:00
|
|
|
($gui = lc($ENV{GUI})) || die "can't determine GUI";
|
2004-04-13 10:35:48 -05:00
|
|
|
|
2002-04-29 04:40:17 -05:00
|
|
|
# zip is default for RE
|
2003-12-01 09:17:17 -06:00
|
|
|
$opt_zip = 1 if ( defined($ENV{UPDATER}) && $ENV{UPDATER} eq 'YES' && defined($ENV{DELIVER_TO_ZIP}) );
|
2002-04-29 04:40:17 -05:00
|
|
|
|
2001-06-01 06:06:26 -05:00
|
|
|
$has_symlinks = 0; # system supports symlinks
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
for (@action_list) {
|
|
|
|
$action_hash{$_}++;
|
|
|
|
}
|
|
|
|
|
2002-07-18 10:47:26 -05:00
|
|
|
# trap normal signals (HUP, INT, PIPE, TERM)
|
|
|
|
# for clean up on unexpected termination
|
|
|
|
use sigtrap 'handler' => \&cleanup_and_die, 'normal-signals';
|
|
|
|
|
2001-04-19 09:43:15 -05:00
|
|
|
#### main ####
|
|
|
|
|
|
|
|
parse_options();
|
|
|
|
init_globals();
|
|
|
|
push_default_actions();
|
|
|
|
parse_dlst();
|
2004-05-26 08:12:05 -05:00
|
|
|
parse_imagelists();
|
2001-04-19 09:43:15 -05:00
|
|
|
walk_action_data();
|
2001-04-25 07:26:33 -05:00
|
|
|
walk_hedabu_list();
|
2001-08-02 05:03:24 -05:00
|
|
|
zip_files() if $opt_zip;
|
2003-07-02 07:42:21 -05:00
|
|
|
delete_output() if $opt_deloutput;
|
2001-04-19 09:43:15 -05:00
|
|
|
print_stats();
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
#### implemented actions #####
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub do_copy
|
|
|
|
{
|
2003-12-01 09:17:17 -06:00
|
|
|
# We need to copy up to four times:
|
2003-04-24 07:00:19 -05:00
|
|
|
# from the platform dependent output tree,
|
2003-12-01 09:17:17 -06:00
|
|
|
# from the SO platform dependent tree,
|
2003-04-24 07:00:19 -05:00
|
|
|
# from the common output tree,
|
2003-12-01 09:17:17 -06:00
|
|
|
# and from the SO common output tree
|
2003-04-24 07:00:19 -05:00
|
|
|
# in this order.
|
2001-04-19 09:43:15 -05:00
|
|
|
my ($dependent, $common, $from, $to, $file_list);
|
|
|
|
my $line = shift;
|
2001-04-25 07:26:33 -05:00
|
|
|
my $touch = 0;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
$dependent = expand_macros($line);
|
|
|
|
($from, $to) = split(' ', $dependent);
|
2002-03-08 04:45:14 -06:00
|
|
|
print "copy dependent: from: $from, to: $to\n" if $is_debug;
|
2001-04-25 07:26:33 -05:00
|
|
|
glob_and_copy($from, $to, $touch);
|
2001-04-19 09:43:15 -05:00
|
|
|
|
2003-04-24 07:00:19 -05:00
|
|
|
my $line_so = mod_so($line);
|
|
|
|
if ( $line_so ) {
|
|
|
|
my $dependent = expand_macros($line_so);
|
|
|
|
($from, $to) = split(' ', $dependent);
|
|
|
|
print "copy dependent: from: $from, to: $to\n" if $is_debug;
|
|
|
|
glob_and_copy($from, $to, $touch);
|
|
|
|
}
|
|
|
|
|
2003-12-01 09:17:17 -06:00
|
|
|
if ( $common_build ) {
|
|
|
|
$line =~ s/%__SRC%/%COMMON_OUTDIR%/ig;
|
|
|
|
if ( $line =~ /%COMMON_OUTDIR%/ ) {
|
|
|
|
$line =~ s/%_DEST%/%COMMON_DEST%/ig;
|
|
|
|
$common = expand_macros($line);
|
2003-04-24 07:00:19 -05:00
|
|
|
($from, $to) = split(' ', $common);
|
|
|
|
print "copy common: from: $from, to: $to\n" if $is_debug;
|
|
|
|
glob_and_copy($from, $to, $touch);
|
2003-12-01 09:17:17 -06:00
|
|
|
|
|
|
|
my $line_so = mod_so($line);
|
|
|
|
if ( $line_so ) {
|
|
|
|
$common = expand_macros($line_so);
|
|
|
|
($from, $to) = split(' ', $common);
|
|
|
|
print "copy common: from: $from, to: $to\n" if $is_debug;
|
|
|
|
glob_and_copy($from, $to, $touch);
|
|
|
|
}
|
2003-04-24 07:00:19 -05:00
|
|
|
}
|
2002-11-08 03:59:58 -06:00
|
|
|
}
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub do_dos
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
my $line = shift;
|
2001-04-25 07:26:33 -05:00
|
|
|
|
2003-05-27 09:43:53 -05:00
|
|
|
my $command = expand_macros($line);
|
2001-04-19 09:43:15 -05:00
|
|
|
if ( $opt_check ) {
|
2003-05-27 09:43:53 -05:00
|
|
|
print "DOS: $command\n";
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
else {
|
2001-05-03 06:22:28 -05:00
|
|
|
# HACK: remove MACOSX stuff which is wrongly labled with dos
|
|
|
|
# better: fix broken d.lst
|
2003-05-27 09:43:53 -05:00
|
|
|
return if ( $command =~ /MACOSX/ );
|
|
|
|
$command =~ s#/#\\#g if $^O eq 'MSWin32';
|
|
|
|
system($command);
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub do_hedabu
|
|
|
|
{
|
2001-04-25 07:26:33 -05:00
|
|
|
# just collect all hedabu files, actual filtering is done later
|
|
|
|
my $line = shift;
|
2001-05-03 07:46:01 -05:00
|
|
|
my ($from, $to);
|
|
|
|
my @globbed_files = ();
|
2001-04-19 09:43:15 -05:00
|
|
|
|
2001-04-25 07:26:33 -05:00
|
|
|
$line = expand_macros($line);
|
|
|
|
($from, $to) = split(' ', $line);
|
2001-05-03 07:46:01 -05:00
|
|
|
|
|
|
|
push( @hedabu_list, @{glob_line($from, $to)});
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub do_linklib
|
|
|
|
{
|
2001-06-06 06:36:02 -05:00
|
|
|
my ($lib_base, $lib_major,$from_dir, $to_dir);
|
2001-06-01 06:06:26 -05:00
|
|
|
my $lib = shift;
|
2001-06-06 06:36:02 -05:00
|
|
|
my @globbed_files = ();
|
|
|
|
my %globbed_hash = ();
|
2001-06-01 06:06:26 -05:00
|
|
|
|
|
|
|
print "linklib: $lib\n" if $is_debug;
|
|
|
|
print "has symlinks\n" if ( $has_symlinks && $is_debug );
|
|
|
|
|
2001-06-06 06:36:02 -05:00
|
|
|
return unless $has_symlinks;
|
2001-06-01 06:06:26 -05:00
|
|
|
|
2001-06-06 06:36:02 -05:00
|
|
|
$from_dir = expand_macros('../%__SRC%/lib');
|
|
|
|
$to_dir = expand_macros('%_DEST%/lib%_EXT%');
|
2001-06-01 06:06:26 -05:00
|
|
|
|
2001-06-06 06:36:02 -05:00
|
|
|
@globbed_files = glob("$from_dir/$lib");
|
|
|
|
|
|
|
|
if ( $#globbed_files == -1 ) {
|
|
|
|
$files_unchanged++;
|
|
|
|
return;
|
2001-06-01 06:06:26 -05:00
|
|
|
}
|
2001-06-06 06:36:02 -05:00
|
|
|
|
|
|
|
foreach $lib (@globbed_files) {
|
|
|
|
$lib = basename($lib);
|
2003-07-16 12:19:10 -05:00
|
|
|
if ( $lib =~ /^(lib[\w-]+(\.so|\.dylib))\.(\d+)\.(\d+)(\.(\d+))?$/ ) {
|
2001-06-06 06:36:02 -05:00
|
|
|
push(@{$globbed_hash{$1}}, $lib);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print_error("invalid library name: $lib");
|
|
|
|
}
|
2001-06-01 06:06:26 -05:00
|
|
|
}
|
2001-06-06 06:36:02 -05:00
|
|
|
|
|
|
|
foreach $lib_base ( sort keys %globbed_hash ) {
|
|
|
|
$lib = get_latest_patchlevel(@{$globbed_hash{$lib_base}});
|
|
|
|
|
2003-07-16 12:19:10 -05:00
|
|
|
$lib =~ /^(lib[\w-]+(\.so|\.dylib))\.(\d+)\.(\d+)(\.(\d+))?$/;
|
|
|
|
$lib_major = "$lib_base.$3";
|
2001-06-06 06:36:02 -05:00
|
|
|
|
|
|
|
if ( $opt_check ) {
|
2002-01-23 05:44:35 -06:00
|
|
|
if ( $opt_delete ) {
|
|
|
|
print "REMOVE: $to_dir/$lib_major\n";
|
|
|
|
print "REMOVE: $to_dir/$lib_base\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "LINKLIB: $to_dir/$lib -> $to_dir/$lib_major\n";
|
|
|
|
print "LINKLIB: $to_dir/$lib -> $to_dir/$lib_base\n";
|
|
|
|
}
|
2001-06-06 06:36:02 -05:00
|
|
|
}
|
|
|
|
else {
|
2002-01-23 05:44:35 -06:00
|
|
|
if ( $opt_delete ) {
|
|
|
|
print "REMOVE: $to_dir/$lib_major\n";
|
|
|
|
print "REMOVE: $to_dir/$lib_base\n";
|
|
|
|
unlink "$to_dir/$lib_major";
|
|
|
|
unlink "$to_dir/$lib_base";
|
2003-03-27 04:48:49 -06:00
|
|
|
if ( $opt_zip ) {
|
|
|
|
push_on_ziplist("$to_dir/$lib_major");
|
|
|
|
push_on_ziplist("$to_dir/$lib_base");
|
|
|
|
}
|
2002-04-09 08:59:37 -05:00
|
|
|
return;
|
2002-01-23 05:44:35 -06:00
|
|
|
}
|
2001-06-06 06:36:02 -05:00
|
|
|
my $symlib;
|
|
|
|
my @symlibs = ("$to_dir/$lib_major", "$to_dir/$lib_base");
|
|
|
|
# remove old symlinks
|
|
|
|
unlink(@symlibs);
|
|
|
|
foreach $symlib (@symlibs) {
|
|
|
|
print "LINKLIB: $lib -> $symlib\n";
|
|
|
|
if ( !symlink("$lib", "$symlib") ) {
|
|
|
|
print_error("can't symlink $lib -> $symlib: $!",0);
|
|
|
|
}
|
2001-08-02 05:03:24 -05:00
|
|
|
else {
|
|
|
|
push_on_ziplist($symlib) if $opt_zip;
|
|
|
|
}
|
2001-06-01 06:06:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub do_mkdir
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
my $path = expand_macros(shift);
|
|
|
|
if ( $opt_check ) {
|
|
|
|
print "MKDIR: $path\n";
|
|
|
|
}
|
|
|
|
else {
|
2001-04-25 07:26:33 -05:00
|
|
|
mkpath($path, 0, 0777-$umask);
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub do_symlink
|
|
|
|
{
|
|
|
|
my $line = shift;
|
|
|
|
|
|
|
|
$line = expand_macros($line);
|
|
|
|
($from, $to) = split(' ',$line);
|
|
|
|
if ( dirname($from) eq dirname($to) ) {
|
|
|
|
$from = basename($from);
|
|
|
|
}
|
|
|
|
elsif ( dirname($from) eq '.' ) {
|
|
|
|
# nothing to do
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print_error("symlink: link must be in the same directory as file",0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
print "symlink: $from, to: $to\n" if $is_debug;
|
|
|
|
|
|
|
|
return unless $has_symlinks;
|
|
|
|
|
|
|
|
if ( $opt_check ) {
|
|
|
|
if ( $opt_delete ) {
|
|
|
|
print "REMOVE: $to\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "SYMLINK $from -> $to\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "REMOVE: $to\n";
|
|
|
|
unlink $to;
|
2003-03-27 04:48:49 -06:00
|
|
|
if ( $opt_delete ) {
|
|
|
|
push_on_ziplist($to) if $opt_zip;
|
|
|
|
return;
|
|
|
|
}
|
2002-04-09 08:59:37 -05:00
|
|
|
|
|
|
|
print "SYMLIB: $from -> $to\n";
|
|
|
|
if ( !symlink("$from", "$to") ) {
|
|
|
|
print_error("can't symlink $from -> $to: $!",0);
|
|
|
|
}
|
|
|
|
else {
|
2002-04-11 09:40:38 -05:00
|
|
|
push_on_ziplist($to) if $opt_zip;
|
2002-04-09 08:59:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub do_touch
|
|
|
|
{
|
2001-04-25 07:26:33 -05:00
|
|
|
my ($from, $to);
|
2001-04-19 09:43:15 -05:00
|
|
|
my $line = shift;
|
2001-04-25 07:26:33 -05:00
|
|
|
my $touch = 1;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
2001-04-25 07:26:33 -05:00
|
|
|
$line = expand_macros($line);
|
|
|
|
($from, $to) = split(' ', $line);
|
|
|
|
print "touch: $from, to: $to\n" if $is_debug;
|
|
|
|
glob_and_copy($from, $to, $touch);
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#### subroutines #####
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub parse_options
|
|
|
|
{
|
2001-05-03 06:22:28 -05:00
|
|
|
my $arg;
|
|
|
|
while ( $arg = shift @ARGV ) {
|
2001-08-02 05:03:24 -05:00
|
|
|
$arg =~ /^-force$/ and $opt_force = 1 and next;
|
|
|
|
$arg =~ /^-minor$/ and $opt_minor = 1 and next;
|
|
|
|
$arg =~ /^-check$/ and $opt_check = 1 and next;
|
|
|
|
$arg =~ /^-zip$/ and $opt_zip = 1 and next;
|
2002-01-23 05:44:35 -06:00
|
|
|
$arg =~ /^-delete$/ and $opt_delete = 1 and next;
|
2003-07-02 07:42:21 -05:00
|
|
|
$arg =~ /^-link$/ and $ENV{GUI} ne 'WNT' and $opt_link = 1 and next;
|
|
|
|
$arg =~ /^-deloutput$/ and $opt_deloutput = 1 and next;
|
2001-05-03 06:22:28 -05:00
|
|
|
print_error("invalid option $arg") if ( $arg =~ /-/ );
|
|
|
|
if ( $arg =~ /-/ || $#ARGV > -1 ) {
|
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
$dest = $arg;
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
2002-01-23 05:44:35 -06:00
|
|
|
# $dest and $opt_zip or $opt_delete are mutually exclusive
|
|
|
|
if ( $dest and ($opt_zip || $opt_delete) ) {
|
2001-08-02 05:03:24 -05:00
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-01-23 05:44:35 -06:00
|
|
|
# $opt_delete implies $opt_force
|
|
|
|
$opt_force = 1 if $opt_delete;
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub init_globals
|
|
|
|
{
|
2001-04-25 07:26:33 -05:00
|
|
|
my $ext;
|
2001-04-19 09:43:15 -05:00
|
|
|
($module, $base_dir, $dlst_file) = get_base();
|
2003-05-08 08:48:01 -05:00
|
|
|
|
|
|
|
# for CWS:
|
|
|
|
$module =~ s/\.lnk$//;
|
|
|
|
|
2004-05-26 08:12:05 -05:00
|
|
|
print "Module=$module, Base_Dir=$base_dir, d.lst=$dlst_file\n" if $is_debug;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
$umask = umask();
|
2001-04-25 07:26:33 -05:00
|
|
|
if ( !defined($umask) ) {
|
|
|
|
$umask = 22;
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
2001-11-28 11:18:45 -06:00
|
|
|
my $build_sosl = $ENV{'BUILD_SOSL'};
|
|
|
|
my $common_outdir = $ENV{'COMMON_OUTDIR'};
|
|
|
|
my $inpath = $ENV{'INPATH'};
|
|
|
|
my $outpath = $ENV{'OUTPATH'};
|
|
|
|
my $solarversion = $ENV{'SOLARVERSION'};
|
|
|
|
my $updater = $ENV{'UPDATER'};
|
|
|
|
my $updminor = $ENV{'UPDMINOR'};
|
|
|
|
my $work_stamp = $ENV{'WORK_STAMP'};
|
|
|
|
|
2002-05-16 11:07:11 -05:00
|
|
|
my $l10n_framework = $ENV{'L10N_framework'};
|
|
|
|
$l10n_framework = "INVALID" if ! defined $l10n_framework;
|
|
|
|
|
2001-11-28 11:18:45 -06:00
|
|
|
# special security check for release engineers
|
2002-01-15 06:06:46 -06:00
|
|
|
if ( defined($updater) && !defined($build_sosl) && !$opt_force) {
|
2001-11-28 11:18:45 -06:00
|
|
|
my $path = cwd();
|
2002-02-18 10:58:50 -06:00
|
|
|
if ( $path !~ /$work_stamp/io ) {
|
2001-11-28 11:18:45 -06:00
|
|
|
print_error("can't deliver from local directory to SOLARVERSION");
|
|
|
|
print STDERR "\nDANGER! Release Engineer:\n";
|
|
|
|
print STDERR "do you really want to deliver from $path to SOLARVERSION?\n";
|
|
|
|
print STDERR "If so, please use the -force switch\n\n";
|
|
|
|
exit(7);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-12 02:55:05 -05:00
|
|
|
# do we have a valid environment?
|
|
|
|
if ( !defined($inpath) ) {
|
|
|
|
print_error("no environment", 0);
|
|
|
|
exit(3);
|
|
|
|
}
|
|
|
|
|
2001-04-19 09:43:15 -05:00
|
|
|
$ext = "";
|
2001-05-21 10:41:11 -05:00
|
|
|
if ( ($opt_minor || $updminor) && !$dest ) {
|
2001-04-19 09:43:15 -05:00
|
|
|
if ( $updminor ) {
|
|
|
|
$ext = ".$updminor";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print_error("can't determine UPDMINOR", 0);
|
|
|
|
exit(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-01 09:17:17 -06:00
|
|
|
# Do we have common trees?
|
|
|
|
if ( defined($ENV{'common_build'}) && $ENV{'common_build'} eq 'TRUE' ) {
|
|
|
|
$common_build = 1;
|
|
|
|
if ((defined $common_outdir) && ($common_outdir ne "")) {
|
|
|
|
$common_outdir = $common_outdir . ".pro" if $inpath =~ /\.pro$/;
|
|
|
|
$common_dest = "$solarversion/$common_outdir" if ( !$dest );
|
|
|
|
$dest = "$solarversion/$inpath" if ( !$dest );
|
|
|
|
} else {
|
|
|
|
print_error("common_build defined without common_outdir", 0);
|
|
|
|
exit(6);
|
|
|
|
}
|
2003-03-27 04:48:49 -06:00
|
|
|
} else {
|
2003-12-01 09:17:17 -06:00
|
|
|
$common_outdir = $inpath;
|
2003-03-27 04:48:49 -06:00
|
|
|
$dest = "$solarversion/$inpath" if ( !$dest );
|
|
|
|
$common_dest = $dest;
|
|
|
|
}
|
2001-04-19 09:43:15 -05:00
|
|
|
|
2004-05-26 08:12:05 -05:00
|
|
|
# find image lists
|
|
|
|
@ilst_file = get_imagelists($common_outdir);
|
|
|
|
|
2001-04-19 09:43:15 -05:00
|
|
|
# the following macros are obsolete, will be flagged as error
|
|
|
|
# %__WORKSTAMP%
|
|
|
|
# %GUIBASE%
|
|
|
|
# %SDK%
|
|
|
|
# %SOLARVER%
|
2003-12-01 09:17:17 -06:00
|
|
|
# %__OFFENV%
|
|
|
|
# %DLLSUFFIX%'
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
# valid macros
|
|
|
|
@macros = (
|
|
|
|
[ '%__PRJROOT%', $base_dir ],
|
|
|
|
[ '%__SRC%', $inpath ],
|
|
|
|
[ '%_DEST%', $dest ],
|
|
|
|
[ '%_EXT%', $ext ],
|
|
|
|
[ '%COMMON_OUTDIR%', $common_outdir ],
|
2002-11-08 03:59:58 -06:00
|
|
|
[ '%COMMON_DEST%', $common_dest ],
|
2001-04-19 09:43:15 -05:00
|
|
|
[ '%GUI%', $gui ],
|
2001-05-03 07:46:01 -05:00
|
|
|
[ '%OUTPATH%', $outpath ],
|
2002-05-16 11:07:11 -05:00
|
|
|
[ '%UPD%', $upd ],
|
|
|
|
[ '%L10N_FRAMEWORK%', $l10n_framework ]
|
2001-04-19 09:43:15 -05:00
|
|
|
);
|
2001-06-01 06:06:26 -05:00
|
|
|
|
|
|
|
# find out if the system supports symlinks
|
|
|
|
$has_symlinks = eval { symlink("",""); 1 };
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub get_base
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
# a module base dir contains a subdir 'prj'
|
|
|
|
# which in turn contains a file 'd.lst'
|
|
|
|
my (@field, $base, $dlst);
|
|
|
|
my $path = cwd();
|
|
|
|
|
|
|
|
@field = split(/\//, $path);
|
|
|
|
|
|
|
|
while ( $#field != -1 ) {
|
|
|
|
$base = join('/', @field);
|
|
|
|
$dlst = $base . '/prj/d.lst';
|
|
|
|
last if -e $dlst;
|
|
|
|
pop @field;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $#field == -1 ) {
|
|
|
|
print_error("can't determine module");
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return ($field[-1], $base, $dlst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub parse_dlst
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
my $line_cnt = 0;
|
|
|
|
open(DLST, "<$dlst_file") or die "can't open d.lst";
|
|
|
|
while(<DLST>) {
|
|
|
|
$line_cnt++;
|
|
|
|
tr/\r\n//d;
|
|
|
|
next if /^#/;
|
|
|
|
next if /^\s*$/;
|
|
|
|
if ( /^\s*(\w+?):\s+(.*)$/ ) {
|
|
|
|
if ( !exists $action_hash{$1} ) {
|
|
|
|
print_error("unknown action: \'$1\'", $line_cnt);
|
|
|
|
exit(4);
|
|
|
|
}
|
|
|
|
push(@action_data, [$1, $2]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
push(@action_data, ['copy', $_]);
|
|
|
|
}
|
|
|
|
# call expand_macros()just to find any undefined macros early
|
|
|
|
# real expansion is done later
|
|
|
|
expand_macros($_, $line_cnt);
|
|
|
|
}
|
|
|
|
close(DLST);
|
|
|
|
}
|
|
|
|
|
2004-05-26 08:12:05 -05:00
|
|
|
sub get_imagelists
|
|
|
|
{
|
|
|
|
my $common_outdir = shift;
|
2004-05-27 08:49:44 -05:00
|
|
|
chdir("$base_dir") or die "Cannot change into $base_dir";
|
2004-05-26 08:12:05 -05:00
|
|
|
my @ilst = glob("$common_outdir/bin/*.$ilst_ext");
|
|
|
|
return wantarray ? @ilst : \@ilst;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_imagelists
|
|
|
|
{
|
|
|
|
my $resdirvariable = "%MODULE%";
|
|
|
|
my $destdir; # where to put images and image lists
|
|
|
|
if ( $common_build ) {
|
|
|
|
$destdir = "%COMMON_DEST%\\res%_EXT%\\img";
|
|
|
|
} else {
|
|
|
|
$destdir = "%_DEST%\\res%_EXT%\\img";
|
|
|
|
}
|
|
|
|
if ( ! @ilst_file ) {
|
|
|
|
print "No image lists\n" if $is_debug;
|
|
|
|
return;
|
|
|
|
}
|
2004-06-16 07:46:56 -05:00
|
|
|
# collect files to deliver
|
|
|
|
my %files;
|
|
|
|
my %subdirs;
|
2004-05-26 08:12:05 -05:00
|
|
|
foreach my $list (@ilst_file) {
|
|
|
|
print "$list\n" if $is_debug;
|
|
|
|
# read images list
|
|
|
|
open(IMGLST, "<$list") or die "Error: cannot open image list $list";
|
|
|
|
while(<IMGLST>) {
|
|
|
|
chomp;
|
|
|
|
next if /^#/;
|
|
|
|
next if ! s/$resdirvariable//;
|
2004-06-16 07:46:56 -05:00
|
|
|
s:\\:\/:g;
|
|
|
|
next if ! /^(\/.+)\/\w/;
|
|
|
|
$subdirs{$1} = 1;
|
|
|
|
$files{$_} = 1;
|
2004-05-26 08:12:05 -05:00
|
|
|
}
|
|
|
|
close(IMGLST);
|
|
|
|
}
|
2004-06-16 07:46:56 -05:00
|
|
|
# now add them to @action_data
|
2004-06-07 03:34:09 -05:00
|
|
|
push(@action_data, ['mkdir', $destdir]);
|
|
|
|
push(@action_data, ['copy', "..\\%__SRC%\\bin\\*.$ilst_ext $destdir"]);
|
2004-06-16 07:46:56 -05:00
|
|
|
foreach ( sort keys %subdirs ) {
|
|
|
|
# d.lst syntax uses backslashes as path delimiter
|
|
|
|
s:\/:\\:g;
|
|
|
|
push(@action_data, ['mkdir', $destdir . $_]);
|
|
|
|
}
|
|
|
|
foreach ( sort keys %files ) {
|
|
|
|
# d.lst syntax uses backslashes as path delimiter
|
|
|
|
s:\/:\\:g;
|
|
|
|
my $dlst_line = "$_ $destdir$_";
|
|
|
|
$dlst_line =~ s/^\\$module/\.\./;
|
|
|
|
push(@action_data, ['copy', $dlst_line]);
|
|
|
|
}
|
2004-05-26 08:12:05 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub expand_macros
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
# expand all macros and change backslashes to slashes
|
|
|
|
my $line = shift;
|
|
|
|
my $line_cnt = shift;
|
|
|
|
my $i;
|
|
|
|
|
|
|
|
for ($i=0; $i<=$#macros; $i++) {
|
2002-04-09 08:59:37 -05:00
|
|
|
$line =~ s/$macros[$i][0]/$macros[$i][1]/gi
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
if ( $line =~ /(%\w+%)/ ) {
|
|
|
|
if ( $1 ne '%OS%' ) { # %OS% looks like a macro but is not ...
|
|
|
|
print_error("unknown/obsolete macro: \'$1\'", $line_cnt);
|
|
|
|
}
|
|
|
|
# exit(5);
|
|
|
|
}
|
|
|
|
$line =~ s#\\#/#g;
|
|
|
|
return $line;
|
|
|
|
}
|
|
|
|
|
2003-04-24 07:00:19 -05:00
|
|
|
sub mod_so
|
|
|
|
{
|
|
|
|
my $line = shift;
|
|
|
|
|
|
|
|
if ( $line =~ s/(%__SRC%[\\|\/]bin)/$1\\so/i ) {
|
|
|
|
$line =~ s/(%_DEST%[\\|\/]bin%_EXT%)/$1\\so/i;
|
|
|
|
return $line;
|
|
|
|
}
|
|
|
|
elsif ( $line =~ s/(%COMMON_OUTDIR%[\\|\/]bin)/$1\\so/i ) {
|
|
|
|
$line =~ s/(%COMMON_DEST%[\\|\/]bin%_EXT%)/$1\\so/i;
|
|
|
|
return $line;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return undef;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub walk_action_data
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
# all actions have to be excuted relative to the prj directory
|
|
|
|
chdir("$base_dir/prj");
|
|
|
|
# dispatch depending on action type
|
2001-05-03 07:46:01 -05:00
|
|
|
for (my $i=0; $i <= $#action_data; $i++) {
|
2001-04-19 09:43:15 -05:00
|
|
|
&{"do_".$action_data[$i][0]}($action_data[$i][1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub glob_line
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
my $from = shift;
|
|
|
|
my $to = shift;
|
2001-05-03 07:46:01 -05:00
|
|
|
my $to_dir = shift;
|
2001-04-19 09:43:15 -05:00
|
|
|
my $replace = 0;
|
2001-05-03 07:46:01 -05:00
|
|
|
my @globbed_files = ();
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
if ( $to =~ /[\*\?\[\]]/ ) {
|
|
|
|
my $to_fname;
|
|
|
|
($to_fname, $to_dir) = fileparse($to);
|
|
|
|
$replace = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $from =~ /[\*\?\[\]]/ ) {
|
|
|
|
# globbing necessary, no renaming possible
|
|
|
|
my $file;
|
|
|
|
my @file_list = glob($from);
|
|
|
|
|
|
|
|
foreach $file ( @file_list ) {
|
|
|
|
my ($fname, $dir) = fileparse($file);
|
|
|
|
my $copy = ($replace) ? $to_dir . $fname : $to . '/' . $fname;
|
2001-05-03 07:46:01 -05:00
|
|
|
push(@globbed_files, [$file, $copy]);
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# no globbing but renaming possible
|
2001-05-03 07:46:01 -05:00
|
|
|
push(@globbed_files, [$from, $to]);
|
|
|
|
}
|
|
|
|
return \@globbed_files;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub glob_and_copy
|
|
|
|
{
|
2001-05-03 07:46:01 -05:00
|
|
|
my $from = shift;
|
|
|
|
my $to = shift;
|
|
|
|
my $touch = shift;
|
|
|
|
|
|
|
|
my @copy_files = @{glob_line($from, $to)};
|
|
|
|
|
|
|
|
for (my $i = 0; $i <= $#copy_files; $i++) {
|
2002-03-08 04:45:14 -06:00
|
|
|
next if filter_out($copy_files[$i][0]); # apply copy filter
|
2001-05-03 07:46:01 -05:00
|
|
|
copy_if_newer($copy_files[$i][0], $copy_files[$i][1], $touch)
|
2001-04-25 07:26:33 -05:00
|
|
|
? $files_copied++ : $files_unchanged++;
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-13 05:05:13 -05:00
|
|
|
sub is_unstripped {
|
2004-04-13 10:35:48 -05:00
|
|
|
my $file_name = shift;
|
|
|
|
|
2004-05-04 04:25:05 -05:00
|
|
|
if (-f $file_name && (( `file $file_name` ) =~ /not stripped/o)) {
|
2004-05-13 05:05:13 -05:00
|
|
|
return '1' if ($file_name =~ /\.bin$/o);
|
2004-05-04 04:25:05 -05:00
|
|
|
return '1' if ($file_name =~ /\.so\.*/o);
|
2004-05-10 01:55:38 -05:00
|
|
|
return '1' if (basename($file_name) !~ /\./o);
|
2004-05-04 04:25:05 -05:00
|
|
|
};
|
|
|
|
return '';
|
2004-04-13 10:35:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
sub execute_system {
|
2004-04-27 10:41:03 -05:00
|
|
|
my $command = shift;
|
|
|
|
if (system($command)) {
|
|
|
|
print_error("Failed to execute $command");
|
|
|
|
exit($?);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2004-04-30 06:27:43 -05:00
|
|
|
sub strip_target {
|
2004-04-13 10:35:48 -05:00
|
|
|
my $file = shift;
|
|
|
|
my $temp_file = shift;
|
2004-04-30 06:27:43 -05:00
|
|
|
my $rc = copy($file, $temp_file);
|
|
|
|
execute_system("$strip $temp_file");
|
2004-04-13 10:35:48 -05:00
|
|
|
return $rc;
|
|
|
|
};
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub copy_if_newer
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
# return 0 if file is unchanged ( for whatever reason )
|
|
|
|
# return 1 if file has been copied
|
|
|
|
my $from = shift;
|
|
|
|
my $to = shift;
|
2001-04-25 07:26:33 -05:00
|
|
|
my $touch = shift;
|
|
|
|
my $from_stat_ref;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
print "testing $from, $to\n" if $is_debug;
|
2003-03-27 04:48:49 -06:00
|
|
|
push_on_ziplist($to) if $opt_zip;
|
2001-04-25 07:26:33 -05:00
|
|
|
return 0 unless ($from_stat_ref = is_newer($from, $to, $touch));
|
|
|
|
|
2002-01-23 05:44:35 -06:00
|
|
|
if ( $opt_delete ) {
|
|
|
|
print "REMOVE: $to\n";
|
2003-07-02 07:42:21 -05:00
|
|
|
return 1 if $opt_check;
|
|
|
|
my $rc = unlink($to);
|
|
|
|
return 1 if $rc;
|
|
|
|
return 0;
|
2001-04-25 07:26:33 -05:00
|
|
|
}
|
2003-07-02 07:42:21 -05:00
|
|
|
|
|
|
|
if( !$opt_check && $opt_link ) {
|
|
|
|
# hard link if possible
|
|
|
|
if( link($from, $to) ){
|
|
|
|
print "LINK: $from -> $to\n";
|
|
|
|
return 1;
|
2002-01-23 05:44:35 -06:00
|
|
|
}
|
2001-04-25 07:26:33 -05:00
|
|
|
}
|
2003-07-02 07:42:21 -05:00
|
|
|
|
|
|
|
if( $touch ) {
|
|
|
|
print "TOUCH: $from -> $to\n";
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
else {
|
2003-07-02 07:42:21 -05:00
|
|
|
print "COPY: $from -> $to\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1 if( $opt_check );
|
|
|
|
|
|
|
|
#
|
|
|
|
# copy to temporary file first and rename later
|
|
|
|
# to minimize the possibility for race conditions
|
|
|
|
local $temp_file = sprintf('%s.%d-%d', $to, $$, time());
|
2004-04-13 10:35:48 -05:00
|
|
|
my $rc = '';
|
2004-05-19 06:14:44 -05:00
|
|
|
if ((defined $strip) && (defined $ENV{PROEXT}) && (is_unstripped($from))) {
|
2004-04-30 06:27:43 -05:00
|
|
|
$rc = strip_target($from, $temp_file);
|
2004-04-13 10:35:48 -05:00
|
|
|
} else {
|
|
|
|
$rc = copy($from, $temp_file);
|
|
|
|
};
|
2003-07-02 07:42:21 -05:00
|
|
|
if ( $rc) {
|
|
|
|
$rc = utime($$from_stat_ref[9], $$from_stat_ref[9], $temp_file);
|
|
|
|
if ( !$rc ) {
|
2004-02-02 12:03:41 -06:00
|
|
|
# try again
|
|
|
|
sleep 3;
|
|
|
|
$rc = utime($$from_stat_ref[9], $$from_stat_ref[9], $temp_file);
|
|
|
|
if ( !$rc ) {
|
|
|
|
print_error("can't update temporary file modification time '$temp_file': $!",0);
|
|
|
|
}
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
2003-07-02 07:42:21 -05:00
|
|
|
fix_file_permissions($$from_stat_ref[2], $temp_file);
|
|
|
|
$rc = rename($temp_file, $to);
|
|
|
|
if ( $rc ) {
|
|
|
|
# handle special packaging of *.dylib files for Mac OS X
|
|
|
|
if ( $^O eq 'darwin' )
|
|
|
|
{
|
|
|
|
system("create-bundle", $to) if ( $to =~ /\.dylib/ );
|
|
|
|
system("create-bundle", "$to=$from.app") if ( -d "$from.app" );
|
|
|
|
system("ranlib", "$to" ) if ( $to =~ /\.a/ );
|
2002-01-23 05:44:35 -06:00
|
|
|
}
|
2003-07-02 07:42:21 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print_error("can't rename temporary file to $to: $!",0);
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
2003-07-02 07:42:21 -05:00
|
|
|
else {
|
|
|
|
print_error("can't copy $from: $!",0);
|
|
|
|
}
|
|
|
|
unlink($temp_file);
|
|
|
|
return 0;
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub is_newer
|
|
|
|
{
|
2001-04-25 07:26:33 -05:00
|
|
|
# returns whole stat buffer if newer
|
2001-04-19 09:43:15 -05:00
|
|
|
my $from = shift;
|
|
|
|
my $to = shift;
|
2001-04-25 07:26:33 -05:00
|
|
|
my $touch = shift;
|
2001-04-19 09:43:15 -05:00
|
|
|
my (@from_stat, @to_stat);
|
|
|
|
|
|
|
|
@from_stat = stat($from);
|
|
|
|
return 0 unless -f _;
|
|
|
|
|
2001-04-25 07:26:33 -05:00
|
|
|
if ( $touch ) {
|
|
|
|
$from_stat[9] = time();
|
|
|
|
}
|
2001-04-19 09:43:15 -05:00
|
|
|
# adjust timestamps to even seconds
|
|
|
|
# this is necessary since NT platforms have a
|
|
|
|
# 2s modified time granularity while the timestamps
|
|
|
|
# on Samba volumes have a 1s granularity
|
|
|
|
|
|
|
|
$from_stat[9]-- if $from_stat[9] % 2;
|
|
|
|
|
|
|
|
@to_stat = stat($to);
|
2001-04-25 07:26:33 -05:00
|
|
|
return \@from_stat unless -f _;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
|
|
|
if ( $opt_force ) {
|
2001-04-25 07:26:33 -05:00
|
|
|
return \@from_stat;
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
else {
|
2001-04-25 07:26:33 -05:00
|
|
|
return ($from_stat[9] > $to_stat[9]) ? \@from_stat : 0;
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-08 04:45:14 -06:00
|
|
|
sub filter_out
|
|
|
|
{
|
|
|
|
my $file = shift;
|
|
|
|
|
|
|
|
foreach my $pattern ( @copy_filter_patterns ) {
|
|
|
|
if ( $file =~ /$pattern/ ) {
|
|
|
|
print "filter out: $file\n" if $is_debug;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub fix_file_permissions
|
|
|
|
{
|
2001-04-25 07:26:33 -05:00
|
|
|
my $mode = shift;
|
|
|
|
my $file = shift;
|
|
|
|
|
|
|
|
if ( $mode%2 == 1 ) {
|
|
|
|
$mode = 0777 - $umask;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$mode = 0666 - $umask;
|
|
|
|
}
|
|
|
|
chmod($mode, $file);
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub get_latest_patchlevel
|
|
|
|
{
|
2001-06-06 06:36:02 -05:00
|
|
|
# note: feed only well formed library names to this function
|
|
|
|
# of the form libfoo.so.x.y.z with x,y,z numbers
|
|
|
|
|
|
|
|
my @sorted_files = sort by_rev @_;
|
2001-06-07 05:33:49 -05:00
|
|
|
return $sorted_files[-1];
|
2001-06-06 06:36:02 -05:00
|
|
|
|
|
|
|
sub by_rev {
|
|
|
|
# comparison function for sorting
|
|
|
|
my (@field_a, @field_b, $i);
|
|
|
|
|
2003-07-16 12:19:10 -05:00
|
|
|
$a =~ /^(lib[\w-]+(\.so|\.dylib))\.(\d+)\.(\d+)\.(\d+)$/;
|
|
|
|
@field_a = ($3, $4, $5);
|
|
|
|
$b =~ /^(lib[\w-]+(\.so|\.dylib))\.(\d+)\.(\d+)\.(\d+)$/;
|
|
|
|
@field_b = ($3, $4, $5);
|
2001-06-06 06:36:02 -05:00
|
|
|
|
|
|
|
for ($i = 0; $i < 3; $i++)
|
|
|
|
{
|
|
|
|
if ( ($field_a[$i] < $field_b[$i]) ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if ( ($field_a[$i] > $field_b[$i]) ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# can't happen
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub push_default_actions
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
# any default action (that is an action which must be done even without
|
|
|
|
# a corresponding d.lst entry) should be pushed here on the
|
2001-08-02 07:17:56 -05:00
|
|
|
# @action_data list.
|
2001-04-19 09:43:15 -05:00
|
|
|
my $subdir;
|
|
|
|
my @subdirs = (
|
2002-12-16 05:28:45 -06:00
|
|
|
'bin',
|
2001-04-19 09:43:15 -05:00
|
|
|
'idl',
|
|
|
|
'inc',
|
|
|
|
'lib',
|
|
|
|
'rdb',
|
|
|
|
'res',
|
2001-08-02 05:03:24 -05:00
|
|
|
'xml',
|
2001-04-19 09:43:15 -05:00
|
|
|
);
|
2001-08-02 05:03:24 -05:00
|
|
|
push(@subdirs, 'zip') if $opt_zip;
|
2002-11-08 03:59:58 -06:00
|
|
|
my @common_subdirs = (
|
|
|
|
'bin',
|
2003-03-27 04:48:49 -06:00
|
|
|
'idl',
|
|
|
|
'inc',
|
2002-11-08 03:59:58 -06:00
|
|
|
'pck',
|
|
|
|
);
|
|
|
|
push(@common_subdirs, 'zip') if $opt_zip;
|
2001-04-19 09:43:15 -05:00
|
|
|
|
2003-04-15 04:32:19 -05:00
|
|
|
if ( ! $opt_delete ) {
|
|
|
|
# create all the subdirectories on solver
|
|
|
|
foreach $subdir (@subdirs) {
|
|
|
|
push(@action_data, ['mkdir', "%_DEST%/$subdir%_EXT%"]);
|
|
|
|
}
|
2003-12-01 09:17:17 -06:00
|
|
|
if ( $common_build ) {
|
|
|
|
foreach $subdir (@common_subdirs) {
|
|
|
|
push(@action_data, ['mkdir', "%COMMON_DEST%/$subdir%_EXT%"]);
|
|
|
|
}
|
2003-04-15 04:32:19 -05:00
|
|
|
}
|
2003-05-14 09:52:02 -05:00
|
|
|
push(@action_data, ['mkdir', "%_DEST%/bin%_EXT%/so"]);
|
|
|
|
push(@action_data, ['mkdir', "%COMMON_DEST%/bin%_EXT%/so"]);
|
2001-08-02 07:17:56 -05:00
|
|
|
|
2003-04-15 04:32:19 -05:00
|
|
|
# deliver build.lst to $dest/inc/$module
|
|
|
|
push(@action_data, ['mkdir', "%_DEST%/inc%_EXT%/$module"]); # might be necessary
|
|
|
|
push(@action_data, ['copy', "build.lst %_DEST%/inc%_EXT%/$module/build.lst"]);
|
2003-12-01 09:17:17 -06:00
|
|
|
if ( $common_build ) {
|
|
|
|
# and to $common_dest/inc/$module
|
|
|
|
push(@action_data, ['mkdir', "%COMMON_DEST%/inc%_EXT%/$module"]); # might be necessary
|
|
|
|
push(@action_data, ['copy', "build.lst %COMMON_DEST%/inc%_EXT%/$module/build.lst"]);
|
|
|
|
}
|
2003-04-15 04:32:19 -05:00
|
|
|
}
|
2002-01-08 03:58:46 -06:00
|
|
|
|
|
|
|
# need to copy libstaticmxp.dylib for Mac OS X
|
|
|
|
if ( $^O eq 'darwin' )
|
|
|
|
{
|
|
|
|
push(@action_data, ['copy', "../%__SRC%/misc/*staticdatamembers.cxx %_DEST%/inc%_EXT%/*staticdatamembers.cxx"]);
|
|
|
|
push(@action_data, ['copy', "../%__SRC%/misc/*staticdatamembers.h* %_DEST%/inc%_EXT%/*staticdatamembers.H*"]);
|
|
|
|
push(@action_data, ['copy', "../%__SRC%/lib/lib*static*.dylib %_DEST%/lib%_EXT%/lib*static*.dylib"]);
|
|
|
|
}
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub walk_hedabu_list
|
|
|
|
{
|
2001-05-03 07:46:01 -05:00
|
|
|
my (@hedabu_headers);
|
2001-04-25 07:26:33 -05:00
|
|
|
return if $#hedabu_list == -1;
|
|
|
|
|
|
|
|
# create hash with all hedabu header names
|
2001-05-03 07:46:01 -05:00
|
|
|
for (my $i = 0; $i <= $#hedabu_list; $i++) {
|
2001-04-25 07:26:33 -05:00
|
|
|
my @field = split('/', $hedabu_list[$i][0]);
|
|
|
|
push (@hedabu_headers, $field[-1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
# now stream all hedabu headers through hedabu filter
|
2001-05-03 07:46:01 -05:00
|
|
|
for (my $i = 0; $i <= $#hedabu_list; $i++) {
|
2001-04-25 07:26:33 -05:00
|
|
|
hedabu_if_newer($hedabu_list[$i][0], $hedabu_list[$i][1], \@hedabu_headers)
|
|
|
|
? $files_copied++ : $files_unchanged++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub hedabu_if_newer
|
|
|
|
{
|
2001-04-25 07:26:33 -05:00
|
|
|
my $from = shift;
|
|
|
|
my $to = shift;
|
|
|
|
my $hedabu_headers_ref = shift;
|
|
|
|
my ($from_stat_ref, $header);
|
|
|
|
|
2003-05-08 05:51:49 -05:00
|
|
|
push_on_ziplist($to) if $opt_zip;
|
|
|
|
|
|
|
|
if ( $opt_delete ) {
|
|
|
|
print "REMOVE: $to\n";
|
|
|
|
my $rc = unlink($to);
|
|
|
|
return 1 if $rc;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-04-25 07:26:33 -05:00
|
|
|
if ( $from_stat_ref = is_newer($from, $to) ) {
|
2003-05-08 05:51:49 -05:00
|
|
|
print "HEDABU: $from -> $to\n";
|
2001-04-25 07:26:33 -05:00
|
|
|
|
|
|
|
return 1 if $opt_check;
|
|
|
|
|
|
|
|
my $save = $/;
|
|
|
|
undef $/;
|
|
|
|
open(FROM, "<$from");
|
|
|
|
# slurp whole file in one big string
|
|
|
|
my $content = <FROM>;
|
|
|
|
close(FROM);
|
|
|
|
$/ = $save;
|
|
|
|
|
|
|
|
# strip any carriage returns
|
|
|
|
$content =~ tr/\r//d;
|
|
|
|
# squeeze lines with white space only
|
|
|
|
$content =~ s/\n\s+\n/\n\n/sg;
|
|
|
|
# squeeze multiple blank lines
|
|
|
|
$content =~ s/\n{3,}/\n\n/sg;
|
|
|
|
|
|
|
|
foreach $header (@$hedabu_headers_ref) {
|
|
|
|
$content =~ s/#include [<"]$header[>"]/#include <$module\/$header>/g;
|
|
|
|
}
|
|
|
|
|
|
|
|
# __SOLAR_PRIVATE hack
|
|
|
|
$content =~ s/#if _SOLAR__PRIVATE/#if 0 \/\/ _SOLAR__PRIVATE/g;
|
|
|
|
|
|
|
|
open(TO, ">$to");
|
|
|
|
print TO $content;
|
|
|
|
close(TO);
|
|
|
|
|
|
|
|
utime($$from_stat_ref[9], $$from_stat_ref[9], $to);
|
|
|
|
fix_file_permissions($$from_stat_ref[2], $to);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-02 05:03:24 -05:00
|
|
|
sub push_on_ziplist
|
|
|
|
{
|
|
|
|
my $file = shift;
|
2003-06-13 03:12:15 -05:00
|
|
|
return if ( $opt_check );
|
2001-08-02 05:03:24 -05:00
|
|
|
# strip $dest from path since we don't want to record it in zip file
|
2002-04-22 08:36:44 -05:00
|
|
|
$dest =~ s#\\#/#g;
|
2002-11-08 03:59:58 -06:00
|
|
|
$common_dest =~ s#\\#/#g;
|
|
|
|
if ( $file =~ s#^$dest/##o ) {
|
|
|
|
if ( $opt_minor ){
|
|
|
|
# strip minor from path
|
|
|
|
my $ext = "%_EXT%";
|
|
|
|
$ext = expand_macros($ext);
|
|
|
|
$file =~ s#^$ext##o;
|
|
|
|
}
|
|
|
|
push(@zip_list, $file);
|
|
|
|
} elsif ( $file =~ s#^$common_dest/##o ) {
|
|
|
|
if ( $opt_minor ){
|
|
|
|
# strip minor from path
|
|
|
|
my $ext = "%_EXT%";
|
|
|
|
$ext = expand_macros($ext);
|
|
|
|
$file =~ s#^$ext##o;
|
|
|
|
}
|
|
|
|
push(@common_zip_list, $file);
|
|
|
|
}
|
2001-08-02 05:03:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
sub zip_files
|
|
|
|
{
|
|
|
|
my $file;
|
|
|
|
my $zipexe = 'zip';
|
|
|
|
$zipexe .= ' -y' unless $^O eq 'MSWin32';
|
|
|
|
|
2003-04-15 04:32:19 -05:00
|
|
|
my $platform_zip_file = "%_DEST%/zip%_EXT%/$module.zip";
|
|
|
|
$platform_zip_file = expand_macros($platform_zip_file);
|
2002-11-08 03:59:58 -06:00
|
|
|
my $common_zip_file = "%COMMON_DEST%/zip%_EXT%/$module.zip";
|
|
|
|
$common_zip_file = expand_macros($common_zip_file);
|
2003-04-15 04:32:19 -05:00
|
|
|
my (%dest_dir, %list_ref);
|
|
|
|
$dest_dir{$platform_zip_file} = $dest;
|
|
|
|
$dest_dir{$common_zip_file} = $common_dest;
|
|
|
|
$list_ref{$platform_zip_file} = \@zip_list;
|
|
|
|
$list_ref{$common_zip_file} = \@common_zip_list;
|
|
|
|
|
2003-12-01 09:17:17 -06:00
|
|
|
my @zipfiles;
|
|
|
|
$zipfiles[0] = $platform_zip_file;
|
|
|
|
if ( $common_build ) {
|
|
|
|
push @zipfiles, ($common_zip_file);
|
|
|
|
}
|
|
|
|
foreach my $zip_file ( @zipfiles ) {
|
2003-04-15 04:32:19 -05:00
|
|
|
print "ZIP: updating $zip_file\n";
|
2003-08-21 09:14:33 -05:00
|
|
|
next if ( $opt_check );
|
2003-04-15 04:32:19 -05:00
|
|
|
# zip content has to be relative to $dest_dir
|
|
|
|
chdir($dest_dir{$zip_file});
|
|
|
|
my $this_ref = $list_ref{$zip_file};
|
|
|
|
if ( $opt_delete ) {
|
|
|
|
open(ZIP, "| $zipexe -q -o -d -@ $zip_file");
|
|
|
|
foreach $file ( @$this_ref ) {
|
|
|
|
print "ZIP: removing $file from $platform_zip_file\n" if $is_debug;
|
|
|
|
print ZIP "$file\n";
|
|
|
|
}
|
|
|
|
close(ZIP);
|
|
|
|
} else {
|
|
|
|
open(ZIP, "| $zipexe -q -o -u -@ $zip_file");
|
|
|
|
foreach $file ( @$this_ref ) {
|
|
|
|
print "ZIP: adding $file to $zip_file\n" if $is_debug;
|
|
|
|
print ZIP "$file\n";
|
|
|
|
}
|
|
|
|
close(ZIP);
|
2003-03-27 04:48:49 -06:00
|
|
|
}
|
2002-11-08 03:59:58 -06:00
|
|
|
}
|
2001-08-02 05:03:24 -05:00
|
|
|
}
|
2001-04-25 07:26:33 -05:00
|
|
|
|
2003-07-02 07:42:21 -05:00
|
|
|
sub delete_output
|
|
|
|
{
|
|
|
|
my $output_path = expand_macros("../%__SRC%");
|
|
|
|
if ( "$output_path" ne "../" ) {
|
|
|
|
if ( rmtree([$output_path], 0, 1) ) {
|
|
|
|
print "Deleted output tree.\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print_error("Error deleting output tree $output_path: $!",0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print_error("Output not deleted - INPATH is not set");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub print_error
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
my $message = shift;
|
|
|
|
my $line = shift;
|
|
|
|
|
|
|
|
print STDERR "$script_name: ";
|
|
|
|
if ( $dlst_file ) {
|
|
|
|
print STDERR "$dlst_file: ";
|
|
|
|
}
|
|
|
|
if ( $line ) {
|
|
|
|
print STDERR "line $line: ";
|
|
|
|
}
|
|
|
|
print STDERR "ERROR: $message\n";
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub print_stats
|
|
|
|
{
|
2001-04-19 09:43:15 -05:00
|
|
|
print "Statistics:\n";
|
2002-01-23 05:44:35 -06:00
|
|
|
if ( $opt_delete ) {
|
|
|
|
print "Files removed $files_copied\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "Files copied: $files_copied\n";
|
|
|
|
}
|
2001-04-19 09:43:15 -05:00
|
|
|
print "Files unchanged/not matching: $files_unchanged\n";
|
|
|
|
}
|
|
|
|
|
2002-07-18 10:47:26 -05:00
|
|
|
sub cleanup_and_die
|
|
|
|
{
|
|
|
|
# clean up on unexpected termination
|
|
|
|
my $sig = shift;
|
|
|
|
if ( defined($temp_file) && -e $temp_file ) {
|
|
|
|
unlink($temp_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
die "caught unexpected signal $sig, terminating ...";
|
|
|
|
}
|
|
|
|
|
2002-04-09 08:59:37 -05:00
|
|
|
sub usage
|
|
|
|
{
|
2002-01-23 05:44:35 -06:00
|
|
|
print STDERR "Usage:\ndeliver [-force] [-minor] [-check] [-zip] [-delete] [destination-path]\n";
|
2001-04-19 09:43:15 -05:00
|
|
|
print STDERR "Options:\n -force\tcopy even if not newer\n";
|
|
|
|
print STDERR " -minor\tdeliver into minor\n";
|
|
|
|
print STDERR " -check\tjust print what would happen, no actual copying of files\n";
|
2001-08-02 05:03:24 -05:00
|
|
|
print STDERR " -zip \tcreate additional zip files of delivered content\n";
|
2002-01-23 05:44:35 -06:00
|
|
|
print STDERR " -delete\tdelete files, use with care\n";
|
2003-07-02 07:42:21 -05:00
|
|
|
if ( !defined($ENV{GUI}) || $ENV{GUI} ne 'WNT' ) {
|
|
|
|
print STDERR " -link \thard link files into the solver to save disk space\n";
|
|
|
|
}
|
|
|
|
print STDERR " -deloutput\tremove the output tree\n";
|
2001-08-02 05:03:24 -05:00
|
|
|
print STDERR "The option -zip and a destination-path are mutually exclusive\n";
|
2001-04-19 09:43:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# vim: set ts=4 shiftwidth=4 expandtab syntax=perl:
|