From 339167c23c0ccd68841f3f3b36490fce4743aaa6 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@bento.schottelius.org>
Date: Sun, 14 Sep 2014 13:51:13 +0200
Subject: [PATCH] catch some errors

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
---
 cdist/preos.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/cdist/preos.py b/cdist/preos.py
index 0aa7eb6f..b61318ed 100644
--- a/cdist/preos.py
+++ b/cdist/preos.py
@@ -148,14 +148,17 @@ cp -L "$src" "$real_dst"
 
         log.debug("Bootstrap: %s" % cmd)
 
-#        try:
-        subprocess.check_call(cmd)
-#        except subprocess.CalledProcessError:
-#            raise 
+        try:
+            subprocess.check_call(cmd)
+        except subprocess.CalledProcessError:
+            raise cdist.Error("Debootstrap failed (root priviliges required)")
 
         # Required to run this - otherwise apt-get install fails
         cmd = [ "chroot", self.target_dir, "/usr/bin/apt-get", "update" ]
-        subprocess.check_call(cmd)
+        try:
+            subprocess.check_call(cmd)
+        except subprocess.CalledProcessError:
+            raise cdist.Error("chrooted apt-get update failed (root priviliges required)")
 
     def create_helper_files(self, base_dir):
         for key, val in self.helper.items():