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