Skip to content

Commit

Permalink
get musl patches from aports for specific range
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Sep 3, 2021
1 parent d5c214e commit 39ec624
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
33 changes: 12 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ ARG QEMU_REPO=https://github.com/qemu/qemu
# xx is a helper for cross-compilation
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:56b19a5fb89b99195ec494d59ad34370d14540858c1f56c560ec1e7f2d1c177f AS xx

FROM --platform=$BUILDPLATFORM ${ALPINE_BASE} AS alpine-patches
RUN apk add --no-cache git
ARG ALPINE_VERSION
RUN <<eof
set -ex
git clone --depth 1 -b ${ALPINE_VERSION}-stable https://github.com/alpinelinux/aports.git
mkdir -p /opt/alpine-patches
cp -a aports/community/qemu/*.patch /opt/alpine-patches/
rm -rf aports
eof

FROM --platform=$BUILDPLATFORM ${ALPINE_BASE} AS src
RUN apk add --no-cache git patch

Expand All @@ -28,19 +17,21 @@ ARG QEMU_VERSION
ARG QEMU_REPO
RUN git clone $QEMU_REPO && cd qemu && git checkout $QEMU_VERSION
COPY patches patches
COPY --from=alpine-patches /opt/alpine-patches patches/alpine-patches
ARG QEMU_PATCHES=cpu-max
ARG QEMU_PATCHES_ALL=${QEMU_PATCHES},alpine-patches,zero-init-msghdr
RUN <<eof
set -ex
# remove patches not needed for 6.1.0+
if [ "$(printf "$(cat qemu/VERSION)\n6.0.90" | sort -V | head -n 1)" = "6.0.90" ]; then
# this issue has been fixed upstream by using non-glibc specific macro
rm -rf patches/alpine-patches/fix-sigevent-and-sigval_t.patch || true
# following patches are already applied upstream
rm -rf patches/alpine-patches/0001-virtio-host-input-use-safe-64-bit-time-accessors-for.patch || true
rm -rf patches/alpine-patches/0002-virtio-user-input-use-safe-64-bit-time-accessors-for.patch || true
rm -rf patches/alpine-patches/CVE-2021-3527.patch || true
if [ "${QEMU_PATCHES_ALL#*alpine-patches}" != "${QEMU_PATCHES_ALL}" ]; then
ver="$(cat qemu/VERSION)"
for l in $(cat patches/aports.config); do
[ "$(printf "$ver\n$l" | sort -V | head -n 1)" != "$ver" ] && commit=$(echo $l | cut -d, -f2) && break;
done
mkdir -p aports && cd aports && git init
git fetch --depth 1 https://github.com/alpinelinux/aports.git "$commit"
git checkout FETCH_HEAD
mkdir -p ../patches/alpine-patches
cp -a community/qemu/*.patch ../patches/alpine-patches/
cd - && rm -rf aports
fi
cd qemu
for p in $(echo $QEMU_PATCHES_ALL | tr ',' '\n'); do
Expand All @@ -56,7 +47,7 @@ ENV PATH=/qemu/install-scripts:$PATH
WORKDIR /qemu

ARG TARGETPLATFORM
RUN xx-apk add musl-dev gcc glib-dev glib-static linux-headers zlib-static
RUN xx-apk add --no-cache musl-dev gcc glib-dev glib-static linux-headers zlib-static
RUN set -e; \
[ "$(xx-info arch)" = "ppc64le" ] && XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple; \
[ "$(xx-info arch)" = "386" ] && XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple; \
Expand Down
6 changes: 6 additions & 0 deletions patches/aports.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
6.1.50,HEAD
6.0.90,5e4ebee7797d3dc39464857886ea239ad4264ce0
5.2.90,da528ad1889bfc924189993463b4ee757d5514b6
5.1.90,29d5522ca4787e49f9c2e69c73f926433606d056
5.0.90,8d80ff4f0f066b5f6a2d02cf2691a0a6e5cc3481
0.0.0,f238bdae4d755f6e7ab6ce0b9a2a71dc833eb106

0 comments on commit 39ec624

Please sign in to comment.