Subversion Repositories DevTools

Rev

Rev 7318 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7318 Rev 7319
Line 30... Line 30...
30
use File::Path;
30
use File::Path;
31
 
31
 
32
#-------------------------------------------------------------------------------
32
#-------------------------------------------------------------------------------
33
# Function        : GeneratePackageSignature 
33
# Function        : GeneratePackageSignature 
34
#
34
#
35
# Description     : Generate a package signature
-
 
36
#
-
 
37
# Inputs          : $pkgBase        - Path to the package's build file
-
 
38
#                   $outPath        - Base of path to create signature files 
-
 
39
#
-
 
40
# Returns         : The package signature
-
 
41
#
-
 
42
sub GeneratePackageSignature
-
 
43
{
-
 
44
    my ($pkgBase, $outPath) = @_;
-
 
45
 
-
 
46
    Error ("No directory specified") unless $pkgBase;
-
 
47
    Error ("Not a directory: $pkgBase") unless -d $pkgBase;
-
 
48
 
-
 
49
    my $parsedInfo = JatsParser::processBuild ($pkgBase);
-
 
50
    #DebugDumpData("GeneratePackageSignature::parsedInfo", $parsedInfo);
-
 
51
    Error ('BuildName not found') unless exists $parsedInfo->{BuildName};
-
 
52
 
-
 
53
    #   Generate a package signature from the parsed data
-
 
54
    #
-
 
55
    return BuildSignature($parsedInfo, $outPath, \&getPackageSignature);
-
 
56
}
-
 
57
 
-
 
58
 
-
 
59
#-------------------------------------------------------------------------------
-
 
60
# Function        : getPackageSignature 
-
 
61
#
-
 
62
# Description     : Helper routine 
-
 
63
#                   Given a package name and package version determine the package
-
 
64
#                   signature.
-
 
65
#                   
-
 
66
#                   Can used predetermined data or perform a package repo scan
-
 
67
#                   
-
 
68
#                   This version assumes that we are buildign within a jats sandbox
-
 
69
#                   Each packages signature file Package.sig is stored in the packages
-
 
70
#                   interface directory (at the moment).
-
 
71
#                   
-
 
72
#                   Process:
-
 
73
#                       Locate the packages interface directory - we have a link file to it
-
 
74
#                       Read in the PAckage Signature file
-
 
75
#
-
 
76
# Inputs          : $pname      - Package Name
-
 
77
#                   $pversion   - Package Version
-
 
78
#                   $mode       - Optional. true -> do not error if not found
-
 
79
#
-
 
80
# Returns         : The package signature. Undefined if the package canot be found
-
 
81
#                    
-
 
82
sub getPackageSignature
-
 
83
{
-
 
84
    my ($pname, $pversion, $mode ) = @_;
-
 
85
    my $prj = '';
-
 
86
    my $pkg;
-
 
87
    my $version;
-
 
88
    my $pkgSig;
-
 
89
 
-
 
90
    #
-
 
91
    #   Try the 'OLD' mode first
-
 
92
    #   This is a temp KLUDGE
-
 
93
    #
-
 
94
    $pkgSig = getPackageSignatureOld($pname, $pversion, 1);
-
 
95
    return $pkgSig if $pkgSig;
-
 
96
 
-
 
97
    # 
-
 
98
    #   We are in a sandbox and expect to find package signatures in the sandbox directory
-
 
99
    #
-
 
100
    my ($pn, $pv, $ps ) = SplitPackage ($pname, $pversion );
-
 
101
    $version = 'sandbox';
-
 
102
    $prj = '.' . $ps if ( $ps ); 
-
 
103
    $version .= $prj;
-
 
104
 
-
 
105
    my $signatureDir =  CatPaths($::GBE_DPKG_SBOX, $pname);
-
 
106
    my $signatureFile = CatPaths($signatureDir, 'sandbox' . $prj .'.Package.sig');
-
 
107
 
-
 
108
    if ( -f $signatureFile)
-
 
109
    {
-
 
110
        $pkgSig = TagFileRead($signatureFile);
-
 
111
        Error("Package signature invalid for $pname/$version", "Signature: $pkgSig") 
-
 
112
            if((length($pkgSig) != 40) && $pkgSig !~ m~^MSG:~) ;
-
 
113
    }
-
 
114
    else
-
 
115
    {
-
 
116
        Warning ("Package signature not found for $pname/$version", "You must 'build' the package before using it") unless $mode;
-
 
117
        $pkgSig = 'MSG: No signature for ' . $pname . '_' . $pversion;
-
 
118
    }
-
 
119
 
-
 
120
    return $pkgSig;
-
 
121
}
-
 
122
#-------------------------------------------------------------------------------
-
 
123
# Function        : getPackageSignatureOld  
-
 
124
#
-
 
125
# Description     : Get PAckage Signature using the old mechanism
-
 
126
#                   The package siganture is in the packages interface directory
-
 
127
#
-
 
128
# Inputs          : as for getPackageSignature 
-
 
129
#
-
 
130
# Returns         : 
-
 
131
#
-
 
132
 
-
 
133
sub getPackageSignatureOld
-
 
134
{
-
 
135
    my ($pname, $pversion, $mode ) = @_;
-
 
136
    my $prj = '';
-
 
137
    my $pkg;
-
 
138
    my $version;
-
 
139
    my $pkgSig;
-
 
140
 
-
 
141
    # 
-
 
142
    #   We are in a sandbox and expect to find a interface/Package.sig file
-
 
143
    #   This will allow us to locate the package in the package store
-
 
144
    #   
-
 
145
    #   If there is no interface/Package.sig, then the user must build (not make)
-
 
146
    #   the package in the sandbox.
-
 
147
    #   
-
 
148
    #   ie: the interface/Package.sig file allows us to use the package from package cache
-
 
149
    #       or indicates that the user has not yet built the package
-
 
150
    #       
-
 
151
    #   First locate the packages interface directory
-
 
152
    #   We have a nice link from the sandbox to assist in this
-
 
153
    #
-
 
154
    my ($pn, $pv, $ps ) = SplitPackage ($pname, $pversion );
-
 
155
    $version = 'sandbox';
-
 
156
    $prj = '.' . $ps if ( $ps ); 
-
 
157
    $version .= $prj;
-
 
158
     
-
 
159
    my $ifaceDir = CatPaths($::GBE_SANDBOX, 'sandbox_dpkg_archive', $pname, $version . '.int');
-
 
160
    $ifaceDir = TagFileRead($ifaceDir);
-
 
161
    $ifaceDir =~ s~\\~/~g;
-
 
162
    $ifaceDir =~ s~GBE_SANDBOX/~$::GBE_SANDBOX/~;
-
 
163
    my $pkgSigFile = CatPaths( $ifaceDir, 'Package.sig');
-
 
164
 
-
 
165
    if ( -f $pkgSigFile)
-
 
166
    {
-
 
167
#Debug0("$pname, $pversion --> $pkgSigFile");
-
 
168
        $pkgSig = TagFileRead($pkgSigFile);
-
 
169
        Error("Package signature invalid for $pname/$version", "Signature: $pkgSig") 
-
 
170
            if((length($pkgSig) != 40) && $pkgSig !~ m~^MSG:~) ;
-
 
171
    }
-
 
172
    else
-
 
173
    {
-
 
174
        Error("Package signature not found for $pname/$version", "You must 'build' the package before using it") unless $mode;
-
 
175
    }
-
 
176
 
-
 
177
    return $pkgSig;
-
 
178
}
-
 
179
 
-
 
180
 
-
 
181
#-------------------------------------------------------------------------------
-
 
182
# Function        : BuildSignature 
-
 
183
#
-
 
184
# Description     : Generate a package 'signature' for this package
35
# Description     : Generate a package 'signature' for this package
185
#               
36
#               
186
#                   The signature is used to bypass the entire Make processing in a sandbox
37
#                   The signature is used to bypass the entire Make processing in a sandbox
187
#                   If we can find a matching package in the package store then we don't 
38
#                   If we can find a matching package in the package store then we don't 
188
#                   need to 'make' this package.
39
#                   need to 'make' this package.
Line 212... Line 63...
212
#                   to give JATS a hint. Use the AsdSrcDir directive to extend
63
#                   to give JATS a hint. Use the AsdSrcDir directive to extend
213
#                   the signature paths to directories not under the build.pl
64
#                   the signature paths to directories not under the build.pl
214
#                   or any makefile included by the build.pl
65
#                   or any makefile included by the build.pl
215
#                   
66
#                   
216
#                   The generated file will be held in the sandbox directory.
67
#                   The generated file will be held in the sandbox directory.
217
#                   
-
 
218
#
68
#
219
#                       
-
 
220
# Inputs          : $parsedInfo         - Ref to the packages JatsParser info
69
# Inputs          : $pkgBase        - Path to the package's build file
221
#                   $outPath            - Base of path to create signature files 
70
#                   $outPath        - Base of path to create signature files 
222
#                   $getPkgSignature    - Ref a function to locate the packages signature 
-
 
223
#
71
#
224
# Returns         : The package signature
72
# Returns         : The package signature
225
#
73
#
226
sub BuildSignature
74
sub GeneratePackageSignature
227
{
75
{
228
    my ($parsedInfo, $outPath, $getPkgSignature) = (@_);
76
    my ($pkgBase, $outPath) = @_;
229
 
-
 
230
    my %sigExcludeDirs;
77
    my %sigExcludeDirs;
231
    my %sigExcludeFiles;
78
    my %sigExcludeFiles;
232
    my $BuildSignatureSha1;
79
    my $BuildSignatureSha1;
233
    my $BuildSignature;
80
    my $BuildSignature;
234
    my @sigList;
81
    my @sigList;
235
    my $sigText;
82
    my $sigText;
236
 
83
 
-
 
84
    Error ("No directory specified") unless $pkgBase;
-
 
85
    Error ("Not a directory: $pkgBase") unless -d $pkgBase;
-
 
86
 
-
 
87
    my $parsedInfo = JatsParser::processBuild ($pkgBase);
237
    Message("Generate NEW Package Signature");
88
    #DebugDumpData("GeneratePackageSignature::parsedInfo", $parsedInfo);
-
 
89
    Error ('BuildName not found') unless exists $parsedInfo->{BuildName};
238
 
90
 
239
    #
91
    #
240
    #   Determine the saved locations for the output files
92
    #   Determine the saved locations for the output files
241
    #
93
    #
242
    mkpath ( $outPath ) unless -d $outPath;
94
    mkpath ( $outPath ) unless -d $outPath;
Line 268... Line 120...
268
    #   Assume that we are starting with a sorted list
120
    #   Assume that we are starting with a sorted list
269
    #
121
    #
270
    foreach my $tag ( @{$parsedInfo->{PkgList}} )
122
    foreach my $tag ( @{$parsedInfo->{PkgList}} )
271
    {
123
    {
272
        my ($pname, $pversion) = split ($;, $tag);
124
        my ($pname, $pversion) = split ($;, $tag);
273
        my $pkgSig = $getPkgSignature->($pname, $pversion);
125
        my $pkgSig = getPackageSignature($pname, $pversion);
274
        $BuildSignatureSha1->add("PKGSIGNATURE: $pkgSig");
126
        $BuildSignatureSha1->add("PKGSIGNATURE: $pkgSig");
275
        push @sigList, sprintf("PKGSIGNATURE: [%s %s] %s: %s", $pname, $pversion, $pkgSig , $BuildSignatureSha1->clone->hexdigest);
127
        push @sigList, sprintf("PKGSIGNATURE: [%s %s] %s: %s", $pname, $pversion, $pkgSig , $BuildSignatureSha1->clone->hexdigest);
276
    }
128
    }
277
 
129
 
278
    if ($gitEnabled)
130
    if ($gitEnabled)
Line 332... Line 184...
332
 
184
 
333
    return $BuildSignature;
185
    return $BuildSignature;
334
}
186
}
335
 
187
 
336
#-------------------------------------------------------------------------------
188
#-------------------------------------------------------------------------------
-
 
189
# Function        : getPackageSignature 
-
 
190
#
-
 
191
# Description     : Helper routine 
-
 
192
#                   Given a package name and package version determine the package
-
 
193
#                   signature.
-
 
194
#                   
-
 
195
#                   Can used predetermined data or perform a package repo scan
-
 
196
#                   
-
 
197
#                   This version assumes that we are buildign within a jats sandbox
-
 
198
#                   Each packages signature file Package.sig is stored in the packages
-
 
199
#                   interface directory (at the moment).
-
 
200
#                   
-
 
201
#                   Process:
-
 
202
#                       Locate the packages interface directory - we have a link file to it
-
 
203
#                       Read in the PAckage Signature file
-
 
204
#
-
 
205
# Inputs          : $pname      - Package Name
-
 
206
#                   $pversion   - Package Version
-
 
207
#                   $mode       - Optional. true -> do not error if not found
-
 
208
#
-
 
209
# Returns         : The package signature. Undefined if the package canot be found
-
 
210
#                    
-
 
211
sub getPackageSignature
-
 
212
{
-
 
213
    my ($pname, $pversion, $mode ) = @_;
-
 
214
    my $prj = '';
-
 
215
    my $pkg;
-
 
216
    my $version;
-
 
217
    my $pkgSig;
-
 
218
 
-
 
219
    # 
-
 
220
    #   We are in a sandbox and expect to find a interface/Package.sig file
-
 
221
    #   This will allow us to locate the package in the package store
-
 
222
    #   
-
 
223
    #   If there is no interface/Package.sig, then the user must build (not make)
-
 
224
    #   the package in the sandbox.
-
 
225
    #   
-
 
226
    #   ie: the interface/Package.sig file allows us to use the package from package cache
-
 
227
    #       or indicates that the user has not yet built the package
-
 
228
    #       
-
 
229
    #   First locate the packages interface directory
-
 
230
    #   We have a nice link from the sandbox to assist in this
-
 
231
    #
-
 
232
    my ($pn, $pv, $ps ) = SplitPackage ($pname, $pversion );
-
 
233
    $version = 'sandbox';
-
 
234
    $prj = '.' . $ps if ( $ps ); 
-
 
235
    $version .= $prj;
-
 
236
     
-
 
237
    my $ifaceDir = CatPaths($::GBE_SANDBOX, 'sandbox_dpkg_archive', $pname, $version . '.int');
-
 
238
    $ifaceDir = TagFileRead($ifaceDir);
-
 
239
    $ifaceDir =~ s~\\~/~g;
-
 
240
    $ifaceDir =~ s~GBE_SANDBOX/~$::GBE_SANDBOX/~;
-
 
241
    my $pkgSigFile = CatPaths( $ifaceDir, 'Package.sig');
-
 
242
 
-
 
243
    if ( -f $pkgSigFile)
-
 
244
    {
-
 
245
#Debug0("$pname, $pversion --> $pkgSigFile");
-
 
246
        $pkgSig = TagFileRead($pkgSigFile);
-
 
247
        Error("Package signature invalid for $pname/$version", "Signature: $pkgSig") 
-
 
248
            if((length($pkgSig) != 40) && $pkgSig !~ m~^MSG:~) ;
-
 
249
    }
-
 
250
    else
-
 
251
    {
-
 
252
        Error("Package signature not found for $pname/$version", "You must 'build' the package before using it") unless $mode;
-
 
253
    }
-
 
254
 
-
 
255
    return $pkgSig;
-
 
256
}
-
 
257
 
-
 
258
#-------------------------------------------------------------------------------
337
# Function        : GitCmd
259
# Function        : GitCmd
338
#
260
#
339
# Description     : Run a Git Command and capture/process the output
261
# Description     : Run a Git Command and capture/process the output
340
#
262
#
341
#                   Based on JatsSvnCore:SvnCmd
263
#                   Based on JatsSvnCore:SvnCmd