X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=tools%2Finstall.pl;fp=tools%2Finstall.pl;h=a515f4e6b9e7be328c0373ed59675fcf34938898;hb=c478cc19985f964d464143253914ee067c3758c4;hp=0000000000000000000000000000000000000000;hpb=84a90e22907dfbf662a42a1fa1c6bb0c054fa02d;p=sugar.git diff --git a/tools/install.pl b/tools/install.pl new file mode 100644 index 0000000..a515f4e --- /dev/null +++ b/tools/install.pl @@ -0,0 +1,31 @@ +use strict; +use warnings; +use Smart::Comments; +use lib 'tools'; +require 'utils.pl'; +use File::stat; +use File::Spec; +use File::Compare; +use File::Copy; + +sub main { + while (defined(my $rel = <>)) { + chomp $rel; + my $saved = rel2saved($rel); + next if !-e $saved; + + my $abs = File::Spec->rel2abs($rel, $ENV{HOME}); + + my $current_st = stat($abs); + my $saved_st = stat($saved); + + if ($current_st->mtime < $saved_st->mtime && + compare($abs, $saved) != 0) { + print "Copying $saved to $abs...\n"; + unlink $abs or die $!; + copy($saved, $abs) or die $!; + } + } +} + +main();