source: gsdl/trunk/perllib/scriptutil.pm@ 14374

Last change on this file since 14374 was 12966, checked in by kjdon, 18 years ago

check_removeold_and_keepold now checks incremental as well

  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1###########################################################################
2#
3# scriptutil.pm -- various useful utilities for the scripts
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26package scriptutil;
27no strict 'subs'; # allow barewords (eg STDERR) as function arguments
28no strict 'refs'; # ...but allow filehandles to be variables and vice versa
29
30use gsprintf 'gsprintf';
31
32# returns $removeold, $keepold
33sub check_removeold_and_keepold {
34
35 my ($removeold, $keepold, $incremental, $dir, $collectcfg) = @_;
36
37 if (($keepold && $removeold) || ($incremental && $removeold) ) {
38 gsprintf(STDERR, "{scripts.both_old_options}\n", $dir);
39 sleep(3); #just in case
40 return (1,0);
41
42 }
43
44 if (!$keepold && !$removeold && !$incremental) {
45 # we only look at config file options if we dont have these on the command line
46 if (defined $collectcfg->{'removeold'} && $collectcfg->{'removeold'} =~ /^true$/i ) {
47 $removeold = 1;
48 } elsif (defined $collectcfg->{'keepold'} && $collectcfg->{'keepold'} =~ /^true$/i) {
49 $keepold = 1;
50 } elsif (defined $collectcfg->{'incremental'} && $collectcfg->{'incremental'} =~ /^true$/i) {
51 $incremental = 1;
52 }
53 }
54
55 if (!$keepold && !$removeold && !$incremental) {
56 gsprintf(STDERR, "{scripts.no_old_options} \n", $dir);
57 sleep(3); #just in case
58 return (1,0);
59 }
60
61 # incremental implies keepold
62 if ($incremental) {
63 $keepold = 1;
64 }
65 return ($removeold, $keepold, $incremental);
66
67}
68
691;
Note: See TracBrowser for help on using the repository browser.