diff --git a/Dockerfile.build b/Dockerfile.build index d3c3c9b4..4161c7b6 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -141,4 +141,4 @@ RUN set -ex; \ RUN find \( -name 'hello' -or -name 'hello.txt' -or -name '.host-arch' \) -exec file '{}' + -exec ls -lh '{}' + -CMD [".host-arch/hello-world/hello"] +CMD [".host-arch/hello"] diff --git a/Makefile b/Makefile index 206022c4..c2707877 100644 --- a/Makefile +++ b/Makefile @@ -2,14 +2,14 @@ SHELL := bash -Eeuo pipefail TARGET_ARCH := amd64 export ARCH_TEST := -C_TARGETS := $(addsuffix hello, $(wildcard $(TARGET_ARCH)/*/)) +HELLO := $(TARGET_ARCH)/hello # norelro: https://stackoverflow.com/a/59084373/433558 export CFLAGS := -Os -fdata-sections -ffunction-sections -Wl,-z,norelro -s $(EXTRA_CFLAGS) STRIP := $(CROSS_COMPILE)strip .PHONY: all -all: $(C_TARGETS) +all: $(HELLO) MUSL_SRC := /usr/local/src/musl MUSL_DIR := $(CURDIR)/musl/$(TARGET_ARCH) @@ -23,11 +23,9 @@ $(MUSL_GCC): .PHONY: musl musl: $(MUSL_GCC) -$(C_TARGETS): hello.c $(MUSL_GCC) +$(HELLO): hello.c $(MUSL_GCC) $(MUSL_GCC) $(CFLAGS) -Wl,--gc-sections -static \ -o '$@' \ - -D DOCKER_IMAGE='"$(notdir $(@D))"' \ - -D DOCKER_GREETING="\"$$(cat 'greetings/$(notdir $(@D)).txt')\"" \ -D DOCKER_ARCH='"$(TARGET_ARCH)"' \ '$<' $(STRIP) --strip-all --remove-section=.comment '$@' @@ -48,14 +46,13 @@ $(C_TARGETS): hello.c $(MUSL_GCC) .PHONY: clean clean: - -rm -vrf $(C_TARGETS) $(MUSL_DIR) + -rm -vrf $(HELLO) $(MUSL_DIR) .PHONY: test -test: $(C_TARGETS) +test: $(HELLO) @for b in $^; do \ if [ -n "$$ARCH_TEST" ] && command -v arch-test > /dev/null && arch-test "$$ARCH_TEST" > /dev/null; then \ ( set -x && "./$$b" ); \ - ( set -x && "./$$b" | grep -q '"'"$$(basename "$$(dirname "$$b")")"'"' ); \ if [ ! -e .host-arch ] && arch-test -n "$$ARCH_TEST" > /dev/null; then \ ln -svfT "$${b%%/*}" .host-arch; \ fi; \ diff --git a/amd64/hello-world/Dockerfile b/amd64/Dockerfile similarity index 100% rename from amd64/hello-world/Dockerfile rename to amd64/Dockerfile diff --git a/amd64/hello-world/hello b/amd64/hello similarity index 100% rename from amd64/hello-world/hello rename to amd64/hello diff --git a/amd64/nanoserver-1809/Dockerfile b/amd64/nanoserver-1809/Dockerfile new file mode 100644 index 00000000..4c3525ee --- /dev/null +++ b/amd64/nanoserver-1809/Dockerfile @@ -0,0 +1,3 @@ +FROM mcr.microsoft.com/windows/nanoserver:1809 +COPY hello.txt C: +CMD ["cmd", "/C", "type C:\\hello.txt"] diff --git a/amd64/hello-world/nanoserver-ltsc2022/Dockerfile b/amd64/nanoserver-ltsc2022/Dockerfile similarity index 100% rename from amd64/hello-world/nanoserver-ltsc2022/Dockerfile rename to amd64/nanoserver-ltsc2022/Dockerfile diff --git a/amd64/hello-world/nanoserver-ltsc2022/hello.txt b/amd64/nanoserver-ltsc2022/hello.txt similarity index 100% rename from amd64/hello-world/nanoserver-ltsc2022/hello.txt rename to amd64/nanoserver-ltsc2022/hello.txt diff --git a/amd64/hello-world/nanoserver-ltsc2025/Dockerfile b/amd64/nanoserver-ltsc2025/Dockerfile similarity index 100% rename from amd64/hello-world/nanoserver-ltsc2025/Dockerfile rename to amd64/nanoserver-ltsc2025/Dockerfile diff --git a/amd64/hello-world/nanoserver-ltsc2025/hello.txt b/amd64/nanoserver-ltsc2025/hello.txt similarity index 100% rename from amd64/hello-world/nanoserver-ltsc2025/hello.txt rename to amd64/nanoserver-ltsc2025/hello.txt diff --git a/arm32v5/hello-world/Dockerfile b/arm32v5/Dockerfile similarity index 100% rename from arm32v5/hello-world/Dockerfile rename to arm32v5/Dockerfile diff --git a/arm32v5/hello-world/hello b/arm32v5/hello similarity index 100% rename from arm32v5/hello-world/hello rename to arm32v5/hello diff --git a/arm32v6/hello-world/Dockerfile b/arm32v6/Dockerfile similarity index 100% rename from arm32v6/hello-world/Dockerfile rename to arm32v6/Dockerfile diff --git a/arm32v6/hello-world/hello b/arm32v6/hello similarity index 100% rename from arm32v6/hello-world/hello rename to arm32v6/hello diff --git a/arm32v7/hello-world/Dockerfile b/arm32v7/Dockerfile similarity index 100% rename from arm32v7/hello-world/Dockerfile rename to arm32v7/Dockerfile diff --git a/arm32v7/hello-world/hello b/arm32v7/hello similarity index 100% rename from arm32v7/hello-world/hello rename to arm32v7/hello diff --git a/arm64v8/hello-world/Dockerfile b/arm64v8/Dockerfile similarity index 100% rename from arm64v8/hello-world/Dockerfile rename to arm64v8/Dockerfile diff --git a/arm64v8/hello-world/hello b/arm64v8/hello similarity index 100% rename from arm64v8/hello-world/hello rename to arm64v8/hello diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index fc6c9b02..83dceec7 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -eu -image="${1:-hello-world}" - self="$(basename "$BASH_SOURCE")" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" @@ -45,8 +43,8 @@ join() { echo "${out#$sep}" } -arches=( *"/$image/hello" ) -arches=( "${arches[@]%"/$image/hello"}" ) +arches=( *"/hello" ) +arches=( "${arches[@]%"/hello"}" ) echo cat <<-EOE @@ -55,10 +53,10 @@ cat <<-EOE Architectures: $(join ', ' "${arches[@]}") EOE for arch in "${arches[@]}"; do - commit="$(dirCommit "$arch/$image")" + commit="$(dirCommit "$arch")" cat <<-EOE $arch-GitCommit: $commit - $arch-Directory: $arch/$image + $arch-Directory: $arch EOE done @@ -66,8 +64,8 @@ for winVariant in \ nanoserver-ltsc2025 \ nanoserver-ltsc2022 \ ; do - winArches=( *"/$image/$winVariant/hello.txt" ) - winArches=( "${winArches[@]%"/$image/$winVariant/hello.txt"}" ) + winArches=( *"/$winVariant/hello.txt" ) + winArches=( "${winArches[@]%"/$winVariant/hello.txt"}" ) if [ "${#winArches[@]}" -gt 0 ]; then echo @@ -77,10 +75,10 @@ for winVariant in \ Architectures: $(join ', ' "${winArches[@]/#/windows-}") EOE for arch in "${winArches[@]}"; do - commit="$(dirCommit "$arch/$image/$winVariant")" + commit="$(dirCommit "$arch/$winVariant")" cat <<-EOE windows-$arch-GitCommit: $commit - windows-$arch-Directory: $arch/$image/$winVariant + windows-$arch-Directory: $arch/$winVariant EOE done cat <<-EOE diff --git a/greetings/hello-world.txt b/greetings/hello-world.txt deleted file mode 100644 index 97e9ced7..00000000 --- a/greetings/hello-world.txt +++ /dev/null @@ -1 +0,0 @@ -Hello from Docker! diff --git a/hello.c b/hello.c index b049502b..3671ac49 100644 --- a/hello.c +++ b/hello.c @@ -1,26 +1,18 @@ #include #include -#ifndef DOCKER_IMAGE - #define DOCKER_IMAGE "hello-world" -#endif - -#ifndef DOCKER_GREETING - #define DOCKER_GREETING "Hello from Docker!" -#endif - #ifndef DOCKER_ARCH #define DOCKER_ARCH "amd64" #endif const char message[] = "\n" - DOCKER_GREETING "\n" + "Hello from Docker!\n" "This message shows that your installation appears to be working correctly.\n" "\n" "To generate this message, Docker took the following steps:\n" " 1. The Docker client contacted the Docker daemon.\n" - " 2. The Docker daemon pulled the \"" DOCKER_IMAGE "\" image from the Docker Hub.\n" + " 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\n" " (" DOCKER_ARCH ")\n" " 3. The Docker daemon created a new container from that image which runs the\n" " executable that produces the output you are currently reading.\n" diff --git a/i386/hello-world/Dockerfile b/i386/Dockerfile similarity index 100% rename from i386/hello-world/Dockerfile rename to i386/Dockerfile diff --git a/i386/hello-world/hello b/i386/hello similarity index 100% rename from i386/hello-world/hello rename to i386/hello diff --git a/mips64le/hello-world/Dockerfile b/mips64le/Dockerfile similarity index 100% rename from mips64le/hello-world/Dockerfile rename to mips64le/Dockerfile diff --git a/mips64le/hello-world/hello b/mips64le/hello similarity index 100% rename from mips64le/hello-world/hello rename to mips64le/hello diff --git a/ppc64le/hello-world/Dockerfile b/ppc64le/Dockerfile similarity index 100% rename from ppc64le/hello-world/Dockerfile rename to ppc64le/Dockerfile diff --git a/ppc64le/hello-world/hello b/ppc64le/hello similarity index 100% rename from ppc64le/hello-world/hello rename to ppc64le/hello diff --git a/riscv64/hello-world/Dockerfile b/riscv64/Dockerfile similarity index 100% rename from riscv64/hello-world/Dockerfile rename to riscv64/Dockerfile diff --git a/riscv64/hello-world/hello b/riscv64/hello similarity index 100% rename from riscv64/hello-world/hello rename to riscv64/hello diff --git a/s390x/hello-world/Dockerfile b/s390x/Dockerfile similarity index 100% rename from s390x/hello-world/Dockerfile rename to s390x/Dockerfile diff --git a/s390x/hello-world/hello b/s390x/hello similarity index 100% rename from s390x/hello-world/hello rename to s390x/hello diff --git a/update.sh b/update.sh index b3cc4c2c..bef3dd63 100755 --- a/update.sh +++ b/update.sh @@ -13,14 +13,14 @@ docker run --rm hello-world:build sh -c 'find \( -name hello -or -name hello.txt find -name hello -type f -exec dirname '{}' ';' | xargs -n1 -i'{}' cp Dockerfile-linux.template '{}/Dockerfile' find -name hello.txt -type f -exec dirname '{}' ';' | xargs -n1 -i'{}' cp Dockerfile-windows.template '{}/Dockerfile' -for h in */*/nanoserver-*/Dockerfile; do +for h in */nanoserver-*/Dockerfile; do nano="$(dirname "$h")" nano="$(basename "$nano")" nano="${nano#nanoserver-}" sed -i 's!FROM .*!FROM mcr.microsoft.com/windows/nanoserver:'"$nano"'!' "$h" done -for h in .host-arch/*/hello; do +for h in .host-arch/hello; do d="$(dirname "$h")" b="$(basename "$d")" "$h" > /dev/null @@ -28,4 +28,4 @@ for h in .host-arch/*/hello; do docker run --rm hello-world:"test-$b" done -ls -lh */*/{hello,nanoserver*/hello.txt} || : +ls -lh */{hello,nanoserver*/hello.txt} || :