1 package install_misc
::UpgradeBackup
;
3 # Copyright (C) 2008 LibLime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 #use warnings; FIXME - Bug 2505
22 use File
::Compare
qw(compare);
29 use vars
qw(@ISA @EXPORT $VERSION);
32 @EXPORT = ('backup_changed_files');
37 install_misc::UpgradeBackup
41 This is a helper module used during a 'make upgrade' that
42 creates backups of files updated during an upgrade.
46 sub backup_changed_files {
50 my $inc_uninstall = shift;
53 foreach my $sourceroot (sort keys %$from_to) {
54 my $targetroot = $from_to->{$sourceroot};
55 my $currdir = File::Spec->catdir($cwd, $sourceroot);
57 next unless -d $currdir;
59 chdir $currdir or die "could not change to $currdir: $!";
66 my $targetdir = File::Spec->catdir($targetroot, $File::Find::dir);
67 my $targetfile = File::Spec->catfile($targetdir, $filename);
68 my $sourcedir = File::Spec->catdir($currdir, $File::Find::dir);
69 my $sourcefile = File::Spec->catfile($sourcedir, $filename);
72 my ($size) = (stat $sourcefile)[7];
73 my $backup = $targetfile . $suffix;
74 unless (-s $targetfile == $size and not compare($sourcefile, $targetfile)) {
75 print "Backed up $targetfile to $backup\n";
76 File::Copy::copy($targetfile, $backup);
85 Code based on parts of ExtUtils::Install in order to
86 approximately track how it identifies files to
89 Koha Development Team <http://koha-community.org/>
91 Galen Charlton <galen.charlton@liblime.com>