Subversion Repositories DevTools

Rev

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

Rev 345 Rev 361
Line 48... Line 48...
48
my $opt_list_short;
48
my $opt_list_short;
49
my $opt_export;
49
my $opt_export;
50
my $opt_quiet;
50
my $opt_quiet;
51
my $opt_update_all;
51
my $opt_update_all;
52
my $opt_age;
52
my $opt_age;
-
 
53
my $opt_test;
53
 
54
 
54
#
55
#
55
#   Global Variables
56
#   Global Variables
56
#
57
#
57
my $GBE_DPKG        = $ENV{'GBE_DPKG'};                     # The Master repository
58
my $GBE_DPKG        = $ENV{'GBE_DPKG'};                     # The Master repository
Line 100... Line 101...
100
                "list"                      => \$opt_list,              # flag
101
                "list"                      => \$opt_list,              # flag
101
                "dir"                       => \$opt_list_short,        # flag
102
                "dir"                       => \$opt_list_short,        # flag
102
                "export"                    => \$opt_export,            # flag
103
                "export"                    => \$opt_export,            # flag
103
                "quiet"                     => \$opt_quiet,             # flag
104
                "quiet"                     => \$opt_quiet,             # flag
104
                "age=i"                     => \$opt_age,               # integer
105
                "age=i"                     => \$opt_age,               # integer
-
 
106
                "test"                      => \$opt_test,              # flag
105
                );
107
                );
106
 
108
 
107
                #
109
                #
108
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
110
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
109
                #
111
                #
Line 554... Line 556...
554
    for my $fn ( @dir_list)
556
    for my $fn ( @dir_list)
555
    {
557
    {
556
        my $keep_dir = 0;
558
        my $keep_dir = 0;
557
        next if ( $fn =~ m/^\./ );
559
        next if ( $fn =~ m/^\./ );
558
        next unless ( -d "$cache/$fn" );
560
        next unless ( -d "$cache/$fn" );
-
 
561
        next if ( $fn eq "core_devl" );
559
 
562
 
560
        opendir( DIR, "$cache/$fn" ) || die "Cannot open $cache/$fn\n";
563
        opendir( DIR, "$cache/$fn" ) || die "Cannot open $cache/$fn\n";
561
        while ( my $fn1 = readdir(DIR) )
564
        while ( my $fn1 = readdir(DIR) )
562
        {
565
        {
563
            next if ( $fn1 =~ m/^\./ );
566
            next if ( $fn1 =~ m/^\./ );
Line 569... Line 572...
569
            {
572
            {
570
                #
573
                #
571
                #   No descpkg file
574
                #   No descpkg file
572
                #   This is a badly formed entry - so delete it
575
                #   This is a badly formed entry - so delete it
573
                #
576
                #
-
 
577
                if ( $opt_test )
-
 
578
                {
-
 
579
                    Message("Would Purge: $fn/$fn1" );
-
 
580
                    $keep_dir = 1;
-
 
581
                }
-
 
582
                else
-
 
583
                {
574
                Message("Purging: $fn/$fn1" );
584
                    Message("Purging: $fn/$fn1" );
575
                rmtree( $dir, $opt_debug );
585
                    rmtree( $dir, $opt_debug );
576
 
-
 
-
 
586
                }
577
            }
587
            }
578
            else
588
            else
579
            {
589
            {
580
                #
590
                #
581
                #   used.cache or descpkg file found
591
                #   used.cache or descpkg file found
Line 584... Line 594...
584
                my $timestamp = (stat($file))[9] || 0;
594
                my $timestamp = (stat($file))[9] || 0;
585
                my $age = int( ($now - $timestamp) / (60 * 60 * 24));
595
                my $age = int( ($now - $timestamp) / (60 * 60 * 24));
586
            
596
            
587
                if ( $age > $opt_age )
597
                if ( $age > $opt_age )
588
                {
598
                {
-
 
599
                    if ( $opt_test )
-
 
600
                    {
-
 
601
                        Message("Could Age: $fn/$fn1, $age" );
-
 
602
                        $keep_dir = 1;
-
 
603
                    } else {
589
                    Message("Aging: $fn/$fn1, $age" );
604
                        Message("Aging: $fn/$fn1, $age" );
590
                    rmtree( $dir, $opt_debug );
605
                        rmtree( $dir, $opt_debug );
-
 
606
                    }
591
                }
607
                }
592
                else
608
                else
593
                {
609
                {
594
                    Verbose("Age of: $fn/$fn1, $age" );
610
                    Verbose("Age of: $fn/$fn1, $age" );
595
                    $keep_dir = 1;
611
                    $keep_dir = 1;
Line 613... Line 629...
613
#   Documentation
629
#   Documentation
614
#
630
#
615
 
631
 
616
=pod
632
=pod
617
 
633
 
-
 
634
=for htmltoc    SYSUTIL::
-
 
635
 
618
=head1 NAME
636
=head1 NAME
619
 
637
 
620
cache_dpkg - Maintain a local cache of packages
638
cache_dpkg - Maintain a local cache of packages
621
 
639
 
622
=head1 SYNOPSIS
640
=head1 SYNOPSIS
Line 634... Line 652...
634
    -dir               - List cache contents
652
    -dir               - List cache contents
635
    -export            - Generate a list of cached packages
653
    -export            - Generate a list of cached packages
636
    -refresh_all       - Refresh all packages within the cache
654
    -refresh_all       - Refresh all packages within the cache
637
    -update_all        - Update all packages within the cache as required
655
    -update_all        - Update all packages within the cache as required
638
    -quiet             - Suppress warnings
656
    -quiet             - Suppress warnings
639
    -age=nn            = Remove all packages older than nn days
657
    -age=nn            - Remove all packages older than nn days
-
 
658
    -test              - Use with -age to report ages
640
 
659
 
641
=head1 OPTIONS
660
=head1 OPTIONS
642
 
661
 
643
=over 8
662
=over 8
644
 
663
 
Line 713... Line 732...
713
=item B<-age=nn>
732
=item B<-age=nn>
714
 
733
 
715
This option will delete all package versions that are older than the nn days.
734
This option will delete all package versions that are older than the nn days.
716
The age of a package is calculated from the timestamp of the descpkg file.
735
The age of a package is calculated from the timestamp of the descpkg file.
717
 
736
 
-
 
737
=item B<-test>
-
 
738
 
-
 
739
This option modifies the operation of the B<-age=nn> option such that it will not
-
 
740
delete old package-versions. It will simply report what would be deleted.
-
 
741
 
718
=back
742
=back
719
 
743
 
720
=head1 DESCRIPTION
744
=head1 DESCRIPTION
721
 
745
 
722
This program simplifies the operation of maintaining a local copy of
746
This program simplifies the operation of maintaining a local copy of