diff --git a/29-rc/cli/Dockerfile b/29-rc/cli/Dockerfile index 679296f51..4250919fb 100644 --- a/29-rc/cli/Dockerfile +++ b/29-rc/cli/Dockerfile @@ -31,26 +31,33 @@ RUN set -eux; \ case "$apkArch" in \ 'x86_64') \ url='https://download.docker.com/linux/static/test/x86_64/docker-29.10.0-rc.1.tgz'; \ + sha256='d023bcab935f045548c5df79ea96d1f3fccbc091cf9a8347139154859f4767b8'; \ ;; \ 'armhf') \ url='https://download.docker.com/linux/static/test/armel/docker-29.10.0-rc.1.tgz'; \ + sha256='55aedd3f6b42d8dd3e397358f0ca4fb321cb89cce325b9a239842866ecee3f8f'; \ ;; \ 'armv7') \ url='https://download.docker.com/linux/static/test/armhf/docker-29.10.0-rc.1.tgz'; \ + sha256='d244956ea5ba6b9ca88acd24b6cc67ee5bd56c39f1d870a8d317ec472b0cc223'; \ ;; \ 'aarch64') \ url='https://download.docker.com/linux/static/test/aarch64/docker-29.10.0-rc.1.tgz'; \ + sha256='48348b68501015c3d9cc2c2a0344588eb0676cf68c38dd4ffd881a75e2d8662c'; \ ;; \ 'ppc64le') \ url='https://download.docker.com/linux/static/test/ppc64le/docker-29.10.0-rc.1.tgz'; \ + sha256='1db34bee3e77a4af021631a5492b9385c3aafedd1b2aa3f693a60ca6760a3315'; \ ;; \ 's390x') \ url='https://download.docker.com/linux/static/test/s390x/docker-29.10.0-rc.1.tgz'; \ + sha256='78546fc2dcf04c7844e3e3f54b05485da64c852fceee453f2c8bac7b4ecd896b'; \ ;; \ *) echo >&2 "error: unsupported 'docker.tgz' architecture ($apkArch)"; exit 1 ;; \ esac; \ \ wget -O 'docker.tgz' "$url"; \ + echo "$sha256 *"'docker.tgz' | sha256sum -c -; \ \ tar --extract \ --file docker.tgz \ diff --git a/29-rc/dind-rootless/Dockerfile b/29-rc/dind-rootless/Dockerfile index 0b588e617..93e4eda43 100644 --- a/29-rc/dind-rootless/Dockerfile +++ b/29-rc/dind-rootless/Dockerfile @@ -27,9 +27,11 @@ RUN set -eux; \ case "$apkArch" in \ 'x86_64') \ url='https://download.docker.com/linux/static/test/x86_64/docker-rootless-extras-29.10.0-rc.1.tgz'; \ + sha256='e63ea3c6e4a28575be61bae88303b335c9637198d79a1b1aaae17ad0f955abc9'; \ ;; \ 'aarch64') \ url='https://download.docker.com/linux/static/test/aarch64/docker-rootless-extras-29.10.0-rc.1.tgz'; \ + sha256='2db6e2f180b66a4b5f6555f56041c85e55537230aaf939fdf18d60e1cea59c9e'; \ ;; \ *) echo >&2 "error: unsupported 'rootless.tgz' architecture ($apkArch)"; exit 1 ;; \ esac; \ diff --git a/29-rc/dind/Dockerfile b/29-rc/dind/Dockerfile index 9f5bcfb64..a9331210f 100644 --- a/29-rc/dind/Dockerfile +++ b/29-rc/dind/Dockerfile @@ -57,26 +57,33 @@ RUN set -eux; \ case "$apkArch" in \ 'x86_64') \ url='https://download.docker.com/linux/static/test/x86_64/docker-29.10.0-rc.1.tgz'; \ + sha256='d023bcab935f045548c5df79ea96d1f3fccbc091cf9a8347139154859f4767b8'; \ ;; \ 'armhf') \ url='https://download.docker.com/linux/static/test/armel/docker-29.10.0-rc.1.tgz'; \ + sha256='55aedd3f6b42d8dd3e397358f0ca4fb321cb89cce325b9a239842866ecee3f8f'; \ ;; \ 'armv7') \ url='https://download.docker.com/linux/static/test/armhf/docker-29.10.0-rc.1.tgz'; \ + sha256='d244956ea5ba6b9ca88acd24b6cc67ee5bd56c39f1d870a8d317ec472b0cc223'; \ ;; \ 'aarch64') \ url='https://download.docker.com/linux/static/test/aarch64/docker-29.10.0-rc.1.tgz'; \ + sha256='48348b68501015c3d9cc2c2a0344588eb0676cf68c38dd4ffd881a75e2d8662c'; \ ;; \ 'ppc64le') \ url='https://download.docker.com/linux/static/test/ppc64le/docker-29.10.0-rc.1.tgz'; \ + sha256='1db34bee3e77a4af021631a5492b9385c3aafedd1b2aa3f693a60ca6760a3315'; \ ;; \ 's390x') \ url='https://download.docker.com/linux/static/test/s390x/docker-29.10.0-rc.1.tgz'; \ + sha256='78546fc2dcf04c7844e3e3f54b05485da64c852fceee453f2c8bac7b4ecd896b'; \ ;; \ *) echo >&2 "error: unsupported 'docker.tgz' architecture ($apkArch)"; exit 1 ;; \ esac; \ \ wget -O 'docker.tgz' "$url"; \ + echo "$sha256 *"'docker.tgz' | sha256sum -c -; \ \ tar --extract \ --file docker.tgz \ diff --git a/29-rc/windows/windowsservercore-ltsc2022/Dockerfile b/29-rc/windows/windowsservercore-ltsc2022/Dockerfile index 1ec5d07eb..0f6a7f5fd 100644 --- a/29-rc/windows/windowsservercore-ltsc2022/Dockerfile +++ b/29-rc/windows/windowsservercore-ltsc2022/Dockerfile @@ -17,13 +17,17 @@ RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ ENV DOCKER_VERSION 29.10.0-rc.1 ENV DOCKER_URL https://download.docker.com/win/static/test/x86_64/docker-29.10.0-rc.1.zip -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) +ENV DOCKER_SHA256 d3f21d8d1487ee8a0bc936cb65c5149b1f5bebe2d05499c6bcfdcd8b81030c7b RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_SHA256); \ + if ((Get-FileHash docker.zip -Algorithm sha256).Hash -ne $env:DOCKER_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ Write-Host 'Expanding ...'; \ Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ # (this archive has a "docker/..." directory in it already) diff --git a/29-rc/windows/windowsservercore-ltsc2025/Dockerfile b/29-rc/windows/windowsservercore-ltsc2025/Dockerfile index 77da2b170..1518e5861 100644 --- a/29-rc/windows/windowsservercore-ltsc2025/Dockerfile +++ b/29-rc/windows/windowsservercore-ltsc2025/Dockerfile @@ -17,13 +17,17 @@ RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ ENV DOCKER_VERSION 29.10.0-rc.1 ENV DOCKER_URL https://download.docker.com/win/static/test/x86_64/docker-29.10.0-rc.1.zip -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) +ENV DOCKER_SHA256 d3f21d8d1487ee8a0bc936cb65c5149b1f5bebe2d05499c6bcfdcd8b81030c7b RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_SHA256); \ + if ((Get-FileHash docker.zip -Algorithm sha256).Hash -ne $env:DOCKER_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ Write-Host 'Expanding ...'; \ Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ # (this archive has a "docker/..." directory in it already) diff --git a/Dockerfile-cli.template b/Dockerfile-cli.template index 101e75358..273ddf5af 100644 --- a/Dockerfile-cli.template +++ b/Dockerfile-cli.template @@ -26,7 +26,7 @@ RUN set -eux; \ download({ arches: .arches, urlKey: "dockerUrl", - # TODO sha256Key (once Docker publishes them 😭) + sha256Key: "dockerSha256", target: "docker.tgz", }) }}; \ diff --git a/Dockerfile-dind-rootless.template b/Dockerfile-dind-rootless.template index 884fb56b0..85ba8c6f0 100644 --- a/Dockerfile-dind-rootless.template +++ b/Dockerfile-dind-rootless.template @@ -22,7 +22,7 @@ RUN set -eux; \ download({ arches: .arches, urlKey: "rootlessExtrasUrl", - # TODO sha256Key (once Docker publishes them 😭) + sha256Key: "rootlessExtrasSha256", target: "rootless.tgz", }) }}; \ diff --git a/Dockerfile-dind.template b/Dockerfile-dind.template index 446c03414..3c9459358 100644 --- a/Dockerfile-dind.template +++ b/Dockerfile-dind.template @@ -52,7 +52,7 @@ RUN set -eux; \ download({ arches: .arches, urlKey: "dockerUrl", - # TODO sha256Key (once Docker publishes them 😭) + sha256Key: "dockerSha256", target: "docker.tgz", }) }}; \ diff --git a/Dockerfile-windows-servercore.template b/Dockerfile-windows-servercore.template index b607c222b..d7969968d 100644 --- a/Dockerfile-windows-servercore.template +++ b/Dockerfile-windows-servercore.template @@ -11,13 +11,26 @@ RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ ENV DOCKER_VERSION {{ .version }} ENV DOCKER_URL {{ .arches["windows-amd64"].dockerUrl }} +{{ if .arches["windows-amd64"].dockerSha256 then ( -}} +ENV DOCKER_SHA256 {{ .arches["windows-amd64"].dockerSha256 }} +{{ ) else ( -}} +{{ # TODO remove this whole else block! as of 29.10.0-rc.1, we have checksums 🥳 -}} # TODO ENV DOCKER_SHA256 # https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! # (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) +{{ ) end -}} RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ \ +{{ if .arches["windows-amd64"].dockerSha256 then ( -}} + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_SHA256); \ + if ((Get-FileHash docker.zip -Algorithm sha256).Hash -ne $env:DOCKER_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ +{{ ) else "" end -}} Write-Host 'Expanding ...'; \ Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ # (this archive has a "docker/..." directory in it already) diff --git a/shared.jq b/shared.jq index c3213117e..ed950bbb3 100644 --- a/shared.jq +++ b/shared.jq @@ -40,11 +40,11 @@ def download(opts): | .value | .[opts.urlKey] as $url | (if $notSha256 then "none" else .[opts.sha256Key] end) as $sha256 - | select($apkArch and $url and $sha256) + | select($apkArch and $url) | (" \($apkArch | @sh)) url=\($url | @sh);" - + if $notSha256 then "" else " + + if $notSha256 or ($sha256 == null) then "" else " sha256=\($sha256 | @sh);" end + " ;;" @@ -57,9 +57,9 @@ def download(opts): wget -O \(opts.target | @sh) \"$url\";" , - if $notSha256 then "" else " + if opts.sha256Key and all(opts.arches[]; has(opts.sha256Key)) then " echo \"$sha256 *\"\(opts.target | @sh) | sha256sum -c -;" - end + else "" end ] | add | rtrimstr(";") | gsub("(?<=[^[:space:]])\n"; " \\\n") diff --git a/versions.json b/versions.json index 01c7980d4..c475497ac 100644 --- a/versions.json +++ b/versions.json @@ -182,26 +182,35 @@ "29-rc": { "arches": { "amd64": { + "dockerSha256": "d023bcab935f045548c5df79ea96d1f3fccbc091cf9a8347139154859f4767b8", "dockerUrl": "https://download.docker.com/linux/static/test/x86_64/docker-29.10.0-rc.1.tgz", + "rootlessExtrasSha256": "e63ea3c6e4a28575be61bae88303b335c9637198d79a1b1aaae17ad0f955abc9", "rootlessExtrasUrl": "https://download.docker.com/linux/static/test/x86_64/docker-rootless-extras-29.10.0-rc.1.tgz" }, "arm32v6": { + "dockerSha256": "55aedd3f6b42d8dd3e397358f0ca4fb321cb89cce325b9a239842866ecee3f8f", "dockerUrl": "https://download.docker.com/linux/static/test/armel/docker-29.10.0-rc.1.tgz" }, "arm32v7": { + "dockerSha256": "d244956ea5ba6b9ca88acd24b6cc67ee5bd56c39f1d870a8d317ec472b0cc223", "dockerUrl": "https://download.docker.com/linux/static/test/armhf/docker-29.10.0-rc.1.tgz" }, "arm64v8": { + "dockerSha256": "48348b68501015c3d9cc2c2a0344588eb0676cf68c38dd4ffd881a75e2d8662c", "dockerUrl": "https://download.docker.com/linux/static/test/aarch64/docker-29.10.0-rc.1.tgz", + "rootlessExtrasSha256": "2db6e2f180b66a4b5f6555f56041c85e55537230aaf939fdf18d60e1cea59c9e", "rootlessExtrasUrl": "https://download.docker.com/linux/static/test/aarch64/docker-rootless-extras-29.10.0-rc.1.tgz" }, "ppc64le": { + "dockerSha256": "1db34bee3e77a4af021631a5492b9385c3aafedd1b2aa3f693a60ca6760a3315", "dockerUrl": "https://download.docker.com/linux/static/test/ppc64le/docker-29.10.0-rc.1.tgz" }, "s390x": { + "dockerSha256": "78546fc2dcf04c7844e3e3f54b05485da64c852fceee453f2c8bac7b4ecd896b", "dockerUrl": "https://download.docker.com/linux/static/test/s390x/docker-29.10.0-rc.1.tgz" }, "windows-amd64": { + "dockerSha256": "d3f21d8d1487ee8a0bc936cb65c5149b1f5bebe2d05499c6bcfdcd8b81030c7b", "dockerUrl": "https://download.docker.com/win/static/test/x86_64/docker-29.10.0-rc.1.zip" } }, diff --git a/versions.sh b/versions.sh index e67957bb8..0ef1ea359 100755 --- a/versions.sh +++ b/versions.sh @@ -228,7 +228,18 @@ for version in "${versions[@]}"; do else continue fi + if sha256="$(_curl "$url.sha256")"; then + sha256="${sha256%% *}" + if [[ ! "$sha256" =~ ^[[:xdigit:]]{64}$ ]]; then + echo >&2 "error: invalid checksum for $url: '$sha256'" + exit 1 + fi + export sha256 + doc="$(jq <<<"$doc" -c ' + .arches[env.bashbrewArch].dockerSha256 = env.sha256 + ')" + fi hasArches["$bashbrewArch"]=1 if [ -n "$windows" ]; then @@ -241,9 +252,24 @@ for version in "${versions[@]}"; do amd64 | arm64v8) rootlessExtrasUrl="https://download.docker.com/linux/static/$channel/$arch/docker-rootless-extras-$fullVersion.tgz" if _curl --head "$rootlessExtrasUrl" > /dev/null; then - export rootlessExtrasUrl + if rootlessExtrasSha256="$(_curl "$rootlessExtrasUrl.sha256")"; then + rootlessExtrasSha256="${rootlessExtrasSha256%% *}" + if [[ ! "$rootlessExtrasSha256" =~ ^[[:xdigit:]]{64}$ ]]; then + echo >&2 "error: invalid checksum for $rootlessExtrasUrl: '$rootlessExtrasSha256'" + exit 1 + fi + else + rootlessExtrasSha256= + fi + + export rootlessExtrasUrl rootlessExtrasSha256 doc="$(jq <<<"$doc" -c ' - .arches[env.bashbrewArch].rootlessExtrasUrl = env.rootlessExtrasUrl + .arches[env.bashbrewArch] |= ( + .rootlessExtrasUrl = env.rootlessExtrasUrl + | if env.rootlessExtrasSha256 != "" then + .rootlessExtrasSha256 = env.rootlessExtrasSha256 + end + ) ')" fi ;;