Fix more trouble with .do scripts that cd to other directories.

The interaction of REDO_STARTDIR, REDO_PWD, and getcwd() are pretty
complicated.  In this case, we accidentally assumed that the current
instance of redo was running with getcwd() == REDO_STARTDIR+REDO_PWD, and so
the new target was REDO_STARTDIR+REDO_PWD+t, but this isn't the case if the
current .do script did chdir().

The correct answer is REDO_STARTDIR+getcwd()+t.
This commit is contained in:
Avery Pennarun 2010-11-25 06:35:22 -08:00
commit c29de89051
4 changed files with 22 additions and 12 deletions

View file

@ -95,9 +95,13 @@ class BuildJob:
jwack.start_job(t, self._do_subproc, self._after)
def _do_subproc(self):
td = os.environ.get('REDO_PWD', '')
# careful: REDO_PWD was the PWD relative to the STARTPATH at the time
# we *started* building the current target; but that target ran
# redo-ifchange, and it might have done it from a different directory
# than we started it in. So os.getcwd() might be != REDO_PWD right now.
dn = os.path.dirname(self.t)
os.environ['REDO_PWD'] = os.path.join(td, dn)
newp = os.path.realpath(dn)
os.environ['REDO_PWD'] = state.relpath(newp, vars.STARTDIR)
os.environ['REDO_TARGET'] = os.path.basename(self.t)
os.environ['REDO_DEPTH'] = vars.DEPTH + ' '
if dn: