FROM alpine:3.22 AS build RUN apk add --no-cache \ build-base \ bison \ flex \ linux-headers \ file \ binutils \ tar WORKDIR /src ARG UBOOT_TAR ARG UBOOT_VERSION COPY ${UBOOT_TAR} /tmp/ RUN tar zxf "/tmp/$(basename "${UBOOT_TAR}")" RUN make tools-only_defconfig # Build the env tools using the supported target. RUN make -j"$(nproc)" \ HOSTCC=gcc \ HOSTLD=gcc \ HOSTCFLAGS='-O2' \ HOSTLDFLAGS='-static' \ envtools # fw_setenv is the same program; create the link ourselves. RUN ln -sf fw_printenv tools/env/fw_setenv RUN file tools/env/fw_printenv tools/env/fw_setenv RUN readelf -d tools/env/fw_printenv || true RUN ! readelf -d tools/env/fw_printenv | grep -q '(NEEDED)' FROM scratch AS export COPY --from=build /src/tools/env/fw_printenv /fw_printenv COPY --from=build /src/tools/env/fw_setenv /fw_setenv