1: # -*- perl -*- 2eval 'exec perl -wS $0 ${1+"$@"}' 3 if 0; 4# ************************************************************* 5# 6# Licensed to the Apache Software Foundation (ASF) under one 7# or more contributor license agreements. See the NOTICE file 8# distributed with this work for additional information 9# regarding copyright ownership. The ASF licenses this file 10# to you under the Apache License, Version 2.0 (the 11# "License"); you may not use this file except in compliance 12# with the License. You may obtain a copy of the License at 13# 14# http://www.apache.org/licenses/LICENSE-2.0 15# 16# Unless required by applicable law or agreed to in writing, 17# software distributed under the License is distributed on an 18# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19# KIND, either express or implied. See the License for the 20# specific language governing permissions and limitations 21# under the License. 22# 23# ************************************************************* 24# create setup self extracting script 25 26if( $#ARGV < 2 ) 27 { 28 print <<ENDHELP; 29USAGE: $0 <inputshellscript> <libraryfile> <outputshellscript> 30 <inputshellscript>: the start shell script, located next to this perl script 31 <libraryfile>: the library file, that is included into the shell script 32 <outfile>: the target shellscript 33 34ENDHELP 35 exit; 36 } 37 38$infile = $ARGV[0]; 39$library = $ARGV[1]; 40$outfile = $ARGV[2]; 41$infile =~ tr/[A-Z]/[a-z]/; 42 43# read script header 44open( SCRIPT, "<$infile" ) || die "cannot open $infile"; 45open( OUTFILE, ">$outfile$$.tmp" ) || die "cannot open $outfile"; 46@scriptlines = <SCRIPT>; 47$linenum = $#scriptlines+2; 48foreach (@scriptlines) 49{ 50 # lineend conversion (be on the safe side) 51 chomp; 52 $_ =~ tr/\r//; 53 s/^\s*linenum=.*$/linenum=$linenum/; 54 print OUTFILE "$_\n"; 55} 56close( SCRIPT ); 57close( OUTFILE ); 58 59system( "cat $library >>$outfile$$.tmp" ); 60rename "$outfile$$.tmp", "$outfile"; 61 62chmod 0775, $outfile; 63 64exit; 65