melange icon indicating copy to clipboard operation
melange copied to clipboard

ERROR: failed to build package

Open viveksahu26 opened this issue 1 year ago • 1 comments

Hey, i am getting error on running below command. ERRO ERROR: failed to build package. the build environment has been preserved: arch=x86_64

Any idea, why it so ??

$ melange build cosign.yaml
                                         
2024/02/13 21:35:01 WARN skipping arch 386
2024/02/13 21:35:01 WARN skipping arch arm64
2024/02/13 21:35:01 WARN skipping arch arm/v6
2024/02/13 21:35:01 WARN skipping arch arm/v7
2024/02/13 21:35:01 WARN skipping arch ppc64le
2024/02/13 21:35:01 WARN skipping arch riscv64
2024/02/13 21:35:01 WARN skipping arch s390x
2024/02/13 21:35:01 INFO melange is building: arch=x86_64
2024/02/13 21:35:01 INFO   configuration file: cosign.yaml arch=x86_64
2024/02/13 21:35:01 INFO   workspace dir: /tmp/melange-workspace-1905072080 arch=x86_64
2024/02/13 21:35:01 INFO evaluating pipelines for package requirements arch=x86_64
2024/02/13 21:35:01 INFO   adding packages [wget] for pipeline "Fetch and extract external object into workspace" arch=x86_64
2024/02/13 21:35:01 INFO   adding packages [go busybox ca-certificates-bundle] for pipeline "Run a build using the go compiler" arch=x86_64
2024/02/13 21:35:01 INFO   adding packages [binutils scanelf] for pipeline "Strip binaries" arch=x86_64
2024/02/13 21:35:01 INFO populating workspace /tmp/melange-workspace-1905072080 from . arch=x86_64
2024/02/13 21:35:01 INFO --cache-dir ./melange-cache/ not a dir; skipping arch=x86_64
2024/02/13 21:35:01 INFO building workspace in '/tmp/melange-guest-4118887769' with apko arch=x86_64
2024/02/13 21:35:01 ERRO ERROR: failed to build package. the build environment has been preserved: arch=x86_64
2024/02/13 21:35:01 INFO   workspace dir: /tmp/melange-workspace-1905072080 arch=x86_64
2024/02/13 21:35:01 INFO   guest dir: /tmp/melange-guest-4118887769 arch=x86_64
2024/02/13 21:35:01 INFO error during command execution: failed to build package: unable to build guest: unable to create build context: initializing apk: failed to initialize apk repositories: must provide at least one repository

cat cosign.yaml

package:
  name: cosign
  version: 2.2.3
  epoch: 0
  description: Container Signing
  copyright:
    - license: Apache-2.0
  target-architecture: [x86_64]
  dependencies:
    runtime:
      - ca-certificates-bundle

environment:
  contents:
    packages:
      - busybox
      - ca-certificates-bundle
      - go
  environment:
    CGO_ENABLED: "0"

pipeline:
  - uses: fetch
    with:
      expected-sha256: 2135a2e3c40c570dc99d5784e5482ab2df903136e48fa63d4a55ade3707cad09
      uri: https://github.com/sigstore/cosign/archive/v${{package.version}}/cosign-v${{package.version}}.tar.gz

  - uses: go/build
    with:
      ldflags: -s -w -X sigs.k8s.io/release-utils/version.gitVersion=${{package.version}}
      output: cosign
      packages: ./cmd/cosign

  - uses: strip

update:
  enabled: true
  github:
    identifier: sigstore/cosign
    strip-prefix: v

viveksahu26 avatar Feb 13 '24 16:02 viveksahu26

you need to modify environment block to environment: keyring:
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub repositories:
- https://packages.wolfi.dev/os contents: packages: - busybox - ca-certificates-bundle - go environment: CGO_ENABLED: "0"

manhvu1997 avatar Mar 08 '24 17:03 manhvu1997

currently the environment block should be like


environment:
  contents:
    keyring:
      - https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
    repositories:
      - https://packages.wolfi.dev/os
    packages:
      - busybox
      - ca-certificates-bundle
      - go
  environment:
    CGO_ENABLED: "0"

mbovo avatar May 16 '24 09:05 mbovo

@viveksahu26 Is this resolved on your end?

krishjainx avatar Jun 13 '24 08:06 krishjainx

@viveksahu26 Is this resolved on your end?

Yeah, you can close this issue.

viveksahu26 avatar Jun 13 '24 08:06 viveksahu26