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
 
409 alewis 26
require 5.006_001;
407 dpurdie 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
    #
409 alewis 84
    #   Allow ( and cleanup )
85
    #       ERGxxxxx    -> erg-xxx
86
    #       _           -> -
87
    #
88
    my $cvt = 0;
89
    $cvt = 1 if ( $build_name =~ s/^ERG/erg-/ );
90
    $cvt = 1 if ( $build_name =~ s~_~-~g );
91
    $cvt = 1 if ( $build_name =~ tr/-//s );
407 dpurdie 92
 
409 alewis 93
    Warning ("Package Name converted to debian friendly form: $build_name")
94
        if ( $cvt );
95
 
407 dpurdie 96
    unless ( $build_name =~ m/^[a-z]{2}[-+a-z0-9]+$/ )
97
    {
98
        Error ("Package Name does not conform to Debian Requirements",
99
               "Must start with two alphabetic characters",
100
               "Must only contain: (a-z) (0-9) and -",
101
               "Provided Name: $::ScmBuildPackage");
102
    }
103
 
104
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
105
    {
106
        Error ("Package Version does not conform to Debian Requirements",
107
               "Must only contain: (a-zA-Z) (0-9), - and .",
108
               "Must sart with a number",
109
               );
110
    }
111
 
112
    #
113
    #   Create the name of the target package
114
    #   The form of the name is of a fixed form.
115
    #
116
    #   Note: "_" used since this is the format of dpkg-name
117
    #   Note: dpkg-name generates: Name _ Version _ Architecture
118
    #
119
    #
120
    my $DebianPkgName = "${build_name}_${::ScmBuildVersionFull}_${::ScmPlatform}.deb";
121
 
122
    #
123
    #   Simply use Generate Files
124
    #   With lots of options
125
    #
126
    Src ( '*', $script );
127
    GenerateFiles ('*', "--Tool=DebianPackager.pl",               # Associated tool
128
                        "-DebianPackage=--Prerequisite($script)", # Packager script
129
                        "--AutoGenerate",                         # Build when needed
130
                        "--UnknownPreq",                          # Always build
131
                        "--Clean",                                # Script supports jats clean
132
                        "--Text=Debian Package",                  # Display when building
133
 
134
                        '--Var(BuildName)',                       # Target Package
135
                        '--Var(BuildVersion)',                    # Target Version
136
                        '--Var(Platform)',                        # Target platform
137
                        '--Var(Product)',                         # Target product
138
                        '--Var(Target)',                          # Underlying Target
139
                        '--Var(Type)',                            # Build Type
140
 
141
                        '--Var(Verbose)',                         # Verbose operation
142
 
143
                        '--Var(InterfaceDir)',                    # Interface Directory
144
                        '--Var(InterfaceIncDir)',
145
                        '--Var(InterfaceLibDir)',
146
                        '--Var(InterfaceBinDir)',
147
 
148
                        '--Var(LibDir)',                          # My Artifacts
149
                        '--Var(BinDir)',
150
 
151
                        '--Var(PackageDir)',                      # My Package
152
                        '--Var(PackageLibDir)',                   # My Package Library
153
                        '--Var(PackageBinDir)',                   # My Package Bin
154
                        '--Var(PackagePkgDir)',                   # My Package/pkg.target
155
 
156
                        '--Var(LocalIncDir)',                     # Installed Artifacts
157
                        '--Var(LocalLibDir)',
158
                        '--Var(LocalBinDir)',
159
 
160
                        "-Output=--GeneratedProg($DebianPkgName)",# Specify output file
161
                        );
162
 
163
    #
164
    #   The Packager has created a binary in the 'PROG' directory
165
    #   Lets package it as a program.
166
    #
167
    PackageProg ('*', $DebianPkgName );
168
}
169
 
170
1;