#!/usr/local/bin/perl -w
###########################################
# binlinks - Link various helper scripts 
#  located in git repos to ~/bin
# Mike Schilli, 2011 (m@perlmeister.com)
###########################################
use strict;
use Log::Log4perl qw(:easy);
use File::Basename;
use Sysadm::Install qw(mkd);

Log::Log4perl->easy_init($DEBUG);

my ($home)   = glob "~";
my $home_bin = "$home/bin";

while (<DATA>) {
 chomp;

 my ($linkbase, $src) = split ' ', $_;

 $src        = "$home/$src";
 my $binpath = "$home_bin/$linkbase";

 if (-l $binpath) {
  DEBUG "$binpath already exists";
  next;
 } elsif (-e $binpath) {
  ERROR "$binpath already exists, ",
    "but not a link!";
  next;
 }

 INFO "Linking $binpath -> $src";

 symlink $src, $binpath
   or LOGDIE
   "Cannot link $binpath->$src ($!)";
}

__DATA__
logtemp git/articles/temper/eg/logtemp
cvs2git git/sandbox/cvs2git/cvs2git
