Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ftl-build container to Alpine v3.21 #100

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ftl-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG CONTAINER="alpine:latest"
ARG CONTAINER="alpine:3.21"
FROM ${CONTAINER} AS builder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻


ARG TARGETPLATFORM
Expand Down Expand Up @@ -45,9 +45,12 @@ RUN apk add --no-cache \
ENV STATIC true
ENV TEST true

# As of Alpine 3.21 (Dec 2024), we need to patch the termcap library to include
# the standard headers as well as unistd.h for the write function
RUN curl -sSL https://ftl.pi-hole.net/libraries/termcap-${termcapversion}.tar.gz | tar -xz \
&& cd termcap-${termcapversion} \
&& ./configure --enable-static --disable-shared --disable-doc --without-examples \
&& sed -i '1i #define STDC_HEADERS 1\n#include <unistd.h>' termcap.c tparam.c \
&& make -j $(nproc) \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patching is necessary due to a breaking change in GCC 14:

Implicit function declarations (-Werror=implicit-function-declaration)
It is no longer possible to call a function that has not been declared. In general, the solution is to include a header file with an appropriate function prototype. Note that GCC will perform further type checks based on the function prototype, which can reveal further type errors that require additional changes.

For well-known functions declared in standard headers, GCC provides fix-it hints with the appropriate #include directives:

error: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
   5 |   return strlen (s);
     |          ^~~~~~
note: include ‘<string.h>’ or provide a declaration of ‘strlen’
 +++ |+#include <string.h>
   1 |

On GNU systems, headers described in standards (such as the C standard, or POSIX) may require the definition of certain macros at the start of the compilation before all required function declarations are made available. See Feature Test Macros in the GNU C Library manual for details.

&& make install \
&& ls /usr/local/lib/ \
Expand Down Expand Up @@ -109,6 +112,14 @@ ARG CI_ARCH="$TARGETPLATFORM"
ARG GIT_TAG="test-build"
ARG GIT_BRANCH="special/CI_development"

# Ensure that the TERM environment variable is set
ENV TERM=${TERM:-xterm}

# Monkeypatch BATS to remove duplicate output of starting and finished test
# BATS uses ANSI escape codes to overwrite the line after the test has finished
# This is not supported by Github Actions as it does not provide a TTY to the docker build container
RUN sed -i '/buffer_with_truncation /d' /bats-core/libexec/bats-core/bats-format-pretty

# Test compile FTL's development branch, the result is removed from the final container
# Run the full test suite to ensure that the container is still capable of running the tests
RUN git clone https://github.com/pi-hole/FTL.git --branch "${GIT_BRANCH}" \
Expand Down
Loading