chiark / gitweb /
Improve error reporting for rm problems
authorCiaran Gultnieks <ciaran@ciarang.com>
Fri, 15 Nov 2013 09:46:04 +0000 (09:46 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Fri, 15 Nov 2013 09:46:04 +0000 (09:46 +0000)
fdroidserver/common.py

index 3e394354525e8fbf48c85ff7fcee331808b89a10..f6853fd0ad53828fab46d93037efa0c38f90d1f9 100644 (file)
@@ -1543,11 +1543,14 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
     if 'rm' in build:
         for part in build['rm'].split(';'):
             dest = os.path.join(build_dir, part.strip())
-            if not os.path.realpath(dest).startswith(os.path.realpath(build_dir)):
+            rdest = os.path.realpath(dest)
+            if not rdest.startswith(os.path.realpath(build_dir)):
                 raise BuildException("rm for {0} is outside build root {1}".format(
                     os.path.realpath(build_dir),os.path.realpath(dest)))
-            if os.path.exists(dest):
-                subprocess.call('rm -rf ' + dest, shell=True)
+            if rdest == os.path.realpath(build_dir):
+                raise BuildException("rm removes whole build directory")
+            if os.path.exists(rdest):
+                subprocess.call('rm -rf ' + rdest, shell=True)
 
     # Fix apostrophes translation files if necessary...
     if build['fixapos']: