xref: /aoo41x/main/solenv/bin/modules/packager/check.pm (revision 72bd2d34)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24package packager::check;
25
26use packager::exiter;
27use packager::globals;
28
29##############################################
30# Check 1: The package list has to exist
31##############################################
32
33sub check_packlist
34{
35	my $custompacklist = $ENV{'CUSTOM_PACK_LIST'};
36	if ( defined $custompacklist && length $custompacklist > 0 )
37	{
38		$packager::globals::packlistname = $custompacklist;
39	}
40	else
41	{
42		my $projectdir = $ENV{'PRJ'};
43		$projectdir =~ s/$packager::globals::separator\s*$//;
44		$packager::globals::packlistname = $projectdir . $packager::globals::separator . "util" . $packager::globals::separator . $packager::globals::packlistname;
45	}
46
47	print "Using pack list " . $packager::globals::packlistname . "\n";
48
49	if ( ! -f $packager::globals::packlistname )
50	{
51		packager::exiter::exit_program("ERROR: Package list not found: $packager::globals::packlistname", "check_packlist");
52	}
53}
54
55#############################################################
56# Check 2: The environment variable OUTPATH has to be set
57#############################################################
58
59sub check_environment
60{
61	if ( ! $ENV{'OUTPATH'} )
62	{
63		packager::exiter::exit_program("ERROR: Environment variable OUTPATH not set!", "check_environment");
64	}
65
66	if ( ! $ENV{'PRJ'} )
67	{
68		packager::exiter::exit_program("ERROR: Environment variable PRJ not set!", "check_environment");
69	}
70}
71
72#############################################################
73# Check 3: Checking the parameter. Only "-i" is valid
74#############################################################
75
76sub check_parameter
77{
78	while ( $#ARGV >= 0 )
79	{
80		my $param = shift(@ARGV);
81
82		if ($param eq "-i") { $packager::globals::ignoreerrors = 1; }
83		else
84		{
85			print("\n*************************************\n");
86			print("Sorry, unknown parameter: $param");
87			print("\n*************************************\n");
88			usage();
89			exit(-1);
90		}
91	}
92}
93
941;
95