Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
407 dpurdie 1
########################################################################
2
# Copyright (C) 2007 ERG Limited, All rights reserved
3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : This package extends the JATS toolset at build time
10
#                 It provides additional directives to the JATS makefiles
11
#                 to simplify the directives.
12
#
13
#                 The directive matches up with a run-time tool to
14
#                 do the bulk of the work.
15
#
16
# Operation     : This package adds the JATS directive MakeDebianPackage
17
#                 When used the directive will use GenerateFiles to invoke
18
#                 a script (DebianPackager.pl) to actually do the hard work.
19
#
20
# Syntax        : MakeDebianPackage (<platforms>, Options+);
21
#                 Where Options may be one of:
22
#                   --Script=DebianPackagerScript       - Mandatory. Name of a the debian script
23
#
24
#......................................................................#
25
 
26
require 5.6.1;
27
#use strict;
28
use warnings;
29
 
30
#-------------------------------------------------------------------------------
31
# Function        : MakeDebianPackage
32
#
33
# Description     : Create a Debian Package
34
#
35
# Inputs          : PkgName                 - Symbolic Package Name
36
#                   --Script=Name           - Script to use in the packaging process
37
#
38
# Returns         : 
39
#
40
sub MakeDebianPackage
41
{
42
    my( $platforms, @elements ) = @_;
43
    Debug2( "MakeDebianPackage($platforms, @elements)" );
44
    return if ( ! ActivePlatform($platforms) );
45
 
46
    my $build_name =  $::ScmBuildPackage;
47
    my $build_version = $::ScmBuildVersionFull;
48
 
49
    #
50
    #   Take the project name and convert it into a full path
51
    #
52
    my $script;
53
 
54
    #
55
    #   Collect user arguments
56
    #   They are all processed within the toolset
57
    #
58
    foreach ( @elements )
59
    {
60
        if ( m/^--Script=(.+)/ ) {
61
            $script = $1;
62
 
63
        } elsif ( m/^--/ ) {
64
            Error("MakeDebianPackage. Unknown option: $_");
65
 
66
        } else {
67
            Error("MakeDebianPackage. Unknown argument: $_");
68
        }
69
    }
70
 
71
    #
72
    #   Sanity test
73
    #
74
    Error ("MakeDebianPackage: Script name not defined") unless ( $script );
75
 
76
 
77
    #
78
    #   Sanity check the package name and version
79
    #   Debian has strict requirements than JATS
80
    #       Name:    Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
81
    #                Release Manager does not allow '.'
82
    #       Version: alphanumerics and the characters . + - : (full stop, plus, hyphen, colon) and should start with a digit
83
    #
84
    if ( $build_name =~ m/_/ )
85
    {
86
        $build_name =~ s~_~-~g;
87
        Warning ("Package Name converted to debian friendly form: $build_name");
88
    }
89
 
90
    unless ( $build_name =~ m/^[a-z]{2}[-+a-z0-9]+$/ )
91
    {
92
        Error ("Package Name does not conform to Debian Requirements",
93
               "Must start with two alphabetic characters",
94
               "Must only contain: (a-z) (0-9) and -",
95
               "Provided Name: $::ScmBuildPackage");
96
    }
97
 
98
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
99
    {
100
        Error ("Package Version does not conform to Debian Requirements",
101
               "Must only contain: (a-zA-Z) (0-9), - and .",
102
               "Must sart with a number",
103
               );
104
    }
105
 
106
    #
107
    #   Create the name of the target package
108
    #   The form of the name is of a fixed form.
109
    #
110
    #   Note: "_" used since this is the format of dpkg-name
111
    #   Note: dpkg-name generates: Name _ Version _ Architecture
112
    #
113
    #
114
    my $DebianPkgName = "${build_name}_${::ScmBuildVersionFull}_${::ScmPlatform}.deb";
115
 
116
    #
117
    #   Simply use Generate Files
118
    #   With lots of options
119
    #
120
    Src ( '*', $script );
121
    GenerateFiles ('*', "--Tool=DebianPackager.pl",               # Associated tool
122
                        "-DebianPackage=--Prerequisite($script)", # Packager script
123
                        "--AutoGenerate",                         # Build when needed
124
                        "--UnknownPreq",                          # Always build
125
                        "--Clean",                                # Script supports jats clean
126
                        "--Text=Debian Package",                  # Display when building
127
 
128
                        '--Var(BuildName)',                       # Target Package
129
                        '--Var(BuildVersion)',                    # Target Version
130
                        '--Var(Platform)',                        # Target platform
131
                        '--Var(Product)',                         # Target product
132
                        '--Var(Target)',                          # Underlying Target
133
                        '--Var(Type)',                            # Build Type
134
 
135
                        '--Var(Verbose)',                         # Verbose operation
136
 
137
                        '--Var(InterfaceDir)',                    # Interface Directory
138
                        '--Var(InterfaceIncDir)',
139
                        '--Var(InterfaceLibDir)',
140
                        '--Var(InterfaceBinDir)',
141
 
142
                        '--Var(LibDir)',                          # My Artifacts
143
                        '--Var(BinDir)',
144
 
145
                        '--Var(PackageDir)',                      # My Package
146
                        '--Var(PackageLibDir)',                   # My Package Library
147
                        '--Var(PackageBinDir)',                   # My Package Bin
148
                        '--Var(PackagePkgDir)',                   # My Package/pkg.target
149
 
150
                        '--Var(LocalIncDir)',                     # Installed Artifacts
151
                        '--Var(LocalLibDir)',
152
                        '--Var(LocalBinDir)',
153
 
154
                        "-Output=--GeneratedProg($DebianPkgName)",# Specify output file
155
                        );
156
 
157
    #
158
    #   The Packager has created a binary in the 'PROG' directory
159
    #   Lets package it as a program.
160
    #
161
    PackageProg ('*', $DebianPkgName );
162
}
163
 
164
1;