-if (not exists $EximBuild::Conf{auto_update} or $EximBuild::Conf{auto_update})
-{
- my $remote = $EximBuild::Conf{auto_update} // 'origin';
+eval {
+ if (not exists $EximBuild::Conf{auto_update} or $EximBuild::Conf{auto_update})
+ {
+ my $remote = $EximBuild::Conf{auto_update} // 'origin';
+
+ die "auto-update not possible: need write permissions in @{[cwd]}\n"
+ if not -w '.';
+
+ # Get information about our remote and calculate the chance for a
+ # successfull auto-updat. Based on:
+ # http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
+ system("git fetch $remote") == 0 or die "'git fetch $remote' failed\n";
+ my ($upstream, $local, $base) = qx'git rev-parse ...@{upstream}' or die "'git rev-parse' failed\n";