xref: /AOO41X/main/solenv/bin/modules/packager/check.pm (revision 4bfbcde8d64cc5d114df10dce4a9ed79eff32278)
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 $projectdir = $ENV{'PRJ'};
36    $projectdir =~ s/$packager::globals::separator\s*$//;
37    $packager::globals::packlistname = $projectdir . $packager::globals::separator . "util" . $packager::globals::separator . $packager::globals::packlistname;
38
39    if ( ! -f $packager::globals::packlistname )
40    {
41        packager::exiter::exit_program("ERROR: Package list not found: $packager::globals::packlistname", "check_packlist");
42    }
43}
44
45#############################################################
46# Check 2: The environment variable OUTPATH has to be set
47#############################################################
48
49sub check_environment
50{
51    if ( ! $ENV{'OUTPATH'} )
52    {
53        packager::exiter::exit_program("ERROR: Environment variable OUTPATH not set!", "check_environment");
54    }
55
56    if ( ! $ENV{'PRJ'} )
57    {
58        packager::exiter::exit_program("ERROR: Environment variable PRJ not set!", "check_environment");
59    }
60}
61
62#############################################################
63# Check 3: Checking the parameter. Only "-i" is valid
64#############################################################
65
66sub check_parameter
67{
68    while ( $#ARGV >= 0 )
69    {
70        my $param = shift(@ARGV);
71
72        if ($param eq "-i") { $packager::globals::ignoreerrors = 1; }
73        else
74        {
75            print("\n*************************************\n");
76            print("Sorry, unknown parameter: $param");
77            print("\n*************************************\n");
78            usage();
79            exit(-1);
80        }
81    }
82}
83
841;
85