View | Details | Raw Unified | Return to issue 14653
Collapse All | Expand All

(-)deliver.pl (-50 / +65 lines)
Lines 126-131 $opt_force = 0; # op Link Here
126
$opt_minor          = 0;            # option deliver in minor
126
$opt_minor          = 0;            # option deliver in minor
127
$opt_check          = 0;            # do actually execute any action
127
$opt_check          = 0;            # do actually execute any action
128
$opt_zip            = 0;            # create an additional zip file
128
$opt_zip            = 0;            # create an additional zip file
129
$opt_link           = 0;            # hard link files into the solver to save disk space
130
$opt_deloutput      = 0;            # delete the output tree for the project once successfully delivered
129
131
130
# zip is default for RE
132
# zip is default for RE
131
$opt_zip = 1 if ( defined($ENV{UPDATER}) && $ENV{UPDATER} eq 'YES' && !defined($ENV{BUILD_SOSL}) );
133
$opt_zip = 1 if ( defined($ENV{UPDATER}) && $ENV{UPDATER} eq 'YES' && !defined($ENV{BUILD_SOSL}) );
Lines 149-154 parse_dlst(); Link Here
149
walk_action_data();
151
walk_action_data();
150
walk_hedabu_list();
152
walk_hedabu_list();
151
zip_files() if $opt_zip;
153
zip_files() if $opt_zip;
154
delete_output() if $opt_deloutput;
152
print_stats();
155
print_stats();
153
156
154
exit(0);
157
exit(0);
Lines 386-391 sub parse_options Link Here
386
        $arg =~ /^-check$/  and $opt_check  = 1 and next;
389
        $arg =~ /^-check$/  and $opt_check  = 1 and next;
387
        $arg =~ /^-zip$/    and $opt_zip    = 1 and next;
390
        $arg =~ /^-zip$/    and $opt_zip    = 1 and next;
388
        $arg =~ /^-delete$/ and $opt_delete = 1 and next;
391
        $arg =~ /^-delete$/ and $opt_delete = 1 and next;
392
        $arg =~ /^-link$/   and $opt_link   = 1 and next;
393
        $arg =~ /^-deloutput$/ and $opt_deloutput = 1 and next;
389
        print_error("invalid option $arg") if ( $arg =~ /-/ ); 
394
        print_error("invalid option $arg") if ( $arg =~ /-/ ); 
390
        if ( $arg =~ /-/ || $#ARGV > -1 ) {
395
        if ( $arg =~ /-/ || $#ARGV > -1 ) {
391
            usage(); 
396
            usage(); 
Lines 660-722 sub copy_if_newer Link Here
660
665
661
    if ( $opt_delete ) {
666
    if ( $opt_delete ) {
662
        print "REMOVE: $to\n";
667
        print "REMOVE: $to\n";
668
        return 1 if $opt_check;
669
        my $rc = unlink($to);
670
        return 1 if $rc;
671
        return 0;
663
    }
672
    }
664
    else {
673
665
        if ( $touch ) {
674
    if( !$opt_check && $opt_link ) {
666
            print "TOUCH: $from -> $to\n";
675
        # hard link if possible
667
        }
676
        if( link($from, $to) ){
668
        else {
677
            print "LINK: $from -> $to\n";
669
            print "COPY: $from -> $to\n";
678
            return 1;
670
        }
679
        }
671
    }
680
    }
672
    if ( $opt_check ) {
681
673
        return 1;
682
    if( $touch ) {
674
    } 
683
       print "TOUCH: $from -> $to\n";
675
    else {
684
    }
676
        if ( $opt_delete ) {
685
    else {
677
            my $rc = unlink($to);
686
       print "COPY: $from -> $to\n";
678
            return 1 if $rc;
687
    }
679
            return 0;
688
     
689
    return 1 if( $opt_check );
690
691
    #
692
    # copy to temporary file first and rename later
693
    # to minimize the possibility for race conditions
694
    local $temp_file = sprintf('%s.%d-%d', $to, $$, time());
695
    my $rc = copy($from, $temp_file);
696
    if ( $rc) {
697
        $rc = utime($$from_stat_ref[9], $$from_stat_ref[9], $temp_file);
698
        if ( !$rc ) {
699
            print_error("can't update temporary file modification time '$temp_file': $!",0);
700
        }   
701
        fix_file_permissions($$from_stat_ref[2], $temp_file);
702
        $rc = rename($temp_file, $to);
703
        if ( $rc ) {
704
            # handle special packaging of *.dylib files for Mac OS X
705
            if ( $^O eq 'darwin' )
706
            {
707
                system("create-bundle", $to) if ( $to =~ /\.dylib/ );
708
                system("create-bundle", "$to=$from.app") if ( -d "$from.app" );
709
                system("ranlib", "$to" ) if ( $to =~ /\.a/ );
710
            }
711
            return 1;
680
        }
712
        }
681
        else {
713
        else {
682
            if ( -l $from ) {
714
            print_error("can't rename temporary file to $to: $!",0);
683
                print "$from is a link, don't copy.\n";
684
                return 0;
685
            }
686
            else {
687
                # copy to temporary file first and rename later
688
                # to minimize the possibility for race conditions
689
                local $temp_file = sprintf('%s.%d-%d', $to, $$, time());
690
                my $rc = copy($from, $temp_file);
691
                if ( $rc) {
692
                    $rc = utime($$from_stat_ref[9], $$from_stat_ref[9], $temp_file);
693
                    if ( !$rc ) {
694
                        print_error("can't update temporary file modification time '$temp_file': $!",0);
695
                    }   
696
                    fix_file_permissions($$from_stat_ref[2], $temp_file);
697
                    $rc = rename($temp_file, $to);
698
                    if ( $rc ) {
699
                        # handle special packaging of *.dylib files for Mac OS X
700
                        if ( $^O eq 'darwin' )
701
                        {
702
                            system("create-bundle", $to) if ( $to =~ /\.dylib/ );
703
                            system("create-bundle", "$to=$from.app") if ( -d "$from.app" );
704
                            system("ranlib", "$to" ) if ( $to =~ /\.a/ );
705
                        }
706
                        return 1;
707
                    }
708
                    else {
709
                        print_error("can't rename temporary file to $to: $!",0);
710
                    }
711
                }
712
                else {
713
                    print_error("can't copy $from: $!",0);
714
                }
715
                unlink($temp_file);
716
                return 0;
717
            }
718
        }
715
        }
719
    }
716
    }
717
    else {
718
        print_error("can't copy $from: $!",0);
719
    }
720
    unlink($temp_file);
721
    return 0;
720
}
722
}
721
723
722
sub is_newer 
724
sub is_newer 
Lines 1004-1009 sub zip_files Link Here
1004
    }
1006
    }
1005
}
1007
}
1006
1008
1009
sub delete_output
1010
{
1011
    my $output_path = expand_macros("../%__SRC%");
1012
    if ( rmtree([$output_path], 0, 1) ) {
1013
        print "Deleted output tree.\n";
1014
    }
1015
    else {
1016
        print_error("Error deleting output tree $output_path: $!",0);
1017
    }
1018
}
1019
1007
sub print_error 
1020
sub print_error 
1008
{
1021
{
1009
    my $message = shift;
1022
    my $message = shift;
Lines 1050-1055 sub usage Link Here
1050
    print STDERR "  -check\tjust print what would happen, no actual copying of files\n";
1063
    print STDERR "  -check\tjust print what would happen, no actual copying of files\n";
1051
    print STDERR "  -zip  \tcreate additional zip files of delivered content\n";
1064
    print STDERR "  -zip  \tcreate additional zip files of delivered content\n";
1052
    print STDERR "  -delete\tdelete files, use with care\n";
1065
    print STDERR "  -delete\tdelete files, use with care\n";
1066
    print STDERR "  -link \thard link files into the solver to save disk space\n";
1067
    print STDERR "  -deloutput\tremove the output tree\n";
1053
    print STDERR "The option -zip and a destination-path are mutually exclusive\n";
1068
    print STDERR "The option -zip and a destination-path are mutually exclusive\n";
1054
}
1069
}
1055
1070

Return to issue 14653