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