]> gitweb @ CieloNegro.org - sugar.git/blob - tools/export.pl
46f50c03ab0e3710b8b52ee5a4776bebe68269d7
[sugar.git] / tools / export.pl
1 use strict;
2 use warnings;
3 use Smart::Comments;
4 use lib 'tools';
5 require 'utils.pl';
6 use File::Spec;
7 use File::Compare;
8 use File::Copy;
9
10 sub main {
11     while (defined(my $arg = <>)) {
12         chomp $arg;
13
14         my $rel   = File::Spec->file_name_is_absolute($arg)
15                   ? File::Spec->abs2rel($arg, $ENV{HOME})
16                   : $arg;
17         my $abs   = File::Spec->rel2abs($rel, $ENV{HOME});
18         my $saved = rel2saved($rel);
19
20         if (!-e $saved) {
21             print "SKIP: $rel is not in the repository.\n";
22             next;
23         }
24         elsif (-e $abs) {
25             if (compare($abs, $saved) == 0) {
26                 print "SKIP: $rel is identical to the copy in the repository.\n";
27             }
28             else {
29                 print "SKIP: $rel is different from the copy in the repository.\n";
30             }
31         }
32         else {
33             print "Copying $saved to $abs...\n";
34             copy($saved, $abs) or die $!;
35         }
36     }
37 }
38
39 main();