]> gitweb @ CieloNegro.org - sugar.git/blob - tools/update.pl
Auto commit by The Sugar System.
[sugar.git] / tools / update.pl
1 use strict;
2 use warnings;
3 use Smart::Comments;
4 use lib 'tools';
5 require 'utils.pl';
6 use File::stat;
7 use File::Spec;
8 use File::Compare;
9 use File::Copy;
10
11 sub main {
12     while (defined(my $rel = <>)) {
13         chomp $rel;
14         my $saved = rel2saved($rel);
15         next if !-e $saved;
16
17         my $abs = File::Spec->rel2abs($rel, $ENV{HOME});
18
19         my $current_st = stat($abs);
20         my $saved_st   = stat($saved);
21
22         if ($current_st->mtime > $saved_st->mtime &&
23               compare($abs, $saved) != 0) {
24             print "Copying $abs to $saved...\n";
25             copy($abs, $saved) or die $!;
26         }
27     }
28 }
29
30 main();