chainguard-dev / melange

build APKs from source code
Apache License 2.0
399 stars 94 forks source link

subpackages if: does not seem to contain substitutions #1377

Open xnox opened 1 month ago

xnox commented 1 month ago
package:
  name: wolfi-base
  version: 1
  epoch: 7
  description: "Wolfi base metapackage"
  copyright:
    - license: MIT
  dependencies:
    runtime:
      - apk-tools
      - busybox
      - wolfi-keys

environment:
  contents:
    packages:
      - busybox

pipeline:
  - name: Install
    runs: |
      mkdir -p "${{targets.destdir}}"

subpackages:
  - if: ${{build.arch}} == 'x86_64'
    name: "${{package.name}}-x86"
    description: "empty x86 package"
    pipeline:
      - runs: |
          echo build arch is ${{build.arch}}

  - if: ${{build.arch}} == 'aarch64'
    name: "${{package.name}}-arm64"
    description: "empty arm64 package"
    pipeline:
      - runs: |
          echo build arch is ${{build.arch}}

update:
  enabled: false

During build expect one of the subpackages to be produced, but instead none are:

2024/07/15 14:11:03 INFO evaluating pipelines for package requirements
2024/07/15 14:11:03 INFO skipping subpackage wolfi-base-x86 because ${{build.arch}} == 'x86_64' == false
2024/07/15 14:11:03 INFO skipping subpackage wolfi-base-arm64 because ${{build.arch}} == 'aarch64' == false
2024/07/15 14:11:03 INFO populating workspace /home/xnox/.cache/melange-tmp/melange-workspace-3916530863 from ./wolfi-base/

There are attempts to substitute variables, but maybe not the one in question?

xnox commented 1 month ago

It fills to me that the substituion map computed in compile.go and substituted into subpackage.... doesn't actually modify the subpackage struct, and thus doesn't change the value of it upon exit back to build.go. Meaning evaluation of sp.If after Compile() does not actually see substituted values.

xnox commented 1 month ago

Ideally want to use this to skip building empty libquadmath on arm64.