Variable substitution in snapcraft.yaml does not work in keys

Bug #1746636 reported by Lucy Llewellyn
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Kyle Fazzari

Bug Description

Currently the variables $SNAPCRAFT_PROJECT_NAME and $SNAPCRAFT_PROJECT_VERSION are substituted in the snapcraft.yaml when building. However, it is currently not possible to use these variables as part of the key side of the organize: key-value pairs.

Consider the following for the usage I envisaged but failed to achieve:

parts:
  alsa-lib:
    plugin: autotools
    source: ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.1.5.tar.bz2
    configflags:
    - --prefix=/usr
    - --sysconfdir=/etc
    - --libexec=/usr/lib
    - --libdir=/usr/lib
    - --localstatedir=/var
    - --with-configdir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/share/alsa
    - --with-plugindir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/alsa-lib
    - --disable-static
    organize:
      snap/$SNAPCRAFT_PROJECT_NAME/current/usr/: usr/

With the above organize setting I expected the files under $SNAP/snap/<project-name>/current/usr to be moved to $SNAP/usr, however it does not work because the variable $SNAPCRAFT_PROJECT_NAME is not expanded in the key. The previous two instances of the same variable in the values of the list in configflags: do get correctly replaced. It seems that the substitution only works on values, and not keys, which is a problem when the keys are also freeform such as in the organize: block.

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Indeed, we need to replace these across the board (including in the `environment` keyword).

Changed in snapcraft:
status: New → Triaged
Revision history for this message
Kyle Fazzari (kyrofa) wrote :
Changed in snapcraft:
status: Triaged → In Progress
importance: Undecided → High
assignee: nobody → Kyle Fazzari (kyrofa)
Changed in snapcraft:
milestone: none → 2.43
Revision history for this message
Lucy Llewellyn (lucyllewy) wrote :

Kyle, There's two potentially related bugs: #1746633 and #1766878

Kyle Fazzari (kyrofa)
Changed in snapcraft:
status: In Progress → Fix Committed
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.