Skip to content

Commit 61c917f

Browse files
committed
Add librsvg
Turns out to be a bit messy: librsvg needs cairo, pango and gio (glib) cairo alpine package builds with x11 stuff glib alpine package only has shared libraries and builds with libmount etc and so on... So i think only sane solution is to build some of these on our own. Also fixes problem with git checkout commit not updating submodules and also fixes race condition in checkelf. TODO: cleanup
1 parent cf69240 commit 61c917f

File tree

3 files changed

+156
-15
lines changed

3 files changed

+156
-15
lines changed

Dockerfile

Lines changed: 146 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ RUN apk add --no-cache \
2626
fontconfig-dev fontconfig-static \
2727
freetype freetype-dev freetype-static \
2828
graphite2-static \
29-
glib-static \
3029
tiff tiff-dev \
3130
libjpeg-turbo libjpeg-turbo-dev \
3231
libpng-dev libpng-static \
3332
giflib giflib-dev \
34-
harfbuzz-dev harfbuzz-static \
3533
fribidi-dev fribidi-static \
3634
brotli-dev brotli-static \
3735
soxr-dev soxr-static \
@@ -44,7 +42,12 @@ RUN apk add --no-cache \
4442
snappy snappy-dev snappy-static \
4543
xxd \
4644
xz-dev xz-static \
45+
python3 py3-packaging \
46+
linux-headers \
4747
curl
48+
49+
# linux-headers need by rtmpdump
50+
# python3 py3-packaging needed by glib
4851

4952
# -O3 makes sure we compile with optimization. setting CFLAGS/CXXFLAGS seems to override
5053
# default automake cflags.
@@ -78,6 +81,118 @@ RUN \
7881
# extra libs stdc++ is for vmaf https://github.com/Netflix/vmaf/issues/788
7982
RUN sed -i 's/-lvmaf /-lvmaf -lstdc++ /' /usr/local/lib/pkgconfig/libvmaf.pc
8083

84+
# own build as alpine glib links with libmount etc
85+
# bump: glib /GLIB_VERSION=([\d.]+)/ https://gitlab.gnome.org/GNOME/glib.git|^2
86+
# bump: glib after ./hashupxate Dockerfile GLIB $LATEST
87+
# bump: glib link "NEWS" https://gitlab.gnome.org/GNOME/glib/-/blob/main/NEWS?ref_type=heads
88+
ARG GLIB_VERSION=2.80.2
89+
ARG GLIB_URL="https://download.gnome.org/sources/glib/2.80/glib-$GLIB_VERSION.tar.xz"
90+
ARG GLIB_SHA256=b9cfb6f7a5bd5b31238fd5d56df226b2dda5ea37611475bf89f6a0f9400fe8bd
91+
RUN \
92+
wget -O glib.tar.xz "$GLIB_URL" && \
93+
echo "$GLIB_SHA256 glib.tar.xz" | sha256sum --status -c - && \
94+
tar xf glib.tar.xz && \
95+
cd glib-* && \
96+
mkdir -p _build && \
97+
meson \
98+
-Dbuildtype=release \
99+
-Ddefault_library=static \
100+
-Dlibmount=disabled \
101+
build && \
102+
meson compile -C build && \
103+
meson install --no-rebuild -C build
104+
105+
# bump: harfbuzz /LIBHARFBUZZ_VERSION=([\d.]+)/ https://github.com/harfbuzz/harfbuzz.git|*
106+
# bump: harfbuzz after ./hashupxate Dockerfile LIBHARFBUZZ $LATEST
107+
# bump: harfbuzz link "NEWS" https://github.com/harfbuzz/harfbuzz/blob/main/NEWS
108+
ARG LIBHARFBUZZ_VERSION=8.5.0
109+
ARG LIBHARFBUZZ_URL="https://github.com/harfbuzz/harfbuzz/releases/download/$LIBHARFBUZZ_VERSION/harfbuzz-$LIBHARFBUZZ_VERSION.tar.xz"
110+
ARG LIBHARFBUZZ_SHA256=77e4f7f98f3d86bf8788b53e6832fb96279956e1c3961988ea3d4b7ca41ddc27
111+
RUN \
112+
wget -O harfbuzz.tar.xz "$LIBHARFBUZZ_URL" && \
113+
echo "$LIBHARFBUZZ_SHA256 harfbuzz.tar.xz" | sha256sum --status -c - && \
114+
tar xf harfbuzz.tar.xz && \
115+
cd harfbuzz-* && \
116+
mkdir -p _build && \
117+
meson \
118+
-Dbuildtype=release \
119+
-Ddefault_library=static \
120+
build && \
121+
meson compile -C build && \
122+
meson install --no-rebuild -C build
123+
124+
# bump: cairo /CAIRO_VERSION=([\d.]+)/ https://gitlab.freedesktop.org/cairo/cairo.git|^1
125+
# bump: cairo after ./hashupxate Dockerfile CAIRO $LATEST
126+
# bump: cairo link "NEWS" https://gitlab.freedesktop.org/cairo/cairo/-/blob/master/NEWS?ref_type=heads
127+
ARG CAIRO_VERSION=1.18.0
128+
ARG CAIRO_URL="https://cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz"
129+
ARG CAIRO_SHA256=243a0736b978a33dee29f9cca7521733b78a65b5418206fef7bd1c3d4cf10b64
130+
RUN \
131+
wget -O cairo.tar.xz "$CAIRO_URL" && \
132+
echo "$CAIRO_SHA256 cairo.tar.xz" | sha256sum --status -c - && \
133+
tar xf cairo.tar.xz && \
134+
cd cairo-* && \
135+
mkdir -p _build && \
136+
meson \
137+
-Dbuildtype=release \
138+
-Ddefault_library=static \
139+
-Dtests=disabled \
140+
-Dquartz=disabled \
141+
-Dxcb=disabled \
142+
-Dxlib=disabled \
143+
-Dxlib-xcb=disabled \
144+
build && \
145+
meson compile -C build && \
146+
meson install --no-rebuild -C build
147+
148+
# TODO: there is weird "1.90" tag, skip it
149+
# bump: pango /PANGO_VERSION=([\d.]+)/ https://github.com/GNOME/pango.git|/\d+\.\d+\.\d+/|*
150+
# bump: pango after ./hashupxate Dockerfile PANGO $LATEST
151+
# bump: pango link "NEWS" https://gitlab.gnome.org/GNOME/pango/-/blob/main/NEWS?ref_type=heads
152+
ARG PANGO_VERSION=1.52.2
153+
ARG PANGO_URL="https://download.gnome.org/sources/pango/1.52/pango-$PANGO_VERSION.tar.xz"
154+
ARG PANGO_SHA256=d0076afe01082814b853deec99f9349ece5f2ce83908b8e58ff736b41f78a96b
155+
# TODO: add -Dbuild-testsuite=false when in stable release
156+
# TODO: -Ddefault_library=both currently to not fail building tests
157+
RUN \
158+
wget -O pango.tar.xz "$PANGO_URL" && \
159+
echo "$PANGO_SHA256 pango.tar.xz" | sha256sum --status -c - && \
160+
tar xf pango.tar.xz && \
161+
cd pango-* && \
162+
mkdir -p _build && \
163+
meson \
164+
-Dbuildtype=release \
165+
-Ddefault_library=both \
166+
-Dintrospection=disabled \
167+
-Dgtk_doc=false \
168+
build && \
169+
meson compile -C build && \
170+
meson install --no-rebuild -C build
171+
172+
# bump: librsvg /LIBRSVG_VERSION=([\d.]+)/ https://gitlab.gnome.org/GNOME/librsvg.git|^2
173+
# bump: librsvg after ./hashupxate Dockerfile LIBRSVG $LATEST
174+
# bump: librsvg link "NEWS" https://gitlab.gnome.org/GNOME/librsvg/-/blob/master/NEWS
175+
ARG LIBRSVG_VERSION=2.58.91
176+
ARG LIBRSVG_URL="https://download.gnome.org/sources/librsvg/2.58/librsvg-$LIBRSVG_VERSION.tar.xz"
177+
ARG LIBRSVG_SHA256=65846ae57c11aba288bf3a6fe517f800f7e38e7fbc79b98c99a8177634ed29f7
178+
RUN \
179+
wget -O librsvg.tar.xz "$LIBRSVG_URL" && \
180+
echo "$LIBRSVG_SHA256 librsvg.tar.xz" | sha256sum --status -c - && \
181+
tar xf librsvg.tar.xz && \
182+
cd librsvg-* && \
183+
mkdir -p _build && \
184+
meson setup _build \
185+
-Dbuildtype=release \
186+
-Ddefault_library=static \
187+
-Ddocs=disabled \
188+
-Dintrospection=disabled \
189+
-Dpixbuf=disabled \
190+
-Dpixbuf-loader=disabled \
191+
-Dvala=disabled \
192+
-Dtests=false && \
193+
meson compile -C _build && \
194+
meson install -C _build
195+
81196
# build after libvmaf
82197
# bump: aom /AOM_VERSION=([\d.]+)/ git:https://aomedia.googlesource.com/aom|*
83198
# bump: aom after ./hashupdate Dockerfile AOM $LATEST
@@ -151,7 +266,7 @@ RUN \
151266
cd libbluray-* && \
152267
sed -i 's/dec_init/libbluray_dec_init/' src/libbluray/disc/* && \
153268
git clone https://code.videolan.org/videolan/libudfread.git contrib/libudfread && \
154-
(cd contrib/libudfread && git checkout $LIBUDFREAD_COMMIT) && \
269+
(cd contrib/libudfread && git checkout --recurse-submodules $LIBUDFREAD_COMMIT) && \
155270
autoreconf -fiv && \
156271
./configure \
157272
--with-pic \
@@ -212,7 +327,7 @@ ARG LIBGME_URL="https://github.com/libgme/game-music-emu.git"
212327
ARG LIBGME_COMMIT=74449b553fef6528e1fd9d2dccc6413ded1d5e39
213328
RUN \
214329
git clone "$LIBGME_URL" && \
215-
cd game-music-emu && git checkout $LIBGME_COMMIT && \
330+
cd game-music-emu && git checkout --recurse-submodules $LIBGME_COMMIT && \
216331
mkdir build && cd build && \
217332
cmake \
218333
-G"Unix Makefiles" \
@@ -230,7 +345,7 @@ ARG LIBGSM_URL="https://github.com/timothytylee/libgsm.git"
230345
ARG LIBGSM_COMMIT=98f1708fb5e06a0dfebd58a3b40d610823db9715
231346
RUN \
232347
git clone "$LIBGSM_URL" && \
233-
cd libgsm && git checkout $LIBGSM_COMMIT && \
348+
cd libgsm && git checkout --recurse-submodules $LIBGSM_COMMIT && \
234349
# Makefile is hard to use, hence use specific compile arguments and flags
235350
# no need to build toast cli tool \
236351
rm src/toast* && \
@@ -415,7 +530,8 @@ ARG LIBRTMP_URL="https://git.ffmpeg.org/rtmpdump.git"
415530
ARG LIBRTMP_COMMIT=6f6bb1353fc84f4cc37138baa99f586750028a01
416531
RUN \
417532
git clone "$LIBRTMP_URL" && \
418-
cd rtmpdump && git checkout $LIBRTMP_COMMIT && \
533+
cd rtmpdump && \
534+
git checkout --recurse-submodules $LIBRTMP_COMMIT && \
419535
make SYS=posix SHARED=off -j$(nproc) install
420536

421537
# bump: rubberband /RUBBERBAND_VERSION=([\d.]+)/ https://github.com/breakfastquay/rubberband.git|^2
@@ -600,7 +716,8 @@ ARG UAVS3D_COMMIT=1fd04917cff50fac72ae23e45f82ca6fd9130bd8
600716
# Removes BIT_DEPTH 10 to be able to build on other platforms. 10 was overkill anyways.
601717
RUN \
602718
git clone "$UAVS3D_URL" && \
603-
cd uavs3d && git checkout $UAVS3D_COMMIT && \
719+
cd uavs3d && \
720+
git checkout --recurse-submodules $UAVS3D_COMMIT && \
604721
mkdir build/linux && cd build/linux && \
605722
cmake \
606723
-G"Unix Makefiles" \
@@ -706,7 +823,7 @@ ARG X264_VERSION=31e19f92f00c7003fa115047ce50978bc98c3a0d
706823
RUN \
707824
git clone "$X264_URL" && \
708825
cd x264 && \
709-
git checkout $X264_VERSION && \
826+
git checkout --recurse-submodules $X264_VERSION && \
710827
./configure --enable-pic --enable-static --disable-cli --disable-lavf --disable-swscale && \
711828
make -j$(nproc) install
712829

@@ -871,9 +988,15 @@ ARG FFMPEG_URL="https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2"
871988
ARG FFMPEG_SHA256=a24d9074bf5523a65aaa9e7bd02afe4109ce79d69bd77d104fed3dab4b934d7a
872989
ARG ENABLE_FDKAAC=
873990
# sed changes --toolchain=hardened -pie to -static-pie
874-
# extra ldflags stack-size=2097152 is to increase default stack size from 128KB (musl default) to something
991+
#
992+
# ldflags stack-size=2097152 is to increase default stack size from 128KB (musl default) to something
875993
# more similar to glibc (2MB). This fixing segfault with libaom-av1 and libsvtav1 as they seems to pass
876994
# large things on the stack.
995+
#
996+
# ldfalgs -Wl,--allow-multiple-definition is a workaround for linking with multiple rust staticlib to
997+
# not cause collision in toolchain symbols
998+
# TODO: could this hide real problems with other libraries?
999+
# see https://github.com/rust-lang/rust/issues/104707
8771000
RUN \
8781001
wget $WGET_OPTS -O ffmpeg.tar.bz2 "$FFMPEG_URL" && \
8791002
echo "$FFMPEG_SHA256 ffmpeg.tar.bz2" | sha256sum -c - && \
@@ -884,7 +1007,7 @@ RUN \
8841007
./configure \
8851008
--pkg-config-flags="--static" \
8861009
--extra-cflags="-fopenmp" \
887-
--extra-ldflags="-fopenmp -Wl,-z,stack-size=2097152" \
1010+
--extra-ldflags="-fopenmp -Wl,--allow-multiple-definition -Wl,-z,stack-size=2097152" \
8881011
--toolchain=hardened \
8891012
--disable-debug \
8901013
--disable-shared \
@@ -918,6 +1041,7 @@ RUN \
9181041
--enable-libopus \
9191042
--enable-librabbitmq \
9201043
--enable-librav1e \
1044+
--enable-librsvg \
9211045
--enable-librtmp \
9221046
--enable-librubberband \
9231047
--enable-libshine \
@@ -939,8 +1063,8 @@ RUN \
9391063
--enable-libx264 \
9401064
--enable-libx265 \
9411065
--enable-libxavs2 \
942-
--enable-libxeve \
9431066
--enable-libxevd \
1067+
--enable-libxeve \
9441068
--enable-libxml2 \
9451069
--enable-libxvid \
9461070
--enable-libzimg \
@@ -955,7 +1079,6 @@ RUN \
9551079
FONTCONFIG_VERSION=$(pkg-config --modversion fontconfig) \
9561080
FREETYPE_VERSION=$(pkg-config --modversion freetype2) \
9571081
FRIBIDI_VERSION=$(pkg-config --modversion fribidi) \
958-
LIBHARFBUZZ_VERSION=$(pkg-config --modversion harfbuzz) \
9591082
LIBSAMPLERATE_VERSION=$(pkg-config --modversion samplerate) \
9601083
LIBVO_AMRWBENC_VERSION=$(pkg-config --modversion vo-amrwbenc) \
9611084
LIBXML2_VERSION=$(pkg-config --modversion libxml-2.0) \
@@ -992,6 +1115,7 @@ RUN \
9921115
libopus: env.OPUS_VERSION, \
9931116
librabbitmq: env.LIBRABBITMQ_VERSION, \
9941117
librav1e: env.RAV1E_VERSION, \
1118+
librsvg: env.LIBRSVG_VERSION, \
9951119
librtmp: env.LIBRTMP_COMMIT, \
9961120
librubberband: env.RUBBERBAND_VERSION, \
9971121
libsamplerate: env.LIBSAMPLERATE_VERSION, \
@@ -1014,8 +1138,8 @@ RUN \
10141138
libx264: env.X264_VERSION, \
10151139
libx265: env.X265_VERSION, \
10161140
libxavs2: env.XAVS2_VERSION, \
1017-
libxeve: env.XEVE_VERSION, \
10181141
libxevd: env.XEVD_VERSION, \
1142+
libxeve: env.XEVE_VERSION, \
10191143
libxml2: env.LIBXML2_VERSION, \
10201144
libxvid: env.XVID_VERSION, \
10211145
libzimg: env.ZIMG_VERSION, \
@@ -1028,10 +1152,17 @@ RUN \
10281152
/checkelf /usr/local/bin/ffmpeg && \
10291153
/checkelf /usr/local/bin/ffprobe
10301154

1155+
# some basic fonts that don't take up much space
1156+
RUN apk add font-terminus font-inconsolata font-dejavu font-awesome
1157+
10311158
FROM scratch AS final1
10321159
COPY --from=builder /versions.json /usr/local/bin/ffmpeg /usr/local/bin/ffprobe /
10331160
COPY --from=builder /usr/local/share/doc/ffmpeg/* /doc/
10341161
COPY --from=builder /etc/ssl/cert.pem /etc/ssl/cert.pem
1162+
COPY --from=builder /etc/fonts/ /etc/fonts/
1163+
COPY --from=builder /usr/share/fonts/ /usr/share/fonts/
1164+
COPY --from=builder /usr/share/consolefonts/ /usr/share/consolefonts/
1165+
COPY --from=builder /var/cache/fontconfig/ /var/cache/fontconfig/
10351166

10361167
# sanity tests
10371168
RUN ["/ffmpeg", "-version"]
@@ -1043,6 +1174,8 @@ RUN ["/ffmpeg", "-f", "lavfi", "-i", "testsrc", "-c:v", "libsvtav1", "-t", "100m
10431174
RUN ["/ffprobe", "-i", "https://github.com/favicon.ico"]
10441175
# tls/https certs
10451176
RUN ["/ffprobe", "-tls_verify", "1", "-ca_file", "/etc/ssl/cert.pem", "-i", "https://github.com/favicon.ico"]
1177+
# svg
1178+
RUN ["/ffprobe", "-i", "https://github.githubassets.com/favicons/favicon.svg"]
10461179

10471180
# clamp all files into one layer
10481181
FROM scratch AS final2

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ alias ffprobe='docker run -i --rm -u $UID:$GROUPS -v "$PWD:$PWD" -w "$PWD" --ent
6060
- libopus
6161
- librabbitmq
6262
- librav1e
63+
- librsvg
6364
- librtmp
6465
- librubberband
6566
- libshine
@@ -81,8 +82,8 @@ alias ffprobe='docker run -i --rm -u $UID:$GROUPS -v "$PWD:$PWD" -w "$PWD" --ent
8182
- libx264
8283
- libx265 (multilib with support for 10 and 12 bits)
8384
- libxavs2
84-
- libxeve
8585
- libxevd
86+
- libxeve
8687
- libxml2
8788
- libxvid
8889
- libzimg
@@ -140,6 +141,13 @@ docker run --rm mwader/static-ffmpeg -v quiet -f data -i versions.json -map 0 -c
140141
This could happen if the hostname resolve to more IP-addresses than can fit in [DNS UDP packet](https://www.rfc-editor.org/rfc/rfc791) (probably 512 bytes) causing the response to be truncated. Usually clients should then switch to TCP and redo the query.
141142
This should only be a problem with version 6.0-1 or earlier of this image that uses [musl libc](https://www.musl-libc.org) 1.2.3 or older.
142143

144+
### Fonts usage with SVG or draw text filters etc
145+
146+
The image ships with some basic fonts (`font-terminus font-inconsolata font-dejavu font-awesome`) that can be used when running the image directly. If your copying the binaries into some image you have to install fonts somehow. How to do this depends a bit on distributions but in general look for font packages and how to make [fontconfig](https://www.freedesktop.org/wiki/Software/fontconfig/) know about them.
147+
148+
- Alpine Linux see https://wiki.alpinelinux.org/wiki/Fonts
149+
- Debian/Ubuntu see https://wiki.debian.org/Fonts
150+
143151
### TLS
144152

145153
Binaries are built with TLS support but, by default, ffmpeg currently do

checkelf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
set -euo pipefail
2+
set -eu
33

44
NOEXTLIBS=$(test "$(ldd "$1" | wc -l)" -eq 1 && echo yes || echo no)
55
RELRO=$(readelf -l "$1" | grep -q GNU_RELRO && echo yes || echo no)

0 commit comments

Comments
 (0)