usr/src/tools/install-proto.pl
changeset 6 1fb1123973f8
parent 0 b34509ac961f
child 66 f9848e44a68b
child 231 64b14ad80c09
equal deleted inserted replaced
5:d07534556b03 6:1fb1123973f8
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    19 #
    19 #
    20 # CDDL HEADER END
    20 # CDDL HEADER END
    21 #
    21 #
    22 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
    22 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
    23 # Use is subject to license terms.
    23 # Use is subject to license terms.
    24 #
    24 #
    25 #ident	"@(#)install-proto.pl	1.4	09/06/15 SMI"
    25 #ident	"@(#)install-proto.pl	1.5	10/01/08 SMI"
    26 #
    26 #
    27 # BSD compatible install(1b) that honors DESTDIR and performs SFW post
    27 # BSD compatible install(1b) that honors DESTDIR and performs SFW post
    28 # processing on various file types
    28 # processing on various file types
    29 #
    29 #
    30 
    30 
    31 use Getopt::Std;
    31 use Getopt::Std;
    32 use File::Basename;
    32 use File::Basename;
    33 use File::Copy;
    33 use File::Copy;
    34 
    34 
    35 my ($PERL, $DESTDIR, $SRC, $MANSCRIPT, %opts, @paths) =
    35 my ($PERL, $DESTDIR, $SRC, $MANSCRIPT, $PYTHON, %opts, @paths) =
    36 	($ENV{'PERL'}, $ENV{'DESTDIR'}, $ENV{'SRC'}, $ENV{'MANSCRIPT'});
    36 	($ENV{'PERL'}, $ENV{'DESTDIR'}, $ENV{'SRC'}, $ENV{'MANSCRIPT'}, $ENV{'PYTHON'});
    37 my ($post_process, $post_process_so, $strip) = (
    37 my ($post_process, $post_process_so, $strip) = (
    38 	$SRC.'/tools/post_process',
    38 	$SRC.'/tools/post_process',
    39 	$SRC.'/tools/post_process_so',
    39 	$SRC.'/tools/post_process_so',
    40 	'/usr/ccs/bin/strip');
    40 	'/usr/ccs/bin/strip');
    41 my $progname = basename($0);
    41 my $progname = basename($0);
    42 
    42 
    43 defined($PERL) || ($PERL = $);	# fallback to this version of perl
    43 defined($PERL) || ($PERL = $);	# fallback to this version of perl
       
    44 defined($PYTHON) || ($PYTHON = '/usr/bin/python2.4');	# fallback to this version of perl
    44 
    45 
    45 (defined($DESTDIR)) || ($DESTDIR = $ENV{'ROOT'});
    46 (defined($DESTDIR)) || ($DESTDIR = $ENV{'ROOT'});
    46 
    47 
    47 sub usage {
    48 sub usage {
    48 	print "$progname [-cs] [-g group] [-o owner] [-m mode] file1 file2\n";
    49 	print "$progname [-cs] [-g group] [-o owner] [-m mode] file1 file2\n";
    78 	my $type = file_type($src);
    79 	my $type = file_type($src);
    79 	if ((defined($MANSCRIPT)) && ($type =~ /roff,/)) {
    80 	if ((defined($MANSCRIPT)) && ($type =~ /roff,/)) {
    80 		(-f $MANSCRIPT) ||
    81 		(-f $MANSCRIPT) ||
    81 			die "$progname: error: $MANSCRIPT does not exist\n";
    82 			die "$progname: error: $MANSCRIPT does not exist\n";
    82 		system("sed -f $MANSCRIPT <$src >$dst");
    83 		system("sed -f $MANSCRIPT <$src >$dst");
    83 	} elsif ($type =~ /perl .*script/) {
    84 	} elsif ($type =~ / .*script/) {
    84 		my $IFH, $OFH;
    85 		my $IFH, $OFH;
    85 
    86 
    86 		open($IFH, "<$src") || die("$progname: open(<$src): $!\n");
    87 		open($IFH, "<$src") || die("$progname: open(<$src): $!\n");
    87 		open($OFH, ">$dst") || die("$progname: open(>$dst): $!\n");
    88 		open($OFH, ">$dst") || die("$progname: open(>$dst): $!\n");
    88 
    89 
    89 		while (<$IFH>) {
    90 		while (<$IFH>) {
    90 			($. == 1) && (s|^#!.*perl|#!${PERL}|g);
    91 			if ($. == 1) {
       
    92 				(s|^#!.*perl|#!${PERL}|g);
       
    93 				(s|^#!.*python[\d\.]*|#!${PYTHON}|g);
       
    94 			}
    91 			print($OFH "$_");
    95 			print($OFH "$_");
    92 		}
    96 		}
    93 
    97 
    94 		close($IFH);
    98 		close($IFH);
    95 		close($OFH);
    99 		close($OFH);