Incorrect ref used in junctions

Summary

When building a project which uses a junction, BuildStream does not always use the correct ref.

Steps to reproduce

I reproduced this with bst-1.2 and master, using the following steps:

  • Add a new element to gnome-build-meta to build a VM image which uses new additions to freedesktop-sdk
  • Build gnome-build-meta

The result I get in both scenarios, when running bst build vm/desktop-vm-image-x86_64.bst in gnome-build-meta (an element that I have added locally) is:

vm/desktop-vm.bst [line 37 column 2]: Could not find element 'vm/linux-vm-boot/weston.bst' in project referred to by junction element 'freedesktop-sdk.bst'

Note that we use project.refs ref storage and so the refs are stored in junction.refs

I will create a test case to prove this more clearly. I also have a suspicion that in master, we might be staging junctions in subproject .bst/staged-junctions directories instead of always consulting the toplevel project directory for where to stage a junction, in the case of deeply nested projects (will have to verify this).

What is the current bug behavior?

We do not stage the ref indicated by junction.refs.

I verified this in bst-1.2 branch by commenting out some code which cleans up the staged junction.

The staged freedesktop-sdk junction was at the tip of my local copy of 18.08, and not at the ref indicated in the junction.refs file.

In master, I tried to verify this but I could not find a .bst/staged-junctions directory in the project where I launched bst.

What is the expected correct behavior?

It should use the ref indicated in junction.refs all the time.