Subversion Repositories DevTools

Rev

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

Rev 279 Rev 297
Line 1... Line 1...
1
#! perl
1
#! perl
2
########################################################################
2
########################################################################
3
# Copyright ( C ) 2004 ERG Limited, All rights reserved
3
# Copyright ( C ) 2009 ERG Limited, All rights reserved
4
#
4
#
5
# Module name   : jats.sh
5
# Module name   : jats.sh
6
# Module type   : Makefile system
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
7
# Compiler(s)   : n/a
8
# Environment(s): jats
8
# Environment(s): jats
9
#
9
#
10
# Description   : Create a COTS package
10
# Description   : Create a buildable package based on a COTS package
-
 
11
#                 or other package image.
11
#
12
#
-
 
13
#                 Designed to simplify the process of version controlling
-
 
14
#                 handcrafted packages that have been dropped into dpkg_archive
12
# Usage:
15
#
-
 
16
# Usage:        See Embedded documentation below
-
 
17
#               jats gen_cots ...
13
#
18
#
14
# Version   Who      Date        Description
-
 
15
#
19
#
16
#......................................................................#
20
#......................................................................#
17
 
21
 
18
require 5.006_001;
22
require 5.006_001;
19
use Cwd;
23
use Cwd;
Line 55... Line 59...
55
my $opt_vob;
59
my $opt_vob;
56
my $opt_test;
60
my $opt_test;
57
my $opt_keep;
61
my $opt_keep;
58
my $opt_subdir;
62
my $opt_subdir;
59
my $opt_image;
63
my $opt_image;
-
 
64
my $opt_clear_case = 1;
60
 
65
 
61
 
66
 
62
#-------------------------------------------------------------------------------
67
#-------------------------------------------------------------------------------
63
# Function        : Mainline Entry Point
68
# Function        : Mainline Entry Point
64
#
69
#
Line 74... Line 79...
74
                "vob=s"         => \$opt_vob,               # String
79
                "vob=s"         => \$opt_vob,               # String
75
                "test"          => \$opt_test,              # Flag
80
                "test"          => \$opt_test,              # Flag
76
                "keep"          => \$opt_keep,              # Flag
81
                "keep"          => \$opt_keep,              # Flag
77
                "subdir=s"      => \$opt_subdir,            # string
82
                "subdir=s"      => \$opt_subdir,            # string
78
                "image=s"       => \$opt_image,             # string
83
                "image=s"       => \$opt_image,             # string
-
 
84
                "clearcase!"    => \$opt_clear_case,        # flag
79
 
85
 
80
                );
86
                );
81
 
87
 
82
                #
88
                #
83
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
89
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
Line 102... Line 108...
102
#   Init the file uitilites
108
#   Init the file uitilites
103
#
109
#
104
InitFileUtils();
110
InitFileUtils();
105
Error ("This utility only runs on WINDOWS, not $::ScmHost") unless ( $::ScmHost eq 'WIN' );
111
Error ("This utility only runs on WINDOWS, not $::ScmHost") unless ( $::ScmHost eq 'WIN' );
106
Error ("No DPK_ARCHIVE") unless ( $GBE_DPKG );
112
Error ("No DPK_ARCHIVE") unless ( $GBE_DPKG );
107
Error ("Must specify a target VOB") unless ( $opt_vob );
113
Error ("Must specify a target VOB") unless ( $opt_vob || ! $opt_clear_case);
108
Error ("Need two arguments: package and version") unless ( $#ARGV eq 1 );
114
Error ("Need two arguments: package and version") unless ( $#ARGV eq 1 );
-
 
115
Error ("Use -keep when clearcase is not used") unless ( $opt_clear_case || $opt_keep );
109
 
116
 
110
#
117
#
111
#   Determine base image
118
#   Determine base image
112
#   Either from dpkg_archive or user image
119
#   Either from dpkg_archive or user image
113
#
120
#
Line 137... Line 144...
137
$temp_dir =~ s~\\~/~g;
144
$temp_dir =~ s~\\~/~g;
138
Error ("TEMPDIR is not a directory" ) unless ( -d $temp_dir );
145
Error ("TEMPDIR is not a directory" ) unless ( -d $temp_dir );
139
my $dest_dir = "$temp_dir/gen_cots/$opt_subdir";
146
my $dest_dir = "$temp_dir/gen_cots/$opt_subdir";
140
Verbose ("Work Dir: $dest_dir");
147
Verbose ("Work Dir: $dest_dir");
141
 
148
 
-
 
149
if ( $opt_clear_case )
142
#
150
{
-
 
151
    #
143
#   Validate / locate the target VOB
152
    #   Validate / locate the target VOB
144
#
153
    #
145
locate_vob();
154
    locate_vob();
146
 
155
 
147
#
156
    #
148
#   Generate a label, if the user has not already specified one
157
    #   Generate a label, if the user has not already specified one
149
#
158
    #
150
$opt_label = "$ARGV[0]_$ARGV[1]"
159
    $opt_label = "$ARGV[0]_$ARGV[1]"
151
    unless ( $opt_label );
160
        unless ( $opt_label );
152
 
161
 
153
#
162
    #
154
#   Ensure that the label is not locked
163
    #   Ensure that the label is not locked
155
#   The user will not be able to move the label if it is already locked
164
    #   The user will not be able to move the label if it is already locked
156
#
165
    #
157
my $label_exists = 0;
166
    my $label_exists = 0;
158
Verbose ("Check label exists");
167
    Verbose ("Check label exists");
159
ClearCmd ("describe -short lbtype:$opt_label@/$vob_name" ) unless $opt_test;
168
    ClearCmd ("describe -short lbtype:$opt_label@/$vob_name" ) unless $opt_test;
160
$label_exists = 1 unless( $opt_test || grep ( /Label type not found/, @error_list ));
169
    $label_exists = 1 unless( $opt_test || grep ( /Label type not found/, @error_list ));
161
Verbose ("Check label: $label_exists");
170
    Verbose ("Check label: $label_exists");
162
 
171
 
163
if ( $label_exists )
172
    if ( $label_exists )
164
{
-
 
165
    Verbose ("Check label not locked");
-
 
166
    ClearCmd ("describe -fmt %[locked]p lbtype:$opt_label@/$vob_name" );
-
 
167
    unless ( $last_result && $last_result =~ m~unlocked~ )
-
 
168
    {
173
    {
-
 
174
        Verbose ("Check label not locked");
-
 
175
        ClearCmd ("describe -fmt %[locked]p lbtype:$opt_label@/$vob_name" );
-
 
176
        unless ( $last_result && $last_result =~ m~unlocked~ )
-
 
177
        {
169
        Error("Label is locked: $opt_label");
178
            Error("Label is locked: $opt_label");
-
 
179
        }
170
    }
180
    }
171
}
181
}
172
 
182
 
173
#
183
#
174
#   Transfer source to target and remove generated files
184
#   Transfer source to target and remove generated files
Line 286... Line 296...
286
 
296
 
287
#
297
#
288
#   Transfer the image into the target VOB
298
#   Transfer the image into the target VOB
289
#   The clearcase command will adjust the target directory to match the source
299
#   The clearcase command will adjust the target directory to match the source
290
#
300
#
291
 
-
 
292
Message ("Import to clearcase vob: $opt_vob");
-
 
293
my $cmd = "clearfsimport.exe -nsetevent -rec -rmname";
-
 
294
   $cmd .= " -preview" if $opt_test;
-
 
295
   $cmd .= " -mklabel $opt_label";
-
 
296
   $cmd .= " -c \"Package snapshot $ARGV[0]_$ARGV[1]\"";
-
 
297
   $cmd .= " $dest_dir $opt_vob$target_path";
-
 
298
 
-
 
299
Verbose($cmd);
-
 
300
@error_list = ();
301
if ( $opt_clear_case )
301
open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
-
 
302
while (<CMD>)
-
 
303
{
302
{
-
 
303
    Message ("Import to clearcase vob: $opt_vob");
-
 
304
    my $cmd = "clearfsimport.exe -nsetevent -rec -rmname";
-
 
305
       $cmd .= " -preview" if $opt_test;
-
 
306
       $cmd .= " -mklabel $opt_label";
-
 
307
       $cmd .= " -c \"Package snapshot $ARGV[0]_$ARGV[1]\"";
-
 
308
       $cmd .= " $dest_dir $opt_vob$target_path";
-
 
309
 
-
 
310
    Verbose($cmd);
-
 
311
    @error_list = ();
-
 
312
    open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
-
 
313
    while (<CMD>)
-
 
314
    {
-
 
315
        #
-
 
316
        #   Filter output from the user
-
 
317
        #
-
 
318
        chomp;
-
 
319
        Verbose($_);
-
 
320
        push @error_list, $_ if ( m~Error:~ );
-
 
321
    }
-
 
322
    close(CMD);
-
 
323
    if ( @error_list )
-
 
324
    {
-
 
325
        display_error_list();
-
 
326
        Error("Problem encountered saving package image");
-
 
327
    }
-
 
328
 
304
    #
329
    #
-
 
330
    #   Apply label to all directories upto the root of the VOB
305
    #   Filter output from the user
331
    #   The label will have been applied to the TIP
306
    #
332
    #
307
    chomp;
333
    Verbose ("Label package path");
308
    Verbose($_);
334
    my $lpath = $opt_vob;
309
    push @error_list, $_ if ( m~Error:~ );
335
    foreach ( split ('/', $target_path) )
310
}
336
    {
311
close(CMD);
-
 
312
if ( @error_list )
337
        $lpath = $lpath . '/' . $_;
313
{
-
 
314
    display_error_list();
338
        Verbose ("Label package path: $lpath");
-
 
339
        ClearCmd ("mklabel -replace $opt_label $lpath" ) unless $opt_test;
315
    Error("Problem encountered saving package image");
340
        Error ("Program Terminated") if ( @error_list );
316
}
341
    }
317
 
342
 
318
#
343
    #
319
#   Apply label to all directories upto the root of the VOB
-
 
320
#   The label will have been applied to the TIP
344
    #   Lock the label
321
#
345
    #
322
Verbose ("Label package path");
-
 
323
my $lpath = $opt_vob;
-
 
324
foreach ( split ('/', $target_path) )
-
 
325
{
-
 
326
    $lpath = $lpath . '/' . $_;
-
 
327
    Verbose ("Label package path: $lpath");
346
    Message ("Locking label: $opt_label");
328
    ClearCmd ("mklabel -replace $opt_label $lpath" ) unless $opt_test;
347
    ClearCmd ("lock lbtype:$opt_label\@/$vob_name" ) unless $opt_test;
329
    Error ("Program Terminated") if ( @error_list );
348
    Error ("Program Terminated") if ( @error_list );
330
}
349
}
331
 
-
 
332
#
-
 
333
#   Lock the label
-
 
334
#
-
 
335
Message ("Locking label: $opt_label");
-
 
336
ClearCmd ("lock lbtype:$opt_label\@/$vob_name" ) unless $opt_test;
-
 
337
Error ("Program Terminated") if ( @error_list );
-
 
338
 
-
 
339
#
350
#
340
#   Remove the created directory
351
#   Remove the created directory
341
#
352
#
342
if ( $opt_keep )
353
if ( $opt_keep )
343
{
354
{
Line 350... Line 361...
350
}
361
}
351
 
362
 
352
#
363
#
353
#   All done
364
#   All done
354
#
365
#
-
 
366
if ( $opt_clear_case )
-
 
367
{
355
Message ("\n");
368
    Message ("\n");
356
Message ("Release Manager information");
369
    Message ("Release Manager information");
357
Message ("Package path : /$vob_name/$opt_subdir");
370
    Message ("Package path : /$vob_name/$opt_subdir");
358
Message ("Label        : $opt_label");
371
    Message ("Label        : $opt_label");
359
 
372
 
360
Warning ("Test Mode: Not changes made to the VOB") if ( $opt_test );
373
    Warning ("Test Mode: Not changes made to the VOB") if ( $opt_test );
-
 
374
}
361
exit 0;
375
exit 0;
362
 
376
 
363
 
377
 
364
#-------------------------------------------------------------------------------
378
#-------------------------------------------------------------------------------
365
# Function        : CopyDir
379
# Function        : CopyDir
Line 420... Line 434...
420
 
434
 
421
#-------------------------------------------------------------------------------
435
#-------------------------------------------------------------------------------
422
# Function        : locate_vob
436
# Function        : locate_vob
423
#
437
#
424
# Description     : Locate the target VOB
438
# Description     : Locate the target VOB
425
#                   This is a bit tricky as itmakes a few assumptions
439
#                   This is a bit tricky as it makes a few assumptions
426
#                       1) That clearcase dynamic views are mounted through the "o" drive
440
#                       1) That clearcase dynamic views are mounted through the "o" drive
427
#                          This appears to be a standard(ish) configuration.
441
#                          This appears to be a standard(ish) configuration.
428
#
442
#
429
#                       2) There must be a dynamic view on the machine that does have the
443
#                       2) There must be a dynamic view on the machine that does have the
430
#                          required VOB mounted
444
#                          required VOB mounted
Line 535... Line 549...
535
    }
549
    }
536
}
550
}
537
 
551
 
538
 
552
 
539
__DATA__
553
__DATA__
540
# Copyright (C) 1998-2006 ERG Limited, All rights reserved
554
# Copyright (C) 1998-2009 ERG Limited, All rights reserved
541
#
555
#
542
# Module name   : build.pl
556
# Module name   : build.pl
543
# Module type   : Makefile system
557
# Module type   : JATS Build File
544
# Environment(s): n/a
558
# Environment(s): JATS Build System
545
#
559
#
546
# Description:    build.pl for package __PACKAGENAME__
560
# Description:    build.pl for package __PACKAGENAME__
547
#.........................................................................#
561
#.........................................................................#
548
 
562
 
549
#..     Build system
563
#..     Build system
Line 569... Line 583...
569
#
583
#
570
#   Generate Files
584
#   Generate Files
571
BuildDescpkg   ();
585
BuildDescpkg   ();
572
BuildMake      ();
586
BuildMake      ();
573
__ENDBUILD
587
__ENDBUILD
574
# Copyright (C) 1998-2006 ERG Limited, All rights reserved
588
# Copyright (C) 1998-2009 ERG Limited, All rights reserved
575
#
589
#
576
# Module name   : Makefile.pl
590
# Module name   : Makefile.pl
577
# Module type   : Makefile system
591
# Module type   : JATS Build File
578
# Compiler(s)   : ANSI C
-
 
579
# Environment(s): n/a
592
# Environment(s): JATS Build System
580
#
593
#
581
# Description:    makefile.pl for package __PACKAGENAME__
594
# Description:    makefile.pl for package __PACKAGENAME__
582
#
595
#
583
#.........................................................................#
596
#.........................................................................#
584
 
597
 
Line 635... Line 648...
635
    -help -help        - Detailed help message
648
    -help -help        - Detailed help message
636
    -man               - Full documentation
649
    -man               - Full documentation
637
    -label=name        - Specify a label for the versions source
650
    -label=name        - Specify a label for the versions source
638
    -vob=vvv           - VOB to use, my be a full path. default is COTS
651
    -vob=vvv           - VOB to use, my be a full path. default is COTS
639
    -subdir=nnn        - Named subdir in VOB
652
    -subdir=nnn        - Named subdir in VOB
640
    -test              - Do not perform any clearcase operations
653
    -test              - Do not perform operations that modify clearcase
641
    -keep              - Keep the creating dpkg_archive image
654
    -keep              - Keep the creating dpkg_archive image
642
    -image=path        - Path to alternate source image
655
    -image=path        - Path to alternate source image
-
 
656
    -[no]clearcase     - ClearCase is not present
643
 
657
 
644
=head1 OPTIONS
658
=head1 OPTIONS
645
 
659
 
646
=over 8
660
=over 8
647
 
661
 
Line 707... Line 721...
707
specified source path, otherwise the package will be extracted from dpkg_acrhive.
721
specified source path, otherwise the package will be extracted from dpkg_acrhive.
708
 
722
 
709
This option allows a locally created image to be stored as a COTS package
723
This option allows a locally created image to be stored as a COTS package
710
before it is placed in dpkg_archive.
724
before it is placed in dpkg_archive.
711
 
725
 
-
 
726
=item B<-[no]clearcase>
-
 
727
 
-
 
728
This option may be used to supress all clearcase operations. The utility will
-
 
729
simply create a directory tree containing a buildable image.
-
 
730
 
-
 
731
This option should be used in conjunction with -test, else the results will
-
 
732
be discarded.
-
 
733
 
712
=back
734
=back
713
 
735
 
714
=head1 DESCRIPTION
736
=head1 DESCRIPTION
715
 
737
 
716
This program will create a version controlled and JATS buildable package from
738
This program will create a version controlled and JATS buildable package from