Skip to content

Commit 774e032

Browse files
oharboeclaude
andcommitted
makeIssue: run-me follows a relative WORK_HOME as spelled
tar keeps WORK_HOME's spelling in the archive's member names, but run-me's paths came from the directory WORK_HOME resolves to. With link -> work/real and WORK_HOME=link, the archive holds link/vars-*.sh while run-me climbed two levels and sourced work/real/vars-*.sh, so it stopped. Both of run-me's paths, the climb back to the archive's root and the vars file's path from there, now follow WORK_HOME as tar was given it. An absolute WORK_HOME and WORK_HOME=. give the same run-me as before. TestRunMe unpacks and runs an archive made with a relative WORK_HOME that is a symlink; it failed before this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 329a41a commit 774e032

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎flow/test/test_make_issue.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ def test_work_home_absolute(self):
204204
def test_work_home_relative(self):
205205
self.assert_runs("work/stub")
206206

207+
def test_work_home_relative_through_a_symlink(self):
208+
"""tar keeps WORK_HOME's spelling in the member names, so run-me
209+
follows the spelling, not the directory the link resolves to."""
210+
os.makedirs(os.path.join(self.stub.flow, "work", "real"))
211+
os.symlink(os.path.join("work", "real"), os.path.join(self.stub.flow, "link"))
212+
self.assert_runs("link")
213+
207214

208215
class TestOptions(StubFlowTestCase):
209216
def test_copy_issue_copies_the_archive(self):

‎flow/util/makeIssue.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ def archive_root_from_run_me(work_home, vars_basename):
127127
file's path from there: the archive's root, where the vars' paths
128128
start. run-me is at the root when WORK_HOME is absolute (its path is
129129
stripped from the members) or the flow directory; a relative WORK_HOME
130-
keeps its place under the root, and run-me climbs back from it."""
131-
here = os.path.realpath(".")
132-
if work_home.startswith("/") or os.path.realpath(work_home) == here:
130+
keeps its place under the root, spelled as tar was given it, and
131+
run-me climbs back from it. Both paths follow that spelling, not the
132+
directory a symlink in it resolves to, as the member names do."""
133+
work = os.path.normpath(work_home)
134+
if os.path.isabs(work) or work == ".":
133135
return None, f"./{os.path.basename(vars_basename)}.sh"
134-
root = os.path.relpath(here, os.path.realpath(work_home))
135-
vars_path = os.path.relpath(os.path.realpath(vars_basename), here)
136-
return root, f"./{vars_path}.sh"
136+
root = os.path.join(*[".."] * len(work.split(os.sep)))
137+
return root, f"./{os.path.normpath(vars_basename)}.sh"
137138

138139

139140
def run_me_text(env, issue_target, vars_basename, yosys):

0 commit comments

Comments
 (0)