1*cdf0e10cSrcweir: # -*- perl -*- 2*cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}' 3*cdf0e10cSrcweir if 0; 4*cdf0e10cSrcweir# create setup self extracting script 5*cdf0e10cSrcweir 6*cdf0e10cSrcweirif( $#ARGV < 2 ) 7*cdf0e10cSrcweir { 8*cdf0e10cSrcweir print <<ENDHELP; 9*cdf0e10cSrcweirUSAGE: $0 <inputshellscript> <libraryfile> <outputshellscript> 10*cdf0e10cSrcweir <inputshellscript>: the start shell script, located next to this perl script 11*cdf0e10cSrcweir <libraryfile>: the library file, that is included into the shell script 12*cdf0e10cSrcweir <outfile>: the target shellscript 13*cdf0e10cSrcweir 14*cdf0e10cSrcweirENDHELP 15*cdf0e10cSrcweir exit; 16*cdf0e10cSrcweir } 17*cdf0e10cSrcweir 18*cdf0e10cSrcweir$infile = $ARGV[0]; 19*cdf0e10cSrcweir$library = $ARGV[1]; 20*cdf0e10cSrcweir$outfile = $ARGV[2]; 21*cdf0e10cSrcweir$infile =~ tr/[A-Z]/[a-z]/; 22*cdf0e10cSrcweir 23*cdf0e10cSrcweir# read script header 24*cdf0e10cSrcweiropen( SCRIPT, "<$infile" ) || die "cannot open $infile"; 25*cdf0e10cSrcweiropen( OUTFILE, ">$outfile$$.tmp" ) || die "cannot open $outfile"; 26*cdf0e10cSrcweir@scriptlines = <SCRIPT>; 27*cdf0e10cSrcweir$linenum = $#scriptlines+2; 28*cdf0e10cSrcweirforeach (@scriptlines) 29*cdf0e10cSrcweir{ 30*cdf0e10cSrcweir # lineend conversion (be on the safe side) 31*cdf0e10cSrcweir chomp; 32*cdf0e10cSrcweir $_ =~ tr/\r//; 33*cdf0e10cSrcweir s/^\s*linenum=.*$/linenum=$linenum/; 34*cdf0e10cSrcweir print OUTFILE "$_\n"; 35*cdf0e10cSrcweir} 36*cdf0e10cSrcweirclose( SCRIPT ); 37*cdf0e10cSrcweirclose( OUTFILE ); 38*cdf0e10cSrcweir 39*cdf0e10cSrcweirsystem( "cat $library >>$outfile$$.tmp" ); 40*cdf0e10cSrcweirrename "$outfile$$.tmp", "$outfile"; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweirchmod 0775, $outfile; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweirexit; 45