source: ProjectBuilder/devel/pb/lib/common.pm@ 7

Last change on this file since 7 was 7, checked in by Bruno Cornec, 17 years ago

Begin to compile and execute

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates common environment
4#
5# $Id$
6#
7require Exporter;
8@ISA = qw(Exporter);
9@EXPORT = qw(set_env);
10
11use lib qw (lib);
12use pb qw (pb_init);
13use strict;
14use File::Basename;
15use ExtUtils::Command;
16use File::Temp qw /tempdir/;
17use vars qw (%defpkgdir %extpkgdir %version);
18
19$ENV{'PBCONF'} = "/etc/pb";
20
21sub set_env {
22
23my $proj=shift;
24my $ver;
25my $tag;
26
27# Check project name
28if ((defined $ENV{'PBPROJ'}) &&
29 (not (defined $proj))) {
30 $proj = $ENV{'PBPROJ'};
31}
32die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
33
34# Use project configuration file
35pb_init("$ENV{'PBCONF'}/$proj.pb");
36
37# Check content
38die "PBROOT doesn't exist in $ENV{'PBCONF'}/$proj.pb" if (not (defined $ENV{'PBROOT'}));
39die "defpkgdir doesn't exist in $ENV{'PBCONF'}/$proj.pb" if (not (defined %defpkgdir));
40
41# Set temp directory
42if (not defined $ENV{'TMPDIR'}) {
43 $ENV{'TMPDIR'}="/tmp";
44}
45$ENV{'PBTMP'} = tempdir( "pb.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 );
46
47# Get global VERSION
48open(VER, "$ENV{'PBROOT'}/VERSION") || die "Unable to open $ENV{'PBROOT'}/VERSION: $?";
49$ver = <VER>;
50chomp($ver);
51die "Invalid version name $ver in $ENV{'PBROOT'}/VERSION" if ($ver !~ /[0-9.]+/) || (defined $version{$ver});
52$ENV{'PBVER'}=$ver;
53close(VER);
54
55#Get global TAG
56open(TAG, "$ENV{'PBROOT'}/TAG") || die "Unable to open $ENV{'PBROOT'}/TAG: $?";
57$tag = <TAG>;
58chomp($tag);
59die "Invalid version tag $tag in $ENV{'PBROOT'}/TAG" if ($tag !~ /[0-9]+/);
60$ENV{'PBTAG'}=$tag;
61close(TAG);
62
63# Adapt to your needs
64# Set delivery directory
65$ENV{'PBTOPDIR'}="$ENV{'PBROOT'}/../delivery";
66$ENV{'PBDESTDIR'}=$ENV{'TOPDIR'}."/".$ENV{'PBVER'}."-".$ENV{'PBTAG'};
67mkpath $ENV{'PBDESTDIR'};
68
69umask 0022
70}
711;
Note: See TracBrowser for help on using the repository browser.