Subversion Repositories DevTools

Rev

Rev 1044 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1044 Rev 5793
Line 44... Line 44...
44
#   Options
44
#   Options
45
#
45
#
46
our $opt_age        = 100;                          # Keep for xxx days
46
our $opt_age        = 100;                          # Keep for xxx days
47
our $opt_verbose    = 0;
47
our $opt_verbose    = 0;
48
our $opt_info       = 0;
48
our $opt_info       = 0;
-
 
49
our $opt_help       = 0;
49
 
50
 
50
#
51
#
51
#   Globals
52
#   Globals
52
#
53
#
53
our $needPkgs;                                  # Need these packages
54
our $needPkgs;                                  # Need these packages
Line 62... Line 63...
62
#
63
#
63
# Returns         : None Zero on error
64
# Returns         : None Zero on error
64
#
65
#
65
 
66
 
66
my $result = GetOptions (
67
my $result = GetOptions (
-
 
68
                "help:+"        => \$opt_help,
67
                "verbose:+"     => \$opt_verbose,
69
                "verbose:+"     => \$opt_verbose,
68
                "info:+"        => \$opt_info,
70
                "info:+"        => \$opt_info,
69
                "age=i"         => \$opt_age,
71
                "age=i"         => \$opt_age,
70
 
72
 
71
                );
73
                );
72
die ("Bad options") if ! $result;
74
die ("Bad options") if ! $result;
73
 
-
 
-
 
75
pod2usage(-verbose => $opt_help - 1 ) if $opt_help;
74
 
76
 
75
#
77
#
76
#   Must have an archive
78
#   Must have an archive
77
#
79
#
78
die ("Home directory MUST have link to dpkg_archive") if ( ! -d $dpkg  );
80
die ("Home directory MUST have link to dpkg_archive") if ( ! -d $dpkg  );
Line 207... Line 209...
207
#
209
#
208
# Returns         : Nothing
210
# Returns         : Nothing
209
#
211
#
210
sub Log
212
sub Log
211
{
213
{
212
	my ($text) = @_;
214
    my ($text) = @_;
213
    if ( $opt_info )
215
    if ( $opt_info )
214
    {
216
    {
215
        print "$text\n";
217
        print "$text\n";
216
        return;
218
        return;
217
    }
219
    }
Line 219... Line 221...
219
    my $logfile = "$metadir/pkg_purge/";
221
    my $logfile = "$metadir/pkg_purge/";
220
    mkpath ($logfile);
222
    mkpath ($logfile);
221
    
223
    
222
    $logfile .= strftime "pkg_purge.%Y-%m-%d.txt", localtime();
224
    $logfile .= strftime "pkg_purge.%Y-%m-%d.txt", localtime();
223
 
225
 
224
	open my $fh, ">>$logfile" or die "Can't logfile $logfile: $!\n";
226
    open my $fh, ">>$logfile" or die "Can't logfile $logfile: $!\n";
225
	print $fh localtime()." : $text\n";
227
    print $fh localtime()." : $text\n";
226
    close $fh;
228
    close $fh;
227
}
229
}
228
 
230
 
-
 
231
#-------------------------------------------------------------------------------
-
 
232
#   Documentation
-
 
233
#
-
 
234
 
-
 
235
=pod
-
 
236
 
-
 
237
=head1 NAME
-
 
238
 
-
 
239
pkg_purge - Purge packages from the archive
-
 
240
 
-
 
241
=head1 SYNOPSIS
-
 
242
 
-
 
243
  pkg_purge [options]
-
 
244
 
-
 
245
 Options:
-
 
246
    -help               - brief help message
-
 
247
    -help -help         - Detailed help message
-
 
248
    -verbose            - Verbose operation
-
 
249
    -info               - Display operations that would be done
-
 
250
    -age=nn             - Set purge age
-
 
251
 
-
 
252
=head1 OPTIONS
-
 
253
 
-
 
254
=over 8
-
 
255
 
-
 
256
=item B<-help>
-
 
257
 
-
 
258
Print a brief help message and exits.
-
 
259
 
-
 
260
=item B<-help -help>
-
 
261
 
-
 
262
Print a detailed help message with an explanation for each option.
-
 
263
 
-
 
264
=item B<-man>
-
 
265
 
-
 
266
Prints the manual page and exits.
-
 
267
 
-
 
268
=item B<-verbose>
-
 
269
 
-
 
270
Increases program output. This option may be specified multiple times
-
 
271
 
-
 
272
=item B<-info>
-
 
273
 
-
 
274
Display operations that would be done, but does not purge any files.
-
 
275
 
-
 
276
=item B<-age=nn>
-
 
277
 
-
 
278
Sets the purge age. Packages that have been flagged for deletion more than nn days ago will be purged.
-
 
279
 
-
 
280
=back
-
 
281
 
-
 
282
=cut
-
 
283
 
-
 
284