Subversion Repositories DevTools

Rev

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

Rev 6738 Rev 6937
Line 94... Line 94...
94
 
94
 
95
use Getopt::Long;
95
use Getopt::Long;
96
use File::Path;
96
use File::Path;
97
use File::Copy;
97
use File::Copy;
98
use File::Find;
98
use File::Find;
-
 
99
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
99
use JatsSystem;
100
use JatsSystem;
100
use FileUtils;
101
use FileUtils;
101
use ArrayHashUtils;
102
use ArrayHashUtils;
102
use JatsError;
103
use JatsError;
103
use JatsLocateFiles;
104
use JatsLocateFiles;
Line 129... Line 130...
129
my $opt_pkgbindir;
130
my $opt_pkgbindir;
130
my $opt_pkgpkgdir;
131
my $opt_pkgpkgdir;
131
my $opt_noarch;
132
my $opt_noarch;
132
my $opt_tarFile;
133
my $opt_tarFile;
133
my $opt_tarOnly;
134
my $opt_tarOnly;
-
 
135
my $opt_zipFile;
-
 
136
my $opt_zipOnly;
134
my $opt_rpm = 0;
137
my $opt_rpm = 0;
135
my $opt_debian = 0;
138
my $opt_debian = 0;
136
my $opt_output;
139
my $opt_output;
137
 
140
 
138
#
141
#
Line 225... Line 228...
225
                'ExtDesc:s'         => \$opt_extdesc,
228
                'ExtDesc:s'         => \$opt_extdesc,
226
                'PkgArch:s'         => \$opt_pkgarch,
229
                'PkgArch:s'         => \$opt_pkgarch,
227
                'NoArch'            => \$opt_noarch,
230
                'NoArch'            => \$opt_noarch,
228
                'tarFile=s'         => \$opt_tarFile,
231
                'tarFile=s'         => \$opt_tarFile,
229
                'tarOnly'           => \$opt_tarOnly,
232
                'tarOnly'           => \$opt_tarOnly,
-
 
233
                'zipFile=s'         => \$opt_zipFile,
-
 
234
                'zipOnly'           => \$opt_zipOnly,
230
                'genRpm'            => \$opt_rpm,
235
                'genRpm'            => \$opt_rpm,
231
                'genDeb'            => \$opt_debian,
236
                'genDeb'            => \$opt_debian,
232
                'output=s'          => \$opt_output,
237
                'output=s'          => \$opt_output,
233
                'script=s'          => \$opt_package_script,
238
                'script=s'          => \$opt_package_script,
234
                'rpmRelease=s'      => \$opt_rpmRelease,
239
                'rpmRelease=s'      => \$opt_rpmRelease,
Line 283... Line 288...
283
    #
288
    #
284
    #   Determine build operations
289
    #   Determine build operations
285
    #   
290
    #   
286
    my $genDebian = $opt_debian;
291
    my $genDebian = $opt_debian;
287
    my $genRpm = $opt_rpm;
292
    my $genRpm = $opt_rpm;
288
    if ($opt_tarOnly) {
293
    if ($opt_tarOnly || $opt_zipOnly) {
289
        $genDebian = $genRpm = 0; 
294
        $genDebian = $genRpm = 0; 
290
    }
295
    }
291
     
296
     
292
 
297
 
293
    #
298
    #
Line 295... Line 300...
295
    #
300
    #
296
    Message    ("= Building Installer ================================================");
301
    Message    ("= Building Installer ================================================");
297
    Message    ("        Format: Debian") if ($genDebian);
302
    Message    ("        Format: Debian") if ($genDebian);
298
    Message    ("        Format: RPM") if ($genRpm);
303
    Message    ("        Format: RPM") if ($genRpm);
299
    Message    ("        Format: TGZ") if ($opt_tarFile);
304
    Message    ("        Format: TGZ") if ($opt_tarFile);
-
 
305
    Message    ("        Format: ZIP") if ($opt_zipFile);
300
    Message    ("          Name: $opt_name");
306
    Message    ("          Name: $opt_name");
301
    Message    ("       Package: $opt_buildname");
307
    Message    ("       Package: $opt_buildname");
302
    Message    ("       Variant: $opt_variant") if ($opt_variant);
308
    Message    ("       Variant: $opt_variant") if ($opt_variant);
303
    Message    ("       Version: $opt_version");
309
    Message    ("       Version: $opt_version");
304
    Message    ("  Building for: $opt_platform");
310
    Message    ("  Building for: $opt_platform");
Line 309... Line 315...
309
    Message    ("      Pkg Arch: $opt_pkgarch") if ($opt_pkgarch);
315
    Message    ("      Pkg Arch: $opt_pkgarch") if ($opt_pkgarch);
310
    Verbose    ("       Verbose: $opt_verbose");
316
    Verbose    ("       Verbose: $opt_verbose");
311
    Verbose    ("  InterfaceDir: $opt_interfacedir");
317
    Verbose    ("  InterfaceDir: $opt_interfacedir");
312
    Message    ("        Output: " . StripDir($opt_output))  if ($genDebian || $genRpm);
318
    Message    ("        Output: " . StripDir($opt_output))  if ($genDebian || $genRpm);
313
    Message    ("        Output: " . StripDir($opt_tarFile)) if $opt_tarFile;
319
    Message    ("        Output: " . StripDir($opt_tarFile)) if $opt_tarFile;
-
 
320
    Message    ("        Output: " . StripDir($opt_zipFile)) if $opt_zipFile;
314
    Message    ("======================================================================");
321
    Message    ("======================================================================");
315
 
322
 
316
    #
323
    #
317
    #   Perform Clean up
324
    #   Perform Clean up
318
    #   Invoked during "make clean" or "make clobber"
325
    #   Invoked during "make clean" or "make clobber"
Line 325... Line 332...
325
        #   Remove the directory for this package
332
        #   Remove the directory for this package
326
        #   Remove the general work dir - if all packages have been cleaned
333
        #   Remove the general work dir - if all packages have been cleaned
327
        #
334
        #
328
        rmtree( $WorkDirBase );
335
        rmtree( $WorkDirBase );
329
        rmtree ($opt_tarFile) if ( defined($opt_tarFile) && -f $opt_tarFile );
336
        rmtree ($opt_tarFile) if ( defined($opt_tarFile) && -f $opt_tarFile );
-
 
337
        rmtree ($opt_zipFile) if ( defined($opt_zipFile) && -f $opt_zipFile );
330
        rmtree ($opt_output) if ( $opt_output && -f $opt_output );
338
        rmtree ($opt_output) if ( $opt_output && -f $opt_output );
331
        exit;
339
        exit;
332
    }
340
    }
333
 
341
 
334
    #
342
    #
Line 375... Line 383...
375
    if ($opt_tarFile) {
383
    if ($opt_tarFile) {
376
        BuildTarFile();
384
        BuildTarFile();
377
        Message ("Created TGZ file");
385
        Message ("Created TGZ file");
378
    }
386
    }
379
 
387
 
-
 
388
    if ($opt_zipFile) {
-
 
389
        BuildZipFile();
-
 
390
        Message ("Created ZIP file");
-
 
391
    }
-
 
392
 
380
    #
393
    #
381
    #   Create an RPM
394
    #   Create an RPM
382
    #
395
    #
383
    if ($genRpm) {
396
    if ($genRpm) {
384
        BuildRPM ();
397
        BuildRPM ();
Line 528... Line 541...
528
            '.'
541
            '.'
529
            );
542
            );
530
}
543
}
531
 
544
 
532
#-------------------------------------------------------------------------------
545
#-------------------------------------------------------------------------------
-
 
546
# Function        : BuildZipFile 
-
 
547
#
-
 
548
# Description     : This function will create a ZIP file of the constructed package
-
 
549
#                   Not often used
-
 
550
#                   
-
 
551
#                   Tricky bit is excluding the DEBIAN directory 
-
 
552
#
-
 
553
# Inputs          : None
-
 
554
#
-
 
555
# Returns         : Nothing
-
 
556
#
-
 
557
sub BuildZipFile
-
 
558
{
-
 
559
    Verbose ("Create ZIP file containing body of the package");
-
 
560
 
-
 
561
    my $zip = Archive::Zip->new();
-
 
562
    $zip->addTree( $WorkDirInit, '', sub { $_ !~ m~^DEBIAN$~ } );
-
 
563
    if ( $zip->writeToFileNamed($opt_zipFile) != AZ_OK ) {
-
 
564
        Error("Canot create ZIP file");
-
 
565
    }
-
 
566
}
-
 
567
 
-
 
568
#-------------------------------------------------------------------------------
533
# Function        : Section 
569
# Function        : Section 
534
#
570
#
535
# Description     : Allows the Package file to be split into section
571
# Description     : Allows the Package file to be split into section
536
#                   This direcive is always active.
572
#                   This direcive is always active.
537
#
573
#
538
# Inputs          : Selector
574
# Inputs          : Selector
539
#                       ALL     - Active
575
#                       ALL     - Active
540
#                       RPM     - Active section when building an RPM
576
#                       RPM     - Active section when building an RPM
541
#                       DEBIAN  - Active section if build a Debian package
577
#                       DEBIAN  - Active section if build a Debian package
542
#                       TAR     - Active section if building a TAR
578
#                       TAR     - Active section if building a TAR
-
 
579
#                       ZIP     - Active section if building a ZIP
543
#
580
#
544
# Returns         : Nothing
581
# Returns         : Nothing
545
#                   Will fkag to indicate if directives are active. 
582
#                   Will fkag to indicate if directives are active. 
546
#
583
#
547
sub Section
584
sub Section
Line 565... Line 602...
565
            $newActiveSection = 1 if  $flip->($opt_rpm, $1);
602
            $newActiveSection = 1 if  $flip->($opt_rpm, $1);
566
 
603
 
567
        } elsif ($arg =~ m/^(!)*TAR/i) {
604
        } elsif ($arg =~ m/^(!)*TAR/i) {
568
            $newActiveSection = 1 if $flip->($opt_tarFile, $1);
605
            $newActiveSection = 1 if $flip->($opt_tarFile, $1);
569
 
606
 
-
 
607
        } elsif ($arg =~ m/^(!)*ZIP/i) {
-
 
608
            $newActiveSection = 1 if $flip->($opt_zipFile, $1);
-
 
609
 
570
        } elsif (uc($arg) eq 'ALL') {
610
        } elsif (uc($arg) eq 'ALL') {
571
            $newActiveSection = 1;
611
            $newActiveSection = 1;
572
 
612
 
573
        } elsif ( $arg eq 1  ) {
613
        } elsif ( $arg eq 1  ) {
574
                $newActiveSection = 1;
614
                $newActiveSection = 1;
Line 2883... Line 2923...
2883
#                   IsVariant
2923
#                   IsVariant
2884
#                   IsAlias
2924
#                   IsAlias
2885
#                   IsDebian
2925
#                   IsDebian
2886
#                   IsRpm
2926
#                   IsRpm
2887
#                   IsTar
2927
#                   IsTar
-
 
2928
#                   IsZip
2888
#
2929
#
2889
# Description     : This function allows some level of control in the
2930
# Description     : This function allows some level of control in the
2890
#                   packaging scripts. It will return true if the current
2931
#                   packaging scripts. It will return true if the current
2891
#                   product is listed.
2932
#                   product is listed.
2892
#
2933
#
Line 2972... Line 3013...
2972
sub IsTar()
3013
sub IsTar()
2973
{
3014
{
2974
    return $opt_tarFile ? 1 : 0;
3015
    return $opt_tarFile ? 1 : 0;
2975
}
3016
}
2976
 
3017
 
-
 
3018
sub IsZip()
-
 
3019
{
-
 
3020
    return $opt_zipFile ? 1 : 0;
-
 
3021
}
-
 
3022
 
-
 
3023
 
2977
#-------------------------------------------------------------------------------
3024
#-------------------------------------------------------------------------------
2978
# Function        : PackageVersion 
3025
# Function        : PackageVersion 
2979
#
3026
#
2980
# Description     : Return the version of the named package 
3027
# Description     : Return the version of the named package 
2981
#
3028
#
Line 3131... Line 3178...
3131
#
3178
#
3132
 
3179
 
3133
sub folderHasFiles {
3180
sub folderHasFiles {
3134
    my $dirname = shift;
3181
    my $dirname = shift;
3135
    my $rv = 0;
3182
    my $rv = 0;
-
 
3183
    my $dh;
-
 
3184
    return 0 unless -d $dirname;
3136
 
3185
 
3137
    opendir(my $dh, $dirname) or return 0;
3186
    opendir($dh, $dirname) || return 0;
3138
    while (readdir $dh)
3187
    while (my $file = readdir $dh)
3139
    {
3188
    {
-
 
3189
        next unless (defined $file);
3140
        next if ($_ eq "." || $_ eq "..");
3190
        next if ($file eq "." || $file eq "..");
3141
        $rv = 1;
3191
        $rv = 1;
3142
        last;
3192
        last;
3143
    }
3193
    }
3144
    closedir $dh;
3194
    closedir $dh;
3145
    return $rv;
3195
    return $rv;