merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / modules / par2script / parameter.pm
blobf9e7f72a3f82aed25b873c8a4c303b3f96a96f58
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: parameter.pm,v $
11 # $Revision: 1.6 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
33 package par2script::parameter;
35 use Cwd;
36 use par2script::files;
37 use par2script::globals;
38 use par2script::systemactions;
40 ############################################
41 # Parameter Operations
42 ############################################
44 ###############################################################################
45 # Usage:
46 # perl par2script.pl -i ..\wntmsci8.pro\par,o:\SRX645\wntmsci8.pro\par.m24
47 # @@C:\DOCUMEN~1\is\LOCALS~1\Temp\mk6pd
48 # -o ..\wntmsci8.pro\bin\osl\setup_osl.inf
49 ###############################################################################
51 sub usage
53 print <<Ende;
55 --------------------------------------------------------------
56 $par2script::globals::prog
57 The following parameter are needed:
58 -i: include pathes, comma separated list
59 -o: setup script file name
60 -v: writing logfile.txt (optional)
61 \@\@list: list of all par files
63 Example:
64 perl par2script.pl -i ..\\wntmsci8\\par\,o\:\\SRX645\\wntmsci8\\par.m24
65 \@\@C\:\\DOCUMEN\~1\\is\\LOCALS\~1\\Temp\\mk6pd
66 -o ..\\wntmsci8.pro\\bin\\osl\\setup_osl.inf \[-v\]
68 --------------------------------------------------------------
69 Ende
70 exit(-1);
73 #####################################
74 # Reading parameter
75 #####################################
77 sub getparameter
79 while ( $#ARGV >= 0 )
81 my $param = shift(@ARGV);
83 if ($param eq "-o") { $par2script::globals::scriptname = shift(@ARGV); }
84 elsif ($param eq "-v") { $par2script::globals::logging = 1; }
85 elsif ($param =~ /\@\@/) { $par2script::globals::parfilelistorig = $param; }
86 elsif ($param eq "-i") { $par2script::globals::includepathlist = shift(@ARGV); }
87 elsif (($param =~ /\//) || ($param =~ /\\/)) # another include parameter!
89 $par2script::globals::includepathlist = $par2script::globals::includepathlist . "," . $param;
91 else
93 print("\n*************************************\n");
94 print("Sorry, unknown parameter: $param");
95 print("\n*************************************\n");
96 usage();
97 exit(-1);
102 ############################################
103 # Controlling the fundamental parameter
104 # (required for every process)
105 ############################################
107 sub control_parameter
109 if ($par2script::globals::includepathlist eq "")
111 print "\n************************************************\n";
112 print "Error: Include pathes not set not set (-i)!";
113 print "\n************************************************\n";
114 usage();
115 exit(-1);
118 if ($par2script::globals::scriptname eq "")
120 print "\n************************************************\n";
121 print "Error: Name of the setup script not set (-o)!";
122 print "\n************************************************\n";
123 usage();
124 exit(-1);
127 if ($par2script::globals::parfilelistorig eq "")
129 print "\n************************************************\n";
130 print "Error: List of par files not set!";
131 print "\n************************************************\n";
132 usage();
133 exit(-1);
136 # The par file list has to exist
138 $par2script::globals::parfilelist = $par2script::globals::parfilelistorig;
139 $par2script::globals::parfilelist =~ s/\@\@//;
140 par2script::files::check_file($par2script::globals::parfilelist);
143 #####################################
144 # Writing parameter to shell
145 #####################################
147 sub outputparameter
149 my $outputline = "\n$par2script::globals::prog -i $par2script::globals::includepathlist $par2script::globals::parfilelistorig -o $par2script::globals::scriptname";
151 if ($par2script::globals::logging) { $outputline .= " -v"; }
153 $outputline .= "\n";
155 print $outputline;