Subversion Repositories DevTools

Rev

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

Rev 4417 Rev 4419
Line 44... Line 44...
44
my $opt_help = 0;
44
my $opt_help = 0;
45
my $opt_manual;
45
my $opt_manual;
46
my $opt_outdir = 'tmp';
46
my $opt_outdir = 'tmp';
47
my $opt_outdirFin;
47
my $opt_outdirFin;
48
my $opt_outdirTmp;
48
my $opt_outdirTmp;
49
my $opt_flat = 0;
49
my $opt_flat = 1;
50
my $opt_quiet;
50
my $opt_quiet;
-
 
51
my $opt_deepDebs = 0;
-
 
52
my $opt_dpkg_archive;
-
 
53
my $opt_relativeLinks = 1;
51
 
54
 
52
#
55
#
53
#   Data Items
56
#   Data Items
54
#
57
#
55
my $startTime = strftime("%F %T", localtime);
58
my $startTime = strftime("%F %T", localtime);
Line 66... Line 69...
66
#
69
#
67
# Returns         :
70
# Returns         :
68
#
71
#
69
{
72
{
70
    my $result = GetOptions (
73
    my $result = GetOptions (
71
                    "help+"         => \$opt_help,          # flag, multiple use allowed
74
                    "help+"             => \$opt_help,          # flag, multiple use allowed
72
                    "manual"        => \$opt_manual,        # flag
75
                    "manual"            => \$opt_manual,        # flag
73
                    "verbose:+"     => \$opt_verbose,       # flag
76
                    "verbose:+"         => \$opt_verbose,       # flag
74
                    "quiet:+"       => \$opt_quiet,         # flag
77
                    "quiet:+"           => \$opt_quiet,         # flag
75
                    "outdir:s"      => \$opt_outdir,        # String
78
                    "outdir:s"          => \$opt_outdir,        # String
-
 
79
                    "dpkg_archive:s"    => \$opt_dpkg_archive,  # String
76
                    "flat!"         => \$opt_flat,          # flag
80
                    "flat!"             => \$opt_flat,          # flag
-
 
81
                    "relativelinks!"    => \$opt_relativeLinks, # flag
-
 
82
                    "deepDebian!"       => \$opt_deepDebs,      # flag
77
                    );
83
                    );
78
 
84
 
79
    #
85
    #
80
    #   Process help and manual options
86
    #   Process help and manual options
81
    #
87
    #
Line 95... Line 101...
95
 
101
 
96
    Error("This program does not run under Windows","Windows cannot create Symbolic Links")
102
    Error("This program does not run under Windows","Windows cannot create Symbolic Links")
97
        unless ($GBE_UNIX);
103
        unless ($GBE_UNIX);
98
 
104
 
99
    #
105
    #
-
 
106
    #   Validate the path to dpkg_archive
-
 
107
    #
-
 
108
    if ($opt_dpkg_archive)
-
 
109
    {
-
 
110
        Error("dpkg_archive is not a directory") 
-
 
111
            unless -d $opt_dpkg_archive;
-
 
112
        $GBE_DPKG = $opt_dpkg_archive;
-
 
113
    }
-
 
114
 
-
 
115
 
-
 
116
    #
100
    #   Check that the parent of the base directory exists
117
    #   Check that the parent of the base directory exists
101
    #   Check that the CWD is not within the target directory 
118
    #   Check that the CWD is not within the target directory 
102
    #   If the output directory exists - check they we created it
119
    #   If the output directory exists - check they we created it
103
    #       Try to prevent users from kill entire directory trees
120
    #       Try to prevent users from kill entire directory trees
104
    #
121
    #
105
    InitFileUtils();
122
    InitFileUtils();
106
    my $pdir = FullPath( catdir($opt_outdir, '..') );
123
    my $pdir = FullPath( catdir($opt_outdir, '..') );
-
 
124
    my $udir = StripDir($opt_outdir);
107
    Error ("Cannot create deployment sets in non existent directory","Parent directory must exist", $pdir) 
125
    Error ("Cannot create deployment sets in non existent directory","Parent directory must exist", $pdir) 
108
        unless(-d $pdir);
126
        unless(-d $pdir);
109
 
127
 
110
    my $rdir = RelPath( FullPath($opt_outdir));
128
    my $rdir = RelPath( FullPath($opt_outdir));
111
    Error ("Cannot create deployment sets in a parent of the current directory")
129
    Error ("Cannot create deployment sets in a parent of the current directory")
Line 116... Line 134...
116
        Error("Cannot create deployment sets into a directory not created by this utility", catdir($opt_outdir,'.deploy_builder'))
134
        Error("Cannot create deployment sets into a directory not created by this utility", catdir($opt_outdir,'.deploy_builder'))
117
            unless (-f catdir($opt_outdir,'.deploy_builder'));
135
            unless (-f catdir($opt_outdir,'.deploy_builder'));
118
    }
136
    }
119
 
137
 
120
    #
138
    #
-
 
139
    #   Convert the user-provided base directory into a real path - one that does
-
 
140
    #   not contain any symlinks. Need a physical path to correctly calculate relative
-
 
141
    #   paths.
-
 
142
    #
-
 
143
    my $realPath = Realpath($pdir);
-
 
144
    $opt_outdir = catdir($realPath, $udir);
-
 
145
 
-
 
146
    #
121
    #   Set up paths for a build and swap
147
    #   Set up paths for a build and swap
122
    #       $opt_outdirFin - The final output directory
148
    #       $opt_outdirFin - The final output directory
123
    #       $opt_outdir    - Working (tmp) output directory
149
    #       $opt_outdir    - Working (tmp) output directory
124
    #       $opt_outdirTmp - Temp output. Used in renaming
150
    #       $opt_outdirTmp - Temp output. Used in renaming
125
    #
151
    #
Line 330... Line 356...
330
# Returns         : Clean Element
356
# Returns         : Clean Element
331
#
357
#
332
sub cleanName
358
sub cleanName
333
{
359
{
334
    my ($arg) = @_;
360
    my ($arg) = @_;
335
    $arg =~ s~[/\\]~_~;
361
    $arg =~ s~[/\\]~-~g;
336
    $arg =~ tr~åÅäÄöÖéÉ~aAaAoOeE~s;
362
    $arg =~ tr~åÅäÄöÖéÉ~aAaAoOeE~s;
337
    $arg =~ tr~_~~s;
363
    $arg =~ tr~_~~s;
-
 
364
    $arg =~ tr~-~~s;
338
 
365
 
339
    return $arg;
366
    return $arg;
340
}
367
}
341
 
368
 
342
#-------------------------------------------------------------------------------
369
#-------------------------------------------------------------------------------
Line 391... Line 418...
391
                next if(m~^\.~);
418
                next if(m~^\.~);
392
                next if(m~^built.~);
419
                next if(m~^built.~);
393
                next if(m~^descpkg~);
420
                next if(m~^descpkg~);
394
 
421
 
395
                my $fname = catdir($pkgDir, $_);
422
                my $fname = catdir($pkgDir, $_);
396
                scanDebian($fname,$projName,$releaseName,$entry->{pkgName},$entry->{version}) if (m~^bin$~);
423
                scanDebian($fname,$projName,$releaseName,$entry->{pkgName},$entry->{version}) 
-
 
424
                    if (m~^bin$~ && $opt_deepDebs);
397
 
425
 
398
                next if( -d $fname );
426
                next if( -d $fname );
399
 
427
 
400
                #
428
                #
401
                #   Scan for allowed file types
429
                #   Scan for allowed file types
402
                #       Defined as regexps
430
                #       Defined as regexps
403
                #
431
                #
404
                my @allowedExtensions = qw( \.pkg.gz$ \.exe$ \.msi$ \.deb$ ^IzPack-.*\.jar$ );
432
                my @allowedExtensions = qw( \.pkg.gz$ \.exe$ \.msi$ \.deb$ ^IzPack-.*\.jar$ );
405
                my $allowed;
433
                my $allowed;
406
                foreach my $ext ( @allowedExtensions) {
434
                foreach my $ext ( @allowedExtensions) {
407
                    if ( m~$ext~)
435
                    if ( m~$ext~i)
408
                    {
436
                    {
409
                        $allowed = $ext;
437
                        $allowed = $ext;
410
                        last;
438
                        last;
411
                    }
439
                    }
412
                }
440
                }
-
 
441
 
-
 
442
                #
-
 
443
                #   Specifically exclude some files
-
 
444
                #
-
 
445
                if ($allowed)
-
 
446
                {
-
 
447
                    foreach my $name ( qw(^setup\.exe$ ^setup\.msi$)) {
-
 
448
                        if ( m~$name~i)
-
 
449
                        {
-
 
450
                            $allowed = 0;
-
 
451
                            last;
-
 
452
                        }
-
 
453
                    }
-
 
454
                }
413
                
455
                
414
                if ($allowed)
456
                if ($allowed)
415
                {
457
                {
416
                    addDeployedFile($_, $fname,$projName,$releaseName,$entry->{pkgName},$entry->{version});
458
                    addDeployedFile($_, $fname,$projName,$releaseName,$entry->{pkgName},$entry->{version});
417
                }
459
                }
Line 463... Line 505...
463
        $tdir = catdir($opt_outdir,$projName,$releaseName);
505
        $tdir = catdir($opt_outdir,$projName,$releaseName);
464
    } else {
506
    } else {
465
        $tdir = catdir($opt_outdir,$projName,$releaseName,$pkgName,$version );
507
        $tdir = catdir($opt_outdir,$projName,$releaseName,$pkgName,$version );
466
    }
508
    }
467
    mkpath($tdir);
509
    mkpath($tdir);
-
 
510
 
-
 
511
    # Convert Absolute path to relative path
-
 
512
    if ($opt_relativeLinks) {
-
 
513
 
-
 
514
        my $base = $target;
-
 
515
        $target = RelPath( $target, AbsPath($tdir));
-
 
516
        my $relPathTest = catdir($tdir, $target);
-
 
517
        Error ("Relative path calculation error",
-
 
518
               "Possible case. One of the elements of the output path is a symlink",
-
 
519
               $base, AbsPath($tdir), $target, $relPathTest) 
-
 
520
            unless -f $relPathTest;
-
 
521
    }
-
 
522
 
468
    my $linkDone = eval{ symlink( $target, catdir($tdir,$name)); 1};
523
    my $linkDone = eval{ symlink( $target, catdir($tdir,$name)); 1};
469
    Error ("Target file system does not appear to support symlinks") 
524
    Error ("Target file system does not appear to support symlinks") 
470
        unless $linkDone;
525
        unless $linkDone;
471
#    print("$_\n");
526
#    print("$_\n");
472
}
527
}
Line 599... Line 654...
599
 
654
 
600
            foreach my $pkgName (sort keys %{$data{$projName}{$releaseName}}) {
655
            foreach my $pkgName (sort keys %{$data{$projName}{$releaseName}}) {
601
                foreach my $version (sort keys %{$data{$projName}{$releaseName}{$pkgName}}) {
656
                foreach my $version (sort keys %{$data{$projName}{$releaseName}{$pkgName}}) {
602
                    next unless $data{$projName}{$releaseName}{$pkgName}{$version}{ignored};
657
                    next unless $data{$projName}{$releaseName}{$pkgName}{$version}{ignored};
603
                    print $oh ("\nIgnored Files from Package: $pkgName, $version\n");
658
                    print $oh ("\nIgnored Files from Package: $pkgName, $version\n");
604
                    foreach my $ifile (@{$data{$projName}{$releaseName}{$pkgName}{$version}{ignored}}) {
659
                    foreach my $ifile (sort @{$data{$projName}{$releaseName}{$pkgName}{$version}{ignored}}) {
-
 
660
                        $ifile =~ s~$GBE_DPKG/~~;
605
                        print $oh ("    $ifile\n");
661
                        print $oh ("    $ifile\n");
606
                    }
662
                    }
607
                }
663
                }
608
            }
664
            }
-
 
665
 
-
 
666
            print $oh ("\nFile List:\n");
-
 
667
            foreach my $pkgName (sort keys %{$data{$projName}{$releaseName}}) {
-
 
668
                foreach my $version (sort keys %{$data{$projName}{$releaseName}{$pkgName}}) {
-
 
669
                    next unless $data{$projName}{$releaseName}{$pkgName}{$version}{files};
-
 
670
                    print $oh ("$pkgName, $version\n");
-
 
671
                    foreach my $tfile (sort @{$data{$projName}{$releaseName}{$pkgName}{$version}{files}}) {
-
 
672
                        $tfile =~ s~$GBE_DPKG/~~;
-
 
673
                        print $oh ("    $tfile\n");
-
 
674
                    }
-
 
675
                }
-
 
676
            }
-
 
677
 
-
 
678
 
609
        close $oh;
679
        close $oh;
610
        }
680
        }
611
    }
681
    }
612
}
682
}
613
 
683
 
Line 632... Line 702...
632
    -help -help        - Detailed help message
702
    -help -help        - Detailed help message
633
    -man               - Full documentation
703
    -man               - Full documentation
634
    -verbose[=n]       - Display additional progress messages
704
    -verbose[=n]       - Display additional progress messages
635
    -quiet[=n]         - Supress output
705
    -quiet[=n]         - Supress output
636
    -[no]flat          - Control output structure. Default noflat
706
    -[no]flat          - Control output structure. Default noflat
-
 
707
    -[no]deepDebian    - Dig debian packages from BIN directories
-
 
708
    -[no]relativeLinks - Create Relative or Absolute symlinks
-
 
709
    -dpkg_archive=path - Path the dpkg_archive
637
    -outdir=name       - [Optional] Root of the output directory
710
    -outdir=name       - Root of the output directory
638
    
711
    
639
 
712
 
640
=head1 OPTIONS
713
=head1 OPTIONS
641
 
714
 
642
=over 8
715
=over 8
Line 667... Line 740...
667
The flat structure places all the files in one directory under the 'release' directory.
740
The flat structure places all the files in one directory under the 'release' directory.
668
 
741
 
669
The noflat structure creates package-name/package-version subdirectories 
742
The noflat structure creates package-name/package-version subdirectories 
670
under the 'release' directory.
743
under the 'release' directory.
671
 
744
 
-
 
745
=item B<-[no]deepDebian>
-
 
746
 
-
 
747
Dig debian packages from BIN directories. The default is to assume the correct deployable 
-
 
748
package format - with all deployable packages in the root of the package
-
 
749
 
-
 
750
=item B<-[no]relativeLinks>
-
 
751
 
-
 
752
This option control the type of link created between the deployed file set and dpkg_archive.
-
 
753
The default operation is to create relative symlinks.
-
 
754
 
-
 
755
=item B<-dpkg_archive=path>
-
 
756
 
-
 
757
This option specifies the path to dpkg_archive; where packages will be found. If provided 
-
 
758
this value will be used otherwise it will be taken from the environment variable GBE_DPKG.
-
 
759
 
672
=item B<-outdir=name>
760
=item B<-outdir=name>
673
 
761
 
674
This option specifies the root of the output directory tree created by this tool.
762
This option specifies the root of the output directory tree created by this tool.
675
 
763
 
676
If the directory exists it may be deleted. The entire directory subtree is in the 
764
If the directory exists it may be deleted. The entire directory subtree is in the 
Line 788... Line 876...
788
 
876
 
789
The concept is that only these files are deployable.
877
The concept is that only these files are deployable.
790
 
878
 
791
=item * 
879
=item * 
792
 
880
 
793
Debian packages found within subdirectores of the 'bin' directory.
881
If the -deepDebian option is given, then Debian packages found within subdirectores 
-
 
882
of the 'bin' directory will be located.
794
 
883
 
795
Debian packages that are to be deployed should be built to follow the deployable
884
Debian packages that are to be deployed should be built to follow the deployable
796
convention. Unfortunately many have not been. This tool attampts to cater for this bad
885
convention. Unfortunately many have not been. This tool attampts to cater for this bad
797
practice. It will examine all directories with the 'bin' subdirectory and locate one 
886
practice. It will examine all directories with the 'bin' subdirectory and locate one 
798
of the production or debug builds. It will then transfer debians packages from the 
887
of the production or debug builds. It will then transfer debians packages from the 
Line 802... Line 891...
802
 
891
 
803
=back
892
=back
804
 
893
 
805
=head1 EXAMPLE
894
=head1 EXAMPLE
806
 
895
 
807
=head2 jats deploy_builder -outfile=/export/devl/releases/current
896
=head2 jats deploy_builder -outdir=/export/devl/releases/current
808
 
897
 
809
This will mainatin the package sets in the '/export/devl/releases/current' directory.
898
This will mainatin the package sets in the '/export/devl/releases/current' directory.
810
 
899
 
811
=cut
900
=cut