Subversion Repositories DevTools

Rev

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

Rev 5726 Rev 5827
Line 82... Line 82...
82
my $opt_preDelete;
82
my $opt_preDelete;
83
my $opt_tmpDir;
83
my $opt_tmpDir;
84
my $opt_keepFragments;
84
my $opt_keepFragments;
85
my $opt_testArchive;
85
my $opt_testArchive;
86
my $opt_DeleteVersion;
86
my $opt_DeleteVersion;
-
 
87
my $opt_housekeeping = 1;
87
 
88
 
88
#-------------------------------------------------------------------------------
89
#-------------------------------------------------------------------------------
89
# Function        : main entry point 
90
# Function        : main entry point 
90
#
91
#
91
# Description     : Main Entry point
92
# Description     : Main Entry point
Line 107... Line 108...
107
                'tmpdir=s'          => \$opt_tmpDir,            # String
108
                'tmpdir=s'          => \$opt_tmpDir,            # String
108
                'predelete!'        => \$opt_preDelete,         # [no]flag
109
                'predelete!'        => \$opt_preDelete,         # [no]flag
109
                'keepFragments!'    => \$opt_keepFragments ,    # [no]flag
110
                'keepFragments!'    => \$opt_keepFragments ,    # [no]flag
110
                'testArchive'       => \$opt_testArchive,       # [no]flag
111
                'testArchive'       => \$opt_testArchive,       # [no]flag
111
                'DeleteVersion'     => \$opt_DeleteVersion,     # flag
112
                'DeleteVersion'     => \$opt_DeleteVersion,     # flag
-
 
113
                'PurgeOld!'         => \$opt_housekeeping,      # [no]flag
112
                );              
114
                );              
113
 
115
 
114
    #
116
    #
115
    #   Process help and manual options
117
    #   Process help and manual options
116
    #
118
    #
Line 150... Line 152...
150
    #   Basic sanity testing
152
    #   Basic sanity testing
151
    #
153
    #
152
    Error ("Path for package fragments not specified") unless defined $opt_srcPath;
154
    Error ("Path for package fragments not specified") unless defined $opt_srcPath;
153
    Error ("Package fragment path not found", $opt_srcPath) unless -d $opt_srcPath;
155
    Error ("Package fragment path not found", $opt_srcPath) unless -d $opt_srcPath;
154
    Error ("DPKG_ARCHIVE not found", $GBE_DPKG) unless -d $GBE_DPKG;
156
    Error ("DPKG_ARCHIVE not found", $GBE_DPKG) unless -d $GBE_DPKG;
155
    Error ("Package name not specified") unless defined $opt_pname;
-
 
156
    Error ("Package version not specified") unless defined $opt_pversion;
-
 
157
    Error ("Output path not specified" ) unless defined $opt_outputPath;
157
    Error ("Output path not specified" ) unless defined $opt_outputPath;
158
    Error ("Output path does not exist", $opt_outputPath) unless -d $opt_outputPath;
158
    Error ("Output path does not exist", $opt_outputPath) unless -d $opt_outputPath;
159
    Error ("TmpDir does not exist:", $opt_tmpDir) if (defined($opt_tmpDir) && ! -d ($opt_tmpDir));
159
    Error ("TmpDir does not exist:", $opt_tmpDir) if (defined($opt_tmpDir) && ! -d ($opt_tmpDir));
160
 
160
 
161
    #
161
    #
-
 
162
    #   Always perform house keeping
-
 
163
    #
-
 
164
    if ($opt_housekeeping)
-
 
165
    {
-
 
166
        PurgeOldFragments();
-
 
167
    }
-
 
168
 
-
 
169
    #
-
 
170
    #   Bit more sanity testing
-
 
171
    #
-
 
172
    Error ("Package name not specified") unless defined $opt_pname;
-
 
173
    Error ("Package version not specified") unless defined $opt_pversion;
-
 
174
 
-
 
175
    #
162
    #   Alternate Modes
176
    #   Alternate Modes
163
    #   These will not return, but will exis the utility
177
    #   These will not return, but will exit the utility
164
    #   
178
    #   
165
    if ($opt_DeleteVersion)
179
    if ($opt_DeleteVersion)
166
    {
180
    {
167
        DeletePackageVersion();
181
        DeletePackageVersion();
168
        exit 1;
182
        exit 1;
Line 584... Line 598...
584
    }
598
    }
585
 
599
 
586
    exit 0;
600
    exit 0;
587
}
601
}
588
 
602
 
-
 
603
#-------------------------------------------------------------------------------
-
 
604
# Function        : PurgeOldFragments 
-
 
605
#
-
 
606
# Description     : Housekeeping task
-
 
607
#                   Purge old fragments from the fragment store.
-
 
608
#                   Used to prevent very old fragments from filling up the fragment store
-
 
609
#                   
-
 
610
#                   Purge files that are more than 2 days old
-
 
611
#
-
 
612
# Inputs          : None
-
 
613
#
-
 
614
# Returns         : Nothing
-
 
615
#
-
 
616
sub PurgeOldFragments
-
 
617
{
-
 
618
    Verbose("PurgeOldFragments: $opt_srcPath");
-
 
619
    my @files = glob (catfile($opt_srcPath, '*'  ));
-
 
620
    my @purgeList;
-
 
621
    my @purgeError;
-
 
622
    foreach my $file ( @files)
-
 
623
    {
-
 
624
        my $age = int(-M $file);
-
 
625
        Verbose ("Age $file : $age");
-
 
626
        if ($age >= 2 )
-
 
627
        {
-
 
628
            if (RmDirTree($file)) {
-
 
629
                push @purgeError, $file;
-
 
630
            } else {
-
 
631
                push @purgeList, $file;
-
 
632
            }
-
 
633
        }
-
 
634
    }
-
 
635
 
-
 
636
    #
-
 
637
    #   Pretty reporting
-
 
638
    #   
-
 
639
    Message('Purge old fragment', @purgeList) if (@purgeList); 
-
 
640
    Message('Fragment purge error', @purgeError) if (@purgeError); 
-
 
641
}
-
 
642
 
-
 
643
 
589
 
644
 
590
#-------------------------------------------------------------------------------
645
#-------------------------------------------------------------------------------
591
# Function        : END 
646
# Function        : END 
592
#
647
#
593
# Description     : Cleanup process 
648
# Description     : Cleanup process 
Line 736... Line 791...
736
    -verbose           - Display additional progress messages
791
    -verbose           - Display additional progress messages
737
    -pname=name        - Ensure package is named correctly
792
    -pname=name        - Ensure package is named correctly
738
    -pversion=version  - Ensure package version is correct
793
    -pversion=version  - Ensure package version is correct
739
    -srcdir=path       - Location of the package fragments
794
    -srcdir=path       - Location of the package fragments
740
    -DeleteVersion     - Alternate Mode. Delete package-version
795
    -DeleteVersion     - Alternate Mode. Delete package-version
-
 
796
    -PurgeOld          - Purge old fragments
741
 
797
 
742
  Debug and Testing:
798
  Debug and Testing:
743
    -[no]mergeErrors   - Allow merge errors
799
    -[no]mergeErrors   - Allow merge errors
744
    -[no]preDelete     - Predelete generated package
800
    -[no]preDelete     - Predelete generated package
745
    -[no]keepFragments - Delete input package fragments
801
    -[no]keepFragments - Delete input package fragments
Line 783... Line 839...
783
 
839
 
784
This mode is used by the 'buildtool' while cleaning up failed builds.
840
This mode is used by the 'buildtool' while cleaning up failed builds.
785
 
841
 
786
Is is not an error for the named package versio to not exist.
842
Is is not an error for the named package versio to not exist.
787
 
843
 
-
 
844
=item B<-PurgeOld>
-
 
845
 
-
 
846
This option controls the purging of old package fragments.
-
 
847
 
-
 
848
By default package fragments modified more than two days ago will be purged
-
 
849
from the fragment store.
-
 
850
 
-
 
851
This option allows this feature to be disabled.
-
 
852
 
788
=item B<-[no]mergeErrors>
853
=item B<-[no]mergeErrors>
789
 
854
 
790
This option allows the merging process to continue if merge errors are located.
855
This option allows the merging process to continue if merge errors are located.
791
The default is -noMergeErrors
856
The default is -noMergeErrors
792
 
857