Don't send a string as cmds to SilentPopen

Also, rm= checks for the validity of the paths. That's not useful, since one
could easily do "init=rm -rf ." without that same error popping up.
This commit is contained in:
Daniel Martí 2014-02-17 14:59:55 +01:00
parent 8533b8c44e
commit a051ea9b93

View file

@ -486,7 +486,7 @@ class vcs_svn(vcs):
for svncommand in ( for svncommand in (
'svn revert -R .', 'svn revert -R .',
r"svn status | awk '/\?/ {print $2}' | xargs rm -rf"): r"svn status | awk '/\?/ {print $2}' | xargs rm -rf"):
p = SilentPopen(svncommand, cwd=self.local, shell=True) p = SilentPopen([svncommand], cwd=self.local, shell=True)
if p.returncode != 0: if p.returncode != 0:
raise VCSException("Svn reset ({0}) failed in {1}".format(svncommand, self.local)) raise VCSException("Svn reset ({0}) failed in {1}".format(svncommand, self.local))
if not self.refreshed: if not self.refreshed:
@ -518,7 +518,7 @@ class vcs_hg(vcs):
if p.returncode != 0: if p.returncode != 0:
raise VCSException("Hg clone failed") raise VCSException("Hg clone failed")
else: else:
p = SilentPopen('hg status -uS | xargs rm -rf', cwd=self.local, shell=True) p = SilentPopen(['hg status -uS | xargs rm -rf'], cwd=self.local, shell=True)
if p.returncode != 0: if p.returncode != 0:
raise VCSException("Hg clean failed") raise VCSException("Hg clean failed")
if not self.refreshed: if not self.refreshed:
@ -1016,19 +1016,13 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
# Delete unwanted files # Delete unwanted files
if 'rm' in build: if 'rm' in build:
for part in build['rm']: for part in build['rm']:
dest = os.path.join(build_dir, part.strip()) dest = os.path.join(build_dir, part)
rdest = os.path.abspath(dest) logging.info("Removing {0}".format(part))
logging.info("Removing {0}".format(rdest)) if os.path.lexists(dest):
if not rdest.startswith(os.path.abspath(build_dir)): if os.path.islink(dest):
raise BuildException("rm for {1} is outside build root {0}".format( SilentPopen(['unlink ' + dest], shell=True)
os.path.abspath(build_dir),os.path.abspath(dest)))
if rdest == os.path.abspath(build_dir):
raise BuildException("rm removes whole build directory")
if os.path.lexists(rdest):
if os.path.islink(rdest):
SilentPopen('unlink ' + rdest, shell=True)
else: else:
SilentPopen('rm -rf ' + rdest, shell=True) SilentPopen(['rm -rf ' + dest], shell=True)
else: else:
logging.info("...but it didn't exist") logging.info("...but it didn't exist")