Subversion Repositories DevTools

Rev

Rev 5709 | Rev 5744 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#! perl
2
########################################################################
5709 dpurdie 3
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
227 dpurdie 4
#
5
# Module name   : cache_dpkg
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
10
# Description:
5743 dpurdie 11
#       Maintain a local cache of dpkg_archive
227 dpurdie 12
#
13
# Notes:
335 dpurdie 14
#       Stopped using the JATS "cp.exe" utility as there was a weird problem under
227 dpurdie 15
#       windows. The package orahops-ssw-install/1.0.1000.ssw could not be installed
335 dpurdie 16
#       correctly. It appears that the 'cp' could not process the subdir pair
227 dpurdie 17
#       "DBMGR/DBMGR". Change the name it was OK.
18
#
19
#       Solution: Avoid system functions
20
#
21
#......................................................................#
22
 
23
use strict;
24
use warnings;
25
use JatsError;
26
use FileUtils;
27
use File::Find;
28
use File::Path;
29
use File::Copy;
30
 
31
use Getopt::Long;
32
use Pod::Usage;                             # required for help support
33
 
5743 dpurdie 34
my $VERSION = "1.5.0";
227 dpurdie 35
 
36
 
37
#
38
#   Options
39
#
40
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
41
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
42
my $opt_help = 0;
43
my $opt_clear;
44
my $opt_flush;
45
my $opt_refresh;
46
my $opt_refresh_all;
47
my $opt_list;
48
my $opt_list_short;
49
my $opt_export;
50
my $opt_quiet;
51
my $opt_update_all;
52
my $opt_age;
361 dpurdie 53
my $opt_test;
227 dpurdie 54
 
55
#
56
#   Global Variables
57
#
4688 dpurdie 58
my $GBE_DPKG            = $ENV{'GBE_DPKG'};                     # The Master repository
59
my $GBE_DPKG_CACHE      = $ENV{'GBE_DPKG_CACHE'} || "";         # Caches
60
my $GBE_DPKG_LOCAL      = $ENV{'GBE_DPKG_LOCAL'} || "";         # Local scratch
61
my $GBE_DPKG_STORE      = $ENV{'GBE_DPKG_STORE'} || "";         # Global Store
62
my $GBE_DPKG_REPLICA    = $ENV{'GBE_DPKG_REPLICA'} || "";       # Site Local Replica
63
my $GBE_BIN             = $ENV{'GBE_BIN'};
227 dpurdie 64
 
4688 dpurdie 65
my $istore;
227 dpurdie 66
my $gstore;
67
my $archive;
68
my $cache;
69
my $parchive;
70
my $local = '';
71
my $local_pkg;
72
my @package_list;
73
my @refresh_list;
74
#
75
#   Globals for recursive copy
76
#
77
my $copyFind_dst;
78
my $copyFind_src;
79
my $copyFind_src_len;
80
 
81
#
82
#   Globals for error recovery
83
#
84
my  $remove_on_error;
85
 
86
#-------------------------------------------------------------------------------
87
# Function        : Mainline Entry Point
88
#
89
# Description     :
90
#
91
# Inputs          :
92
#
93
my $result = GetOptions (
337 dpurdie 94
                "help|h:+"                  => \$opt_help,
95
                "manual:3"                  => \$opt_help,
96
                "verbose:+"                 => \$opt_verbose,           # flag, multiple use allowed
97
                "debug:+"                   => \$opt_debug,             # flag, multiple use allowed
227 dpurdie 98
                "flush"                     => \$opt_flush,             # flag
99
                "clear"                     => \$opt_clear,             # flag
100
                "refresh!"                  => \$opt_refresh,           # flag
101
                "refresh_all|refresh-all"   => \$opt_refresh_all,       # flag
102
                "update_all|update-all"     => \$opt_update_all,        # flag
103
                "list"                      => \$opt_list,              # flag
104
                "dir"                       => \$opt_list_short,        # flag
105
                "export"                    => \$opt_export,            # flag
106
                "quiet"                     => \$opt_quiet,             # flag
107
                "age=i"                     => \$opt_age,               # integer
361 dpurdie 108
                "test"                      => \$opt_test,              # flag
227 dpurdie 109
                );
110
 
111
                #
112
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
113
                #
114
 
115
#
116
#   Process help and manual options
117
#
118
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
119
pod2usage(-verbose => 1)  if ($opt_help == 2 );
337 dpurdie 120
pod2usage(-verbose => 2)  if ($opt_help > 2);
227 dpurdie 121
 
122
#
123
#   Configure the error reporting process now that we have the user options
124
#
125
ErrorConfig( 'name'    =>'CACHE',
126
             'verbose' => $opt_verbose,
127
             'debug'   => $opt_debug );
128
 
129
#
130
#   Validate user options
131
#
132
Error( "GBE_BIN not defined in the environment" ) unless ( defined($GBE_BIN) );
133
Error( "GBE_DPKG not defined in the environment" ) unless ( defined($GBE_DPKG) );
134
 
135
#
136
#   No cache - nothing to do
137
#   Generate a status message and exit
138
#
139
unless ( defined($GBE_DPKG_CACHE) )
140
{
141
    Warning ( "GBE_DPKG_CACHE not defined in the environment" );
142
    return 0;
143
}
144
 
145
 
146
$opt_refresh = 1
147
    if ( $opt_refresh_all );
148
 
149
#
150
#   Locate the archive cache
151
#
152
#   Determine the archive to work on
153
#   Search the cache archive list for one with the keyword "_cache"
154
#   or use the last one.
155
#
156
$GBE_DPKG =~ tr~\\/~/~s;
157
$GBE_DPKG =~ s~/$~~;
158
 
159
my @pkg_list = split ( ';', $GBE_DPKG_CACHE );
160
for (@pkg_list)
161
{
162
    $cache = $_
163
        if ( m/_cache/ );
164
}
165
$cache = pop @pkg_list unless ( $cache );
166
$archive = $GBE_DPKG;
167
$local = $GBE_DPKG_LOCAL;
168
$gstore = $GBE_DPKG_STORE;
4688 dpurdie 169
$istore = $GBE_DPKG_REPLICA;
227 dpurdie 170
 
171
Error ("No dpkg_archive_cache found") unless ( $cache );
172
Error ("dpkg_archive_cache is the main archive") if ( $cache eq $archive );
4688 dpurdie 173
Error ("dpkg_archive_image is the main archive") if ( $istore && $istore eq $archive );
227 dpurdie 174
Error ("main archive is local archive" )         if ( $local && $local eq $archive );
175
Warning  ("dpkg_archive_cache is local_archive" )   if ( $local && $local eq $cache );
176
 
177
#
178
#   Export the list of cache entries
179
#
180
if ( $opt_export or $opt_refresh_all or $opt_list_short or $opt_update_all )
181
{
182
    opendir (DIR, $cache) || die "Cannot open $cache\n";
183
    my @dir_list = readdir(DIR);
184
    closedir DIR;
185
 
186
    for my $fn ( @dir_list)
187
    {
188
        my $count = 0;
189
        next if ( $fn =~ m/^\./ );
190
        next unless ( -d "$cache/$fn" );
191
 
192
        opendir( DIR, "$cache/$fn" ) || die "Cannot open $cache/$fn\n";
193
        while ( my $fn1 = readdir(DIR) )
194
        {
195
            next if ( $fn1 =~ m/^\./ );
196
            push @package_list, "$fn/$fn1";
197
        }
198
        closedir DIR;
199
    }
200
 
201
    if ( $opt_refresh_all or $opt_update_all )
202
    {
203
        @refresh_list = @package_list
204
    }
205
 
206
    #
207
    #   Simply export a list of packages in the cache
208
    #   Used by other programs
209
    #
210
    if ( $opt_export )
211
    {
212
        print join ' ', @package_list;
213
        exit 0;
214
    }
215
}
216
 
217
#
218
#   Display cache information
219
#   This is done AFTER the export - since the export command does not
220
#   need this header.
221
if ( $opt_verbose || $#ARGV < 0 )
222
{
223
    print  "dpkg_store        : $gstore\n" if ($gstore);
224
    print  "dpkg_archive      : $archive\n";
4688 dpurdie 225
    print  "dpkg_archive image: $istore\n";
227 dpurdie 226
    print  "dpkg_archive cache: $cache\n";
227
    print  "dpkg_archive local: $local\n";
228
    Verbose ("args:               @ARGV");
229
}
230
 
231
#
232
#   List the contents of the cache
233
#
234
if ( $opt_list_short )
235
{
236
    print join "\n", @package_list;
237
}
238
 
239
if ( $opt_list )
240
{
241
    #
242
    #   Process user commands
243
    #   List: A nice pretty display of the cache
244
    #
245
    opendir (DIR, $cache) || die "Cannot open $cache\n";
246
    my @dir_list = readdir(DIR);
247
    closedir DIR;
248
 
249
    #
250
    #   Determine max length of a name so that the display is nicely aligned
251
    #
252
    my $nl = 10;
253
    for my $fn ( @dir_list)
254
    {
255
        my $ns = length($fn);
256
        $nl = $ns if ( $ns > $nl )
257
    }
258
 
259
    #
260
    #   Display information by package
261
    #   A nicely formatted list with line wrapping
262
    #
263
    for my $fn ( @dir_list)
264
    {
265
        my $count = 0;
266
        next if ( $fn =~ m/^\./ );
267
        next unless ( -d "$cache/$fn" );
268
 
269
        opendir( DIR, "$cache/$fn" ) || die "Cannot open $cache/$fn\n";
270
        printf "%-*s :", $nl, $fn;
271
        while ( my $fn1 = readdir(DIR) )
272
        {
273
            next if ( $fn1 =~ m/^\./ );
274
            if ( $count++ >= 4 )
275
            {
276
                $count = 1;
277
                printf "\n%*s  ", $nl, "";
278
            }
279
            printf " %14.14s", $fn1;
280
        }
281
        closedir DIR;
282
        print "\n";
283
    }
284
}
285
 
286
#
287
#   Clear the cache
288
#
289
if ( $opt_clear )
290
{
291
    Warning   ( "Deleting the ENTIRE cache");
292
    rmtree( $cache, $opt_debug );
293
    mkpath( $cache, $opt_debug, 0777);
294
}
295
 
296
#
297
#   Perform cache aging
298
#
299
if ( $opt_age )
300
{
301
    Error ("Age parameter cannot be negative") if ( $opt_age < 0 );
302
    age_the_cache();
303
}
304
 
305
#
306
#   Process the command line arguments
307
#   These MUST be of the form
308
#       packagename
309
#       packagename/version
310
#
311
 
312
for (@ARGV, @refresh_list)
313
{
314
    $remove_on_error = undef;
315
    if ( $opt_flush )
316
    {
317
        unless ( -d "$cache/$_" )
318
        {
319
            Warning ("Package not in cache: $_")
320
                unless ( $opt_quiet );
321
        }
322
        else
323
        {
324
            rmtree( "$cache/$_", $opt_debug );
325
            print "Package removed: $_\n"
326
                unless ( $opt_quiet );
327
        }
328
    }
329
    else
330
    {
331
        #
332
        #   Speed up - for remote access
333
        #   If the package is found in the local archive and we aren't doing
334
        #   anything fancy then don't access the remote archive
335
        #
336
        my $local_pkg = ( -d "$local/$_" || -f "$local/$_.lnk" );
337
        if ( $local_pkg )
338
        {
339
            if ( !$opt_refresh )
340
            {
341
                print "Cache SkipLocal: $_ Local copy found\n";
342
 
343
                #
344
                # Delete the cache copy
345
                # The user is playing with local copy
346
                #
347
                if ( -d "$cache/$_" )
348
                {
349
                    print  "Cache SkipLocalDelete: $_ -> $cache\n";
350
                    Verbose ( "Remove: $_" );
351
                    rmtree( "$cache/$_", $opt_debug );
352
                    Verbose ( "Remove Complete: $_" );
353
                }
354
                next;
355
            }
356
        }
357
 
358
        #
359
        #   Locate package.
4688 dpurdie 360
        #   It may be in GBE_DPKG_REPLICA, GBE_DPKG or GBE_DPKG_STORE
227 dpurdie 361
        #
4688 dpurdie 362
        my $pkg_found;
363
        foreach my $store ( $istore, $archive, $gstore)
227 dpurdie 364
        {
4688 dpurdie 365
            $parchive = "$store/$_";
366
            if ( -d $parchive )
227 dpurdie 367
            {
4688 dpurdie 368
                $pkg_found = 1;
369
                last;
227 dpurdie 370
            }
371
        }
4688 dpurdie 372
 
373
        unless ($pkg_found )
374
        {
375
            Warning ("Package not in archive: $_")
376
                unless ( $opt_quiet );
377
            next;
378
        }
227 dpurdie 379
 
380
        ########################################################################
381
        #   We have a package to process
382
        #
383
 
384
        my $dir_found = ( -d "$cache/$_" ) ;
385
        my $force_update = 0;
386
        my $opr = "Update";
387
 
388
 
389
        #
390
        #   Setup error recovery
335 dpurdie 391
        #       1) Tag the directory to be deleted on error
227 dpurdie 392
        #
393
        $remove_on_error = "$cache/$_";
394
        ErrorConfig( 'on_exit' => \&error_recovery );
395
 
396
        #
335 dpurdie 397
        #   Not a forced refresh. Ensure that the cached copy is
227 dpurdie 398
        #   up to date. Examine descpkg
399
        #
400
        if ( $dir_found )
401
        {
402
            if ( -f "$cache/$_/built.cache" )
403
            {
404
                $force_update = 1;
405
                $opr = "Incomplete";
406
                Verbose ("Cache Copy Incomplete: $_");
407
            }
408
            elsif ( FileIsNewer( "$parchive/descpkg", "$cache/$_/descpkg" ) )
409
            {
410
                $force_update = 1;
411
                $opr = "OutOfDate";
412
                Verbose ("Cache out-of-date: $_");
413
            }
414
        }
415
 
416
        #
417
        #   If we need to refresh the cache copy - delete it first
418
        #
419
        if ( ($opt_refresh || $force_update) && $dir_found )
420
        {
421
            print  "Cache $opr: $_ -> $cache\n";
422
            Verbose ( "Remove: $_" );
423
            rmtree( "$cache/$_", $opt_debug );
424
            Verbose ( "Remove Complete: $_" );
229 dpurdie 425
 
426
            #
427
            #   Force transfer, but without the status message
428
            #
227 dpurdie 429
            $dir_found = 0;
229 dpurdie 430
            $opr = '';
227 dpurdie 431
        }
432
 
433
        #
434
        #   If its not in the cache then copy it in
435
        #
436
        unless ( $dir_found )
437
        {
229 dpurdie 438
            print "Cache $opr: $_ -> $cache\n" if $opr;
227 dpurdie 439
            mkpath( "$cache/$_", $opt_debug, 0777);
440
            TouchFile ( "$cache/$_/built.cache", "Marks the cache copy as incomplete");
441
            Verbose ( "Copy in: $_" );
442
            $copyFind_dst = "$cache/$_";
443
            $copyFind_src = $parchive;
444
            $copyFind_src_len = length( $copyFind_src );
445
            File::Find::find( \&copyFind, $parchive );
446
            rmtree( "$cache/$_/built.cache", $opt_debug );  # Works on files too !!
447
        }
448
        else
449
        {
450
            $opr = "Skip";
451
            print "Cache $opr: $_ -> $cache\n";
452
        }
453
    }
454
}
455
 
456
#-------------------------------------------------------------------------------
457
# Function        : copyFind
458
#
459
# Description     : File:Find:find callback function to transfer files
460
#
461
# Inputs          : None
462
#                   Global: $copyFind_dst       : Target directory
463
#                   Global: $copyFind_src       : Source directory
464
#                   Global: $copyFind_src_len   : Length of Source dir
465
#
466
# Returns         : 
467
#
468
 
469
sub copyFind
470
{
471
    my $item = $File::Find::name;
472
 
473
    #
474
    #   Calculate the target directory name
475
    #
5743 dpurdie 476
    my $tgt_path = substr($item, $copyFind_src_len );
477
    my $target = $copyFind_dst . $tgt_path;
478
 
479
    # Do not cache some parts of a package when being used by the build system
480
    #   /lcov ...
481
    #
482
    if ( $ENV{GBE_ABT})
483
    {
484
        if ($tgt_path =~ m~^/lcov(/|$)~)
485
        {
486
            Verbose("Prune directory: $tgt_path");
487
            $File::Find::prune = 1;
488
            return;
489
        }
490
    }
491
 
227 dpurdie 492
    if ( -d $item )
493
    {
494
        #
495
        #   Directories are handled differently
496
        #       - Directories are created with nice permissions
497
        #
498
        if ( ! -d $target )
499
        {
500
            mkpath( $target, $opt_debug, 0755);
501
        }
502
    }
503
    else
504
    {
505
        #
506
        #   File copy
507
        #
508
        #
509
        #   Copy file to destination
510
        #   If the file is a link, then duplicate the link contents
511
        #   Use: Unix libraries are created as two files:
512
        #        lib.xxxx.so -> libxxxx.so.vv.vv.vv
513
        #
514
        if ( -l $item )
515
        {
516
            Debug("Clone Link: $target");
517
            my $link = readlink $item;
518
            Debug( "Link: $item, $link");
519
            symlink ($link, $target );
520
            unless ( $link && -l $target )
521
            {
522
                Error("Failed to copy link [$item] to [$target]: $!");
523
            }
524
        }
525
        elsif (File::Copy::copy($item, $target))
526
        {
527
            Debug("Copying File: $target");
528
 
529
            #   Make the file ReadOnly
530
            my $perm = (stat $item)[2] & 07777;
531
            CORE::chmod $perm & 0555, $target;
532
        }
533
        else
534
        {
535
            Error("Failed to copy file [$item] to [$target]: $!");
536
        }
537
    }
538
}
539
 
540
#-------------------------------------------------------------------------------
541
# Function        : error_recovery
542
#
543
# Description     : Error recovery routine
544
#                   Delete the cached entry
545
#
546
# Inputs          :  Globals
547
#
548
# Returns         : None
549
#
550
sub error_recovery
551
{
552
    if ( $remove_on_error )
553
    {
345 dpurdie 554
        ReportError ("Error cleanup. Delete cache entry: $remove_on_error");
227 dpurdie 555
        rmtree( $remove_on_error, $opt_debug );
556
        $remove_on_error = undef;
557
    }
558
}
559
 
560
 
561
#-------------------------------------------------------------------------------
562
# Function        : age_the_cache
563
#
564
# Description     : Age cache entries
565
#                   Determine the age by:
566
#                       Use used.cache file if present
567
#                       Use descpkg file
568
#                       Not a proper entry - delete
569
#
570
# Inputs          : opt_age         - Delete packages older than XX days
571
#
572
# Returns         : Nothing
573
#
574
sub age_the_cache
575
{
576
    my $now = time;
577
 
578
    opendir (DIR, $cache) || die "Cannot open $cache\n";
579
    my @dir_list = readdir(DIR);
580
    closedir DIR;
581
 
582
    for my $fn ( @dir_list)
583
    {
584
        my $keep_dir = 0;
585
        next if ( $fn =~ m/^\./ );
586
        next unless ( -d "$cache/$fn" );
361 dpurdie 587
        next if ( $fn eq "core_devl" );
227 dpurdie 588
 
589
        opendir( DIR, "$cache/$fn" ) || die "Cannot open $cache/$fn\n";
590
        while ( my $fn1 = readdir(DIR) )
591
        {
592
            next if ( $fn1 =~ m/^\./ );
593
            my $dir = "$cache/$fn/$fn1";
594
            my $file = "$dir/used.cache" ;
595
            $file = "$dir/descpkg" unless ( -f $file );
596
 
597
            if ( ! -f $file )
598
            {
599
                #
600
                #   No descpkg file
601
                #   This is a badly formed entry - so delete it
602
                #
361 dpurdie 603
                if ( $opt_test )
604
                {
605
                    Message("Would Purge: $fn/$fn1" );
606
                    $keep_dir = 1;
607
                }
608
                else
609
                {
610
                    Message("Purging: $fn/$fn1" );
611
                    rmtree( $dir, $opt_debug );
612
                }
227 dpurdie 613
            }
614
            else
615
            {
616
                #
617
                #   used.cache or descpkg file found
618
                #   How old is it
619
                #
620
                my $timestamp = (stat($file))[9] || 0;
621
                my $age = int( ($now - $timestamp) / (60 * 60 * 24));
622
 
623
                if ( $age > $opt_age )
624
                {
361 dpurdie 625
                    if ( $opt_test )
626
                    {
627
                        Message("Could Age: $fn/$fn1, $age" );
628
                        $keep_dir = 1;
629
                    } else {
630
                        Message("Aging: $fn/$fn1, $age" );
631
                        rmtree( $dir, $opt_debug );
632
                    }
227 dpurdie 633
                }
634
                else
635
                {
636
                    Verbose("Age of: $fn/$fn1, $age" );
637
                    $keep_dir = 1;
638
                }
639
            }
640
        }
641
        closedir DIR;
642
 
643
        #
644
        #   Delete the entire directory if is is empty
645
        #
646
        unless ( $keep_dir )
647
        {
648
            Message("Remove Empty Dir: $cache/$fn"  );
649
            rmtree( "$cache/$fn", $opt_debug );
650
        }
651
    }
652
}
653
 
654
#-------------------------------------------------------------------------------
655
#   Documentation
656
#
657
 
658
=pod
659
 
361 dpurdie 660
=for htmltoc    SYSUTIL::
661
 
227 dpurdie 662
=head1 NAME
663
 
664
cache_dpkg - Maintain a local cache of packages
665
 
666
=head1 SYNOPSIS
667
 
668
 jats cache_dpkg.pl [options] package/version ...
669
 
670
 Options:
671
    -help              - brief help message
672
    -help -help        - Detailed help message
673
    -man               - Full documentation
674
    -clear             - Delete the entire cache
675
    -flush             - Flush all named packages
676
    -[no]refresh       - Refresh package in cache
677
    -list              - List cache contents with nice format
678
    -dir               - List cache contents
679
    -export            - Generate a list of cached packages
680
    -refresh_all       - Refresh all packages within the cache
681
    -update_all        - Update all packages within the cache as required
682
    -quiet             - Suppress warnings
361 dpurdie 683
    -age=nn            - Remove all packages older than nn days
684
    -test              - Use with -age to report ages
227 dpurdie 685
 
686
=head1 OPTIONS
687
 
688
=over 8
689
 
690
=item B<-help>
691
 
692
Print a brief help message and exits.
693
 
694
=item B<-help -help>
695
 
696
Print a detailed help message with an explanation for each option.
697
 
698
=item B<-man>
699
 
700
Prints the manual page and exits.
701
 
702
=item B<-clear>
703
 
704
Delete the B<entire> contents of the dpkg_archive cache. This will occur before
705
any new packages are copied into the cache.
706
 
707
=item B<-flush>
708
 
709
If set then the utility will delete the named packages from the cache. All named
710
packaged will be deleted. This option affects all named packages. It is not
711
possible to flush and copy packages with the same command.
712
 
713
=item B<-[no]refresh>
714
 
715
If the B<refresh> option has been specified then packages will be deleted, from
716
the cache and then a new copy will be copied in. If not specified then no copy
717
will occur if the package is present in the cache.
718
 
719
=item B<-list>
720
 
721
Display a list of all packages in the cache. A formatted display is generated.
722
 
723
This will be done before any packages are transferred.
724
 
725
=item B<-dir>
726
 
727
Display a list of all packages in the cache. This is a raw directory like
728
listing of the cache.
729
 
730
This will be done before any packages are transferred.
731
 
732
=item B<-export>
733
 
734
Generate a space separated list of cached packages as a single line. This is
735
intended to allow a list be exported for later import.
736
 
737
=item B<-refresh_all>
738
 
739
This option will force the program to refresh all the packages in the cache.
740
This forces a B<-refresh> and may be combined with other packages specified
741
on the command line.
742
 
743
=item B<-update_all>
744
 
745
This option will force the program to examine all packages within the cache and
746
refresh packages that are out of date. This option may be combined with other
747
packages specified on the command line.
748
 
749
A package is deemed to be out-of-date if the modification time of the package's
335 dpurdie 750
descpkg file in the cache is older than the one in the archive.
227 dpurdie 751
 
752
=item B<-quiet>
753
 
754
This option will suppress almost all of the progress messages, except for a single
755
copy message. It is intended to be used when the program is called from another
756
script.
757
 
758
=item B<-age=nn>
759
 
760
This option will delete all package versions that are older than the nn days.
761
The age of a package is calculated from the timestamp of the descpkg file.
762
 
361 dpurdie 763
=item B<-test>
764
 
765
This option modifies the operation of the B<-age=nn> option such that it will not
766
delete old package-versions. It will simply report what would be deleted.
767
 
227 dpurdie 768
=back
769
 
770
=head1 DESCRIPTION
771
 
772
This program simplifies the operation of maintaining a local copy of
773
used packages from the maintaining dpkg_archive store. The cache should be
774
stored on your local disk for speed.
775
 
776
=head2 Location of the cache
777
 
4688 dpurdie 778
The local cache is specified with the EnvVar GBE_DPKG_CACHE
227 dpurdie 779
 
4688 dpurdie 780
=head2 Location of the maintaining archive
227 dpurdie 781
 
4688 dpurdie 782
The required pacjage version can be found in three archives. These are:
227 dpurdie 783
 
4688 dpurdie 784
=over 4
227 dpurdie 785
 
4688 dpurdie 786
=item *
227 dpurdie 787
 
4688 dpurdie 788
GBE_DPKG_REPLICA. A local image of the main dpkg_archive. This is used when dpkg_archive is synced locally and is expected to be faster than GBE_DPKG
789
 
790
=item *
791
 
792
GBE_DPKG. The main dpkg_archive
793
 
794
=item *
795
 
796
GBE_DPKG_STORE. A global package archive. The search repository of last choice.
797
 
798
=back
799
 
227 dpurdie 800
=head2 Interaction with local_dpkg_archive
801
 
802
If a package is located in the users local_dpkg_archive and we are doing a
803
simple cache update then the package will be deleted from the cache. This is
804
done to speed use on slow remote links and ensure cache consistency.
805
 
5743 dpurdie 806
=head2 Interaction with build system
807
 
808
If the cache operating is done withinthe context of the Build System (GBE_ABT is not zero), 
809
then some parts of the package will not be transferred. This is done to speed up the caching.
810
 
811
Directories that will not be cached:
812
 
813
=over 4
814
 
815
=item * 
816
 
817
lcov - A directory that contains code coverage information. This directory normally 
818
contains a large number of files, none of which are used by the build system. Over long 
819
links the trasnfer time of the 'lcov' directory can take hours.
820
 
821
=back
822
 
227 dpurdie 823
=head1 EXAMPLE
824
 
825
=head2 jats dpkg_cache -list
826
 
827
This will list the current contents of the cache.
828
 
829
=head2 jats dpkg_cache -refresh crc/1.0.4.cr
830
 
831
This will delete any cached copy of the package crc/1.0.4.cr, if one exists,
832
and then copy in a new version.
833
 
834
=head2 jats dpkg_cache crc
835
 
836
This will copy in all versions of the crc package. This may not be desirable.
837
 
838
=head2 jats dpkg_cache -update_all
839
 
840
This will examine all packages in the cache and refresh those packages that are
841
out of date.
842
 
843
=cut
844