[
  {
    "path": ".buildkite/fpm-pipeline.yml",
    "content": "# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json\n\nenv:\n  IMAGE_UBUNTU_X86_64: \"family/platform-ingest-eng-prod-base-ubuntu-2204\"\n  STAGING_IMAGE: \"docker.elastic.co/observability-ci\"\n  MAKEFILE: \"fpm\"\n  BUILDX: \"0\"\n\n# This section is used to define the plugins that will be used in the pipeline.\n# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins\ncommon:\n  - oblt_google_auth_plugin: &gcp_oidc_plugin\n      # See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/golang-crossbuild/01-gcp-buildkite-oidc.tf\n      # This plugin authenticates to Google Cloud using the OIDC token.\n      elastic/oblt-google-auth#v1.3.0:\n        lifetime: 10800 # seconds\n        project-id: \"elastic-observability-ci\"\n        project-number: \"911195782929\"\n  - docker_elastic_login_plugin: &docker_elastic_login_plugin\n      elastic/vault-docker-login#v0.6.0:\n        secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'\n  - dockerhub_login_plugin: &dockerhub_login_plugin\n      elastic/vault-docker-login#v0.6.0:\n        secret_path: 'kv/ci-shared/observability-github-secrets/shared/docker/dockerhub/observabilityrobots'\n\nsteps:\n  - label: \":linux: multiarch Linux x86_64/arm64 FPM docker image\"\n    key: \"build-and-publish-ubuntu-x86-fpm\"\n    if: build.env(\"BUILDKITE_PULL_REQUEST\") != \"false\" || build.source == \"ui\" || build.branch == \"main\" || build.branch =~ /^[0-9]+\\.[0-9]+$$/\n    command:\n      - \".buildkite/scripts/llvm-fpm/build_and_publish.sh ${MAKEFILE}\"\n    notify:\n      - github_commit_status:\n          context: \"Build FPM / Ubuntu X86_64\"\n    env:\n      REPOSITORY: \"${STAGING_IMAGE}\"\n    agents:\n      provider: \"gcp\"\n      image: \"${IMAGE_UBUNTU_X86_64}\"\n    plugins:\n      - *gcp_oidc_plugin\n      - *docker_elastic_login_plugin\n      - *dockerhub_login_plugin\n"
  },
  {
    "path": ".buildkite/hooks/pre-command",
    "content": "#!/bin/bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nif [[ \"$BUILDKITE_PIPELINE_SLUG\" == \"golang-crossbuild\" && \"$BUILDKITE_STEP_KEY\" == \"release-post\" ]]; then\n    export GITHUB_USERNAME=\"elasticmachine\"\n    export GITHUB_EMAIL=\"elasticmachine@elastic.co\"\n    export GITHUB_TOKEN_SECRET=$VAULT_GITHUB_TOKEN\nfi\n"
  },
  {
    "path": ".buildkite/hooks/pre-exit",
    "content": "#!/bin/bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nunset_secrets\n\n# Ensure that any temporal files created during any step are removed\ncleanup\n"
  },
  {
    "path": ".buildkite/llvm-apple-pipeline.yml",
    "content": "# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json\n\nenv:\n  IMAGE_UBUNTU_X86_64: \"family/platform-ingest-eng-prod-base-ubuntu-2204\"\n  IMAGE_UBUNTU_ARM_64: \"platform-ingest-eng-prod-base-ubuntu-2204-aarch64\"\n  INSTANCE_TYPE_ARM_64: \"t4g.large\"\n  STAGING_IMAGE: \"docker.elastic.co/observability-ci\"\n  MAKEFILE: \"go/llvm-apple\"\n  BUILDX: \"0\"\n\n# This section is used to define the plugins that will be used in the pipeline.\n# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins\ncommon:\n  - oblt_google_auth_plugin: &gcp_oidc_plugin\n      # See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/golang-crossbuild/01-gcp-buildkite-oidc.tf\n      # This plugin authenticates to Google Cloud using the OIDC token.\n      elastic/oblt-google-auth#v1.3.0:\n        lifetime: 20000 # seconds\n        project-id: \"elastic-observability-ci\"\n        project-number: \"911195782929\"\n  - docker_elastic_login_plugin: &docker_elastic_login_plugin\n      elastic/vault-docker-login#v0.6.0:\n        secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'\n  - dockerhub_login_plugin: &dockerhub_login_plugin\n      elastic/vault-docker-login#v0.6.0:\n        secret_path: 'kv/ci-shared/observability-github-secrets/shared/docker/dockerhub/observabilityrobots'\n\nsteps:\n  - label: \":linux: Build LLVM Apple / Ubuntu X86_64 - {{matrix.debianVersion}}\"\n    key: \"build-ubuntu-x86-llvm-apple\"\n    if: build.env(\"BUILDKITE_PULL_REQUEST\") != \"false\" || build.source == \"ui\" || build.branch == \"main\" || build.branch =~ /^[0-9]+\\.[0-9]+$$/\n    command:\n      - \".buildkite/scripts/llvm-apple/build.sh ${MAKEFILE}\"\n      - \".buildkite/scripts/llvm-apple/publish.sh ${MAKEFILE}\"\n    notify:\n      - github_commit_status:\n          context: \"Build LLVM Apple / Ubuntu X86_64\"\n    env:\n      TAG_EXTENSION: \"-debian{{matrix.debianVersion}}-amd64\"\n      DEBIAN_VERSION: \"{{matrix.debianVersion}}\"\n    agents:\n      provider: \"gcp\"\n      image: \"${IMAGE_UBUNTU_X86_64}\"\n    plugins:\n      - *gcp_oidc_plugin\n      - *docker_elastic_login_plugin\n      - *dockerhub_login_plugin\n    matrix:\n      setup:\n        debianVersion:\n          - \"10\"\n          - \"11\"\n          - \"12\"\n\n  - label: \":linux: Build LLVM Apple / Ubuntu ARM - {{matrix.debianVersion}}\"\n    key: \"build-ubuntu-arm-llvm-apple\"\n    if: build.env(\"BUILDKITE_PULL_REQUEST\") != \"false\" || build.source == \"ui\" || build.branch == \"main\" || build.branch =~ /^[0-9]+\\.[0-9]+$$/\n    command:\n      - \".buildkite/scripts/llvm-apple/build.sh ${MAKEFILE}\"\n      - \".buildkite/scripts/llvm-apple/publish.sh ${MAKEFILE}\"\n    notify:\n      - github_commit_status:\n          context: \"Build LLVM Apple / Ubuntu ARM\"\n    env:\n      TAG_EXTENSION: \"-debian{{matrix.debianVersion}}-arm64\"\n      DEBIAN_VERSION: \"{{matrix.debianVersion}}\"\n    agents:\n      provider: \"aws\"\n      imagePrefix: \"${IMAGE_UBUNTU_ARM_64}\"\n      instanceType: \"${INSTANCE_TYPE_ARM_64}\"\n    plugins:\n      - *gcp_oidc_plugin\n      - *docker_elastic_login_plugin\n      - *dockerhub_login_plugin\n    matrix:\n      setup:\n        debianVersion:\n          - \"10\"\n          - \"11\"\n          - \"12\"\n"
  },
  {
    "path": ".buildkite/pipeline.yml",
    "content": "# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json\n\nenv:\n  SETUP_GVM_VERSION: \"v0.6.0\"\n  IMAGE_UBUNTU_X86_64: \"family/platform-ingest-eng-prod-base-ubuntu-2204\"\n  INSTANCE_TYPE_X86_64: \"n2-standard-4\"\n  IMAGE_UBUNTU_ARM_64: \"platform-ingest-eng-prod-base-ubuntu-2204-aarch64\"\n  INSTANCE_TYPE_ARM_64: \"t4g.large\"\n  STAGING_IMAGE: \"docker.elastic.co/observability-ci\"\n  BUILDX: 1\n\n# This section is used to define the plugins that will be used in the pipeline.\n# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins\ncommon:\n  - oblt_google_auth_plugin: &gcp_oidc_plugin\n      # See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/golang-crossbuild/01-gcp-buildkite-oidc.tf\n      # This plugin authenticates to Google Cloud using the OIDC token.\n      elastic/oblt-google-auth#v1.3.0:\n        lifetime: 10800 # seconds\n        project-id: \"elastic-observability-ci\"\n        project-number: \"911195782929\"\n  - docker_elastic_login_plugin: &docker_elastic_login_plugin\n      elastic/vault-docker-login#v0.6.0:\n        secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'\n  - dockerhub_login_plugin: &dockerhub_login_plugin\n      elastic/vault-docker-login#v0.6.0:\n        secret_path: 'kv/ci-shared/observability-github-secrets/shared/docker/dockerhub/observabilityrobots'\n\nsteps:\n\n  - label: \":linux: Validate Go version consistency\"\n    command:\n      - \".buildkite/scripts/validate-go-version.sh\"\n\n  - wait: ~\n\n  - group: \"FPM\"\n    key: \"fpm\"\n\n    steps:\n      - label: \"Trigger fpm-pipeline\"\n        if: build.pull_request.id != null && build.env(\"BUILDKITE_PULL_REQUEST_BASE_BRANCH\") == \"main\"\n        if_changed:\n          - .buildkite/pipeline.yml\n          - .buildkite/fpm-pipeline.yml\n          - .buildkite/scripts/llvm-fpm\n          - fpm/**\n        command: \"buildkite-agent pipeline upload .buildkite/fpm-pipeline.yml\"\n        env:\n          BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}\n          BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}\n          GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}\n\n      # Trigger for the main branch only\n      - label: \":pipeline: Upload FPM Pipeline\"\n        if: build.branch == 'main'\n        command: \"buildkite-agent pipeline upload .buildkite/fpm-pipeline.yml\"\n        env:\n          BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}\n          BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}\n          GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}\n\n  - group: \"llvm-apple\"\n    key: \"llvm-apple\"\n\n    steps:\n      - label: \"Trigger llvm-apple-pipeline\"\n        if: build.pull_request.id != null && build.env(\"BUILDKITE_PULL_REQUEST_BASE_BRANCH\") == \"main\"\n        if_changed:\n          # As long as https://github.com/elastic/golang-crossbuild/issues/615\n          #- .buildkite/pipeline.yml\n          - .buildkite/llvm-apple-pipeline.yml\n          - .buildkite/scripts/llvm-apple\n          - go/llvm-apple/**\n        command: \"buildkite-agent pipeline upload .buildkite/llvm-apple-pipeline.yml\"\n        env:\n          BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}\n          BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}\n          GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}\n\n      # Trigger for the main branch only if no a scheduled build\n      - label: \":pipeline: Upload llvm-apple Pipeline\"\n        if: build.branch == 'main' && build.source != \"schedule\"\n        command: \"buildkite-agent pipeline upload .buildkite/llvm-apple-pipeline.yml\"\n        env:\n          BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}\n          BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}\n          GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}\n\n  - group: \"Staging\"\n    key: \"staging\"\n\n    steps:\n      - label: \":linux: Staging / Ubuntu X86_64 - {{matrix.makefile}} - fips: {{matrix.fips}}\"\n        key: \"build-ubuntu-x86\"\n        command:\n          - \".buildkite/scripts/build.sh {{matrix.makefile}}\"\n          - \".buildkite/scripts/publish.sh {{matrix.makefile}}\"\n        env:\n          REPOSITORY: \"${STAGING_IMAGE}\"\n          FIPS: \"{{matrix.fips}}\"\n        if: build.env(\"BUILDKITE_PULL_REQUEST\") != \"false\"\n        notify:\n          - github_commit_status:\n              context: \"Staging / Ubuntu X86_64\"\n        agents:\n          provider: \"gcp\"\n          image: \"${IMAGE_UBUNTU_X86_64}\"\n          instanceType: \"${INSTANCE_TYPE_X86_64}\"\n        plugins:\n          - *gcp_oidc_plugin\n          - *docker_elastic_login_plugin\n          - *dockerhub_login_plugin\n        retry:\n          automatic:\n            limit: 1\n        matrix:\n          setup:\n            makefile:\n              - \"Makefile\"\n              - \"Makefile.debian7\"\n              - \"Makefile.debian8\"\n              - \"Makefile.debian9\"\n              - \"Makefile.debian10\"\n              - \"Makefile.debian11\"\n              - \"Makefile.debian12\"\n            fips:\n              - \"false\"\n              - \"true\"\n\n      - label: \":linux: Staging / Ubuntu ARM - {{matrix.makefile}} - fips: {{matrix.fips}}\"\n        key: \"build-ubuntu-arm\"\n        command:\n          - \".buildkite/scripts/build.sh {{matrix.makefile}}\"\n          - \".buildkite/scripts/publish.sh {{matrix.makefile}}\"\n        env:\n          REPOSITORY: \"${STAGING_IMAGE}\"\n          FIPS: \"{{matrix.fips}}\"\n        if: build.env(\"BUILDKITE_PULL_REQUEST\") != \"false\"\n        notify:\n          - github_commit_status:\n              context: \"Staging / Ubuntu ARM\"\n        agents:\n          provider: \"aws\"\n          imagePrefix: \"${IMAGE_UBUNTU_ARM_64}\"\n          instanceType: \"${INSTANCE_TYPE_ARM_64}\"\n        plugins:\n          - *gcp_oidc_plugin\n          - *docker_elastic_login_plugin\n          - *dockerhub_login_plugin\n        retry:\n          automatic:\n            limit: 1\n        matrix:\n          setup:\n            makefile:\n              - \"Makefile.debian8\"\n              - \"Makefile.debian9\"\n              - \"Makefile.debian10\"\n              - \"Makefile.debian11\"\n              - \"Makefile.debian12\"\n            fips:\n              - \"false\"\n              - \"true\"\n\n  - group: \"Release\"\n    key: \"release\"\n\n    steps:\n      - label: \":linux: Release / Ubuntu X86_64 - {{matrix.makefile}} - fips: {{matrix.fips}}\"\n        key: \"release-ubuntu-x86\"\n        command:\n          - \".buildkite/scripts/build.sh {{matrix.makefile}}\"\n          - \".buildkite/scripts/publish.sh {{matrix.makefile}}\"\n        env:\n          FIPS: \"{{matrix.fips}}\"\n        # Releases should only be for main for ^[0-9].[0-9] branches (therefore support for major.minor.patch.x too).\n        if: build.branch == \"main\" || build.branch =~ /^[0-9]+\\.[0-9]+/ || build.branch =~ /^[0-9]+\\.[0-9]+\\.[0-9]+\\.x$$/\n        agents:\n          provider: \"gcp\"\n          image: \"${IMAGE_UBUNTU_X86_64}\"\n          instanceType: \"${INSTANCE_TYPE_X86_64}\"\n        plugins:\n          - *gcp_oidc_plugin\n          - *docker_elastic_login_plugin\n          - *dockerhub_login_plugin\n        retry:\n          automatic:\n            limit: 1\n        matrix:\n          setup:\n            makefile:\n              - \"Makefile\"\n              - \"Makefile.debian7\"\n              - \"Makefile.debian8\"\n              - \"Makefile.debian9\"\n              - \"Makefile.debian10\"\n              - \"Makefile.debian11\"\n              - \"Makefile.debian12\"\n            fips:\n              - \"false\"\n              - \"true\"\n        notify:\n          - github_commit_status:\n              context: \"Release / Ubuntu X86_64\"\n\n      - label: \":linux: Release / Ubuntu ARM - {{matrix.makefile}} - fips: {{matrix.fips}}\"\n        key: \"release-ubuntu-arm\"\n        command:\n          - \".buildkite/scripts/build.sh {{matrix.makefile}}\"\n          - \".buildkite/scripts/publish.sh {{matrix.makefile}}\"\n        env:\n          FIPS: \"{{matrix.fips}}\"\n        # Releases should only be for main for ^[0-9].[0-9] branches (therefore support for major.minor.patch.x too).\n        if: build.branch == \"main\" || build.branch =~ /^[0-9]+\\.[0-9]+$$/ || build.branch =~ /^[0-9]+\\.[0-9]+\\.[0-9]+\\.x$$/\n        agents:\n          provider: \"aws\"\n          imagePrefix: \"${IMAGE_UBUNTU_ARM_64}\"\n          instanceType: \"${INSTANCE_TYPE_ARM_64}\"\n        plugins:\n          - *gcp_oidc_plugin\n          - *docker_elastic_login_plugin\n          - *dockerhub_login_plugin\n        retry:\n          automatic:\n            limit: 1\n        matrix:\n          setup:\n            makefile:\n              - \"Makefile.debian8\"\n              - \"Makefile.debian9\"\n              - \"Makefile.debian10\"\n              - \"Makefile.debian11\"\n              - \"Makefile.debian12\"\n            fips:\n              - \"false\"\n              - \"true\"\n        notify:\n          - github_commit_status:\n              context: \"Release / Ubuntu ARM\"\n\n      - label: \"Post-Release\"\n        key: \"release-post\"\n        command: \".buildkite/scripts/post-release.sh ${GOLANG_VERSION}\"\n        # Releases should only be for main for ^[0-9].[0-9]$ branches.\n        if: build.branch == \"main\" || build.branch =~ /^[0-9]+\\.[0-9]+$$/\n        depends_on:\n          - \"release-ubuntu-x86\"\n          - \"release-ubuntu-arm\"\n        notify:\n          - github_commit_status:\n              context: \"Post-release\"\n        agents:\n          provider: \"gcp\"\n          image: \"${IMAGE_UBUNTU_X86_64}\"\n          instanceType: \"${INSTANCE_TYPE_X86_64}\"\n\n# TODO: look for the right slack channel. Robots team don't own this project.\nnotify:\n  - slack: \"#observablt-bots\"\n    if: build.state == \"failed\"\n"
  },
  {
    "path": ".buildkite/pull-requests.json",
    "content": "{\n    \"jobs\": [\n        {\n            \"enabled\": true,\n            \"pipelineSlug\": \"golang-crossbuild\",\n            \"allow_org_users\": true,\n            \"allowed_repo_permissions\": [\"admin\", \"write\"],\n            \"allowed_list\": [\"dependabot[bot]\", \"mergify[bot]\", \"github-actions[bot]\", \"elastic-vault-github-plugin-prod[bot]\"],\n            \"set_commit_status\": true,\n            \"build_on_commit\": true,\n            \"build_on_comment\": true,\n            \"trigger_comment_regex\": \"^(?:(?:buildkite\\\\W+)?(?:build|test)\\\\W+(?:this|it))|^/test$\",\n            \"always_trigger_comment_regex\": \"^(?:(?:buildkite\\\\W+)?(?:build|test)\\\\W+(?:this|it))|^/test$\",\n            \"skip_ci_labels\": [  ],\n            \"skip_target_branches\": [ ],\n            \"skip_ci_on_only_changed\": [ \"\\\\.md$\", \".mergify.yml\", \"^.github/\" ],\n            \"always_require_ci_on_changed\": [ ],\n            \"fail_on_not_mergeable\": true\n        }\n    ]\n}\n"
  },
  {
    "path": ".buildkite/scripts/build.sh",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nMAKEFILE=${1}\n\ncheck_is_arm\n\nadd_bin_path\nwith_go \"${GOLANG_VERSION}\"\nwith_mage\n\nmake -C go -f \"${MAKEFILE}\" build\"${is_arm}\" GS_BUCKET_PATH=golang-crossbuild-ci-internal\n\necho \"--- List Docker images staging\"\ndocker images --format \"table {{.Repository}}:{{.Tag}}\\t{{.Size}}\" --filter=reference=\"${STAGING_IMAGE}/golang-crossbuild\"\n\necho \"--- List Docker images production\"\ndocker images --format \"table {{.Repository}}:{{.Tag}}\\t{{.Size}}\" --filter=reference=\"docker.elastic.co/beats-dev/golang-crossbuild\"\n"
  },
  {
    "path": ".buildkite/scripts/buildx.sh",
    "content": "#!/usr/bin/env bash\nset -e\nset +x\n\nBUILDPLATFORM=${BUILDPLATFORM:-\"linux/amd64,linux/arm64\"}\n\nBUILDER_NAME=\"multibuilder${RANDOM}\"\necho \"Add support for multiarch\"\n# See https://docs.docker.com/build/building/multi-platform/#install-qemu-manually\n# We use QEMU for non arm platforms using the golang-crossbuild\ndocker run --privileged --rm tonistiigi/binfmt --install all\n\ndocker buildx ls\necho 'Create builder'\ndocker buildx create --name \"${BUILDER_NAME}\"\ndocker buildx use \"${BUILDER_NAME}\"\ndocker buildx inspect --bootstrap\necho 'Build Docker image'\ndocker buildx build --progress=plain --platform \"${BUILDPLATFORM}\" --push $*\n"
  },
  {
    "path": ".buildkite/scripts/common.sh",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nREPO=\"golang-crossbuild\"\nWORKSPACE=\"$(pwd)\"\nBIN=\"${WORKSPACE}/bin\"\nHW_TYPE=\"$(uname -m)\"\nPLATFORM_TYPE=\"$(uname)\"\nTMP_FOLDER=\"tmp.${REPO}\"\n\nif [[ -z \"${GOLANG_VERSION-\"\"}\" ]]; then\n    export GOLANG_VERSION=$(cat \"${WORKSPACE}/.go-version\")\nfi\n\nadd_bin_path() {\n    echo \"Adding PATH to the environment variables...\"\n    create_bin\n    export PATH=\"${PATH}:${BIN}\"\n}\n\nwith_go() {\n    local go_version=\"${1}\"\n    echo \"Setting up the Go environment...\"\n    create_bin\n    check_platform_architecture\n    retry 5 curl -sL -o ${BIN}/gvm \"https://github.com/andrewkroh/gvm/releases/download/v0.6.0/gvm-${PLATFORM_TYPE}-${arch_type}\"\n    export PATH=\"${PATH}:${BIN}\"\n    chmod +x ${BIN}/gvm\n    eval \"$(gvm \"$go_version\")\"\n    go version\n    which go\n    export PATH=\"${PATH}:$(go env GOPATH):$(go env GOPATH)/bin\"\n}\n\nwith_mage() {\n    local install_packages=(\n            \"github.com/magefile/mage\"\n            \"github.com/elastic/go-licenser\"\n            \"golang.org/x/tools/cmd/goimports\"\n            \"github.com/jstemmer/go-junit-report\"\n            \"gotest.tools/gotestsum\"\n    )\n    create_bin\n    for pkg in \"${install_packages[@]}\"; do\n        go install \"${pkg}@latest\"\n    done\n}\n\ncreate_bin() {\n    if [[ ! -d \"${BIN}\" ]]; then\n    mkdir -p ${BIN}\n    fi\n}\n\ncheck_platform_architecture() {\n# for downloading the GVM and Terraform packages\n  case \"${HW_TYPE}\" in\n   \"x86_64\")\n        arch_type=\"amd64\"\n        ;;\n    \"aarch64\")\n        arch_type=\"arm64\"\n        ;;\n    \"arm64\")\n        arch_type=\"arm64\"\n        ;;\n    *)\n    echo \"The current platform/OS type is unsupported yet\"\n    ;;\n  esac\n}\n\nretry() {\n    local retries=$1\n    shift\n    local count=0\n    until \"$@\"; do\n        exit=$?\n        wait=$((2 ** count))\n        count=$((count + 1))\n        if [ $count -lt \"$retries\" ]; then\n            >&2 echo \"Retry $count/$retries exited $exit, retrying in $wait seconds...\"\n            sleep $wait\n        else\n            >&2 echo \"Retry $count/$retries exited $exit, no more retries left.\"\n            return $exit\n        fi\n    done\n    return 0\n}\n\nunset_secrets () {\n  for var in $(printenv | sed 's;=.*;;' | sort); do\n    if [[ \"$var\" == *_SECRET || \"$var\" == *_TOKEN ]]; then\n      unset \"$var\"\n    fi\n  done\n}\n\ncleanup() {\n  echo \"Deleting temporary files...\"\n  rm -rf ${BIN}/${TMP_FOLDER}.*\n  echo \"Done.\"\n}\n\ntag_Exists() {\n  local tag=$1\n  local url=https://api.github.com/repos/elastic/${REPO}/releases/tags/${tag}\n  local status=$(retry 3 curl -s -o /dev/null -w \"%{http_code}\" -u ${GITHUB_TOKEN_SECRET}:x-oauth-basic ${url})\n\n  if [ \"${status}\" == \"200\" ]; then\n    echo true\n  else\n    echo false\n  fi\n}\n\ncheck_is_arm() {\n  if [[ ${HW_TYPE} == \"aarch64\" || ${HW_TYPE} == \"arm64\" ]]; then\n    is_arm=\"-arm\"\n  else\n    is_arm=\"\"\n  fi\n}\n"
  },
  {
    "path": ".buildkite/scripts/llvm-apple/build.sh",
    "content": "#!/usr/bin/env bash\n# This script builds the Docker images but does not push them to a registry.\n# Env variables:\n# - RELEASE: If set, indicates that this is a production release and images should be name to production. For manual releases\n# - GOLANG_VERSION: Version of Go to use for the build. Defaults to the value in .buildkite/pipeline.yml.\n# - MAKEFILE: Path to the Makefile to use.\n# - STAGING_IMAGE: Docker repository to use for staging images.\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nmakefile=${1}\n\nadd_bin_path\nwith_go \"${GOLANG_VERSION}\"\nwith_mage\n\n# if RELEASE is not set then set REPOSITORY to STAGING_IMAGE\nif [[ -z \"${RELEASE:-}\" ]]; then\n  export REPOSITORY=\"${STAGING_IMAGE}\"\nfi\n\nretry 3 make -C \"${makefile}\" build GS_BUCKET_PATH=golang-crossbuild-ci-internal\n\necho \"--- List Docker images\"\ndocker images --format \"table {{.Repository}}:{{.Tag}}\\t{{.Size}}\"\n"
  },
  {
    "path": ".buildkite/scripts/llvm-apple/publish.sh",
    "content": "#!/usr/bin/env bash\n# Env variables:\n# - RELEASE: If set, indicates that this is a production release and images should be pushed to production. For manual releases\n# - MAKEFILE: Path to the Makefile to use.\n# - STAGING_IMAGE: Docker repository to use for staging images.\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nmakefile=${1}\n\nadd_bin_path\n\n# if RELEASE is not set then set REPOSITORY to STAGING_IMAGE\nif [[ -z \"${RELEASE:-}\" ]]; then\n  export REPOSITORY=\"${STAGING_IMAGE}\"\nfi\n\nretry 3 make -C ${makefile} push\n"
  },
  {
    "path": ".buildkite/scripts/llvm-fpm/build_and_publish.sh",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nmakefile=${1}\n\nadd_bin_path\nwith_go \"${GOLANG_VERSION}\"\nwith_mage\n\nretry 3 make -C \"${makefile}\" build GS_BUCKET_PATH=golang-crossbuild-ci-internal\n\necho \"--- List Docker images\"\ndocker images --format \"table {{.Repository}}:{{.Tag}}\\t{{.Size}}\"\n"
  },
  {
    "path": ".buildkite/scripts/post-release.sh",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nTAG=\"v$1\"\nTAG_EXISTS=$(tag_Exists ${TAG})\n\nset_git_config() {\n    git config user.name \"${GITHUB_USERNAME}\"\n    git config user.email \"${GITHUB_EMAIL}\"\n}\n\ntag_commit() {\n  echo \"Tagging commit ${BUILDKITE_COMMIT}\"\n  git tag -a -m \"${BUILDKITE_COMMIT}\" \"${TAG}\"\n}\n\ngit_push_with_auth() {\n  echo \"Pushing tag ${TAG}\"\n  retry 3 git push https://${GITHUB_USERNAME}:${GITHUB_TOKEN_SECRET}@github.com/elastic/golang-crossbuild.git ${TAG}\n}\n\nif [[ \"${TAG_EXISTS}\" == true ]]; then\n  message=\"Tag '$TAG' already exists! Exiting Post-release stage.\"\n  echo \"$message\"\n  buildkite-agent annotate \"$message\" --style 'warning' --context 'ctx-warn'\n  # This should return any error but skip the release.\n  exit 0\nfi\n\nset_git_config\ntag_commit\ngit_push_with_auth\nbuildkite-agent annotate \"Tag '$TAG' has been created.\" --style 'success' --context 'ctx-success'\n"
  },
  {
    "path": ".buildkite/scripts/publish.sh",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nMAKEFILE=${1}\n\ncheck_is_arm\nadd_bin_path\nretry 3 make -C go -f \"${MAKEFILE}\" push\"${is_arm}\"\n"
  },
  {
    "path": ".buildkite/scripts/validate-go-version.sh",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\ngo_version=$(cat .go-version)\nif grep -q \"VERSION\\s*:=\\s*${go_version}\" go/Makefile.common ; then\n    echo \"Go version ${go_version} is consistent between .go-version and go/Makefile.common\"\n    exit 0\nfi\n\necho \"Go version mismatch detected!\"\necho \"  .go-version: ${go_version}\"\necho \"  go/Makefile.common: $(grep '^VERSION' go/Makefile.common)\"\nexit 1\n"
  },
  {
    "path": ".editorconfig",
    "content": "# See: http://editorconfig.org\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[*.yml]\nindent_style = space\nindent_size = 2\n\n[Dockerfile]\nindent_style = space\nindent_size = 2\n\n[Makefile]\nindent_style = tab\n"
  },
  {
    "path": ".github/CODEOWNERS",
    "content": "* @elastic/elastic-agent-control-plane\n\n# Ownership of CI or related files by the Ingest Eng Prod team\n/.buildkite @elastic/observablt-ci\n/catalog-info.yaml @elastic/observablt-ci\n"
  },
  {
    "path": ".github/actions/bump-golang/action.yml",
    "content": "---\nname: common build tasks\ninputs:\n  branch:\n    description: 'What branch'\n    required: true\n  go-minor:\n    description: 'What Go minor version ([0-9]+.[0.9]+)'\n    required: true\n  command:\n    description: 'What updatecli command'\n    default: 'apply'\n    required: false\n  slack-message:\n    description: 'Slack message if failure'\n    required: false\n    default: \":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @agent-team please look what's going on <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>\"\n  slack-channel-id:\n    description: 'Slack channel ID'\n    required: false\n    default: \"#ingest-notifications\"\n  slack-bot-token:\n    description: 'Specify the slack bot token.'\n    required: true\n  github-token:\n    description: \"The GitHub access token.\"\n    required: true\nruns:\n  using: \"composite\"\n  steps:\n      - uses: actions/checkout@v6\n        with:\n          ref: ${{ inputs.branch }}\n\n      - uses: elastic/oblt-actions/updatecli/run@v1\n        with:\n          command: ${{ env.COMMAND }} --config ./.github/updatecli.d/\n          version-file: .updatecli-version\n        env:\n          COMMAND: ${{ inputs.command }}\n          BRANCH: ${{ inputs.branch }}\n          GO_MINOR: ${{ inputs.go-minor }}\n          GITHUB_TOKEN: ${{ inputs.github-token }}\n\n      - uses: elastic/oblt-actions/slack/send@v1\n        if: failure()\n        with:\n          bot-token: ${{ inputs.slack-bot-token }}\n          channel-id: ${{ inputs.slack-channel-id }}\n          message: ${{ inputs.slack-message }}\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "---\nversion: 2\nupdates:\n\n  # GitHub actions\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n      day: \"sunday\"\n      time: \"22:00\"\n    groups:\n      github-actions:\n        patterns:\n          - \"*\"\n\n  # GitHub composite actions\n  - package-ecosystem: \"github-actions\"\n    directories:\n      - \"/.github/actions/bump-golang\"\n      - \"/.github/workflows\"\n    schedule:\n      interval: \"weekly\"\n      day: \"sunday\"\n      time: \"22:00\"\n    groups:\n      github-actions:\n        patterns:\n          - \"*\""
  },
  {
    "path": ".github/release-drafter.yml",
    "content": "name-template: 'v$RESOLVED_VERSION 🌈'\ntag-template: 'v$RESOLVED_VERSION'\ncategories:\n  - title: '🚀 Features'\n    labels:\n      - 'feature'\n      - 'enhancement'\n  - title: '🐛 Bug Fixes'\n    labels:\n      - 'fix'\n      - 'bug'\n  - title: '📚 Documentation'\n    labels:\n      - 'docs'\n      - 'question'\n  - title: '🧰 Maintenance'\n    label:\n      - 'chore'\n      - 'ci'\nchange-template: '- $TITLE @$AUTHOR (#$NUMBER)'\nchange-title-escapes: '\\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.\nversion-resolver:\n  major:\n    labels:\n      - 'major'\n  minor:\n    labels:\n      - 'minor'\n  patch:\n    labels:\n      - 'patch'\n  default: patch\ntemplate: |\n  ## Go $RESOLVED_VERSION\n\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armel-debian12(-fips)?`    - linux/armv5, linux/armv6\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian9(-fips)?`     - linux/armv7\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian10(-fips)?`    - linux/armv7\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian11(-fips)?`    - linux/armv7\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian12(-fips)?`    - linux/armv7\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf(-fips)?`             - linux/armv7\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian9(-fips)?`  - linux/arm64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian10(-fips)?` - linux/arm64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian11(-fips)?` - linux/arm64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian12(-fips)?` - linux/arm64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian7(-fips)?`\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian9(-fips)?`\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian10(-fips)?`\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian11(-fips)?`\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian12(-fips)?`\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base(-fips)?`\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-arm64-debian10(-fips)?` - darwin/arm64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-arm64-debian11(-fips)?` - darwin/arm64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-arm64-debian12(-fips)?` - darwin/arm64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian9(-fips)?`  - darwin/amd64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian10(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian11(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian12(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin(-fips)?`          - darwin/amd64 (MacOS 10.11, MacOS 10.14)\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian7(-fips)?`    - linux/i386, linux/amd64, windows/amd64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian9(-fips)?`    - linux/i386, linux/amd64, windows/amd64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian10(-fips)?`   - linux/i386, linux/amd64, windows/amd64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian11(-fips)?`   - linux/i386, linux/amd64, windows/amd64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian12(-fips)?`   - linux/i386, linux/amd64, windows/amd64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main(-fips)?`            - linux/i386, linux/amd64, windows/amd64\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-mips-debian12(-fips)?`   - linux/mips64, linux/mips64el\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-ppc-debian12(-fips)?`    - linux/ppc64, linux/ppc64le\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-s390x-debian12(-fips)?`  - linux/s390x\n  - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-windows-arm64-debian12(-fips)?`   - linux/arm64, windows/arm64\n\n  ### Changes\n\n  $CHANGES\n\n  **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION\n"
  },
  {
    "path": ".github/updatecli.d/bump-go-version.sh",
    "content": "#!/usr/bin/env bash\n#\n# Given the Microsoft Golang release version this script will bump the version.\n#\n# This script is executed by the automation we are putting in place\n#\n# NOTE: \n#   * sha256 is retrieved from https://pkg.go.dev/golang.org/x/website/internal/dl?utm_source=godoc\n#   * sha256 is retrieved from https://github.com/microsoft/go/releases/download/v${GO_RELEASE_VERSION}/assets.json\n#   * https://aka.ms/golang/release/latest/go${MAJOR_MINOR_PATCH_VERSION}.assets.json is not used because it does not fail if version is not available\n#\n# Parameters:\n#\t$1 -> the Microsoft Golang release version to be bumped. Mandatory.\n#\nset -euo pipefail\nMSG=\"parameter missing.\"\nGO_RELEASE_VERSION=${1:?$MSG}\nOS=$(uname -s| tr '[:upper:]' '[:lower:]')\nif [ \"${OS}\" == \"darwin\" ] ; then\n\tSED=\"sed -i .bck\"\nelse\n\tSED=\"sed -i\"\nfi\n\n# Process the GO_RELEASE_VERSION to extract major, minor, patch and security versions\nMAJOR_MINOR_PATCH_VERSION=${GO_RELEASE_VERSION%-*}\nSECURITY_VERSION=\"-${GO_RELEASE_VERSION##*-}\"\n\n# Gather golang/go sha256 values\nGOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl/\\?mode\\=json | jq -r \".[] | select( .version | contains(\\\"go${GO_RELEASE_VERSION}\\\")) | .files[] | select (.filename | contains(\\\"go${GO_RELEASE_VERSION}.linux-arm64.tar.gz\\\")) | .sha256\")\nGOLANG_DOWNLOAD_SHA256_AMD=$(curl -s -L https://golang.org/dl/\\?mode\\=json | jq -r \".[] | select( .version | contains(\\\"go${GO_RELEASE_VERSION}\\\")) | .files[] | select (.filename | contains(\\\"go${GO_RELEASE_VERSION}.linux-amd64.tar.gz\\\")) | .sha256\")\n\n# Gather microsoft/go sha256 values\nMSFT_URL=\"https://github.com/microsoft/go/releases/download/v${GO_RELEASE_VERSION}/assets.json\"\nif ! curl --output /dev/null -L --silent --head --fail \"$MSFT_URL\"; then\n  echo \"No Microsoft Golang release found for version ${GO_RELEASE_VERSION}\"\n  exit 1\nfi\n\nMSFT_DOWNLOAD_METADATA=$(curl -s -L \"$MSFT_URL\")\nMSFT_DOWNLOAD_SHA256_ARM=$(echo $MSFT_DOWNLOAD_METADATA | jq -r \".arches[] | select( .env.GOOS == \\\"linux\\\") | select( .env.GOARCH == \\\"arm64\\\") | .sha256\")\nMSFT_DOWNLOAD_SHA256_AMD=$(echo $MSFT_DOWNLOAD_METADATA | jq -r \".arches[] | select( .env.GOOS == \\\"linux\\\") | select( .env.GOARCH == \\\"amd64\\\") | .sha256\")\n\n## As long as https://golang.org/dl/?mode=json supports only 2 major versions\n## and there is a new major release, then it's required to parse https://golang.org/dl\n## see https://github.com/elastic/golang-crossbuild/pull/389/commits/d0af04f97a2381630ea5e8da5a99f50cf27856a0\nif [ -z \"$GOLANG_DOWNLOAD_SHA256_ARM\" ] ; then\n    GOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl | grep \"go${MAJOR_MINOR_PATCH_VERSION}.linux-arm64.tar.gz\" -A 5 | grep \"<tt>\" | sed 's#.*<tt>##g' | sed 's#</t.*##g')\nfi\n\nif [ -z \"$GOLANG_DOWNLOAD_SHA256_AMD\" ] ; then\n    GOLANG_DOWNLOAD_SHA256_AMD=$(curl -s -L https://golang.org/dl | grep \"go${MAJOR_MINOR_PATCH_VERSION}.linux-amd64.tar.gz\" -A 5 | grep \"<tt>\" | sed 's#.*<tt>##g' | sed 's#</t.*##g')\nfi\n\nfind \"go\" -type f -name Dockerfile.tmpl -print0 |\n    while IFS= read -r -d '' line; do\n        if echo \"$line\" | grep -q 'arm' ; then\n            ${SED} -E -e \"s#(ARG GOLANG_DOWNLOAD_SHA256)=.+#\\1=${GOLANG_DOWNLOAD_SHA256_ARM}#g\" \"$line\"\n            if [ -n \"$MSFT_DOWNLOAD_SHA256_ARM\" ]; then\n                ${SED} -E -e \"s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\\1=${MSFT_DOWNLOAD_SHA256_ARM}#g\" \"$line\"\n            fi\n        else\n            ${SED} -E -e \"s#(ARG GOLANG_DOWNLOAD_SHA256)=.+#\\1=${GOLANG_DOWNLOAD_SHA256_AMD}#g\" \"$line\"\n            if [ -n \"$MSFT_DOWNLOAD_SHA256_AMD\" ]; then\n                ${SED} -E -e \"s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\\1=${MSFT_DOWNLOAD_SHA256_AMD}#g\" \"$line\"\n            fi\n        fi\n        if [ -n \"$SECURITY_VERSION\" ]; then\n            ${SED} -E -e \"s#(ARG SECURITY_VERSION)=.*#\\1=${SECURITY_VERSION}#g\" \"$line\"\n        fi\n        ${SED} -E -e \"s#(ARG VERSION)=.+#\\1=${MAJOR_MINOR_PATCH_VERSION}#g\" \"$line\"\n    done\n\nif git diff --quiet ; then\n    # No modifications – exit successfully but keep stdout empty to that updatecli is happy\n    exit 0\nelse\n    echo \"Update Go version ${GO_RELEASE_VERSION}\"\n    git --no-pager diff\nfi"
  },
  {
    "path": ".github/updatecli.d/bump-golang.yml",
    "content": "---\nname: Bump golang-version to latest version\npipelineid: 'bump-golang-version-{{ requiredEnv \"BRANCH\" }}'\n\nscms:\n  githubConfig:\n    kind: github\n    spec:\n      user: '{{ requiredEnv \"GITHUB_ACTOR\" }}'\n      username: '{{ requiredEnv \"GITHUB_ACTOR\" }}'\n      owner: elastic\n      repository: golang-crossbuild\n      token: '{{ requiredEnv \"GITHUB_TOKEN\" }}'\n      branch: '{{ requiredEnv \"BRANCH\" }}'\n      commitusingapi: true\n\nactions:\n  default:\n    title: '[Automation] Bump Golang version to {{ source \"latestMicrosoftGoVersion\" }}'\n    kind: github/pullrequest\n    scmid: githubConfig\n    spec:\n      automerge: false\n      labels:\n        - automation\n        - dependencies\n        - backport-skip\n      description: |\n        See [changelog](https://github.com/golang/go/issues?q=milestone%3AGo{{ source \"golangVersion\" }}+label%3ACherryPickApproved) for {{ source \"golangVersion\" }}\n\nsources:\n  minor:\n    name: Get minor version\n    kind: shell\n    transformers:\n      - findsubmatch:\n          pattern: '^\\d+.(\\d+)'\n          captureindex: 1\n    spec:\n      command: echo {{ requiredEnv \"GO_MINOR\" }}\n\n  latestMicrosoftGoVersion:\n    name: Get Latest Microsoft Go Release\n    kind: githubrelease\n    dependson:\n      - minor\n    transformers:\n      - trimprefix: v\n    spec:\n      owner: microsoft\n      repository: go\n      token: '{{ requiredEnv \"GITHUB_TOKEN\" }}'\n      username: '{{ requiredEnv \"GITHUB_ACTOR\" }}'\n      versionfilter:\n        kind: regex\n        pattern: v1\\.{{ source \"minor\" }}\\.(\\d*)(-\\d*)$\n\n  golangVersion:\n    # NOTE: FIPS images need the Microsoft version.\n    name: Get the Microsoft version of Golang, as it comes out a little later\n    dependson:\n      - latestMicrosoftGoVersion\n    kind: shell\n    transformers:\n      - findsubmatch:\n          pattern: '^(\\d+.\\d+.\\d+)-(\\d+)'\n          captureindex: 1\n    spec:\n      command: echo {{ source \"latestMicrosoftGoVersion\" }}\n\nconditions:\n  dockerTag:\n    name: Is docker image golang:{{ source \"golangVersion\" }} published\n    kind: dockerimage\n    spec:\n      image: golang\n      tag: '{{ source \"golangVersion\" }}'\n    sourceid: golangVersion\n  is:\n    name: Is version '{{ source \"golangVersion\" }}' not updated in 'go/Makefile.common'?\n    disablesourceinput: true\n    scmid: githubConfig\n    kind: file\n    spec:\n      file: go/Makefile.common\n      line: 5\n      content: VERSION        := {{ source `golangVersion` }}\n    failwhen: true\n\ntargets:\n  update-go-version:\n    name: \"Update .go-version\"\n    sourceid: golangVersion\n    scmid: githubConfig\n    kind: file\n    spec:\n      content: '{{ source \"golangVersion\" }}'\n      file: .go-version\n      matchpattern: '\\d+.\\d+.\\d+'\n  update-go-makefile.common:\n    name: \"Update go/Makefile.common\"\n    sourceid: golangVersion\n    scmid: githubConfig\n    kind: file\n    spec:\n      content: '{{ source \"golangVersion\" }}'\n      file: go/Makefile.common\n      matchpattern: '\\d+.\\d+.\\d+'\n  update-go-versions:\n    name: 'Update go version {{ source \"latestMicrosoftGoVersion\" }}'\n    kind: shell\n    sourceid: latestMicrosoftGoVersion\n    scmid: githubConfig\n    spec:\n      command: .github/updatecli.d/bump-go-version.sh\n      environments:\n        - name: PATH\n"
  },
  {
    "path": ".github/workflows/bump-golang-previous.yml",
    "content": "---\nname: bump-golang-previous\n\non:\n  workflow_dispatch:\n  schedule:\n    - cron: '0 4 * * 1-6'\n\npermissions:\n  contents: read\n\njobs:\n  bump:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: write\n      pull-requests: write\n    steps:\n      - uses: actions/checkout@v6\n      - uses: ./.github/actions/bump-golang\n        with:\n          # NOTE: when a new golang version please update me with 1.<go-version-1>\n          branch: '1.25'\n          # NOTE: when a new golang version please update me with 1.<go-version-1>\n          go-minor: '1.25'\n          command: '--experimental apply'\n          slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/bump-golang.yml",
    "content": "---\nname: bump-golang-main\n\non:\n  workflow_dispatch:\n  schedule:\n    - cron: '0 3 * * 1-6'\n\npermissions:\n  contents: read\n\njobs:\n  bump:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: write\n      pull-requests: write\n    steps:\n      - uses: actions/checkout@v6\n      - uses: ./.github/actions/bump-golang\n        with:\n          branch: 'main'\n          # NOTE: when a new golang version please update me with 1.<go-version>\n          go-minor: '1.26'\n          command: '--experimental apply'\n          slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/catalog-info.yml",
    "content": "---\nname: catalog-info\n\non:\n  pull_request:\n    branches:\n      - main\n    paths:\n      - 'catalog-info.yaml'\n\npermissions:\n  contents: read\n\njobs:\n  validate:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      packages: read\n    steps:\n      - uses: actions/checkout@v6\n\n      - uses: elastic/oblt-actions/elastic/validate-catalog@v1\n\n"
  },
  {
    "path": ".github/workflows/release-drafter.yml",
    "content": "name: Release Drafter\n\non:\n  push:\n    tags:\n      - v*.*\n\npermissions:\n  contents: read\n\njobs:\n  update_release_draft:\n    permissions:\n      # write permission is required to create a github release\n      contents: write\n      # write permission is required for autolabeler\n      # otherwise, read permission is required at least\n      pull-requests: write\n    runs-on: ubuntu-latest\n    steps:\n      - name: version\n        id: version\n        run: |\n          tag=${GITHUB_REF/refs\\/tags\\//}\n          version=${tag#v}\n          echo \"::set-output name=version::${version}\"\n      - uses: release-drafter/release-drafter@v7\n        with:\n          version: ${{ steps.version.outputs.version }}\n          publish: true\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".gitignore",
    "content": "*.iml\n*.swp\n*.o\n.idea\n.vagrant\n.vscode\n_obj\nDockerfile\n.status.*\n*.bck\nnpcap/lib/*.exe\n\n"
  },
  {
    "path": ".go-version",
    "content": "1.26.2"
  },
  {
    "path": ".mergify.yml",
    "content": "queue_rules:\n  - name: default\n    merge_method: squash\n    conditions:\n      - check-success=buildkite/golang-crossbuild\n      - check-success=CLA\npull_request_rules:\n  - name: automatic approval for automated pull requests with golang bump updates\n    conditions:\n      - check-success=buildkite/golang-crossbuild\n      - label=automation\n      - files~=^go/Makefile.common\n    actions:\n      review:\n        type: APPROVE\n        message: Automatically approving mergify\n  - name: ask to resolve conflict\n    conditions:\n      - -merged\n      - -closed\n      - conflict\n    actions:\n        comment:\n          message: |\n            This pull request is now in conflicts. Could you fix it? 🙏\n            To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/\n            ```\n            git fetch upstream\n            git checkout -b {{head}} upstream/{{head}}\n            git merge upstream/{{base}}\n            git push upstream {{head}}\n            ```\n  - name: close automated pull requests with bump updates if any conflict\n    conditions:\n      - -merged\n      - -closed\n      - conflict\n      - label=automation\n    actions:\n      close:\n        message: |\n          This pull request has been automatically closed by Mergify.\n          There are some other up-to-date pull requests.\n  - name: squash and merge updatecli PRs after CI passes with golang bump updates\n    conditions:\n      - label=automation\n      - head~=^updatecli\n      - -conflict\n      - files~=^go/Makefile.common\n    actions:\n      queue:\n        name: default\n  - name: notify the backport has not been merged yet\n    conditions:\n      - -merged\n      - -closed\n      - author=mergify[bot]\n      - \"#check-success>0\"\n      - schedule=Mon-Mon 06:00-10:00[Europe/Paris]\n    actions:\n      comment:\n        message: |\n          This pull request has not been merged yet. Could you please review and merge it @{{ assignee | join(', @') }}? 🙏\n  - name: notify the backport policy\n    conditions:\n      - -label~=^backport\n      - base=main\n      - -merged\n      - -closed\n    actions:\n      comment:\n        message: |\n          This pull request does not have a backport label. Could you fix it @{{author}}? 🙏\n          To fixup this pull request, you need to add the backport labels for the needed\n          branches, such as:\n          * `backport-v./d./d` is the label to automatically backport to the `1./d` branch. `/d` is the digit\n          **NOTE**: `backport-skip` has been added to this pull request.\n      label:\n        add:\n          - backport-skip\n  - name: remove-backport label\n    conditions:\n      - label~=backport-v\n      - -merged\n      - -closed\n    actions:\n      label:\n        remove:\n          - backport-skip\n  - name: backport patches to 1.16 branch\n    conditions:\n      - merged\n      - label=backport-v1.16\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.16\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.17 branch\n    conditions:\n      - merged\n      - label=backport-v1.17\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.17\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.18 branch\n    conditions:\n      - merged\n      - label=backport-v1.18\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.18\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.19 branch\n    conditions:\n      - merged\n      - label=backport-v1.19\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.19\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.20 branch\n    conditions:\n      - merged\n      - label=backport-v1.20\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.20\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.21 branch\n    conditions:\n      - merged\n      - label=backport-v1.21\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.21\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.22 branch\n    conditions:\n      - merged\n      - label=backport-v1.22\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.22\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.23 branch\n    conditions:\n      - merged\n      - label=backport-v1.23\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.23\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.24 branch\n    conditions:\n      - merged\n      - label=backport-v1.24\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.24\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n  - name: backport patches to 1.25 branch\n    conditions:\n      - merged\n      - label=backport-v1.25\n    actions:\n      backport:\n        assignees:\n          - \"{{ author }}\"\n        branches:\n          - \"1.25\"\n        labels:\n          - \"backport\"\n        title: \"[{{ destination_branch }}](backport #{{ number }}) {{ title }}\"\n"
  },
  {
    "path": ".updatecli-version",
    "content": "v0.109.0"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "Makefile",
    "content": "include Makefile.common\n\nTARGETS=go\nARM_TARGETS=go\n\n\nbuild: status=\".status.build\"\nbuild:\n\t@echo '0' > ${status}\n\t@$(foreach var,$(TARGETS), \\\n\t\t$(MAKE) -C $(var) $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian7 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian8 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian10 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian11 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian12 $@ || echo '1' > ${status})\n\t@make -C fpm $@ || echo '1' > ${status}\n\texit $$(cat ${status})\n\nbuild-arm: status=\".status.build.arm\"\nbuild-arm:\n\techo '0' > ${status}\n\t$(foreach var,$(ARM_TARGETS), \\\n\t\t$(MAKE) -C $(var) $@ || echo '1' > ${status};\\\n\t\t$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status})\n\tmake -C fpm $@ || echo '1' > ${status}\n\texit $$(cat ${status})\n\n# Requires login at https://docker.elastic.co:7000/.\npush: status=\".status.push\"\npush:\n\t@echo '0' > ${status}\n\t@$(foreach var,$(TARGETS), \\\n\t\t$(MAKE) -C $(var) $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian7 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian8 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian10 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian11 $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian12 $@ || echo '1' > ${status})\n\t@make -C fpm $@ || echo '1' > ${status}\n\texit $$(cat ${status})\n\npush-arm: status=\".status.push.arm\"\npush-arm:\n\t@echo '0' > ${status}\n\t@$(foreach var,$(ARM_TARGETS), \\\n\t\t$(MAKE) -C $(var) $@ || echo '1' > ${status}; \\\n\t\t$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status})\n\t@make -C fpm $@ || echo '1' > ${status}\n\texit $$(cat ${status})\n\n.PHONY: build build-arm push push-arm\n"
  },
  {
    "path": "Makefile.common",
    "content": "REPOSITORY    ?= docker.elastic.co/beats-dev\nVCS_REF       := $(shell git rev-parse HEAD)\nVCS_URL       := https://github.com/elastic/golang-crossbuild\nBUILD_DATE    := $(shell date -u +\"%Y-%m-%dT%H:%M:%SZ\")\n.DEFAULT_GOAL := build\nNPCAP_VERSION := 1.87\nNPCAP_FILE    := npcap-$(NPCAP_VERSION)-oem.exe\nSUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION)\nNPCAP_REPOSITORY := docker.elastic.co/observability-ci\nGS_BUCKET_PATH ?= golang-crossbuild-ci-internal\n\n# Requires login at google storage.\ncopy-npcap:\nifeq ($(CI),true)\n\t@gcloud storage cp gs://$(GS_BUCKET_PATH)/private/$(NPCAP_FILE) ../npcap/lib/$(NPCAP_FILE)\nelse\n\t@echo 'Only available if running in the CI'\nendif\n\n# Requires login at google storage.\ncopy-sdks:\nifeq ($(CI),true)\n\t@gcloud storage cp gs://$(GS_BUCKET_PATH)/sdks . --recursive\nelse\n\t@echo 'Only available if running in the CI'\nendif\n\npush:\n\t$(MAKE) atomic-push\n\npush-arm:\n\t@echo \">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\"\n\t@docker push \"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\"\n\n.PHONY: push push-arm\n\n# Requires login at https://docker.elastic.co:7000/.\natomic-push:\n\t@echo \">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\"\n\t@docker push \"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\"\n"
  },
  {
    "path": "NPCAP.md",
    "content": "# NPCAP\n\nIf you'd like to bump the npcap version please follow the below steps:\n\n1) Update `NPCAP_VERSION` value in the `Makefile`.\n  * **NOTE**: Make sure the PR adding this is back-ported to the Go versions required by the Packetbeat CrossBuild target in [the mage file](https://github.com/elastic/beats/blob/main/x-pack/packetbeat/magefile.go). This is specified in the beats `.go-version` file.\n2) Download the new artifact.\n3) Upload the artifact to `gs://golang-crossbuild-ci-internal/private`.\n  * **NOTE**: This particular Google Bucket can be accessible only by Elasticians who have got access to the Google project called `elastic-observability-ci`. It's managed thorugh some Terraform code.\n\nCredentials to the artifact service can be found in the `APM-Shared` folder in the password management tool.\n\n4) After you've updated the npcap version in golang-crossbuild, make sure to change the npcap version specified in the [packetbeat magefile](https://github.com/elastic/beats/blob/main/x-pack/packetbeat/magefile.go)\n\n## Backports\n\nIf you'd like to backport any NCAP_VERSION to any existing golang-crosbuild version, then you need to:\n\n* Create a branch called `major.minor.patch.x` for the `vmajor.minor.patch` tag (where `x` is a literal \"x\" character, not a number placeholder)\n* Cherry-pick your PR, you can use `Mergifyio`, with `@mergifyio backport major.minor.path.x`\n* Then the new PR that has been created can be merged when all the GitHub checks have passed.\n\nFor instance, if ncap version needs to be updated in `1.20.8` then:\n\n```bash\ngit checkout v1.20.8\ngit checkout -b 1.20.8.x\ngit push upstream 1.20.8.x\n```\n\nAfterwards you can then backport your PR with ncap changes with the GitHub command `@Mergifyio backport 1.20.8.x`,\nsee https://github.com/elastic/golang-crossbuild/pull/315 that illustrates this example.\n\nhttps://github.com/elastic/golang-crossbuild/pull/320 is the one that has been created with the backport targeting\n`1.20.8.x`. Automatically when it gets merged, the golang-crossbuild:1.20.8 will be regenerated and contain the\nnew ncap changes.\n"
  },
  {
    "path": "README.md",
    "content": "|                   | main | 1.25 |\n|-------------------|------|-|\n| golang-crossbuild |[![Build status](https://badge.buildkite.com/a62e956ff483d20043847488a8797382db305653ea9fac86b2.svg?branch=main)](https://buildkite.com/elastic/golang-crossbuild/builds?branch=main)|[![Build status](https://badge.buildkite.com/a62e956ff483d20043847488a8797382db305653ea9fac86b2.svg?branch=1.25)](https://buildkite.com/elastic/golang-crossbuild/builds?branch=1.25)|\n| llvm-apple        |[![Build status](https://badge.buildkite.com/608fe26d86b5da77dad646eec77944c306e5ad3a427c88dcf5.svg?branch=main)](https://buildkite.com/elastic/llvm-apple/builds?branch=main)|[![Build status](https://badge.buildkite.com/608fe26d86b5da77dad646eec77944c306e5ad3a427c88dcf5.svg?branch=1.25)](https://buildkite.com/elastic/llvm-apple/builds?branch=1.25)|\n| fpm               |[![Build status](https://badge.buildkite.com/86216c62729e32e235059e42d58bfb54901c20bf3394c704f3.svg?branch=main)](https://buildkite.com/elastic/fpm/builds?branch=main)|[![Build status](https://badge.buildkite.com/86216c62729e32e235059e42d58bfb54901c20bf3394c704f3.svg?branch=1.25)](https://buildkite.com/elastic/fpm/builds?branch=1.25)|\n\n\n# golang-crossbuild Docker images\n\nThis repository contains Dockerfiles for cross building Go binaries for various platforms.\nThe aim is to provide a simple way to build Go binaries for multiple platforms without having to install and configure cross compilers on your host machine.\nTo do that the project provides a set of Docker images that can be used to build Go binaries for the following platforms:\n\n* linux/amd64\n* linux/arm\n* linux/armel\n* linux/armhf\n* linux/arm64\n* linux/mips\n* linux/mipsle\n* linux/mips64\n* linux/ppc64\n* linux/ppc64le\n* linux/s390x\n* windows/amd64\n* darwin/amd64\n* darwin/arm64\n\nThe Docker images are based on Debian and the cross compilers are installed using the crossbuild-essential package.\nEach architecture has its own folder with the files needed to build the Docker image for that architecture.\nEach architecture has its own Dockerfile to build a Docker image for that architecture.\nEach architecture Dockerfile installs the crossbuild-essential package for that architecture and the libraries needed to build our binaries.\nThese Dockerfiles are generated files from `Dockerfile.tmpl` template file that is in the architectures folder.\nThis template is processed using a Makefile that is in the architectures folder.\nEach architecture folder has a `roofs` folder that contains the files that will be copied to the Docker image in the root folder.\nIn `rootfs` we have the `compolers.yml` file that contains the list of compilers that will be installed in the Docker image.\nEach Docker image has a basic compilation test that is executed when the image is built. This test uses `rootfs/helloworld.c` file to compile a simple C program and verify the architecture of the result binary.\nThe compiler used to build the binaries is LLVM.\nSome of the Docker images are build for the amd64 and arm64 architectures, this allow to run the Docker images in linux/amd64, linux/arm64, darwin/amd64, and darwin/arm64. This is done using the `.buildkite/scripts/buildx.sh` command.\n\nThe Docker images are tagged using the following format:\n\n* `docker.elastic.co/beats-dev/golang-crossbuild:<go-version>-<arch>-<debian-version>`\n\nFor the latest version of the images based on the latest Debian and Go versions, the following tag is also used:\n\n* `docker.elastic.co/beats-dev/golang-crossbuild:<go-version>-<arch>`\n\n## Build tags\n\nThe tags match with the Golang version, and for each supported version there is a release in https://github.com/elastic/golang-crossbuild/releases.\n\nReplace `<GOLANG_VERSION>` with the version you would like to use, for instance: `1.17.1`\n\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-arm` - linux/arm64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-armel` - linux/armv5, linux/armv6\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-armhf` - linux/armv7\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-base`\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-darwin` - darwin/amd64 (MacOS 10.11, MacOS 10.14)\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main` - linux/i386, linux/amd64, windows/amd64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian7` - linux/i386, linux/amd64, windows/amd64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian8` - linux/i386, linux/amd64, windows/amd64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian9` - linux/i386, linux/amd64, windows/amd64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian10` - linux/i386, linux/amd64, windows/amd64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian11` - linux/i386, linux/amd64, windows/amd64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian12` - linux/i386, linux/amd64, windows/amd64\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-mips-debian11` - linux/mips64, linux/mips64el\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-mips-debian12` - linux/mips64, linux/mips64el\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-mips32` - linux/mips, linux/mipsle **NOTE**: it does not exist from Golang versions > `1.18.5`/`1.17.12`.\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-ppc-debian12` - linux/ppc64, linux/ppc64le\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-s390x-debian11` - linux/s390x\n- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-s390x-debian12` - linux/s390x\n\n### glibc\n\n* **Debian7** uses `glibc 2.13` so the resulting binaries (if dynamically linked) have greater compatibility.\n* **Debian8** uses `glibc 2.19`.\n* **Debian9** uses `glibc 2.24`.\n* **Debian10** uses `glibc 2.28`.\n* **Debian11** uses `glibc 2.31`.\n\n## Old Build Tags\n\nUntil Golang version 1.15\n\n| Description | Tags for 1.10 | Tags for 1.11 | Tags for 1.12 | Tags for 1.13 | Tags for 1.14 | Tags for 1.15 |\n| ------------- | -----| ------- | ----- |  ------ |  ------ |  ------ |\n| linux/{amd64,386} and windows/{amd64,386} | `1.10.8-main` | `1.11.13-main` | `1.12.12-main` |  `1.13.12-main` | `1.14.15-main` | `1.15.14-main` |\n| linux/{armv5,armv6,armv7} | `1.10.8-arm` | `1.11.13-arm` | `1.12.12-arm` | `1.13.12-arm` | `1.14.15-arm` | `1.15.14-arm` |\n| linux/arm64 | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |\n| linux/{armv5,armv6} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |\n| linux/{armv7} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |\n| darwin/{386} | `1.10.8-darwin` | `1.11.13-darwin` | `1.12.12-darwin` | `1.13.12-darwin` | `1.14.15-darwin` | `1.15.14-darwin` |\n| darwin/{amd64} | `1.10.8-darwin` | `1.11.13-darwin` | `1.12.12-darwin` | `1.13.12-darwin` | `1.14.15-darwin` | `1.15.14-darwin` |\n| linux/{ppc64,ppc64le} | `1.10.8-ppc` | `1.11.13-ppc` | `1.12.12-ppc` | `1.13.12-ppc` | `1.14.15-ppc` | `1.15.14-ppc` |\n| linux/{mips,mipsle,mips64,mips64le} | `1.10.8-mips` | `1.11.13-mips` | `1.12.12-mips` | `1.13.12-mips` | `1.14.15-mips` |\n| linux/{mips64,mips64le} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |\n| linux/{mips,mipsle} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |\n| linux/s390x | `1.10.8-s390x` | `1.11.13-s390x` | `1.12.12-s390` | `1.13.12-s390` | `1.14.15-s390` | `1.15.14-s390` |\n| linux/{amd64,386} and windows/{amd64,386} (Debian 7 (see **below**)) |`1.10.8-main-debian7` | `1.11.13-main-debian7` | `1.12.12-main-debian7` | `1.13.12-main-debian7` | `1.14.15-main-debian7` | `1.15.14-main-debian7` |\n| linux/{amd64,386} and windows/{amd64,386} (Debian 8 (see **below**)) | `1.10.8-main-debian8` | `1.11.13-main-debian8` | `1.12.12-main-debian8` | `1.13.12-debian8` | `1.14.15-main-debian8` | `1.15.14-main-debian8` |\n| linux/{amd64,386} and windows/{amd64,386} (Debian 9 (see **below**)) | NA | NA | NA | NA | NA | `1.15.14-main-debian9` |\n| linux/{amd64,386} and windows/{amd64,386} (Debian 10 (see **below**)) | NA | NA | NA | NA | NA | `1.15.14-main-debian10` |\n| linux/arm64 (Debian 9 (see **below**)) | NA | NA | NA | NA | NA | `1.15.14-base-arm-debian9` |\n\n### glibc\n\n* **Debian7** uses `glibc 2.13` so the resulting binaries (if dynamically linked) have greater compatibility.\n* **Debian8** uses `glibc 2.19`.\n* **Debian9** uses `glibc 2.24`.\n* **Debian10** uses `glibc 2.28`.\n\n## Makefiles\n\nThere are several Makefiles in the profect across the different folders.\nThe Makefile in the root folder is used to build the Docker images for the different architectures,\nit triggers the build of all Docker images for all architectures and Debian versions supported.\n\nThe file `go/Makefile.common` is the default Makefile used to build the Docker images for the different architectures.\nThere is additional Makefile for each Debian version that is used to build the Docker images for that Debian version.\n\n* `go/Makefile.debian7`\n* `go/Makefile.debian8`\n* `go/Makefile.debian9`\n* `go/Makefile.debian10`\n* `go/Makefile.debian11`\n\nNo all architectures are supported in all Debian versions, so the Makefile for each Debian version will only build the Docker images for the architectures that are supported in that Debian version.\n\nOn the Makefiles there are some variables to define the name of the Docker image, the version of the Docker image, the Debian version, and the suffix to use in the tag of the Docker image.\n\n```make\nNAME           := golang-crossbuild\nVERSION        := 1.20.2\nDEBIAN_VERSION ?= 9\nSUFFIX         := -$(shell basename $(CURDIR))\nTAG_EXTENSION  ?=\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nDOCKER_CMD := docker build\n```\n\nIn this example the name of the Docker image is `golang-crossbuild`, the go version is `1.20.2` that is uses as part of the tag, the Debian version is `9`, the suffix is `-debian9`, and the tag extension is empty. Also the `DOCKER_CMD` variable is used to define the command to use to build the Docker image, in this case `docker build`.\n\nThe tag is build using the following format:\n\n```make\nTAG := $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\n```\n\nThe common variables to all the Makefiles are defined at `Makefile.common` file.\n\nTo more information about the supported architextures and the correlation with comercial names,\nyou can check the [Debian Supported Architectures](https://wiki.debian.org/SupportedArchitectures) page.\n\nTo make and push the Docker images for all the architectures and default Debian version, you can run the following command:\n\n```shell\nmake build push\n```\n\nTo make and push the Docker images for all the architectures and Debian 10, you can run the following command:\n\n```shell\nmake -C go -f Makefile.debian10 build push\n```\n\nFinally, to build a single Docker image for `arm` architecture and Debian 10, you can run the following command:\n\n```shell\nmake -C go -f Makefile.debian10 build push IMAGES=arm\n```\n\n## Multiarch Docker images\n\nSome of the Docker images are built for the amd64 and arm64 architectures, this allow to run the Docker images in linux/amd64, linux/arm64, darwin/amd64, and darwin/arm64. This is done using the `.buildkite/scripts/buildx.sh` command.\nTo choose if build a Docker image for amd64 and arm64 or only for amd64, The Makefiles check fot the value o `BUILDX` and `DOCKER_MULTIARCH` variables. In the target Makefile the `DOCKER_COMMAND` is replaced with the `.buildkite/scripts/buildx.sh` command.\n\n```make\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\nendif\n```\n\n## Docker images dependencies\n\nThe Docker images depends on each other, so there is an order to build them.\nThe are two Docker images that are parent of all the other images, the `fpm` and the `go/llvm-apple`.\nAnytime a new Debian version is released, the `fpm` and `go/llvm-apple` image needs to be updated to use the new Debian version.\nThe following diagram shows the dependencies between the Docker images.\n\n```mermaid\nstateDiagram-v2\n    [*] --> Debian\n    Debian --> fpm\n    Debian --> base\n    Debian --> base_arm\n    Debian --> llvm_apple\n    llvm_apple --> darwing_arm64\n    base --> arm\n    base --> armel\n    base --> armhf\n    base --> main\n    base --> darwin\n    base --> darwing_arm64\n    base --> mips\n    base --> mips32\n    base --> npcap\n    base --> ppc\n    base --> s390x\n```\n\n## Releasing\n\nSee [RELEASE.md](RELEASE.md) for the release process.\n\n## FIPS Build\n\n[Makefile.common](./go/Makefile.common) has an env var that can be used to create a FIPS compliant golang-crossbuild image:\n```make\nFIPS           ?=\n```\n\nWhen this var is set to `\"true\"` the [microsoft/go](https://github.com/microsoft/go) will be used instead of the regular upstream go release.\nAdditionally the docker image will have the env vars `CGO_ENABLED=1` and `GOEXPERIMENT=systemcrypto` set to ensure binaries built within the crossbuild image are FIPS compliant by default.\n\n## Packaging MacOS SDK\n\nThe osxcross repository used to cross compile for MacOSX has [instructions for packaging the SDK](https://github.com/tpoechtrager/osxcross#packaging-the-sdk).\n\nThe instructions for packaging the SDK on a Linux instance are:\n\n1. Clone the [osxcross](https://github.com/tpoechtrager/osxcross) repo.\n1. Install `clang`, `make`, `libssl-dev`, `lzma-dev`, `libxml2-dev`, `libbz2-dev`.\n1. Download [Xcode from Apple](Download Xcode: https://developer.apple.com/download/more]).\n1. Run `./tools/gen_sdk_package_pbzx.sh <xcode>.xip`.\n\n## Usage Example\n\n```shell\ndocker run -it --rm \\\n  -v $GOPATH/src/github.com/user/go-project:/go/src/github.com/user/go-project \\\n  -w /go/src/github.com/user/go-project \\\n  -e CGO_ENABLED=1 \\\n  docker.elastic.co/beats-dev/golang-crossbuild:1.16.7-armhf \\\n  --build-cmd \"make build\" \\\n  -p \"linux/armv7\"\n```\n\nThis will execute your projects `make build` target. While executing the build\ncommand the following variables with be added to the environment: GOOS, GOARCH,\nGOARM, PLATFORM_ID, CC, and CXX.\n\n## fpm Docker image\n\nThis Docker image install the [fpm](https://github.com/jordansissel/fpm) tool that is used to build packages.\n\n## go/llvm-apple Docker image\n\nThe LLVM compiler present in Debian does not support arm64e architecture, so we need to build our own LLVM compiler to support this architecture.\nThe llvm-apple Docker image is based on [Apple LLVM fork](https://github.com/apple/llvm-project) and [osxcross](https://codeload.github.com/tpoechtrager/osxcross). The image build the LLVM compiler and configure the image to be able to cross compile for MacOSX.\n\nLLVM need a SDK for macOS, the MacOSX-SDK used in the Docker image must be genarated from a MacOSX machine.\nFor the instructions to package the MacOS SDK see the [Packaging MacOS SDK](#packaging-macos-sdk) section.\n\n## go/base Docker image\n\nThis Docker image is the base image for all the other Docker images, it contains the base packages fro cross compilation.\nIt is build for amd64 and arm64 architectures for Debian 9+.\nIn the folder you can find the `sources.list` file that contains the list of repositories to use to install the packages,\nthis file is different for each Debian version. In some cases, this file must point to `http://archive.debian.org/debian` instead of `http://deb.debian.org/debian` to be able to install the packages, this happens when the Debian version reach the end of life.\n\nThe base image is the one that install the `go` compiler, and the build tools for the rest of Docker images.\nWhen a new version of go is released, the *Dockerimage.tmpl* files must be updated to install the new version.\n\n## go/base-arm Docker image\n\nThe `base-arm` image is the base image to crossbuild `linux/arm64` binaries on `arm` hosts, it is build for Debian 7+.\nThis image is user to crosscompile in `linux/arm`.\nIt was replaced by the `base` image for Debian 9+ when we started to build multiarchitecture Docker images.\nIt could be removed in the future, it allow to `crosscompile` arm binaries in `linux/arm64` machines, that it is not needed because the native architecture is the same than the target architecture.\nIt was added to golang-crossbuild due limitations of the build system.\n\n## go/main Docker image\n\nThe `main` image is the base image for the `amd64` architecture, it is build for Debian 7+.\nIt is used to cross compile for `linux/amd`, `linux/amd64`, `win/amd`, and `win/amd64`.\nThis Docker immage add two libraries to the `base` image, `libpcap` and `WpdPack` to be able to capture network packages on diferent OS.\nThes two libraries are precompiled and stored at https://storage.googleapis.com/golang-crossbuild-ci-internal/sdks.\n\n## go/darwin Docker image\n\nThe `darwin` image is the base image for the MacOSX cross compilation, it is build for Debian 8+.\nIt can compiles for `darwin/amd` (Debian 10+), `darwin/amd64`, `darwin/arm64`, `darwin/arm64e`, and universal binaries.\nThis Docker image is based on the `base` image.\nIt uses [osxcross](https://codeload.github.com/tpoechtrager/osxcross) to configure the crosscompile for MacOSX.\nThis image require a MacOSX SDK to be installed in the Docker image,\nfor the instructions to package the MacOS SDK see the [Packaging MacOS SDK](#packaging-macos-sdk) section.\n\n## go/darwin-arm64 Docker image\n\nThe `darwin-arm64` image is the base image for the MacOSX cross compilation, it is build for Debian 10+.\nIt can compiles for `darwin/amd64`, `darwin/arm64`, and `darwin/arm64e`, and universal binaries.\nThis Docker image is based on the `base` image.\nIt uses the `llvm-apple` image to cross compile for MacOSX.\nThe `darwin-arm64` can replace the `darwin` image in the future, it is faster to build and it does not need to build [osxcross](https://codeload.github.com/tpoechtrager/osxcross) and uses the official LLVM fork from Apple so it support enhacement for `darwin` architectures.\n\n## go/arm Docker image\n\nThe `arm` image is the base image for the `arm64` architecture, it is build for Debian 9+.\nIt is used to cross compile for `linux/arm64`. This Docker image is based on the `base` image.\n\n## go/armel Docker image\n\nThe `armel` image is the base image for the `armel` architecture, it is build for Debian 12+.\nIt is used to cross compile for `linux/armel`. This Docker image is based on the `base` image.\n\n## go/armhf Docker image\n\nThe `armhf` image is the base image for the `armhf` architecture, it is build for Debian 9+.\nIt is used to cross compile for `linux/armhf`. This Docker image is based on the `base` image.\n\n## go/mips Docker image\n\nThe `mips` image is the base image for the `mips` architecture, it is build for Debian 12+.\nIt is used to cross compile for `linux/mips`. This Docker image is based on the `base` image.\n\n## go/mips32 Docker image\n\nThe `mips32` image is the base image for the `mips32` architecture, it is build for Debian 11+.\nIt is used to cross compile for `linux/mips32`. This Docker image is based on the `base` image.\n\n## go/ppc Docker image\n\nThe `ppc` image is the base image for the `ppc` architecture, it is build for Debian 12+.\nIt is used to cross compile for `linux/ppc`. This Docker image is based on the `base` image.\n\n## go/s390x Docker image\n\nThe `s390x` image is the base image for the `s390x` architecture, it is build for Debian 12+.\nIt is used to cross compile for `linux/s390x`. This Docker image is based on the `base` image.\n\n## go/npcap Docker image\n\nThe `npcap` image is a placeholder for the `npcap` library, see [npcap](./NPCAP.md) for more information.\n\n## Troubleshooting\n\n### bzip2 issues\n\nIf the `gen_sdk_package_pbza.sh` script gives an error that reads:\n\n```shell\nError while extracting archive:(Metadata): bzip2 support not compiled in. (Success)\n```\n\nA manual work-around is needed in order to create the SDK (other people have reported that installing `libbz2-dev` fixed this issue).\n\nFirst edit `osxcross/tools/tools.sh` to remove the `trap` line from the `create_tmp_dir` function (currently line 264).\n\nThen re-run  `./tools/gen_sdk_package_pbzx.sh <xcode>.xip`.\n\nGo to the tmp dir created in the build dir: `cd osxcross/build/tmp_<X>`.\n\nThen run:\n\n```shell\n../../target/SDK/tools/bin/pbzx -n Content | cpio -i\ncd ../..\nXCODEDIR=osxcross/build/tmp_<X> ./tools/gen_sdk_package.sh\n```\n\nThe SDK should be in the working directory.\nThe tmp dir can be safely deleted after this.\n\nThe SDKs should be uploaded into the `gs://golang-crossbuild-ci-internal/sdks` bucket on GCP (Google Cloud Platform).\nThis is accessible to authorized users in the `elastic-observability-ci` project [here](https://console.cloud.google.com/storage/browser/golang-crossbuild-ci-internal/sdks).\n"
  },
  {
    "path": "RELEASE.md",
    "content": "# Release Process\n\nThis document provides step-by-step instructions for releasing new versions of the golang-crossbuild project.\n\n## Overview\n\nThis project follows the Golang versioning scheme, creating a GitHub Release for each specific Golang version. The release process ensures backward compatibility by maintaining separate branches for different Go versions.\n\nWe support the last two newer major versions, the same as the official Golang release [policy](https://go.dev/doc/devel/release#policy):\n\n> Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release. We fix critical problems, including critical security problems, in supported releases as needed by issuing minor revisions (for example, Go 1.6.1, Go 1.6.2, and so on).\n\n## 🤖 Primary Release Process: New Minor Go Version\n\nThis is the most common release scenario and it's fully automated using [updatecli](https://www.updatecli.io/docs/prologue/quick-start/).\n\nThe updatecli manifest can be found at:\n* [.github/updatecli.d/bump-golang.yml](.github/updatecli.d/bump-golang.yml)\n\nThere are two GitHub workflows:\n* [.github/workflows/bump-golang.yml](.github/workflows/bump-golang.yml) for updating the `main` branch.\n* [.github/workflows/bump-golang-previous.yml](.github/workflows/bump-golang-previous.yml) for updating the previous active major Go version.\n\n---\n\n## 🚀 New Major Go Version\n\nFollow these steps when a new major Go version is [released](https://go.dev/doc/devel/release).\n\n### Prerequisites\n- New Major Go version has been officially released or even for RCs.\n- You have write access to the repository\n- You're familiar with the current Go version in use\n\n### Step-by-Step Instructions\n\n#### 1. Prepare Version Branch\nCreate a branch for the previous major Go version to maintain backward compatibility.\n\n**Example**: If upgrading from Go 1.25 to Go 1.26:\n```bash\n# Create branch for previous version (1.25)\ngit checkout main\ngit checkout -b 1.25\ngit push origin 1.25\n```\n\n#### 2. Update Core Version Files\nUpdate the Go version in the main configuration files:\n\n- **File**: `.go-version`\n  - Update to the new Go version (e.g., `1.26.0`)\n\n- **File**: `go/Makefile.common` (line 5)\n  - Update the Docker tag to match the new version\n\n#### 3. Run Version Bump Script\nExecute the automated version bump script:\n\n```bash\n# Use Microsoft Golang release versioning normally 1.26.0-1\n.github/updatecli.d/bump-go-version.sh \"$(cat .go-version)-1\"\n```\n\n#### 4. Update Documentation\n- **File**: `README.md`\n  - Update all version references to the new Go version\n\n#### 5. Update GitHub Workflows\n- **File**: `.github/workflows/bump-golang.yml`\n  - Update `go-minor` value to new minor version (e.g., `1.26`)\n\n- **File**: `.github/workflows/bump-golang-previous.yml`\n  - Update `go-minor` to previous minor version (e.g., `1.25`)\n  - Update `branch` value to previous minor version (e.g., `1.25`)\n\n#### 6. Configure Backport Support\n- **File**: `.mergify.yml`\n  - Add entry for new backport label: `backport-v1.25` (using previous version)\n\n- **GitHub Labels**\n  - Create new label at: https://github.com/elastic/golang-crossbuild/labels\n  - Label name: `backport-v1.25` (using previous version)\n\n#### 7. Commit and Create Pull Request in the `main` branch\n```bash\ngit checkout main\ngit add -u\ngit commit -m \"Update to Go 1.26.0\"  # Use actual version\n```\n\nCreate a Pull Request with:\n- **Title**: `Update to Go 1.26.0`\n- **Description**: Brief summary of the Go version update\n\n#### 8. Merge and Release\n- Ensure all CI checks pass\n- Merge the Pull Request\n- The automation will automatically release the Docker images\n\n> **⚠️ Important Note**: Due to changes in Debian package repositories, Docker images for previous Go versions may stop working over time.\n\n### Example Scenario\n```\nCurrent State: Go 1.24 on main branch\nNew Release: Go 1.25\n\nActions:\n1. Create branch \"1.24\" from main\n2. Update main branch to Go 1.25\n3. Follow steps 2-8 above\n```\n\n---\n\n## 🔧 Specialized Release Processes\n\n### NPCAP Release\nFor detailed instructions on releasing NPCAP versions, see the dedicated [NPCAP documentation](./NPCAP.md).\n\n### FPM Release\n> **📋 Status**: Not actively released (deprecated for several years)  \n> **Action**: To be documented when needed\n\n### LLVM Apple Release  \n> **📋 Status**: Infrequent releases (approximately every 3 years)  \n> **Action**: To be documented when needed\n\n---\n\n## 🔄 Hotfix Process: Update Existing Released Version\n\nUse this process for critical fixes to already-released versions.\n\n### Prerequisites\n- Existing release tag (e.g., `v1.25.1`)\n- Critical fix that needs backporting\n- Understanding of git branching and cherry-picking\n\n### Step-by-Step Instructions\n\n#### 1. Create Hotfix Branch\nCreate a maintenance branch for the specific version:\n```bash\n# Example for version 1.25.1\ngit checkout v1.25.1\ngit checkout -b 1.25.1.x  # 'x' is literal, not a placeholder\ngit push upstream 1.25.1.x\n```\n\n#### 2. Apply Your Changes\n\n1. Ensure your original PR is merged to main\n2. Comment on the PR: `@mergifyio backport 1.25.1.x`\n3. Mergify will automatically create a backport PR\n4. Review and merge the backport PR when CI passes\n\n#### 3. Release Process\n- Merge the hotfix PR\n- The automation will handle the release process\n- Verify the new images are published\n\n### Example Hotfix Scenario\n```\nScenario: Critical security fix needed for Go 1.25.1\n\nSteps:\n1. git checkout v1.25.1\n2. git checkout -b 1.25.1.x\n3. git push upstream 1.25.1.x\n4. Apply fix via backport or manual PR\n5. Merge when CI passes\n```\n\n---\n\n## 🍎 LLVM Apple Containers Release Process\n\n> **📋 Status**: Infrequent releases (approximately every 3 years)\n> **Use Case**: Cross-compilation for macOS targets from Linux environments\n\n### When to Release LLVM Containers\n- New Xcode/macOS SDK versions are available\n- Security updates for LLVM toolchain\n- Compatibility requirements for new macOS targets\n- Critical bug fixes in the cross-compilation toolchain\n\n### Prerequisites\n- Access to Buildkite pipeline: https://buildkite.com/elastic/llvm-apple\n- Understanding of LLVM/Clang toolchain versions\n- Knowledge of macOS SDK compatibility requirements\n\n### Step-by-Step Instructions\n\n#### 1. Prepare for Release\n- Verify the current LLVM/Clang version in the containers\n- Check for any pending updates or security patches\n- Review macOS SDK compatibility requirements\n\n#### 2. Trigger Release Build\n1. Navigate to the Buildkite pipeline: https://buildkite.com/elastic/llvm-apple\n2. Click \"New Build\" button\n3. Select branch: `main`\n4. Set environment variable: `RELEASE=true`\n5. Add build message: \"Release LLVM Apple containers - [reason/version]\"\n6. Click \"Create Build\"\n\n#### 3. Monitor Build Process\n- Monitor the build progress in Buildkite console\n- Expected build time: 4-5 hours (due to LLVM compilation)\n- Watch for any compilation or packaging errors\n- Verify all target architectures are built successfully\n\n#### 4. Verify Release\nAfter successful build completion:\n```bash\n# Check available container images\ndocker pull docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian11-arm64\ndocker inspect docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian11-arm64 | grep org.label-schema.build-date\n```\n\nExpected image tags:\n- `docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian<version>(-arm64)?`\n\n#### 5. Test Cross-Compilation\nVerify the containers work correctly.\n\n#### 6. Update Documentation\n- Update any version references in README.md\n- Document any breaking changes or new features\n- Update compatibility matrix if applicable\n\n### Container Image Locations\nAfter successful release, images are available at:\n- **Registry**: `docker.elastic.co/beats-dev/golang-crossbuild`\n- **Tags**: `llvm-apple-debian<version>`, `llvm-apple-debian<version>-arm64`\n- **Architectures**: `linux/amd64`, `linux/arm64`\n\n### Supported Cross-Compilation Targets\n- **macOS**: `darwin/amd64`, `darwin/arm64`\n- **iOS**: `ios/amd64`, `ios/arm64` (if configured)\n\n### Troubleshooting LLVM Releases\n\n#### Common Issues\n1. **Build Timeouts**: LLVM compilation is resource-intensive\n   - **Solution**: Retry build or check Buildkite agent resources\n\n2. **SDK Download Failures**: Xcode SDK downloads may fail\n   - **Solution**: Verify SDK availability and download URLs\n\n3. **Cross-compilation Errors**: Target-specific compilation issues\n   - **Solution**: Test with sample projects before full release\n\n4. **Container Registry Issues**: Push failures to docker.elastic.co\n   - **Solution**: Check registry credentials and network connectivity\n\n---\n\n## 📚 Quick Reference\n\n### File Locations\n| Component | File Path |\n|-----------|-----------|\n| Go Version | `.go-version` |\n| Docker Tag | `go/Makefile.common` (line 5) |\n| Main Workflow | `.github/workflows/bump-golang.yml` |\n| Previous Workflow | `.github/workflows/bump-golang-previous.yml` |\n| Mergify Config | `.mergify.yml` |\n| Version Bump Script | `.github/updatecli.d/bump-go-release-version.sh` |\n\n### Branch Naming Convention\n- **Main development**: `main`\n- **Version branches**: `1.23`, `1.24` (major.minor format)\n- **Hotfix branches**: `1.25.1.x` (major.minor.patch.x format)\n\n### Automation\n- **Docker Images**: Released automatically on PR merge\n- **Backports**: Available via Mergify (`@mergifyio backport <branch>`)\n- **CI/CD**: All releases go through automated testing\n\n---\n\n## ❓ Troubleshooting\n\n### Common Issues\n1. **CI Failures**: Ensure all version references are updated consistently\n2. **Docker Build Errors**: Check Debian package repository availability\n3. **Backport Conflicts**: Resolve manually and create new PR\n4. **Missing Labels**: Create GitHub labels before using backport commands\n\n### Support\n- Check existing GitHub issues and PRs for similar problems\n- Review CI logs for specific error messages\n- Consult team members for complex release scenarios\n"
  },
  {
    "path": "catalog-info.yaml",
    "content": "# Declare a Backstage Component that represents your application.\n---\n# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json\napiVersion: backstage.io/v1alpha1\nkind: Component\nmetadata:\n  name: golang-crossbuild\n\nspec:\n  type: tool\n  owner: group:ingest-fp\n  system: platform-ingest\n  lifecycle: production\n\n---\n# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json\napiVersion: backstage.io/v1alpha1\nkind: Resource\nmetadata:\n  name: buildkite-pipeline-golang-crossbuild\n  description: 'Pipeline for the golang-crossbuild project'\n  links:\n    - title: Pipeline\n      url: https://buildkite.com/elastic/golang-crossbuild\n\nspec:\n  type: buildkite-pipeline\n  owner: group:ingest-fp\n  system: buildkite\n  implementation:\n    apiVersion: buildkite.elastic.dev/v1\n    kind: Pipeline\n    metadata:\n      name: golang-crossbuild\n      description: 'Pipeline for the golang-crossbuild project'\n    spec:\n      branch_configuration: \"main 1.*\" # temporarily disable to build PRs from forks\n      pipeline_file: \".buildkite/pipeline.yml\"\n      maximum_timeout_in_minutes: 360 # LLVM apple pipelines is taking at least 4h to run\n      provider_settings:\n        build_tags: true\n        publish_commit_status: true\n        build_pull_request_forks: false\n        build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot\n        filter_enabled: true\n        filter_condition: >-\n          build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)\n      repository: elastic/golang-crossbuild\n      cancel_intermediate_builds: true\n      cancel_intermediate_builds_branch_filter: '!main !1.*'\n      skip_intermediate_builds: true\n      skip_intermediate_builds_branch_filter: '!main !1.*'\n      env:\n         ELASTIC_PR_COMMENTS_ENABLED: 'true'\n      teams:\n        ingest-fp:\n          access_level: MANAGE_BUILD_AND_READ\n        observablt-robots:\n          access_level: BUILD_AND_READ\n        everyone:\n          access_level: READ_ONLY\n      schedules:\n        Daily:\n          branch: main\n          cronline: \"0 12 * * * America/New_York\"\n          message: \"Builds once per day\"\n\n---\n# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json\napiVersion: backstage.io/v1alpha1\nkind: Resource\nmetadata:\n  name: buildkite-pipeline-llvm-apple-version\n  description: \"Pipeline for LLVM Apple version\"\n  links:\n    - title: Pipeline\n      url: https://buildkite.com/elastic/llvm-apple\n\nspec:\n  type: buildkite-pipeline\n  owner: group:ingest-fp\n  system: buildkite\n  implementation:\n    apiVersion: buildkite.elastic.dev/v1\n    kind: Pipeline\n    metadata:\n      name: llvm-apple\n      description: \"Pipeline for LLVM Apple version\"\n    spec:\n      branch_configuration: \"main 1.*\" # temporarily disable to build PRs from forks\n      pipeline_file: \".buildkite/llvm-apple-pipeline.yml\"\n      maximum_timeout_in_minutes: 360 # cmake is taking at least 4h to run\n      provider_settings:\n        build_tags: true\n        publish_commit_status: true\n        build_pull_request_forks: false\n        build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot\n        filter_enabled: true\n        filter_condition: >-\n          build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)\n      repository: elastic/golang-crossbuild\n      cancel_intermediate_builds: true\n      cancel_intermediate_builds_branch_filter: '!main'\n      skip_intermediate_builds: true\n      skip_intermediate_builds_branch_filter: '!main'\n      env:\n        ELASTIC_PR_COMMENTS_ENABLED: 'false'\n      teams:\n        ingest-fp:\n          access_level: MANAGE_BUILD_AND_READ\n        observablt-robots:\n          access_level: BUILD_AND_READ\n        everyone:\n          access_level: READ_ONLY\n\n---\n# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json\napiVersion: backstage.io/v1alpha1\nkind: Resource\nmetadata:\n  name: buildkite-pipeline-fpm\n  description: \"Pipeline for FPM (packaging made simple)\"\n  links:\n    - title: Pipeline\n      url: https://buildkite.com/elastic/fpm\n\nspec:\n  type: buildkite-pipeline\n  owner: group:ingest-fp\n  system: buildkite\n  implementation:\n    apiVersion: buildkite.elastic.dev/v1\n    kind: Pipeline\n    metadata:\n      name: fpm\n      description: \"Pipeline for FPM (packaging made simple)\"\n    spec:\n      branch_configuration: \"main 1.*\" # temporarily disable to build PRs from forks\n      pipeline_file: \".buildkite/fpm-pipeline.yml\"\n      maximum_timeout_in_minutes: 360 # cmake is taking at least 4h to run\n      provider_settings:\n        build_tags: true\n        publish_commit_status: true\n        build_pull_request_forks: false\n        build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot\n        filter_enabled: true\n        filter_condition: >-\n          build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)\n      repository: elastic/golang-crossbuild\n      cancel_intermediate_builds: true\n      cancel_intermediate_builds_branch_filter: '!main'\n      skip_intermediate_builds: true\n      skip_intermediate_builds_branch_filter: '!main'\n      env:\n        ELASTIC_PR_COMMENTS_ENABLED: 'false'\n      teams:\n        ingest-fp:\n          access_level: MANAGE_BUILD_AND_READ\n        observablt-robots:\n          access_level: BUILD_AND_READ\n        everyone:\n          access_level: READ_ONLY\n"
  },
  {
    "path": "fpm/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "fpm/Dockerfile.tmpl",
    "content": "FROM debian:bullseye\nLABEL maintainer=\"Elastic Beats Team\"\n\nRUN \\\n    apt-get update && \\\n    apt-get install -y --no-install-recommends \\\n        autoconf build-essential libffi-dev ruby-dev rpm zip dos2unix libgmp3-dev \\\n        curl make gcc \\\n    && rm -rf /var/lib/apt/lists/*\n\nARG SUEXEC_VERSION=0.2\nARG SUEXEC_DOWNLOAD_URL=https://github.com/ncopa/su-exec/archive/v${SUEXEC_VERSION}.tar.gz\nARG SUEXEC_DOWNLOAD_SHA256=ec4acbd8cde6ceeb2be67eda1f46c709758af6db35cacbcde41baac349855e25\n\nRUN \\\n    curl -fsSL \"$SUEXEC_DOWNLOAD_URL\" -o suexec.tar.gz \\\n    && echo \"$SUEXEC_DOWNLOAD_SHA256  suexec.tar.gz\" | sha256sum -c - \\\n    && mkdir /suexec \\\n    && tar -C /suexec --strip-components=1 -xzf suexec.tar.gz \\\n    && make -C /suexec \\\n    && mv /suexec/su-exec /usr/bin/ \\\n    && rm -rf /suexec suexec.tar.gz\n\nARG FPM_VERSION\nRUN gem install fpm -v \"$FPM_VERSION\"\n\nCOPY rootfs /\n\nENTRYPOINT  [\"/entrypoint.sh\"]\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "fpm/Makefile",
    "content": "include ../Makefile.common\n\nNAME    := fpm\nVERSION := 1.13.1\n\nbuild:\n\t@echo \">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)\"\n\t@go run ../template.go -t Dockerfile.tmpl -o Dockerfile\n\t@docker run --privileged --rm tonistiigi/binfmt --install all\n\n\t@docker buildx ls\n\t@echo 'Create builder'\n\t@docker buildx create --name \"multiarchcontext\"\n\t@docker buildx use \"multiarchcontext\"\n\t@docker buildx inspect --bootstrap\n\t@echo 'Build Docker image'\n\t@docker buildx build --progress=plain --platform \"linux/amd64,linux/arm64\" -t \"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)\" \\\n\t--build-arg FPM_VERSION=$(VERSION) \\\n\t--build-arg IMAGE=\"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\" \\\n\t--build-arg VCS_REF=\"$(VCS_REF)\" \\\n\t--build-arg VCS_URL=\"$(VCS_URL)\" \\\n\t--build-arg BUILD_DATE=\"$(BUILD_DATE)\" \\\n\t--push .\n\n.PHONY: build\n"
  },
  {
    "path": "fpm/rootfs/entrypoint.sh",
    "content": "#!/usr/bin/env sh\n\nif [ -z ${EXEC_UID+x} ] || [ -z ${EXEC_GID+x} ]; then\n  exec \"$@\"\nfi\n\ngroupadd -f -g \"$EXEC_GID\" fpm\nuseradd -N -m -c 'FPM User' -u \"$EXEC_UID\" -g \"$EXEC_GID\" fpm\n\nsu-exec fpm \"$@\"\n"
  },
  {
    "path": "go/Makefile",
    "content": "include ./Makefile.debian9\n\nTAG_EXTENSION  := \"\"\n"
  },
  {
    "path": "go/Makefile.common",
    "content": "SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))\ninclude $(SELF_DIR)/../Makefile.common\n\nNAME           := golang-crossbuild\nVERSION        := 1.26.2\nDEBIAN_VERSION ?= 9\nSUFFIX         := -$(shell basename $(CURDIR))\nTAG_EXTENSION  ?=\nFIPS           ?=\nifeq \"${FIPS}\" \"true\"\nifeq ($(findstring -fips,$(TAG_EXTENSION)),)\nTAG_EXTENSION:=$(TAG_EXTENSION)-fips\nendif\nendif\n\nexport DEBIAN_VERSION TAG_EXTENSION NPCAP_FILE\n\nDOCKER_CMD := docker build --progress=plain\n\nbuild: copy-npcap copy-sdks\n\t@echo \">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\"\n\t@go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile\n\t@$(DOCKER_CMD) -t \"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\" \\\n\t--build-arg REPOSITORY=$(REPOSITORY) \\\n\t--build-arg VERSION=$(VERSION) \\\n\t--build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \\\n\t--build-arg TAG_EXTENSION=$(TAG_EXTENSION) \\\n\t--build-arg IMAGE=\"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\" \\\n\t--build-arg VCS_REF=\"$(VCS_REF)\" \\\n\t--build-arg VCS_URL=\"$(VCS_URL)\" \\\n\t--build-arg BUILD_DATE=\"$(BUILD_DATE)\" \\\n\t.\n\nbuild-arm: copy-sdks\n\t@echo $(SELF_DIR)\n\t@echo \">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\"\n\t@go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile\n\t@docker build -t \"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\" \\\n\t--progress=plain \\\n\t--build-arg REPOSITORY=$(REPOSITORY) \\\n\t--build-arg VERSION=$(VERSION) \\\n\t--build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \\\n\t--build-arg TAG_EXTENSION=$(TAG_EXTENSION) \\\n\t--build-arg IMAGE=\"$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)\" \\\n\t--build-arg VCS_REF=\"$(VCS_REF)\" \\\n\t--build-arg VCS_URL=\"$(VCS_URL)\" \\\n\t--build-arg BUILD_DATE=\"$(BUILD_DATE)\" \\\n\t.\n\n.PHONY: build build-arm\n"
  },
  {
    "path": "go/Makefile.debian10",
    "content": "IMAGES         := base main darwin armhf npcap\nARM_IMAGES     := base-arm darwin-arm64\nDEBIAN_VERSION := 10\nTAG_EXTENSION  := -debian10\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nbuild:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)\n\nbuild-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)\n\n# Requires login at https://docker.elastic.co:7000/.\npush:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)\n\npush-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)\n\n.PHONY: build build-arm push push-arm\n"
  },
  {
    "path": "go/Makefile.debian11",
    "content": "IMAGES         := base main darwin armhf npcap\nARM_IMAGES     := base-arm darwin-arm64\nDEBIAN_VERSION := 11\nTAG_EXTENSION  := -debian11\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nbuild:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)\n\nbuild-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)\n\n# Requires login at https://docker.elastic.co:7000/.\npush:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)\n\npush-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)\n\n.PHONY: build build-arm push push-arm\n"
  },
  {
    "path": "go/Makefile.debian12",
    "content": "IMAGES         := base main darwin armhf armel mips ppc s390x npcap\nARM_IMAGES     := base-arm darwin-arm64 windows-arm64\nDEBIAN_VERSION := 12\nTAG_EXTENSION  := -debian12\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nbuild:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)\n\nbuild-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)\n\n# Requires login at https://docker.elastic.co:7000/.\npush:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)\n\npush-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)\n\n.PHONY: build build-arm push push-arm\n"
  },
  {
    "path": "go/Makefile.debian7",
    "content": "IMAGES         := base main\nDEBIAN_VERSION := 7\nTAG_EXTENSION  := -debian7\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nbuild:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)\n\n# Requires login at https://docker.elastic.co:7000/.\npush:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)\n\n.PHONY: build push\n"
  },
  {
    "path": "go/Makefile.debian8",
    "content": "IMAGES         := base main darwin npcap\nARM_IMAGES     := base-arm\nDEBIAN_VERSION := 8\nTAG_EXTENSION  := -debian8\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nbuild:\n\texport |grep TAG_EXTENSION\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)\n\nbuild-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)\n\n# Requires login at https://docker.elastic.co:7000/.\npush:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)\n\npush-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)\n\n.PHONY: build build-arm push push-arm\n"
  },
  {
    "path": "go/Makefile.debian9",
    "content": "IMAGES         := base main darwin armhf npcap\nARM_IMAGES     := base-arm\nDEBIAN_VERSION := 9\nTAG_EXTENSION  := -debian9\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nbuild:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)\n\nbuild-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)\n\n# Requires login at https://docker.elastic.co:7000/.\npush:\n\t@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)\n\npush-arm:\n\t@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)\n\n.PHONY: build build-arm push push-arm\n"
  },
  {
    "path": "go/arm/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/arm/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM --platform=linux/amd64 ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} AS stage-amd64\n\nRUN dpkg --add-architecture arm64 \\\n        && apt update -y --no-install-recommends \\\n        && apt upgrade -y --no-install-recommends \\\n        && apt full-upgrade -y --no-install-recommends \\\n        && apt install -qq -y --no-install-recommends \\\n        crossbuild-essential-arm64 \\\n        linux-libc-dev-arm64-cross\n\nRUN apt install -qq -y \\\n        libc-dev:arm64 \\\n        libpopt-dev:arm64 \\\n        linux-libc-dev:arm64\n\n{{- if eq .DEBIAN_VERSION \"9\"}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:arm64 \\\n        librpm3:arm64 \\\n        librpmio3:arm64 \\\n        librpmbuild3:arm64 \\\n        librpmsign3:arm64 \\\n        libxml2-dev:arm64 \\\n        libsqlite3-dev:arm64 \\\n        libnss3:arm64 \\\n        libsqlite3-0:arm64 \\\n        libxml2:arm64 \\\n        libsqlite3-0:arm64\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:arm64 libsystemd0:arm64 liblz4-1:arm64\n{{- end }}\n\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\nRUN apt install -y \\\n        librpm-dev:arm64\n\nRUN apt install -y \\\n        libsystemd-dev:arm64\n{{- end }}\n\nARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM --platform=linux/arm64 ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} AS stage-arm64\n\nRUN dpkg --add-architecture arm64 \\\n        && apt update -y --no-install-recommends \\\n        && apt upgrade -y --no-install-recommends \\\n        && apt full-upgrade -y --no-install-recommends \\\n        && apt install -qq -y --no-install-recommends \\\n        build-essential \\\n        libc-dev \\\n        libpopt-dev \\\n        linux-libc-dev\n\n{{- if eq .DEBIAN_VERSION \"9\"}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev \\\n        librpm3 \\\n        librpmio3 \\\n        librpmbuild3 \\\n        librpmsign3 \\\n        libxml2-dev \\\n        libsqlite3-dev \\\n        libnss3 \\\n        libsqlite3-0 \\\n        libxml2 \\\n        libsqlite3-0\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev libsystemd0 liblz4-1\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n\n# librpm-dev\nRUN apt install -y  \\\n        librpm-dev\n\nRUN apt install -y  \\\n        libsystemd-dev\n{{- end }}\n\n# Declare TARGETARCH to make it available\nARG TARGETARCH=amd64\n# Select final stage based on TARGETARCH ARG\nFROM stage-${TARGETARCH} AS final\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n        && aarch64-linux-gnu-gcc helloWorld.c -o helloWorld \\\n        && file helloWorld \\\n        && readelf -h helloWorld \\\n        && file helloWorld | cut -d \",\" -f 2 | grep -c 'ARM aarch64'\\\n        && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n        && CC=aarch64-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=aarch64-unknown-linux-gnu --with-pcap=linux \\\n        && make\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n        org.label-schema.name=$IMAGE \\\n        org.label-schema.vcs-ref=$VCS_REF \\\n        org.label-schema.vcs-url=$VCS_URL \\\n        org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/arm/Makefile",
    "content": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n\nifeq ($(BUILDX)$(DEBIAN_VERSION),19)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n"
  },
  {
    "path": "go/arm/rootfs/compilers.yaml",
    "content": "---\n\nlinux:\n  arm64:\n    CC:  aarch64-linux-gnu-gcc\n    CXX: aarch64-linux-gnu-g++\n"
  },
  {
    "path": "go/arm/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/armel/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/armel/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN dpkg --add-architecture armel \\\n    && apt update -y --no-install-recommends \\\n    && apt upgrade -y --no-install-recommends \\\n    && apt full-upgrade -y --no-install-recommends \\\n    && apt install -qq -y --no-install-recommends \\\n        crossbuild-essential-armel \\\n        linux-libc-dev-armel-cross\n\nRUN apt install -qq -y \\\n        libc-dev:armel \\\n        libpopt-dev:armel \\\n        linux-libc-dev:armel\n\n{{- if eq .DEBIAN_VERSION \"9\"}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:armel \\\n        librpm3:armel \\\n        librpmio3:armel \\\n        librpmbuild3:armel \\\n        librpmsign3:armel \\\n        libxml2-dev:armel \\\n        libsqlite3-dev:armel \\\n        libnss3:armel \\\n        libsqlite3-0:armel \\\n        libxml2:armel \\\n        libsqlite3-0:armel\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:armel libsystemd0:armel liblz4-1:armel\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:armel\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:armel\n{{- end }}\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && arm-linux-gnueabi-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && file helloWorld | cut -d \",\" -f 3 | grep -c 'EABI'\\\n  && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n\t&& CC=arm-linux-gnueabi-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=arm-linux-gnueabi --with-pcap=linux \\\n\t&& make\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/armel/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/armel/rootfs/compilers.yaml",
    "content": "---\n\nlinux:\n  armv6:\n    # Using debian armel for ARMv6.\n    # This is the same as ARMv5 so it will use softfp instead of hardfp.\n    CC:  arm-linux-gnueabi-gcc\n    CXX: arm-linux-gnueabi-g++\n  armv5:\n    CC:  arm-linux-gnueabi-gcc\n    CXX: arm-linux-gnueabi-g++\n"
  },
  {
    "path": "go/armel/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/armhf/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/armhf/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN dpkg --add-architecture armhf \\\n    && apt update -y --no-install-recommends \\\n    && apt upgrade -y --no-install-recommends \\\n    && apt full-upgrade -y --no-install-recommends \\\n    && apt install -qq -y --no-install-recommends \\\n        crossbuild-essential-armhf \\\n        linux-libc-dev-armhf-cross\n\nRUN apt install -qq -y \\\n        libc-dev:armhf \\\n        libpopt-dev:armhf \\\n        linux-libc-dev:armhf\n\n{{- if eq .DEBIAN_VERSION \"9\"}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:armhf \\\n        librpm3:armhf \\\n        librpmio3:armhf \\\n        librpmbuild3:armhf \\\n        librpmsign3:armhf \\\n        libxml2-dev:armhf \\\n        libsqlite3-dev:armhf \\\n        libnss3:armhf \\\n        libsqlite3-0:armhf \\\n        libxml2:armhf \\\n        libsqlite3-0:armhf\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:armhf libsystemd0:armhf liblz4-1:armhf\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:armhf\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:armhf\n{{- end }}\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && arm-linux-gnueabihf-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && file helloWorld | cut -d \",\" -f 5 | grep -c 'armhf.so'\\\n  && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n\t&& CC=arm-linux-gnueabihf-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=arm-linux-gnueabihf --with-pcap=linux \\\n\t&& make\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/armhf/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/armhf/rootfs/compilers.yaml",
    "content": "---\n\nlinux:\n  armv7:\n    CC:  arm-linux-gnueabihf-gcc\n    CXX: arm-linux-gnueabihf-g++\n"
  },
  {
    "path": "go/armhf/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/base/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/base/Dockerfile.tmpl",
    "content": "ARG DEBIAN_VERSION=9\nFROM debian:${DEBIAN_VERSION}\n\nARG DEBIAN_VERSION\n# Replace sources.list in order to use archive.debian.org.\nCOPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list\n\nRUN apt-get -o Acquire::Check-Valid-Until=false update -y --no-install-recommends --allow-unauthenticated \\\n        && apt-get upgrade -y --no-install-recommends --allow-unauthenticated \\\n        && apt-get dist-upgrade -y --no-install-recommends --allow-unauthenticated \\\n        && apt-get install -y --no-install-recommends --allow-unauthenticated \\\n            build-essential \\\n            ca-certificates \\\n            curl \\\n            git \\\n            gnupg \\\n            make \\\n            file \\\n            flex \\\n            bison \\\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n            binutils-multiarch \\\n            binutils-multiarch-dev \\\n            python3-venv \\\n            python3-pip \\\n            python3 \\\n{{- end }}\n        && rm -rf /var/lib/apt/lists/*\n\n{{- if eq .DEBIAN_VERSION \"10\"}}\nRUN ln -s /usr/bin/pip3 /usr/bin/pip\n{{- end }}\n\nARG VERSION\n{{- if eq .FIPS \"true\"}}\nARG SECURITY_VERSION=-1\nARG GOLANG_DOWNLOAD_URL=https://aka.ms/golang/release/latest/go$VERSION$SECURITY_VERSION.linux-amd64.tar.gz\n# Use a different arg name for microsoft/go sha so it can be handled seperately from the regular golang sha\nARG MSFT_DOWNLOAD_SHA256=68bcd46d095165b37f4773450a8239ae5aa8d7e5be371eb69aea0510526ced5a\nARG DOWNLOAD_SHA256=$MSFT_DOWNLOAD_SHA256\n{{- else}}\nARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$VERSION.linux-amd64.tar.gz\nARG GOLANG_DOWNLOAD_SHA256=990e6b4bbba816dc3ee129eaeaf4b42f17c2800b88a2166c265ac1a200262282\nARG DOWNLOAD_SHA256=$GOLANG_DOWNLOAD_SHA256\n{{- end }}\n\nRUN curl -fsSL \"$GOLANG_DOWNLOAD_URL\" -o golang.tar.gz \\\n\t&& echo \"$DOWNLOAD_SHA256  golang.tar.gz\" | sha256sum -c - \\\n\t&& rm -rf /usr/local/go \\\n\t&& tar -C /usr/local -xzf golang.tar.gz \\\n\t&& rm golang.tar.gz\n\nENV GOPATH=/go\nENV PATH=$PATH:/usr/local/go/bin\n\nRUN mkdir -p \"$GOPATH/src\" \"$GOPATH/bin\" && chmod -R 777 \"$GOPATH\"\nWORKDIR $GOPATH\n\n# Validate the Go installation\nRUN go version \\\n    && go version | grep \"go${VERSION}\" || (echo \"Go version mismatch: expected to contain go${VERSION}\" && exit 1)\n\nCOPY rootfs /\n\n# show the GLIBC version\nRUN ldd --version\n\nWORKDIR /\nRUN mkdir -p /root/.config/go/telemetry && echo \"off 2024-08-23\" > /root/.config/go/telemetry/mode\nENV GOTOOLCHAIN=local\nRUN go mod init github.com/elastic/golang-crossbuild-$VERSION \\\n    && go get . \\\n    && go env \\\n    && echo \"toolcompile=$(go tool compile -V)\" \\\n    && CGO_ENABLED=0 GOARCH=amd64 go build -o /crossbuild /entrypoint.go \\\n    && rm -rf /go/* /root/.cache/* /entrypoint.go\n\nCOPY sdks/libpcap-1.8.1.tar.gz .\nRUN mkdir /libpcap \\\n    && tar -xzf libpcap-1.8.1.tar.gz -C /libpcap \\\n    && rm libpcap-1.8.1.tar.gz\n\n\n{{- if eq .FIPS \"true\"}}\nENV GOEXPERIMENT=systemcrypto\nENV CGO_ENABLED=1\nENV MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0\n{{- end}}\nENV GOLANG_CROSSBUILD=1\nVOLUME      /app\nWORKDIR     /app\nENTRYPOINT  [\"/crossbuild\"]\n"
  },
  {
    "path": "go/base/Makefile",
    "content": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n\nifeq ($(BUILDX)$(DEBIAN_VERSION),19)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n"
  },
  {
    "path": "go/base/rootfs/entrypoint.go",
    "content": "// +build linux\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/spf13/cobra\"\n\t\"gopkg.in/yaml.v2\"\n)\n\nvar rootCmd = &cobra.Command{\n\tUse:   \"crossbuild\",\n\tShort: \"crossbuild is simple tool for cross-compiling Go binaries\",\n\tLong: `crossbuild is a containerized tool for cross-compiling Go binaries\nby mounting the project inside of a container equipped with cross-compilers.\n\nThe root of your project's repo should be mounted at the appropriate location\non the GOPATH which is set to /go.\n\nWhile executing the build command the following variables will be added to the\nenvironment: GOOS, GOARCH, GOARM, GOTOOLCHAIN=local, PLATFORM_ID, CC, and CXX.\n`,\n\tRunE:         doBuild,\n\tSilenceUsage: true,\n}\n\nfunc init() {\n\trootCmd.PersistentFlags().StringVarP(&buildCommand, \"build-cmd\", \"c\",\n\t\t\"make build\", \"Build command to execute.\")\n\n\trootCmd.PersistentFlags().StringSliceVarP(&platforms, \"platforms\", \"p\", nil,\n\t\t\"Target platform for the binary in GOOS/GOARCH format (e.g. windows/amd64).\")\n\trootCmd.MarkPersistentFlagRequired(\"platforms\")\n}\n\nfunc main() {\n\tlog.SetFlags(0)\n\n\tif err := rootCmd.Execute(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nvar (\n\tbuildCommand string\n\tplatforms    []string\n)\n\nfunc doBuild(_ *cobra.Command, _ []string) error {\n\tfor _, p := range platforms {\n\t\tenv, err := buildEnvironment(p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed constructing the build environment for %v: %v\", p, err)\n\t\t}\n\n\t\tif err = execBuildCommand(env); err != nil {\n\t\t\treturn fmt.Errorf(\"failed building for %v: %v\", p, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc isDirEmpty(name string) (bool, error) {\n\tf, err := os.Open(name)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer f.Close()\n\n\t_, err = f.Readdirnames(1)\n\tif err == io.EOF {\n\t\treturn true, nil\n\t}\n\treturn false, err\n}\n\nfunc buildEnvironment(platform string) (map[string]string, error) {\n\tparts := strings.SplitN(platform, \"/\", 2)\n\tif len(parts) != 2 {\n\t\treturn nil, fmt.Errorf(\"invalid platform %v\", platform)\n\t}\n\n\tplatformID := strings.Join(parts, \"-\")\n\tgoos := parts[0]\n\tarch := parts[1]\n\tgoarch := arch\n\tgoarm := \"\"\n\n\tif strings.HasPrefix(arch, \"armv\") {\n\t\tgoarch = \"arm\"\n\t\tgoarm = strings.TrimPrefix(arch, \"armv\")\n\t}\n\n\tenv := map[string]string{\n\t\t\"GOOS\":        goos,\n\t\t\"GOARCH\":      goarch,\n\t\t\"GOARM\":       goarm,\n\t\t\"GOTOOLCHAIN\": \"local\", // Disable automatic downloads of toolchains for reproducible builds.\n\t\t\"PLATFORM_ID\": platformID,\n\t}\n\n\tif err := loadCompilerSettings(goos, arch, env); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed while loading compiler settings: %v\", err)\n\t}\n\n\treturn env, nil\n}\n\ntype Compilers struct {\n\tGOOS map[string]struct {\n\t\tArch map[string]struct {\n\t\t\tEnv map[string]string `yaml:\",inline\"`\n\t\t} `yaml:\",inline\"`\n\t} `yaml:\",inline\"`\n}\n\nfunc loadCompilerSettings(goos, arch string, env map[string]string) error {\n\tdata, err := ioutil.ReadFile(\"/compilers.yaml\")\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"failed to read /compilers.yaml: %v\", err)\n\t}\n\n\tvar compilers Compilers\n\tif err = yaml.Unmarshal(data, &compilers); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse /compilers.yaml: %v\", err)\n\t}\n\n\tarches, found := compilers.GOOS[goos]\n\tif !found {\n\t\treturn fmt.Errorf(\"%v is not supported by this image\", goos)\n\t}\n\n\tsettings, found := arches.Arch[arch]\n\tif !found {\n\t\treturn fmt.Errorf(\"%v/%v is not supported by this image\", goos, arch)\n\t}\n\n\tfor k, v := range settings.Env {\n\t\tenv[k] = v\n\t}\n\n\treturn nil\n}\n\nfunc execBuildCommand(env map[string]string) error {\n\tcmd := exec.Command(\"sh\", \"-c\", buildCommand)\n\tcmd.Env = os.Environ()\n\tlogEnv := make([]string, 0, len(env))\n\tfor k, v := range env {\n\t\tkv := k + \"=\" + v\n\t\tcmd.Env = append(cmd.Env, kv)\n\t\tlogEnv = append(logEnv, kv)\n\t}\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\tcmd.Stdin = os.Stdin\n\n\tvar b strings.Builder\n\tsort.Strings(logEnv)\n\tfmt.Fprintf(&b, \">> Building using: cmd='%v', env=[%v]\", buildCommand, strings.Join(logEnv, \", \"))\n\n\tlog.Println(b.String())\n\treturn cmd.Run()\n}\n"
  },
  {
    "path": "go/base/sources-debian10.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb http://archive.debian.org/debian buster main\ndeb http://archive.debian.org/debian-security buster/updates main\n"
  },
  {
    "path": "go/base/sources-debian11.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bullseye main\ndeb http://deb.debian.org/debian bullseye-updates main\ndeb http://deb.debian.org/debian-security/ bullseye-security main\n"
  },
  {
    "path": "go/base/sources-debian12.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bookworm main\ndeb http://deb.debian.org/debian-security/ bookworm-security main\n"
  },
  {
    "path": "go/base/sources-debian7.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\n# https://bugs.launchpad.net/torios/+bug/1835529\ndeb http://archive.debian.org/debian wheezy main\ndeb http://archive.debian.org/debian-security wheezy/updates main\n"
  },
  {
    "path": "go/base/sources-debian8.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\n# https://bugs.launchpad.net/torios/+bug/1835529\ndeb http://archive.debian.org/debian jessie main\ndeb http://archive.debian.org/debian-security jessie/updates main\n"
  },
  {
    "path": "go/base/sources-debian9.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb http://archive.debian.org/debian stretch main\ndeb http://archive.debian.org/debian-security stretch/updates main\n"
  },
  {
    "path": "go/base-arm/Dockerfile.tmpl",
    "content": "ARG DEBIAN_VERSION=9\nFROM arm64v8/debian:${DEBIAN_VERSION}\n\nARG DEBIAN_VERSION\n# Replace sources.list in order to use archive.debian.org.\nCOPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list\n\nRUN \\\n    apt-get -o Acquire::Check-Valid-Until=false update \\\n        && apt-get dist-upgrade -y \\\n        && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \\\n            build-essential \\\n            ca-certificates \\\n            curl \\\n            git \\\n            gnupg \\\n            make \\\n            file \\\n            flex \\\n            bison \\\n            librpm-dev \\\n            libc-dev \\\n            libpopt-dev \\\n            linux-libc-dev \\\n            libxml2-dev \\\n            libxml2 \\\n            libicu-dev \\\n            icu-devtools \\\n            libsystemd-dev \\\n            {{- if eq .DEBIAN_VERSION \"8\" }}\n            libicu52 \\\n            librpm3  \\\n            librpmio3 \\\n            librpmbuild3 \\\n            librpmsign1 \\\n            {{- else if eq .DEBIAN_VERSION \"9\" }}\n            libicu57 \\\n            librpm3  \\\n            librpmio3 \\\n            librpmbuild3 \\\n            librpmsign3 \\\n            {{- else if eq .DEBIAN_VERSION \"10\" }}\n            libicu63 \\\n            librpm8  \\\n            librpmio8 \\\n            librpmbuild8 \\\n            librpmsign8 \\\n            {{- else if eq .DEBIAN_VERSION \"11\" }}\n            libicu67 \\\n            librpm9  \\\n            librpmio9 \\\n            librpmbuild9 \\\n            librpmsign9 \\\n            {{- else }}\n            libicu72 \\\n            librpm9  \\\n            librpmio9 \\\n            librpmbuild9 \\\n            librpmsign9 \\\n            {{- end }}\n            libsqlite3-dev \\\n            libnss3 \\\n            libsqlite3-0 \\\n        && rm -rf /var/lib/apt/lists/*\n\nARG VERSION\n{{- if eq .FIPS \"true\"}}\nARG SECURITY_VERSION=-1\nARG GOLANG_DOWNLOAD_URL=https://aka.ms/golang/release/latest/go$VERSION$SECURITY_VERSION.linux-arm64.tar.gz\n# Use a different arg name for microsoft/go sha so it can be handled seperately from the regular golang sha\nARG MSFT_DOWNLOAD_SHA256=0274f18451d73bf234798b1d1212e60b59ed1cd86d1b982701df3df76c563571\nARG DOWNLOAD_SHA256=$MSFT_DOWNLOAD_SHA256\n{{- else}}\nARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$VERSION.linux-arm64.tar.gz\nARG GOLANG_DOWNLOAD_SHA256=c958a1fe1b361391db163a485e21f5f228142d6f8b584f6bef89b26f66dc5b23\nARG DOWNLOAD_SHA256=$GOLANG_DOWNLOAD_SHA256\n{{- end}}\n\nRUN curl -fsSL \"$GOLANG_DOWNLOAD_URL\" -o golang.tar.gz \\\n\t&& echo \"$DOWNLOAD_SHA256  golang.tar.gz\" | sha256sum -c - \\\n\t&& rm -rf /usr/local/go \\\n\t&& tar -C /usr/local -xzf golang.tar.gz \\\n\t&& rm golang.tar.gz\n\nENV GOPATH=/go\nENV PATH=$PATH:/usr/local/go/bin\n\nRUN mkdir -p \"$GOPATH/src\" \"$GOPATH/bin\" && chmod -R 777 \"$GOPATH\"\nWORKDIR $GOPATH\n\n# Validate the Go installation\nRUN go version \\\n    && go version | grep \"go${VERSION}\" || (echo \"Go version mismatch: expected to contain go${VERSION}\" && exit 1)\n\nCOPY rootfs /\n\n# show the GLIBC version\nRUN ldd --version\n\nWORKDIR /\n\nRUN mkdir -p /root/.config/go/telemetry && echo \"off 2024-08-23\" > /root/.config/go/telemetry/mode\nENV GOTOOLCHAIN=local\nRUN go mod init github.com/elastic/golang-crossbuild-$VERSION-arm \\\n    && go get . \\\n    && go env \\\n    && echo \"toolcompile=$(go tool compile -V)\" \\\n    && CGO_ENABLED=0 GOARCH=arm64 go build -o /crossbuild /entrypoint.go \\\n    && rm -rf /go/* /root/.cache/* /entrypoint.go\n\nCOPY sdks/libpcap-1.8.1.tar.gz .\nRUN mkdir /libpcap \\\n  && tar -xzf libpcap-1.8.1.tar.gz -C /libpcap \\\n  && cd /libpcap/libpcap-1.8.1 \\\n  && ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=aarch64-unknown-linux-gnu --with-pcap=linux \\\n  && make\n\n{{- if eq .FIPS \"true\"}}\nENV GOEXPERIMENT=systemcrypto\nENV CGO_ENABLED=1\nENV MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0\n{{- end}}\nENV GOLANG_CROSSBUILD=1\nVOLUME      /app\nWORKDIR     /app\nENTRYPOINT  [\"/crossbuild\"]\n"
  },
  {
    "path": "go/base-arm/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/base-arm/rootfs/entrypoint.go",
    "content": "// +build linux\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/spf13/cobra\"\n\t\"gopkg.in/yaml.v2\"\n)\n\nvar rootCmd = &cobra.Command{\n\tUse:   \"crossbuild\",\n\tShort: \"crossbuild is simple tool for cross-compiling Go binaries\",\n\tLong: `crossbuild is a containerized tool for cross-compiling Go binaries\nby mounting the project inside of a container equipped with cross-compilers.\n\nThe root of your project's repo should be mounted at the appropriate location\non the GOPATH which is set to /go.\n\nWhile executing the build command the following variables will be added to the\nenvironment: GOOS, GOARCH, GOARM, GOTOOLCHAIN=local, PLATFORM_ID, CC, and CXX.\n`,\n\tRunE:         doBuild,\n\tSilenceUsage: true,\n}\n\nfunc init() {\n\trootCmd.PersistentFlags().StringVarP(&buildCommand, \"build-cmd\", \"c\",\n\t\t\"make build\", \"Build command to execute.\")\n\n\trootCmd.PersistentFlags().StringSliceVarP(&platforms, \"platforms\", \"p\", nil,\n\t\t\"Target platform for the binary in GOOS/GOARCH format (e.g. windows/amd64).\")\n\trootCmd.MarkPersistentFlagRequired(\"platforms\")\n}\n\nfunc main() {\n\tlog.SetFlags(0)\n\n\tif err := rootCmd.Execute(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nvar (\n\tbuildCommand string\n\tplatforms    []string\n)\n\nfunc doBuild(_ *cobra.Command, _ []string) error {\n\tfor _, p := range platforms {\n\t\tenv, err := buildEnvironment(p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed constructing the build environment for %v: %v\", p, err)\n\t\t}\n\n\t\tif err = execBuildCommand(env); err != nil {\n\t\t\treturn fmt.Errorf(\"failed building for %v: %v\", p, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc isDirEmpty(name string) (bool, error) {\n\tf, err := os.Open(name)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer f.Close()\n\n\t_, err = f.Readdirnames(1)\n\tif err == io.EOF {\n\t\treturn true, nil\n\t}\n\treturn false, err\n}\n\nfunc buildEnvironment(platform string) (map[string]string, error) {\n\tparts := strings.SplitN(platform, \"/\", 2)\n\tif len(parts) != 2 {\n\t\treturn nil, fmt.Errorf(\"invalid platform %v\", platform)\n\t}\n\n\tplatformID := strings.Join(parts, \"-\")\n\tgoos := parts[0]\n\tarch := parts[1]\n\tgoarch := arch\n\tgoarm := \"\"\n\n\tif strings.HasPrefix(arch, \"armv\") {\n\t\tgoarch = \"arm\"\n\t\tgoarm = strings.TrimPrefix(arch, \"armv\")\n\t}\n\n\tenv := map[string]string{\n\t\t\"GOOS\":        goos,\n\t\t\"GOARCH\":      goarch,\n\t\t\"GOARM\":       goarm,\n\t\t\"GOTOOLCHAIN\": \"local\", // Disable automatic downloads of toolchains for reproducible builds.\n\t\t\"PLATFORM_ID\": platformID,\n\t}\n\n\tif err := loadCompilerSettings(goos, arch, env); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed while loading compiler settings: %v\", err)\n\t}\n\n\treturn env, nil\n}\n\ntype Compilers struct {\n\tGOOS map[string]struct {\n\t\tArch map[string]struct {\n\t\t\tEnv map[string]string `yaml:\",inline\"`\n\t\t} `yaml:\",inline\"`\n\t} `yaml:\",inline\"`\n}\n\nfunc loadCompilerSettings(goos, arch string, env map[string]string) error {\n\tdata, err := ioutil.ReadFile(\"/compilers.yaml\")\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"failed to read /compilers.yaml: %v\", err)\n\t}\n\n\tvar compilers Compilers\n\tif err = yaml.Unmarshal(data, &compilers); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse /compilers.yaml: %v\", err)\n\t}\n\n\tarches, found := compilers.GOOS[goos]\n\tif !found {\n\t\treturn fmt.Errorf(\"%v is not supported by this image\", goos)\n\t}\n\n\tsettings, found := arches.Arch[arch]\n\tif !found {\n\t\treturn fmt.Errorf(\"%v/%v is not supported by this image\", goos, arch)\n\t}\n\n\tfor k, v := range settings.Env {\n\t\tenv[k] = v\n\t}\n\n\treturn nil\n}\n\nfunc execBuildCommand(env map[string]string) error {\n\tcmd := exec.Command(\"sh\", \"-c\", buildCommand)\n\tcmd.Env = os.Environ()\n\tlogEnv := make([]string, 0, len(env))\n\tfor k, v := range env {\n\t\tkv := k + \"=\" + v\n\t\tcmd.Env = append(cmd.Env, kv)\n\t\tlogEnv = append(logEnv, kv)\n\t}\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\tcmd.Stdin = os.Stdin\n\n\tvar b strings.Builder\n\tsort.Strings(logEnv)\n\tfmt.Fprintf(&b, \">> Building using: cmd='%v', env=[%v]\", buildCommand, strings.Join(logEnv, \", \"))\n\n\tlog.Println(b.String())\n\treturn cmd.Run()\n}\n"
  },
  {
    "path": "go/base-arm/sources-debian10.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb [arch=arm64] http://archive.debian.org/debian buster main\ndeb [arch=arm64] http://archive.debian.org/debian-security buster/updates main\n"
  },
  {
    "path": "go/base-arm/sources-debian11.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb [arch=arm64] http://deb.debian.org/debian bullseye main\ndeb [arch=arm64] http://deb.debian.org/debian bullseye-updates main\ndeb [arch=arm64] http://deb.debian.org/debian-security/ bullseye-security main\n"
  },
  {
    "path": "go/base-arm/sources-debian12.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb [arch=arm64] http://deb.debian.org/debian bookworm main\ndeb [arch=arm64] http://deb.debian.org/debian-security/ bookworm-security main\n"
  },
  {
    "path": "go/base-arm/sources-debian8.list",
    "content": "deb [arch=arm64] http://archive.debian.org/debian jessie main\n"
  },
  {
    "path": "go/base-arm/sources-debian9.list",
    "content": "deb [arch=arm64] http://archive.debian.org/debian stretch main\ndeb [arch=arm64] http://archive.debian.org/debian-security stretch/updates main\n"
  },
  {
    "path": "go/darwin/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\nFROM --platform=linux/amd64  docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian{{ .DEBIAN_VERSION }}-amd64 AS build-llvm-apple\n{{- end }}\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN \\\n    apt-get -o Acquire::Check-Valid-Until=false update \\\n    && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \\\n        clang \\\n        llvm \\\n        cmake \\\n        patch \\\n{{- if and (ne .DEBIAN_VERSION \"10\") (ne .DEBIAN_VERSION \"11\") (ne .DEBIAN_VERSION \"12\") }}\n        python \\\n{{- end }}\n        libssl-dev \\\n        libxml2-dev \\\n        lzma-dev \\\n        llvm-dev \\\n        uuid-dev \\\n    && rm -rf /var/lib/apt/lists/*\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\") }}\nARG OSXCROSS_PATH=/usr/local/osxcross\nCOPY --from=build-llvm-apple /osxcross.tar.gz /tmp/osxcross.tar.gz\nRUN tar -xzf /tmp/osxcross.tar.gz -C / \\\n  && rm /tmp/osxcross.tar.gz\n{{- else }}\nARG OSXCROSS_PATH=/usr/osxcross\n{{- if or (eq .DEBIAN_VERSION \"8\") (eq .DEBIAN_VERSION \"9\") }}\nARG OSXCROSS_REV=3034f7149716d815bc473d0a7b35d17e4cf175aa\nARG SDK_VERSION=10.11\n{{- else }}\nARG OSXCROSS_REV=f873f534c6cdb0776e457af8c7513da1e02abe59\nARG SDK_VERSION=12.3\n{{- end }}\nARG DARWIN_VERSION=15\nARG OSX_VERSION_MIN=10.10\n\nCOPY sdks/MacOSX${SDK_VERSION}.sdk.tar.xz /tmp/osxcross/tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz\nRUN \\\n    cd /tmp/osxcross \\\n    && curl -sSL \"https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}\" \\\n        | tar -C /tmp/osxcross --strip=1 -xzf - \\\n    && UNATTENDED=yes ./build.sh >/dev/null \\\n    && mv target \"${OSXCROSS_PATH}\" \\\n    && rm -rf /tmp/osxcross \"/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man\"\n{{- end }}\n\nENV PATH=$PATH:$OSXCROSS_PATH/bin\n# Add osxcross libraries to the library PATH\nENV LD_LIBRARY_PATH=$OSXCROSS_PATH/lib:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && o64-clang helloWorld.c -o helloWorld.x86_64 \\\n  && file helloWorld.x86_64 \\\n  && file helloWorld.x86_64 | grep -c 'Mach-O 64-bit x86_64'\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\nRUN cd / \\\n  && oa64-clang helloWorld.c -o helloWorld.arm64 \\\n  && file helloWorld.arm64 \\\n  && file helloWorld.arm64 | grep -c 'Mach-O 64-bit arm64'\n\nRUN cd / \\\n  && lipo -create -output helloWorld.universal helloWorld.x86_64 helloWorld.arm64 \\\n  && file helloWorld.universal | grep 'Mach-O universal binary' \\\n  && rm helloWorld.*\n{{- end }}\n\n# MacOSX10.14 SDK does not have 32bits compiler\n{{- if and (ne .DEBIAN_VERSION \"10\") (ne .DEBIAN_VERSION \"11\") (ne .DEBIAN_VERSION \"12\")}}\nRUN cd / \\\n  && o32-clang helloWorld.c -o helloWorld.i368 \\\n  && file helloWorld.i368 \\\n  && file helloWorld.i368 | grep -c 'Mach-O i386' \\\n  && rm helloWorld.*\n{{- end }}\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/darwin/Makefile",
    "content": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n"
  },
  {
    "path": "go/darwin/rootfs/compilers.yaml",
    "content": "---\n\ndarwin:\n  amd64:\n    CC:  o64-clang\n    CXX: o64-clang++\n"
  },
  {
    "path": "go/darwin/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/darwin-arm64/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\nFROM --platform=linux/arm64  docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian{{ .DEBIAN_VERSION }}-arm64 AS build-llvm-apple\n{{- end }}\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base-arm${TAG_EXTENSION}\n\n{{- if and (ne .DEBIAN_VERSION \"10\") (ne .DEBIAN_VERSION \"11\") (ne .DEBIAN_VERSION \"12\")}}\nRUN echo \"This Docker image will work only with Debian >10\" && exit 1\n{{- end }}\n\nRUN \\\n    apt-get -o Acquire::Check-Valid-Until=false update \\\n    && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \\\n        cmake \\\n        patch \\\n        libssl-dev \\\n        libxml2-dev \\\n        lzma-dev \\\n        uuid-dev \\\n    && rm -rf /var/lib/apt/lists/*\n\nCOPY --from=build-llvm-apple /llvm-apple-Linux.tar.gz /tmp/llvm-apple-Linux.tar.gz\nRUN tar -xzf /tmp/llvm-apple-Linux.tar.gz --strip 1 -C /usr/local \\\n  && rm /tmp/llvm-apple-Linux.tar.gz\n\nARG OSXCROSS_PATH=/usr/local/osxcross\nCOPY --from=build-llvm-apple /osxcross.tar.gz /tmp/osxcross.tar.gz\nRUN tar -xzf /tmp/osxcross.tar.gz -C / \\\n  && rm /tmp/osxcross.tar.gz\n\nENV PATH=$PATH:$OSXCROSS_PATH/bin\n# Add osxcross libraries to the library PATH\nENV LD_LIBRARY_PATH=$OSXCROSS_PATH/lib:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && o64-clang helloWorld.c -o helloWorld.x86_64 \\\n  && file helloWorld.x86_64 \\\n  && file helloWorld.x86_64 | grep -c 'Mach-O 64-bit x86_64'\n\nRUN cd / \\\n  && oa64-clang helloWorld.c -o helloWorld.arm64 \\\n  && file helloWorld.arm64 \\\n  && file helloWorld.arm64 | grep -c 'Mach-O 64-bit arm64'\n\nRUN cd / \\\n  && oa64e-clang helloWorld.c -o helloWorld.arm64e \\\n  && file helloWorld.arm64e \\\n  && file helloWorld.arm64e | grep -c 'Mach-O 64-bit arm64'\n\nRUN cd / \\\n  && lipo -create -output helloWorld.universal helloWorld.x86_64 helloWorld.arm64e \\\n  && file helloWorld.universal | grep 'Mach-O universal binary' \\\n  && rm helloWorld.*\n\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/darwin-arm64/Makefile",
    "content": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n"
  },
  {
    "path": "go/darwin-arm64/rootfs/compilers.yaml",
    "content": "---\n\ndarwin:\n  arm64:\n    CC:  oa64-clang\n    CXX: oa64-clang++\n"
  },
  {
    "path": "go/darwin-arm64/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/llvm-apple/Dockerfile.tmpl",
    "content": "ARG DEBIAN_VERSION=9\nFROM debian:${DEBIAN_VERSION} AS BUILD_LLVM_APPLE\n\nARG DEBIAN_VERSION\n# Replace sources.list in order to use archive.debian.org.\nCOPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list\n\nRUN apt-get -o Acquire::Check-Valid-Until=false update -y --no-install-recommends --allow-unauthenticated \\\n        && apt-get upgrade -y --no-install-recommends --allow-unauthenticated \\\n        && apt-get dist-upgrade -y --no-install-recommends --allow-unauthenticated \\\n        && apt-get install -y --no-install-recommends --allow-unauthenticated \\\n            build-essential \\\n            ca-certificates \\\n            curl \\\n            git \\\n            gnupg \\\n            make \\\n            file \\\n            flex \\\n            bison \\\n            cmake \\\n            patch \\\n            libssl-dev \\\n            libxml2-dev \\\n            lzma-dev \\\n            uuid-dev \\\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n            binutils-multiarch \\\n            binutils-multiarch-dev \\\n            python3-venv \\\n            python3-pip \\\n            python3 \\\n{{- end }}\n        && rm -rf /var/lib/apt/lists/*\n\n#https://www.llvm.org/docs/CMake.html\n#https://github.com/apple/llvm-project\nRUN mkdir -p /tmp/llvm-project && cd /tmp/llvm-project \\\n    && curl -sSL \"https://github.com/apple/llvm-project/archive/refs/tags/swift-5.6.3-RELEASE.tar.gz\" \\\n      | tar -C /tmp/llvm-project --strip=1 -xzf - \\\n    && mkdir build && cd build \\\n    && cmake -DLLVM_ENABLE_PROJECTS=\"clang\" \\\n      -DCMAKE_BUILD_TYPE=\"Release\" \\\n      -DLLVM_TARGETS_TO_BUILD=\"X86;AArch64\" \\\n      -DLLVM_INCLUDE_TESTS=OFF \\\n      -DLLVM_INCLUDE_EXAMPLES=Off \\\n      -DLLVM_ENABLE_BACKTRACES=Off \\\n      -DLLVM_BUILD_32_BITS=OFF \\\n      /tmp/llvm-project/llvm \\\n    && cmake --build . \\\n    && cmake --build . --target package \\\n    && tar -xzf LLVM-*-Linux.tar.gz --strip 1 -C /usr/local\n\n# TODO think about replace this with the Docker image already created at https://github.com/crazy-max/docker-osxcross\nARG OSX_SDK=\"MacOSX12.3.sdk\"\n# Packaging the SDK on macOS https://github.com/tpoechtrager/osxcross#packaging-the-sdk\n# alternative SDK already generated\nARG OSXCROSS_PATH=/usr/local/osxcross\nARG OSXCROSS_REV=f873f534c6cdb0776e457af8c7513da1e02abe59\nARG OSX_VERSION_MIN=10.10\n\nRUN mkdir -p /tmp/osxcross\n# https://raw.githubusercontent.com/crazy-max/docker-osxcross/main/patches/lcxx.patch\nCOPY lcxx.patch /tmp/osxcross/lcxx.patch\n\nCOPY sdks/${OSX_SDK}.tar.xz /tmp/osxcross/tarballs/${OSX_SDK}.tar.xz\nRUN \\\n    cd /tmp/osxcross \\\n    && curl -sSL \"https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}\" \\\n        | tar -C /tmp/osxcross --strip=1 -xzf - \\\n    && patch -p1 < lcxx.patch \\\n    && UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 OSX_VERSION_MIN=${OSX_VERSION_MIN} TARGET_DIR=${OSXCROSS_PATH} ./build.sh >/dev/null \\\n    && rm -rf \"/usr/osxcross/SDK/${OSX_SDK}/usr/share/man\" \\\n    && tar -czf osxcross.tar.gz ${OSXCROSS_PATH}\n\nFROM debian:stable-slim\n\nCOPY --from=BUILD_LLVM_APPLE /tmp/llvm-project/build/LLVM-*-Linux.tar.gz /llvm-apple-Linux.tar.gz\nCOPY --from=BUILD_LLVM_APPLE /tmp/osxcross/osxcross.tar.gz /osxcross.tar.gz\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n\nENTRYPOINT /bin/bash\n"
  },
  {
    "path": "go/llvm-apple/Makefile",
    "content": "include ../Makefile.common\n\nSUFFIX         := $(shell basename $(CURDIR))\nTAG \t\t   := $(REPOSITORY)/$(NAME):$(SUFFIX)$(TAG_EXTENSION)\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n\ncopy-npcap:\n\t@echo \"NOOP\"\n\nbuild:\n\t@echo \">> Building $(TAG)\"\n\t@go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile\n\t@$(DOCKER_CMD) -t \"$(TAG)\" \\\n\t--build-arg REPOSITORY=$(REPOSITORY) \\\n\t--build-arg VERSION=$(VERSION) \\\n\t--build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \\\n\t--build-arg TAG_EXTENSION=$(TAG_EXTENSION) \\\n\t--build-arg IMAGE=\"$(TAG)\" \\\n\t--build-arg VCS_REF=\"$(VCS_REF)\" \\\n\t--build-arg VCS_URL=\"$(VCS_URL)\" \\\n\t--build-arg BUILD_DATE=\"$(BUILD_DATE)\" \\\n\t.\n\natomic-push:\n\t@echo \">> Pushing $(TAG)\"\n\t@docker push \"$(TAG)\"\n"
  },
  {
    "path": "go/llvm-apple/lcxx.patch",
    "content": "diff --git a/wrapper/target.cpp b/wrapper/target.cpp\nindex 82bf65c..a2520e2 100644\n--- a/wrapper/target.cpp\n+++ b/wrapper/target.cpp\n@@ -741,6 +741,9 @@ bool Target::setup() {\n           (stdlib == StdLib::libstdcxx && usegcclibs)) {\n         fargs.push_back(\"-nostdinc++\");\n         fargs.push_back(\"-Qunused-arguments\");\n+        if ((SDKOSNum >= OSVersion(11, 1)) && (stdlib == StdLib::libcxx)) {\n+          fargs.push_back(\"-lc++\");\n+        }\n       }\n\n       if (stdlib == StdLib::libstdcxx && usegcclibs && targetarch.size() < 2 &&\n"
  },
  {
    "path": "go/llvm-apple/sources-debian10.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb http://archive.debian.org/debian buster main\ndeb http://archive.debian.org/debian-security buster/updates main\n"
  },
  {
    "path": "go/llvm-apple/sources-debian11.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bullseye main\ndeb http://deb.debian.org/debian bullseye-updates main\ndeb http://deb.debian.org/debian-security/ bullseye-security main\n"
  },
  {
    "path": "go/llvm-apple/sources-debian12.list",
    "content": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bookworm main\ndeb http://deb.debian.org/debian-security/ bookworm-security main\n"
  },
  {
    "path": "go/main/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/main/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN \\\n  dpkg --add-architecture i386 \\\n  && apt-get -o Acquire::Check-Valid-Until=false update \\\n  && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \\\n  clang \\\n  g++ \\\n  gcc \\\n  gcc-multilib \\\n  libc6-dev \\\n  libc6-dev-i386 \\\n  linux-libc-dev:i386 \\\n  mingw-w64 \\\n  mingw-w64-tools \\\n  patch \\\n  xz-utils \\\n  unzip\n\n{{- if ne .DEBIAN_VERSION \"7\" }}\n# librpm-dev\nRUN apt install -y --no-install-recommends --allow-unauthenticated\\\n  librpm-dev \\\n  libxml2-dev \\\n  libsqlite3-dev\n\nRUN apt install -y --no-install-recommends --allow-unauthenticated\\\n  libsystemd-dev\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"9\") (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n# msitools\nRUN apt install -y --no-install-recommends --allow-unauthenticated\\\n  msitools\n{{- end }}\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && file helloWorld | cut -d \",\" -f 2 | grep -c 'x86-64' \\\n  && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-i386 \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-amd64 \\\n  && cd /libpcap/libpcap-1.8.1-i386 \\\n  && CFLAGS=\"-m32\" LDFLAGS=\"-m32\" ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no \\\n  && make \\\n  && cd /libpcap/libpcap-1.8.1-amd64 \\\n  && ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no \\\n  && make\n\nCOPY sdks/WpdPack_4_1_2.zip . \nRUN mkdir -p /libpcap/win \\\n  && echo \"ea799cf2f26e4afb1892938070fd2b1ca37ce5cf75fec4349247df12b784edbd  WpdPack_4_1_2.zip\" | sha256sum -c - \\\n  && unzip WpdPack_4_1_2.zip -d /libpcap/win \\\n  && rm WpdPack_4_1_2.zip \\\n  && cd /libpcap/win/WpdPack \\\n  && curl -sSLO https://raw.githubusercontent.com/elastic/beats/master/packetbeat/lib/windows-64/wpcap.dll \\\n  && echo \"0948518b229fb502b9c063966fc3afafbb749241a1c184f6eb7d532e00bce1d8  wpcap.dll\" | sha256sum -c - \\\n  && gendef wpcap.dll \\\n  && x86_64-w64-mingw32-dlltool \\\n  --as-flags=--64 \\\n  -m i386:x86-64 \\\n  -k \\\n  --output-lib /libpcap/win/WpdPack/Lib/x64/libwpcap.a \\\n  --input-def /libpcap/win/WpdPack/wpcap.def\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n  org.label-schema.name=$IMAGE \\\n  org.label-schema.vcs-ref=$VCS_REF \\\n  org.label-schema.vcs-url=$VCS_URL \\\n  org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/main/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/main/rootfs/compilers.yaml",
    "content": "---\n\nwindows:\n  386:\n    CC:  i686-w64-mingw32-gcc\n    CXX: i686-w64-mingw32-g++\n  amd64:\n    CC:  x86_64-w64-mingw32-gcc\n    CXX: x86_64-w64-mingw32-g++\n\ndarwin:\n  386:\n    CC:  o32-clang\n    CXX: o32-clang++\n  amd64:\n    CC:  o64-clang\n    CXX: o64-clang++\n\nlinux:\n  386:\n    CC:  gcc\n    CXX: g++\n  amd64:\n    CC:  gcc\n    CXX: g++\n"
  },
  {
    "path": "go/main/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/mips/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/mips/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN dpkg --add-architecture mips64el \\\n    && apt update -y --no-install-recommends \\\n    && apt upgrade -y --no-install-recommends \\\n    && apt full-upgrade -y --no-install-recommends \\\n    && apt install -qq -y --no-install-recommends \\\n        crossbuild-essential-mipsel \\\n        gcc-mips64el-linux-gnuabi64 \\\n        g++-mips64el-linux-gnuabi64 \\\n        gcc-mips64-linux-gnuabi64 \\\n        g++-mips64-linux-gnuabi64 \\\n        linux-libc-dev-mips64el-cross\n\nRUN apt install -qq -y \\\n        libc-dev:mips64el \\\n        libpopt-dev:mips64el \\\n        linux-libc-dev:mips64el\n\n{{- if eq .DEBIAN_VERSION \"9\" }}\n# librpm-dev\nRUN apt install -y \\\n        libelf1:mips64el \\\n        libicu-dev:mips64el \\\n        libicu57:mips64el \\\n        librpm-dev:mips64el \\\n        librpm3:mips64el \\\n        librpmio3:mips64el \\\n        librpmbuild3:mips64el \\\n        librpmsign3:mips64el \\\n        libxml2-dev:mips64el \\\n        libsqlite3-dev:mips64el \\\n        libnss3:mips64el \\\n        libsqlite3-0:mips64el \\\n        libxml2:mips64el \\\n        libsqlite3-0:mips64el\n\n# libsystemd-dev\n# RUN apt install -y \\\n#         libsystemd-dev:mips64el libsystemd0:mips64el liblz4-1:mips64el\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:mips64el\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:mips64el\n{{- end }}\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && mips64el-linux-gnuabi64-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && readelf -h helloWorld | grep -c 'MIPS R3000' \\\n  && readelf -h helloWorld | grep -c 'ELF64' \\\n  && readelf -h helloWorld | grep -c \"little endian\" \\\n  && rm helloWorld\n\n# Basic test\nRUN cd / \\\n  && mips64-linux-gnuabi64-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && readelf -h helloWorld | grep -c 'MIPS R3000' \\\n  && readelf -h helloWorld | grep -c 'ELF64' \\\n  && readelf -h helloWorld | grep -c \"big endian\" \\\n  && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mips64 \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mips64el \\\n  && cd /libpcap/libpcap-1.8.1-mips64 \\\n\t&& CC=mips64-linux-gnuabi64-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mips64-unknown-linux-gnu --with-pcap=linux \\\n\t&& make \\\n  && cd /libpcap/libpcap-1.8.1-mips64el \\\n\t&& CC=mips64el-linux-gnuabi64-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mips64el-unknown-linux-gnu --with-pcap=linux \\\n\t&& make\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/mips/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/mips/rootfs/compilers.yaml",
    "content": "---\n\nlinux:\n  mips64le:\n    CC:  mips64el-linux-gnuabi64-gcc\n    CXX: mips64el-linux-gnuabi64-g++\n  mips64:\n    CC:  mips64-linux-gnuabi64-gcc\n    CXX: mips64-linux-gnuabi64-g++\n"
  },
  {
    "path": "go/mips/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/mips32/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/mips32/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN dpkg --add-architecture mips \\\n    && apt update -y --no-install-recommends \\\n    && apt upgrade -y --no-install-recommends \\\n    && apt full-upgrade -y --no-install-recommends \\\n    && apt install -qq -y --no-install-recommends \\\n        crossbuild-essential-mipsel \\\n        gcc-mips-linux-gnu \\\n        g++-mips-linux-gnu \\\n        linux-libc-dev-mips-cross\n\nRUN apt install -qq -y \\\n        libc-dev:mips \\\n        libpopt-dev:mips \\\n        linux-libc-dev:mips\n\n{{- if eq .DEBIAN_VERSION \"9\" }}\n# librpm-dev\nRUN apt install -y \\\n        libelf1:mips \\\n        libicu-dev:mips \\\n        libicu57:mips \\\n        librpm-dev:mips \\\n        librpm3:mips \\\n        librpmio3:mips \\\n        librpmbuild3:mips \\\n        librpmsign3:mips \\\n        libxml2-dev:mips \\\n        libsqlite3-dev:mips \\\n        libnss3:mips \\\n        libsqlite3-0:mips \\\n        libxml2:mips \\\n        libsqlite3-0:mips\n\n# libsystemd-dev\n# RUN apt install -y \\\n#         libsystemd-dev:mips libsystemd0:mips liblz4-1:mips\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:mips\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:mips\n{{- end }}\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && mips-linux-gnu-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && readelf -h helloWorld | grep -c 'MIPS R3000' \\\n  && readelf -h helloWorld | grep -c 'ELF32' \\\n  && readelf -h helloWorld | grep -c \"big endian\" \\\n  && rm helloWorld\n\n# Basic test\nRUN cd / \\\n  && mipsel-linux-gnu-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && readelf -h helloWorld | grep -c 'MIPS R3000' \\\n  && readelf -h helloWorld | grep -c 'ELF32' \\\n  && readelf -h helloWorld | grep -c \"little endian\" \\\n  && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mips \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mipsel \\\n  && cd /libpcap/libpcap-1.8.1-mips \\\n\t&& CC=mips-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mips-unknown-linux-gnu --with-pcap=linux \\\n\t&& make \\\n  && cd /libpcap/libpcap-1.8.1-mipsel \\\n\t&& CC=mipsel-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mipsel-unknown-linux-gnu --with-pcap=linux \\\n\t&& make\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/mips32/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/mips32/rootfs/compilers.yaml",
    "content": "---\n\nlinux:\n  mips:\n    CC:  mips-linux-gnu-gcc\n    CXX: mips-linux-gnu-g++\n  mipsle:\n    CC:  mipsel-linux-gnu-gcc\n    CXX: mipsel-linux-gnu-g++\n"
  },
  {
    "path": "go/mips32/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/npcap/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/npcap/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-main${TAG_EXTENSION}\n\nCOPY lib/{{.NPCAP_FILE}} /installer/\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/npcap/Makefile",
    "content": "include ../Makefile.common\n\nSUFFIX = $(SUFFIX_NPCAP_VERSION)\n\npush:\n\t@[ \"$(REPOSITORY)\" = \"$(NPCAP_REPOSITORY)\" ] \\\n\t&& $(MAKE) atomic-push \\\n\t|| echo \"WARNING: $(SUFFIX_NPCAP_VERSION) can only be published in $(NPCAP_REPOSITORY)\"\n"
  },
  {
    "path": "go/npcap/lib/.gitkeep",
    "content": ""
  },
  {
    "path": "go/ppc/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/ppc/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN dpkg --add-architecture ppc64el \\\n    && apt update -y --no-install-recommends \\\n    && apt upgrade -y --no-install-recommends \\\n    && apt full-upgrade -y --no-install-recommends \\\n    && apt install -qq -y --no-install-recommends \\\n        g++-powerpc64-linux-gnu \\\n        gcc-powerpc64-linux-gnu \\\n        crossbuild-essential-ppc64el\n\nRUN apt install -qq -y \\\n        libc-dev:ppc64el \\\n        libpopt-dev:ppc64el \\\n        linux-libc-dev:ppc64el\n\n{{- if eq .DEBIAN_VERSION \"9\" }}\nRUN apt install -qq -y \\\n        libelf1:ppc64el \\\n        libicu-dev:ppc64el \\\n        libicu57:ppc64el \\\n        librpm-dev:ppc64el \\\n        libxml2-dev:ppc64el \\\n        libxml2:ppc64el \\\n        librpm3:ppc64el \\\n        librpmio3:ppc64el \\\n        librpmbuild3:ppc64el \\\n        librpmsign3:ppc64el \\\n        libsqlite3-dev:ppc64el \\\n        libnss3:ppc64el \\\n        libsqlite3-0:ppc64el\n\n# RUN apt install -y \\\n#         libsystemd-dev:ppc64el libsystemd0:ppc64el liblz4-1:ppc64el\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:ppc64el\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:ppc64el\n{{- end }}\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && powerpc64le-linux-gnu-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && readelf -h helloWorld | grep -c 'PowerPC64' \\\n  && readelf -h helloWorld | grep -c 'ELF64' \\\n  && readelf -h helloWorld | grep -c \"little endian\" \\\n  && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-ppc64 \\\n  && cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-ppc64el \\\n  && cd /libpcap/libpcap-1.8.1-ppc64 \\\n\t&& CC=powerpc64-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=ppc64-unknown-linux-gnu --with-pcap=linux \\\n\t&& make \\\n  && cd /libpcap/libpcap-1.8.1-ppc64el \\\n\t&& CC=powerpc64le-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=ppc64el-unknown-linux-gnu --with-pcap=linux \\\n\t&& make\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/ppc/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/ppc/rootfs/compilers.yaml",
    "content": "---\n\nlinux:\n  ppc64:\n    CC:  powerpc64-linux-gnu-gcc\n    CXX: powerpc64-linux-gnu-g++\n  ppc64le:\n    CC:  powerpc64le-linux-gnu-gcc\n    CXX: powerpc64le-linux-gnu-g++\n"
  },
  {
    "path": "go/ppc/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/s390x/.dockerignore",
    "content": "Makefile\n"
  },
  {
    "path": "go/s390x/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}\n\nRUN dpkg --add-architecture s390x \\\n    && apt update -y --no-install-recommends \\\n    && apt upgrade -y --no-install-recommends \\\n    && apt full-upgrade -y --no-install-recommends \\\n    && apt install -qq -y --no-install-recommends \\\n        g++-s390x-linux-gnu \\\n        gcc-s390x-linux-gnu\n\nRUN apt install -qq -y \\\n        libc-dev:s390x \\\n        libpopt-dev:s390x \\\n        linux-libc-dev:s390x\n\n{{- if eq .DEBIAN_VERSION \"9\" }}\nRUN apt install -qq -y \\\n        libelf1:s390x \\\n        libicu-dev:s390x \\\n        libicu57:s390x \\\n        librpm-dev:s390x \\\n        libxml2-dev:s390x \\\n        libxml2:s390x \\\n        librpm3:s390x \\\n        librpmio3:s390x \\\n        librpmbuild3:s390x \\\n        librpmsign3:s390x \\\n        libsqlite3-dev:s390x \\\n        libnss3:s390x \\\n        libsqlite3-0:s390x\n\n# RUN apt install -y \\\n#         libsystemd-dev:s390x libsystemd0:s390x liblz4-1:s390x\n{{- end }}\n\n{{- if or (eq .DEBIAN_VERSION \"10\") (eq .DEBIAN_VERSION \"11\") (eq .DEBIAN_VERSION \"12\")}}\n# librpm-dev\nRUN apt install -y \\\n        librpm-dev:s390x\n\n# libsystemd-dev\nRUN apt install -y \\\n        libsystemd-dev:s390x\n{{- end }}\n\nRUN rm -rf /var/lib/apt/lists/*\n\nCOPY rootfs /\n\n# Basic test\nRUN cd / \\\n  && s390x-linux-gnu-gcc helloWorld.c -o helloWorld \\\n  && file helloWorld \\\n  && readelf -h helloWorld \\\n  && readelf -h helloWorld | grep -c 'IBM S/390' \\\n  && readelf -h helloWorld | grep -c 'ELF64' \\\n  && readelf -h helloWorld | grep -c \"big endian\" \\\n  && rm helloWorld.c helloWorld\n\nRUN cd /libpcap/libpcap-1.8.1 \\\n\t&& CC=s390x-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=s390x-ibm-linux-gnu --with-pcap=linux \\\n\t&& make\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/s390x/Makefile",
    "content": "include ../Makefile.common\n"
  },
  {
    "path": "go/s390x/rootfs/compilers.yaml",
    "content": "---\n\nlinux:\n  s390x:\n    CC:  s390x-linux-gnu-gcc\n    CXX: s390x-linux-gnu-g++\n"
  },
  {
    "path": "go/s390x/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/windows-arm64/Dockerfile.tmpl",
    "content": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\n\nFROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base-arm${TAG_EXTENSION}\n\n#ARG LLVM_MINGW64_VER=20250826\nARG LLVM_MINGW64_VER=20250910\nARG LLVM_MINGW_UBUNTU_REL='22.04'\nARG LLVM_MINGW64_SRC=\"https://github.com/mstorsjo/llvm-mingw/releases/download\"\nENV LLVM_MINGW64_VER=\"${LLVM_MINGW64_VER}\"\nENV LLVM_MINGW64_SRC=\"$LLVM_MINGW64_SRC\"\n\n{{- if ne .DEBIAN_VERSION \"12\"}}\nRUN echo \"This Docker image will work only with Debian >12\" && exit 1\n{{- end }}\n\nRUN \\\n    apt-get -o Acquire::Check-Valid-Until=false update \\\n    && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \\\n        cmake \\\n        patch \\\n        libssl-dev \\\n        libxml2-dev \\\n        lzma-dev \\\n        uuid-dev \\\n        make \\\n        bash \\\n        wget \\\n    && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /tmp\nCOPY --chmod=0755 scripts/setup-llvm-mingw64.sh /tmp/\nRUN /tmp/setup-llvm-mingw64.sh\n\nCOPY --chmod=0755 scripts/install-llvm-mingw64.sh /tmp/install-llvm-mingw64.sh\nRUN /tmp/install-llvm-mingw64.sh /tmp/llvm-mingw64 && rm -rf /tmp/*\n\nCOPY rootfs /\n\n# Basic test\nRUN which aarch64-w64-mingw32-gcc\n\nRUN cd / \\\n  && aarch64-w64-mingw32-gcc helloWorld.c -o helloWorld.arm64 \\\n  && file helloWorld.arm64 \\\n  && file helloWorld.arm64 | grep -c 'PE32+ executable (console) Aarch64, for MS Windows'\n\nRUN cd / \\\n  && aarch64-w64-mingw32uwp-gcc helloWorld.c -o helloWorld.arm64e \\\n  && file helloWorld.arm64e \\\n  && file helloWorld.arm64e | grep -c 'PE32+ executable (console) Aarch64, for MS Windows'\n\nENV CGO_ENABLED=1\n#ENV CC aarch64-w64-mingw32-gcc\n#ENV CXX aarch64-w64-mingw32-g++\nENV CGO_FLAGS=\"$CGO_FLAGS -I/usr/generic-w64-mingw32/include\"\nENV CGO_CFLAGS=\"-fno-addrsig\"\nRUN go env\n\nRUN aarch64-w64-mingw32-gcc --version\n\nRUN go clean -cache -modcache -i -r\n\n# Build-time metadata as defined at http://label-schema.org.\nARG BUILD_DATE\nARG IMAGE\nARG VCS_REF\nARG VCS_URL\nLABEL org.label-schema.build-date=$BUILD_DATE \\\n      org.label-schema.name=$IMAGE \\\n      org.label-schema.vcs-ref=$VCS_REF \\\n      org.label-schema.vcs-url=$VCS_URL \\\n      org.label-schema.schema-version=\"1.0\"\n"
  },
  {
    "path": "go/windows-arm64/Makefile",
    "content": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\natomic-push:\n\t@echo \"Already done by buildx (.buildkite/scripts/buildx.sh).\"\nendif\n"
  },
  {
    "path": "go/windows-arm64/rootfs/compilers.yaml",
    "content": "---\n\nwindows:\n  arm64:\n    CC:  aarch64-w64-mingw32-gcc\n    CXX: aarch64-w64-mingw32-g++\n\n"
  },
  {
    "path": "go/windows-arm64/rootfs/helloWorld.c",
    "content": "#include <stdio.h>\nint main() {\n   printf(\"Hello, World!\");\n   return 0;\n}\n"
  },
  {
    "path": "go/windows-arm64/scripts/install-llvm-mingw64.sh",
    "content": "#!/usr/bin/env bash\n#\n# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2fd60\n#\nset -e\nset -o pipefail\n\ntrap 'echo \"$0: Error on line $LINENO\" >&2' ERR\n\nsrc=\"$1\"\nif [ -z \"$src\" ]; then\n    echo \"Error: missing source dir\"\n    exit 1\nfi\n\nbase_dir='/usr'\n\necho \":: Installing llvm-mingw64...\"\necho \"Source dir: $src\"\n\ncd \"$src\" || exit 1\nfind . -mindepth 1 -maxdepth 1 -type d ! -name . | while read -r subdir; do\n    dst_dir=\"$(basename \"$subdir\")\"\n\n    case \"$dst_dir\" in\n    bin)\n        perm=755\n        ;;\n    *)\n        perm=644\n        ;;\n    esac\n\n    find \"$subdir\" -type f | while read -r file; do\n        dst=\"$base_dir/${file/.\\//}\"\n        mkdir -p \"$(dirname \"$dst\")\"\n        install -m $perm \"$file\" \"$dst\"\n    done\ndone\n\necho \":: Restoring symlinks...\"\nwhile IFS= read -r line; do\n    link_src=$(echo \"$line\" | awk '{print $1}')\n    link_src=\"$base_dir/$link_src\"\n\n    link_dest=$(echo \"$line\" | awk '{print $2}')\n    link_dest=\"$(realpath \"$base_dir/$link_dest\")\"\n    ln -s \"$link_dest\" \"$link_src\"\ndone <symlinks.txt\n\necho \":: Creating symlink for aarch64-w64-mingw32 headers...\"\nif [ ! -d \"$base_dir/aarch64-w64-mingw32/include\" ]; then\n    if [ -d \"$base_dir/generic-w64-mingw32/include\" ]; then\n        ln -s \"$base_dir/generic-w64-mingw32/include\" \"$base_dir/aarch64-w64-mingw32/include\"\n        echo \"Created symlink: $base_dir/aarch64-w64-mingw32/include -> $base_dir/generic-w64-mingw32/include\"\n    else\n        echo \"Warning: $base_dir/generic-w64-mingw32/include does not exist\"\n    fi\nelse\n    echo \"Include directory already exists, skipping symlink creation\"\nfi\n\necho \":: Cleanup\"\ncd ..\nrm -rf \"$src\"\n"
  },
  {
    "path": "go/windows-arm64/scripts/setup-llvm-mingw64.sh",
    "content": "#!/usr/bin/env bash\n#\n# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2fd60\n#\nset -e\nset -o pipefail\n\ntrap 'echo \"$0: Error on line $LINENO\" >&2' ERR\n\nif [ -z \"$LLVM_MINGW64_SRC\" ]; then\n    echo \"Error: LLVM_MINGW64_SRC is undefined\"\n    env\n    exit 1\nfi\n\nif [ -z \"$LLVM_MINGW_UBUNTU_REL\" ]; then\n    echo \"Error: LLVM_MINGW_UBUNTU_REL is undefined\"\n    env\n    exit 1\nfi\n\nif [ -z \"$LLVM_MINGW64_VER\" ]; then\n    echo \"Error: LLVM_MINGW64_VER is undefined\"\n    env\n    exit 1\nfi\n\napt update && apt install xz-utils --yes\n\ncase \"$(uname -m)\" in\naarch64 | arm64)\n    m_arch=\"aarch64\"\n    ;;\nx86_64 | amd64)\n    m_arch=\"x86_64\"\n    ;;\n*)\n    echo \"Error: unsupported architecture $(uname -m)\"\n    exit 1\n    ;;\nesac\n\npkg_dir=\"llvm-mingw-$LLVM_MINGW64_VER-ucrt-ubuntu-$LLVM_MINGW_UBUNTU_REL-$m_arch\"\npkg_file=\"$pkg_dir.tar.xz\"\nsrc_url=\"$LLVM_MINGW64_SRC/$LLVM_MINGW64_VER/$pkg_file\"\necho \":: Downloading $src_url ...\"\nwget \"$src_url\"\n# wget -q --spider \"$src_url\"\n\nif [ ! -f \"$pkg_file\" ]; then\n    echo \"Error: can't find downloaded file $pkg_file\"\n    ls -la\n    exit 1\nfi\n\necho \":: Extracting file...\"\ntar -xf \"$pkg_file\"\nrm \"$pkg_file\"\n\necho \":: Preparing file list...\"\nmv \"$pkg_dir\" llvm-mingw64\ncd llvm-mingw64\n\n# Keep llvm-mingw64 only for arm target to avoid conflict with gcc-mingw64\n# Remove x86_64 and i686 binaries but keep the generic headers\nrm -f bin/x86_64* bin/i686*\nrm -rf i686-w64-mingw32/bin i686-w64-mingw32/lib\nrm -rf x86_64-w64-mingw32/bin x86_64-w64-mingw32/lib\n# Keep the include directories as they contain shared headers\n# Only remove the i686 and x86_64 directories if they don't contain needed includes\nif [ -d \"i686-w64-mingw32\" ]; then\n    find i686-w64-mingw32 -mindepth 1 ! -path \"*/include/*\" -delete\n    if [ -z \"$(ls -A i686-w64-mingw32)\" ]; then\n        rm -rf i686-w64-mingw32\n    fi\nfi\nif [ -d \"x86_64-w64-mingw32\" ]; then\n    find x86_64-w64-mingw32 -mindepth 1 ! -path \"*/include/*\" -delete\n    if [ -z \"$(ls -A x86_64-w64-mingw32)\" ]; then\n        rm -rf x86_64-w64-mingw32\n    fi\nfi\n\n# Backup symlinks\nfind . -type l | while read -r symlink; do\n    src=\"${symlink/.\\//}\"\n    dst=\"$(dirname \"$src\")/$(readlink \"$symlink\")\"\n    echo \"$src $dst\" >>symlinks.txt\n    rm \"$symlink\"\ndone\n"
  },
  {
    "path": "template.go",
    "content": "// Licensed to Elasticsearch B.V. under one or more contributor\n// license agreements. See the NOTICE file distributed with\n// this work for additional information regarding copyright\n// ownership. Elasticsearch B.V. licenses this file to you under\n// the Apache License, Version 2.0 (the \"License\"); you may\n// not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied.  See the License for the\n// specific language governing permissions and limitations\n// under the License.\n\npackage main\n\nimport (\n\t\"bytes\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"text/template\"\n)\n\nvar usageText = `\nUsage: template -t <tmpl file> [-o output]\n  This command renders the specified template file using the Go text/template\n  package. It makes the current environment available as variables.\nOptions:\n`[1:]\n\nvar (\n\ttemplateFile string\n\toutputFile   string\n)\n\nfunc init() {\n\tflag.StringVar(&templateFile, \"t\", \"\", \"template file\")\n\tflag.StringVar(&outputFile, \"o\", \"\", \"output file\")\n\tflag.Usage = func() {\n\t\tfmt.Fprintf(os.Stderr, usageText)\n\t\tflag.PrintDefaults()\n\t}\n}\n\nfunc main() {\n\tflag.Parse()\n\tlog.SetFlags(0)\n\n\tif templateFile == \"\" {\n\t\tlog.Fatal(\"Template file (-t) is required.\")\n\t}\n\n\tt := template.Must(template.\n\t\tNew(filepath.Base(templateFile)).\n\t\tParseFiles(templateFile))\n\n\tdata := envVars()\n\tbuf := new(bytes.Buffer)\n\tif err := t.Execute(buf, data); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tif outputFile == \"-\" || outputFile == \"\" {\n\t\tfmt.Println(buf.String())\n\t} else {\n\t\tif err := ioutil.WriteFile(outputFile, buf.Bytes(), 0644); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n}\n\nfunc envVars() map[string]string {\n\tenv := map[string]string{}\n\tfor _, e := range os.Environ() {\n\t\tparts := strings.SplitN(e, \"=\", 2)\n\t\tenv[parts[0]] = parts[1]\n\t}\n\treturn env\n}\n"
  }
]