diff --git a/.dockerignore b/.dockerignore index a8eeb4b41f..df466067e1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,3 @@ .gopath bundles vendor/pkg - diff --git a/.github/actions/always/action.yml b/.github/actions/always/action.yml new file mode 100644 index 0000000000..a5bf5b9faf --- /dev/null +++ b/.github/actions/always/action.yml @@ -0,0 +1,38 @@ +--- +name: cleanup +# https://github.com/product-os/flowzone/tree/master/.github/actions +inputs: + json: + description: "JSON stringified object containing all the inputs from the calling workflow" + required: true + secrets: + description: "JSON stringified object containing all the secrets from the calling workflow" + required: true + + # --- custom environment + VERBOSE: + type: string + default: "true" + +runs: + # https://docs.github.com/en/actions/creating-actions/creating-a-composite-action + using: "composite" + steps: + # delete draft releases if the pull request is closed without merging + - name: Delete draft release + if: | + runner.os == 'Linux' && + github.event_name == 'pull_request' && + github.event.pull_request.merged == false && + github.event.action == 'closed' + + shell: bash + run: | + set -ea + + [[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x + + gh release delete --yes '${{ github.event.pull_request.head.ref }}' || true + + env: + GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }} diff --git a/.github/actions/finalize/action.yml b/.github/actions/finalize/action.yml new file mode 100644 index 0000000000..468c524bf7 --- /dev/null +++ b/.github/actions/finalize/action.yml @@ -0,0 +1,52 @@ +--- +name: publish GitHub release +# https://github.com/product-os/flowzone/tree/master/.github/actions +inputs: + json: + description: "JSON stringified object containing all the inputs from the calling workflow" + required: true + secrets: + description: "JSON stringified object containing all the secrets from the calling workflow" + required: true + + # --- custom environment + VERBOSE: + type: string + default: "true" + +runs: + # https://docs.github.com/en/actions/creating-actions/creating-a-composite-action + using: "composite" + steps: + # https://docs.github.com/en/rest/releases + - name: Finalize release + if: runner.os == 'Linux' + shell: bash + run: | + set -ea + + [[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x + + # prevent git from existing with 141 + set +o pipefail + + current_version="v$(yq e '.[0].version' .versionbot/CHANGELOG.yml)" + previous_version="v$(yq e '.[1].version' .versionbot/CHANGELOG.yml)" + release_notes="$(git log ${previous_version}..HEAD --pretty=reference)" + + gh release edit '${{ github.event.pull_request.head.ref }}' \ + --notes "${release_notes}" \ + --title "${current_version}" \ + --tag "${current_version}" \ + --prerelease=false \ + --draft=false + + release_id="$(gh api "/repos/${{ github.repository }}/releases/tags/${current_version}" \ + -H 'Accept: application/vnd.github+json' | jq -r .id)" + + gh api --method PATCH "/repos/${{ github.repository }}/releases/${release_id}" \ + -H 'Accept: application/vnd.github+json' \ + -F make_latest="true" + + env: + GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }} diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 0000000000..044320948e --- /dev/null +++ b/.github/actions/publish/action.yml @@ -0,0 +1,67 @@ +--- +name: build and draft GitHub release +# https://github.com/product-os/flowzone/tree/master/.github/actions +inputs: + json: + description: "JSON stringified object containing all the inputs from the calling workflow" + required: true + secrets: + description: "JSON stringified object containing all the secrets from the calling workflow" + required: true + + # --- custom environment + VERBOSE: + type: string + default: "true" + +runs: + # https://docs.github.com/en/actions/creating-actions/creating-a-composite-action + using: "composite" + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # https://github.com/moby/moby/blob/master/.github/workflows + - name: Build release + uses: docker/bake-action@v2 + with: + targets: cross + env: + DOCKER_CROSSPLATFORMS: ${{ env.matrix_value }} + + # https://github.com/product-os/scripts/tree/master/balena-engine + # https://github.com/product-os/ci-images/tree/master/pipelines/balena-engine + # https://github.com/product-os/balena-concourse/blob/master/pipelines/github-events/template.yml + - name: Package release + shell: bash + run: | + set -ea + + [[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x + + version="v$(yq e '.[0].version' .versionbot/CHANGELOG.yml)" + + arch="$(echo '${{ env.matrix_value }}' \ + | sed 's#linux/##g' \ + | sed 's#arm/v#armv#g' \ + | sed 's#v5#v5e#g' \ + | sed 's#v6#v6l#g' \ + | sed 's#v7#v7hf#g')" + + mkdir -p dist + + tar -czvf dist/balena-engine-${version}-${arch}.tar.gz \ + -C bundles/cross/${{ env.matrix_value }} . + + # https://github.com/softprops/action-gh-release#-customizing + - name: Publish release assets + uses: softprops/action-gh-release@v1 + with: + # use PR branch name for draft releases + name: ${{ github.event.pull_request.head.ref }} + tag_name: ${{ github.event.pull_request.head.ref }} + draft: true + prerelease: true + token: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }} + files: | + dist/*.tar.gz diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 0000000000..c98397a06f --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,42 @@ +--- +name: prepare draft release +# https://github.com/product-os/flowzone/tree/master/.github/actions +inputs: + json: + description: "JSON stringified object containing all the inputs from the calling workflow" + required: true + secrets: + description: "JSON stringified object containing all the secrets from the calling workflow" + required: true + + # --- custom environment + VERBOSE: + type: string + default: "true" + +runs: + # https://docs.github.com/en/actions/creating-actions/creating-a-composite-action + using: "composite" + steps: + - name: Delete previous draft release + shell: bash + run: | + set -ea + + [[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x + + gh release delete --yes '${{ github.event.pull_request.head.ref }}' || true + + env: + GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }} + + # https://github.com/softprops/action-gh-release#-customizing + - name: Create release placeholder + uses: softprops/action-gh-release@v1 + with: + # use PR branch name for draft releases + name: ${{ github.event.pull_request.head.ref }} + tag_name: ${{ github.event.pull_request.head.ref }} + draft: true + prerelease: true + token: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }} diff --git a/.github/workflows/flowzone.yml b/.github/workflows/flowzone.yml new file mode 100644 index 0000000000..b43875337b --- /dev/null +++ b/.github/workflows/flowzone.yml @@ -0,0 +1,17 @@ +name: Flowzone + +on: + pull_request: + types: [opened, synchronize, closed] + branches: + - "main" + - "master" + +jobs: + flowzone: + name: Flowzone + uses: product-os/flowzone/.github/workflows/flowzone.yml@master + secrets: inherit + with: + # https://github.com/golang/go/blob/master/src/go/build/syslist.go + custom_publish_matrix: "linux/386,linux/amd64,linux/arm/v5,linux/arm/v6,linux/arm/v7,linux/arm64" diff --git a/.resinci.yml b/.resinci.yml deleted file mode 100644 index 0817f26b74..0000000000 --- a/.resinci.yml +++ /dev/null @@ -1,3 +0,0 @@ -docker: - publish: false - builds: [] diff --git a/Dockerfile b/Dockerfile index 44e98e78b5..65b1a0d7fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,12 @@ ARG CROSS="false" ARG SYSTEMD="false" # IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored -ARG GO_VERSION=1.16.10 +ARG GO_VERSION=1.19.3 ARG DEBIAN_FRONTEND=noninteractive ARG VPNKIT_VERSION=0.5.0 ARG DOCKER_BUILDTAGS="apparmor seccomp no_btrfs no_cri no_devmapper no_zfs exclude_disk_quota exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_zfs" -ARG BASE_DEBIAN_DISTRO="buster" +ARG BASE_DEBIAN_DISTRO="bullseye" ARG GOLANG_IMAGE="golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO}" FROM ${GOLANG_IMAGE} AS base @@ -20,26 +20,13 @@ ENV GO111MODULE=off FROM base AS criu ARG DEBIAN_FRONTEND -# Install dependency packages specific to criu +ADD --chmod=0644 https://mirrorcache.opensuse.org/repositories/devel:/tools:/criu/Debian_11/Release.key /etc/apt/trusted.gpg.d/criu.gpg.asc RUN --mount=type=cache,sharing=locked,id=moby-criu-aptlib,target=/var/lib/apt \ --mount=type=cache,sharing=locked,id=moby-criu-aptcache,target=/var/cache/apt \ - apt-get update && apt-get install -y --no-install-recommends \ - libcap-dev \ - libnet-dev \ - libnl-3-dev \ - libprotobuf-c-dev \ - libprotobuf-dev \ - protobuf-c-compiler \ - protobuf-compiler \ - python-protobuf - -# Install CRIU for checkpoint/restore support -ARG CRIU_VERSION=3.14 -RUN mkdir -p /usr/src/criu \ - && curl -sSL https://github.com/checkpoint-restore/criu/archive/v${CRIU_VERSION}.tar.gz | tar -C /usr/src/criu/ -xz --strip-components=1 \ - && cd /usr/src/criu \ - && make \ - && make PREFIX=/build/ install-criu + echo 'deb [trusted=yes] https://mirrorcache.opensuse.org/repositories/devel:/tools:/criu/Debian_11/ /' > /etc/apt/sources.list.d/criu.list \ + && apt-get update \ + && apt-get install -y --no-install-recommends criu \ + && install -D /usr/sbin/criu /build/criu FROM base AS registry WORKDIR /go/src/github.com/docker/distribution @@ -119,7 +106,6 @@ FROM cross-${CROSS} as dev-base FROM dev-base AS runtime-dev-cross-false ARG DEBIAN_FRONTEND -RUN echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list RUN --mount=type=cache,sharing=locked,id=moby-cross-false-aptlib,target=/var/lib/apt \ --mount=type=cache,sharing=locked,id=moby-cross-false-aptcache,target=/var/cache/apt \ apt-get update && apt-get install -y --no-install-recommends \ @@ -128,26 +114,23 @@ RUN --mount=type=cache,sharing=locked,id=moby-cross-false-aptlib,target=/var/lib libapparmor-dev \ libbtrfs-dev \ libdevmapper-dev \ - libseccomp-dev/buster-backports \ + libseccomp-dev \ libsystemd-dev \ libudev-dev FROM --platform=linux/amd64 runtime-dev-cross-false AS runtime-dev-cross-true ARG DEBIAN_FRONTEND # These crossbuild packages rely on gcc-, but this doesn't want to install -# on non-amd64 systems. -# Additionally, the crossbuild-amd64 is currently only on debian:buster, so -# other architectures cannnot crossbuild amd64. -RUN echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list +# on non-amd64 systems, so other architectures cannot crossbuild amd64. RUN --mount=type=cache,sharing=locked,id=moby-cross-true-aptlib,target=/var/lib/apt \ --mount=type=cache,sharing=locked,id=moby-cross-true-aptcache,target=/var/cache/apt \ apt-get update && apt-get install -y --no-install-recommends \ libapparmor-dev:arm64 \ libapparmor-dev:armel \ libapparmor-dev:armhf \ - libseccomp-dev:arm64/buster-backports \ - libseccomp-dev:armel/buster-backports \ - libseccomp-dev:armhf/buster-backports + libseccomp-dev:arm64 \ + libseccomp-dev:armel \ + libseccomp-dev:armhf FROM runtime-dev-cross-${CROSS} AS runtime-dev @@ -185,25 +168,26 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ PREFIX=/build /tmp/install/install.sh proxy FROM base AS golangci_lint -ARG GOLANGCI_LINT_COMMIT +# FIXME: when updating golangci-lint, remove the temporary "nolint" in https://github.com/moby/moby/blob/7860686a8df15eea9def9e6189c6f9eca031bb6f/libnetwork/networkdb/cluster.go#L246 +ARG GOLANGCI_LINT_VERSION=v1.49.0 RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ - --mount=type=bind,src=hack/dockerfile/install,target=/tmp/install \ - PREFIX=/build /tmp/install/install.sh golangci_lint + GOBIN=/build/ GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \ + && /build/golangci-lint --version FROM base AS gotestsum -ARG GOTESTSUM_COMMIT +ARG GOTESTSUM_VERSION=v1.8.1 RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ - --mount=type=bind,src=hack/dockerfile/install,target=/tmp/install \ - PREFIX=/build /tmp/install/install.sh gotestsum + GOBIN=/build/ GO111MODULE=on go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}" \ + && /build/gotestsum --version FROM base AS shfmt -ARG SHFMT_COMMIT +ARG SHFMT_VERSION=v3.0.2 RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ - --mount=type=bind,src=hack/dockerfile/install,target=/tmp/install \ - PREFIX=/build /tmp/install/install.sh shfmt + GOBIN=/build/ GO111MODULE=on go install "mvdan.cc/sh/v3/cmd/shfmt@${SHFMT_VERSION}" \ + && /build/shfmt --version # FROM dev-base AS dockercli # ARG DOCKERCLI_CHANNEL @@ -221,6 +205,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ # --mount=type=bind,src=hack/dockerfile/install,target=/tmp/install \ # PREFIX=/build /tmp/install/install.sh runc # + FROM dev-base AS tini ARG DEBIAN_FRONTEND ARG TINI_COMMIT @@ -270,15 +255,17 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \ --mount=type=cache,sharing=locked,id=moby-dev-aptcache,target=/var/cache/apt \ apt-get update && apt-get install -y --no-install-recommends \ apparmor \ - aufs-tools \ bash-completion \ bzip2 \ + inetutils-ping \ + iproute2 \ iptables \ jq \ libcap2-bin \ libnet1 \ libnl-3-200 \ libprotobuf-c1 \ + libyajl2 \ net-tools \ patch \ pigz \ @@ -286,13 +273,15 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \ python3-setuptools \ python3-wheel \ sudo \ + systemd-journal-remote \ thin-provisioning-tools \ uidmap \ vim \ vim-common \ xfsprogs \ xz-utils \ - zip + zip \ + zstd # Switch to use iptables instead of nftables (to match the CI hosts) @@ -301,7 +290,8 @@ RUN update-alternatives --set iptables /usr/sbin/iptables-legacy || true \ && update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy || true \ && update-alternatives --set arptables /usr/sbin/arptables-legacy || true -RUN pip3 install yamllint==1.26.1 +ARG YAMLLINT_VERSION=1.27.1 +RUN pip3 install yamllint==${YAMLLINT_VERSION} # COPY --from=dockercli /build/ /usr/local/cli COPY --from=frozen-images /build/ /docker-frozen-images @@ -336,9 +326,6 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \ dbus-user-session \ systemd \ systemd-sysv -RUN mkdir -p hack \ - && curl -o hack/dind-systemd https://raw.githubusercontent.com/AkihiroSuda/containerized-systemd/b70bac0daeea120456764248164c21684ade7d0d/docker-entrypoint.sh \ - && chmod +x hack/dind-systemd ENTRYPOINT ["hack/dind-systemd"] FROM dev-systemd-${SYSTEMD} AS dev @@ -354,6 +341,8 @@ ARG PRODUCT ENV PRODUCT=${PRODUCT} ARG DEFAULT_PRODUCT_LICENSE ENV DEFAULT_PRODUCT_LICENSE=${DEFAULT_PRODUCT_LICENSE} +ARG PACKAGER_NAME +ENV PACKAGER_NAME=${PACKAGER_NAME} ARG DOCKER_BUILDTAGS ENV DOCKER_BUILDTAGS="${DOCKER_BUILDTAGS}" ENV PREFIX=/build @@ -382,7 +371,6 @@ FROM binary-base AS build-cross ARG DOCKER_CROSSPLATFORMS RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,target=/go/src/github.com/docker/docker \ - --mount=type=tmpfs,target=/go/src/github.com/docker/docker/autogen \ hack/make.sh cross FROM scratch AS binary diff --git a/Dockerfile.buildx b/Dockerfile.buildx deleted file mode 100644 index d3a46964dd..0000000000 --- a/Dockerfile.buildx +++ /dev/null @@ -1,26 +0,0 @@ -ARG GO_VERSION=1.13.15 -ARG BUILDX_COMMIT=v0.5.1 -ARG BUILDX_REPO=https://github.com/docker/buildx.git - -FROM golang:${GO_VERSION}-buster AS build -ARG BUILDX_REPO -RUN git clone "${BUILDX_REPO}" /buildx -WORKDIR /buildx -ARG BUILDX_COMMIT -RUN git fetch origin "${BUILDX_COMMIT}":build && git checkout build -ARG GOOS -ARG GOARCH -# Keep these essentially no-op var settings for debug purposes. -# It allows us to see what the GOOS/GOARCH that's being built for is. -RUN GOOS="${GOOS}" GOARCH="${GOARCH}" BUILDX_COMMIT="${BUILDX_COMMIT}"; \ - pkg="github.com/docker/buildx"; \ - ldflags="\ - -X \"${pkg}/version.Version=$(git describe --tags)\" \ - -X \"${pkg}/version.Revision=$(git rev-parse --short HEAD)\" \ - -X \"${pkg}/version.Package=buildx\" \ - "; \ - go build -mod=vendor -ldflags "${ldflags}" -o /usr/bin/buildx ./cmd/buildx - -FROM golang:${GO_VERSION}-buster -COPY --from=build /usr/bin/buildx /usr/bin/buildx -ENTRYPOINT ["/usr/bin/buildx"] diff --git a/contrib/install.sh b/contrib/install.sh index 3848246912..bc2ee27cbd 100755 --- a/contrib/install.sh +++ b/contrib/install.sh @@ -2,35 +2,35 @@ set -eo pipefail -tag="v17.12.0" +tag="v20.10.19" tag=$(echo "$tag" | sed 's|+|.|g') machine=$(uname -m) case "$machine" in "armv5"*) - arch="armv5" + arch="armv5e" ;; "armv6"*) - arch="armv6" + arch="armv6l" ;; "armv7"*) - arch="armv7" + arch="armv7hf" ;; "armv8"*) - arch="aarch64" + arch="arm64" ;; "aarch64"*) - arch="aarch64" + arch="arm64" ;; "i386") - arch="i386" + arch="386" ;; "i686") - arch="i386" + arch="386" ;; "x86_64") - arch="x86_64" + arch="amd64" ;; *) echo "Unknown machine type: $machine" >&2 @@ -70,6 +70,16 @@ done curl -sL "$url" | $sudo tar xzv -C /usr/local/bin --strip-components=1 +pushd /usr/local/bin +$sudo ln -sf balena-engine balena +$sudo ln -sf balena-engine balenad +$sudo ln -sf balena-engine balena-containerd +$sudo ln -sf balena-engine balena-containerd-shim +$sudo ln -sf balena-engine balena-containerd-ctr +$sudo ln -sf balena-engine balena-runc +$sudo ln -sf balena-engine balena-proxy +popd + cat <<-EOF diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000000..42aebeff4f --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,58 @@ +variable "BUNDLES_OUTPUT" { + default = "./bundles" +} +variable "DOCKER_CROSSPLATFORMS" { + default = "" +} + +target "_common" { + args = { + BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1 + APT_MIRROR = "cdn-fastly.deb.debian.org" + } +} + +group "default" { + targets = ["binary"] +} + +target "binary" { + inherits = ["_common"] + target = "binary" + output = [BUNDLES_OUTPUT] +} + +target "dynbinary" { + inherits = ["binary"] + target = "dynbinary" +} + +target "cross" { + inherits = ["binary"] + args = { + CROSS = "true" + DOCKER_CROSSPLATFORMS = DOCKER_CROSSPLATFORMS + } + target = "cross" +} + +# +# dev +# + +variable "DEV_IMAGE" { + default = "docker-dev" +} +variable "SYSTEMD" { + default = "false" +} + +target "dev" { + inherits = ["_common"] + target = "final" + args = { + SYSTEMD = SYSTEMD + } + tags = [DEV_IMAGE] + output = ["type=docker"] +} diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000000..b7655637a6 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,15 @@ +--- +version: "2.4" + +services: + sut: + build: + context: . + dockerfile: Dockerfile + target: dev-systemd-false + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - .:/go/src/github.com/docker/docker + privileged: true + command: hack/test/unit + working_dir: /go/src/github.com/docker/docker diff --git a/hack/dind b/hack/dind index 087270a7a8..04bf6aaf92 100755 --- a/hack/dind +++ b/hack/dind @@ -37,6 +37,10 @@ if [ -f /sys/fs/cgroup/cgroup.controllers ]; then > /sys/fs/cgroup/cgroup.subtree_control fi +# Change mount propagation to shared to make the environment more similar to a +# modern Linux system, e.g. with SystemD as PID 1. +mount --make-rshared / + if [ $# -gt 0 ]; then exec "$@" fi diff --git a/hack/make/.binary b/hack/make/.binary index a5e78fbdd2..140b414894 100644 --- a/hack/make/.binary +++ b/hack/make/.binary @@ -49,11 +49,25 @@ hash_files() { ;; linux/arm) case "${GOARM}" in - 5 | "") + 5) export CC="${CC:-arm-linux-gnueabi-gcc}" export CGO_ENABLED=1 + export CGO_CFLAGS="-march=armv5t" + export CGO_CXXFLAGS="-march=armv5t" + ;; + 6) + export CC="${CC:-arm-linux-gnueabi-gcc}" + export CGO_ENABLED=1 + export CGO_CFLAGS="-march=armv6" + export CGO_CXXFLAGS="-march=armv6" ;; 7) + export CC="${CC:-arm-linux-gnueabihf-gcc}" + export CGO_ENABLED=1 + export CGO_CFLAGS="-march=armv7-a" + export CGO_CXXFLAGS="-march=armv7-a" + ;; + *) export CC="${CC:-arm-linux-gnueabihf-gcc}" export CGO_ENABLED=1 ;; @@ -67,6 +81,14 @@ hash_files() { export CC="${CC:-x86_64-linux-gnu-gcc}" export CGO_ENABLED=1 ;; + linux/ppc64le) + export CC="${CC:-powerpc64le-linux-gnu-gcc}" + export CGO_ENABLED=1 + ;; + linux/s390x) + export CC="${CC:-s390x-linux-gnu-gcc}" + export CGO_ENABLED=1 + ;; esac fi diff --git a/hack/make/cross b/hack/make/cross index a528bab4b4..b7e79ab6c8 100644 --- a/hack/make/cross +++ b/hack/make/cross @@ -27,6 +27,12 @@ for platform in ${DOCKER_CROSSPLATFORMS}; do export GOARM fi + # FIXME: package breaks arm* builds + if [[ "${GOARCH}" = "386" ]]; then + apt-get update \ + && apt-get install -y --no-install-recommends gcc-multilib + fi + echo "Cross building: ${DEST}" mkdir -p "${DEST}" ABS_DEST="$(cd "${DEST}" && pwd -P)" diff --git a/pkg/archive/archive_unix_test.go b/pkg/archive/archive_unix_test.go index 6274744b61..82f3c133ef 100644 --- a/pkg/archive/archive_unix_test.go +++ b/pkg/archive/archive_unix_test.go @@ -253,15 +253,15 @@ func TestTarUntarWithXattr(t *testing.T) { t.Skip("getcap not installed") } - origin, err := ioutil.TempDir("", "docker-test-untar-origin") + origin, err := os.MkdirTemp("", "docker-test-untar-origin") assert.NilError(t, err) defer os.RemoveAll(origin) - err = ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700) + err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700) assert.NilError(t, err) - err = ioutil.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700) + err = os.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700) assert.NilError(t, err) - err = ioutil.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0700) + err = os.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0700) assert.NilError(t, err) // there is no known Go implementation of setcap/getcap with support for v3 file capability out, err := exec.Command("setcap", "cap_block_suspend+ep", filepath.Join(origin, "2")).CombinedOutput() @@ -285,7 +285,7 @@ func TestTarUntarWithXattr(t *testing.T) { } out, err := exec.Command("getcap", filepath.Join(origin, "2")).CombinedOutput() assert.NilError(t, err, string(out)) - assert.Check(t, is.Contains(string(out), "= cap_block_suspend+ep"), "untar should have kept the 'security.capability' xattr") + assert.Check(t, is.Contains(string(out), "cap_block_suspend=ep"), "untar should have kept the 'security.capability' xattr") } } diff --git a/repo.yml b/repo.yml index 0515e8ce34..48297cf2af 100644 --- a/repo.yml +++ b/repo.yml @@ -1,2 +1 @@ -type: balena-engine -reviewers: 1 +type: docker