1*cdf0e10cSrcweir: 2*cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}' 3*cdf0e10cSrcweir if 0; 4*cdf0e10cSrcweir 5*cdf0e10cSrcweir#************************************************************************* 6*cdf0e10cSrcweir# 7*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8*cdf0e10cSrcweir# 9*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 10*cdf0e10cSrcweir# 11*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 12*cdf0e10cSrcweir# 13*cdf0e10cSrcweir# This file is part of OpenOffice.org. 14*cdf0e10cSrcweir# 15*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 16*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 17*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 18*cdf0e10cSrcweir# 19*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 20*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 21*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 23*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 24*cdf0e10cSrcweir# 25*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 26*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 27*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 28*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 29*cdf0e10cSrcweir# 30*cdf0e10cSrcweir#************************************************************************* 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir#********************************************************************* 34*cdf0e10cSrcweir# 35*cdf0e10cSrcweir# main 36*cdf0e10cSrcweir# 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir$destdir = pop @ARGV; 39*cdf0e10cSrcweirmkdir $destdir,0777; 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir$productname = "OpenOffice.org"; 42*cdf0e10cSrcweir$productfilename = "openoffice"; 43*cdf0e10cSrcweir$prefix = ""; 44*cdf0e10cSrcweir$iconprefix = ""; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweirwhile ($_ = $ARGV[0], /^-/) { 47*cdf0e10cSrcweir shift; 48*cdf0e10cSrcweir last if /^--$/; 49*cdf0e10cSrcweir if (/^-p/) { 50*cdf0e10cSrcweir $productname = $ARGV[0]; 51*cdf0e10cSrcweir shift; 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir if (/^-u/) { 54*cdf0e10cSrcweir $productfilename = $ARGV[0]; 55*cdf0e10cSrcweir shift; 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir if (/^--prefix/) { 58*cdf0e10cSrcweir $prefix = $ARGV[0]; 59*cdf0e10cSrcweir shift; 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir if (/^--iconprefix/) { 62*cdf0e10cSrcweir $iconprefix = $ARGV[0]; 63*cdf0e10cSrcweir shift; 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir if (/^--category/) { 66*cdf0e10cSrcweir $category = $ARGV[0]; 67*cdf0e10cSrcweir shift; 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir} 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir 72*cdf0e10cSrcweirwhile (<>) { 73*cdf0e10cSrcweir unless (open INFILE,$ARGV) { 74*cdf0e10cSrcweir print STDOUT "Can't open input file $ARGV: $!\n"; 75*cdf0e10cSrcweir exit 1; 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir $srcfile = substr($ARGV, rindex($ARGV, "/") + 1); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir unless (open OUTFILE,"> $destdir/$prefix$srcfile") { 81*cdf0e10cSrcweir print STDOUT "Can't open output file $destdir/$prefix$srcfile: $!\n"; 82*cdf0e10cSrcweir exit 1; 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir while (<INFILE>) { 86*cdf0e10cSrcweir # remove possible Windows line-ends 87*cdf0e10cSrcweir chomp; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir # patch all occurances of openoffice in ICON line with 90*cdf0e10cSrcweir # $prefix 91*cdf0e10cSrcweir s/Icon=/Icon=$iconprefix/; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir # patch all occurances of openoffice in icon_filename 94*cdf0e10cSrcweir # line with $prefix 95*cdf0e10cSrcweir s/icon_filename=/icon_filename=$iconprefix/; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir # patch all occurances of openoffice in EXEC line with 98*cdf0e10cSrcweir # $productfilename 99*cdf0e10cSrcweir if ( /Exec/ ) { 100*cdf0e10cSrcweir s/openoffice/$productfilename/; 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir # if $productfilename != "openoffice, add it to the list 104*cdf0e10cSrcweir # of applications. 105*cdf0e10cSrcweir if ( /user_level=$/ ) { 106*cdf0e10cSrcweir $_ = $_ . $productfilename; 107*cdf0e10cSrcweir } elsif ( /user_level/ ) { 108*cdf0e10cSrcweir s/$productfilename,//; 109*cdf0e10cSrcweir s/user_level=/user_level=$productfilename,/ 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir # append special category if specified 113*cdf0e10cSrcweir if ( /Categories/ ) { 114*cdf0e10cSrcweir if ( length($category) > 0 ) { 115*cdf0e10cSrcweir $_ = "$_$category;"; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir # replace %PRODUCTNAME placeholders 120*cdf0e10cSrcweir s/%PRODUCTNAME/$productname/g; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir print OUTFILE "$_\n"; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir close(OUTFILE); 126*cdf0e10cSrcweir close(INFILE); 127*cdf0e10cSrcweir} 128