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