1*b1cdbd2cSJim Jagielski: 2*b1cdbd2cSJim Jagielskieval 'exec perl -wS $0 ${1+"$@"}' 3*b1cdbd2cSJim Jagielski if 0; 4*b1cdbd2cSJim Jagielski 5*b1cdbd2cSJim Jagielski#************************************************************** 6*b1cdbd2cSJim Jagielski# 7*b1cdbd2cSJim Jagielski# Licensed to the Apache Software Foundation (ASF) under one 8*b1cdbd2cSJim Jagielski# or more contributor license agreements. See the NOTICE file 9*b1cdbd2cSJim Jagielski# distributed with this work for additional information 10*b1cdbd2cSJim Jagielski# regarding copyright ownership. The ASF licenses this file 11*b1cdbd2cSJim Jagielski# to you under the Apache License, Version 2.0 (the 12*b1cdbd2cSJim Jagielski# "License"); you may not use this file except in compliance 13*b1cdbd2cSJim Jagielski# with the License. You may obtain a copy of the License at 14*b1cdbd2cSJim Jagielski# 15*b1cdbd2cSJim Jagielski# http://www.apache.org/licenses/LICENSE-2.0 16*b1cdbd2cSJim Jagielski# 17*b1cdbd2cSJim Jagielski# Unless required by applicable law or agreed to in writing, 18*b1cdbd2cSJim Jagielski# software distributed under the License is distributed on an 19*b1cdbd2cSJim Jagielski# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20*b1cdbd2cSJim Jagielski# KIND, either express or implied. See the License for the 21*b1cdbd2cSJim Jagielski# specific language governing permissions and limitations 22*b1cdbd2cSJim Jagielski# under the License. 23*b1cdbd2cSJim Jagielski# 24*b1cdbd2cSJim Jagielski#************************************************************** 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski#********************************************************************* 30*b1cdbd2cSJim Jagielski# 31*b1cdbd2cSJim Jagielski# main 32*b1cdbd2cSJim Jagielski# 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski$destdir = pop @ARGV; 35*b1cdbd2cSJim Jagielskimkdir $destdir,0777; 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski$productname = "OpenOffice"; 38*b1cdbd2cSJim Jagielski$productfilename = "apacheopenoffice"; 39*b1cdbd2cSJim Jagielski$prefix = ""; 40*b1cdbd2cSJim Jagielski$iconprefix = ""; 41*b1cdbd2cSJim Jagielski 42*b1cdbd2cSJim Jagielskiwhile ($_ = $ARGV[0], /^-/) { 43*b1cdbd2cSJim Jagielski shift; 44*b1cdbd2cSJim Jagielski last if /^--$/; 45*b1cdbd2cSJim Jagielski if (/^-p/) { 46*b1cdbd2cSJim Jagielski $productname = $ARGV[0]; 47*b1cdbd2cSJim Jagielski shift; 48*b1cdbd2cSJim Jagielski } 49*b1cdbd2cSJim Jagielski if (/^-u/) { 50*b1cdbd2cSJim Jagielski $productfilename = $ARGV[0]; 51*b1cdbd2cSJim Jagielski shift; 52*b1cdbd2cSJim Jagielski } 53*b1cdbd2cSJim Jagielski if (/^--prefix/) { 54*b1cdbd2cSJim Jagielski $prefix = $ARGV[0]; 55*b1cdbd2cSJim Jagielski shift; 56*b1cdbd2cSJim Jagielski } 57*b1cdbd2cSJim Jagielski if (/^--iconprefix/) { 58*b1cdbd2cSJim Jagielski $iconprefix = $ARGV[0]; 59*b1cdbd2cSJim Jagielski shift; 60*b1cdbd2cSJim Jagielski } 61*b1cdbd2cSJim Jagielski if (/^--category/) { 62*b1cdbd2cSJim Jagielski $category = $ARGV[0]; 63*b1cdbd2cSJim Jagielski shift; 64*b1cdbd2cSJim Jagielski } 65*b1cdbd2cSJim Jagielski} 66*b1cdbd2cSJim Jagielski 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielskiwhile (<>) { 69*b1cdbd2cSJim Jagielski unless (open INFILE,$ARGV) { 70*b1cdbd2cSJim Jagielski print STDOUT "Can't open input file $ARGV: $!\n"; 71*b1cdbd2cSJim Jagielski exit 1; 72*b1cdbd2cSJim Jagielski } 73*b1cdbd2cSJim Jagielski 74*b1cdbd2cSJim Jagielski $srcfile = substr($ARGV, rindex($ARGV, "/") + 1); 75*b1cdbd2cSJim Jagielski 76*b1cdbd2cSJim Jagielski unless (open OUTFILE,"> $destdir/$prefix$srcfile") { 77*b1cdbd2cSJim Jagielski print STDOUT "Can't open output file $destdir/$prefix$srcfile: $!\n"; 78*b1cdbd2cSJim Jagielski exit 1; 79*b1cdbd2cSJim Jagielski } 80*b1cdbd2cSJim Jagielski 81*b1cdbd2cSJim Jagielski while (<INFILE>) { 82*b1cdbd2cSJim Jagielski # remove possible Windows line-ends 83*b1cdbd2cSJim Jagielski chomp; 84*b1cdbd2cSJim Jagielski 85*b1cdbd2cSJim Jagielski # patch all occurances of openoffice in ICON line with 86*b1cdbd2cSJim Jagielski # $prefix 87*b1cdbd2cSJim Jagielski s/Icon=/Icon=$iconprefix/; 88*b1cdbd2cSJim Jagielski 89*b1cdbd2cSJim Jagielski # patch all occurances of openoffice in icon_filename 90*b1cdbd2cSJim Jagielski # line with $prefix 91*b1cdbd2cSJim Jagielski s/icon_filename=/icon_filename=$iconprefix/; 92*b1cdbd2cSJim Jagielski 93*b1cdbd2cSJim Jagielski # patch all occurances of openoffice in EXEC line with 94*b1cdbd2cSJim Jagielski # $productfilename 95*b1cdbd2cSJim Jagielski if ( /Exec/ ) { 96*b1cdbd2cSJim Jagielski s/openoffice/$productfilename/; 97*b1cdbd2cSJim Jagielski } 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski # if $productfilename != "openoffice, add it to the list 100*b1cdbd2cSJim Jagielski # of applications. 101*b1cdbd2cSJim Jagielski if ( /user_level=$/ ) { 102*b1cdbd2cSJim Jagielski $_ = $_ . $productfilename; 103*b1cdbd2cSJim Jagielski } elsif ( /user_level/ ) { 104*b1cdbd2cSJim Jagielski s/$productfilename,//; 105*b1cdbd2cSJim Jagielski s/user_level=/user_level=$productfilename,/ 106*b1cdbd2cSJim Jagielski } 107*b1cdbd2cSJim Jagielski 108*b1cdbd2cSJim Jagielski # append special category if specified 109*b1cdbd2cSJim Jagielski if ( /Categories/ ) { 110*b1cdbd2cSJim Jagielski if ( length($category) > 0 ) { 111*b1cdbd2cSJim Jagielski $_ = "$_$category;"; 112*b1cdbd2cSJim Jagielski } 113*b1cdbd2cSJim Jagielski } 114*b1cdbd2cSJim Jagielski 115*b1cdbd2cSJim Jagielski # replace %PRODUCTNAME placeholders 116*b1cdbd2cSJim Jagielski s/%PRODUCTNAME/$productname/g; 117*b1cdbd2cSJim Jagielski 118*b1cdbd2cSJim Jagielski print OUTFILE "$_\n"; 119*b1cdbd2cSJim Jagielski } 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski close(OUTFILE); 122*b1cdbd2cSJim Jagielski close(INFILE); 123*b1cdbd2cSJim Jagielski} 124