Skip to content

Commit 7624bbb

Browse files
committed
fix again opera build.
it seems that the latest opera build is not the latest chromium version anymore and thats why ffmpeg is not compatible with the current version.
1 parent 552e622 commit 7624bbb

3 files changed

Lines changed: 121 additions & 10 deletions

File tree

apps/opera/Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ ARG BASE_IMAGE=ghcr.io/m1k1o/neko/base:latest
22
FROM $BASE_IMAGE
33

44
ARG API_URL="https://download5.operacdn.com/pub/opera/desktop/"
5-
ARG LIBFFMPEG_API_URL="https://api.github.com/repos/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases/latest"
5+
6+
COPY fix-ffmpeg-widevine.sh /tmp/fix-ffmpeg-widevine.sh
67

78
#
89
# install opera
@@ -23,16 +24,12 @@ RUN set -eux; apt-get update; \
2324
fi; \
2425
echo "Using Opera version: $VERSION"; \
2526
wget -O /tmp/opera.deb "${API_URL}${VERSION}/linux/opera-stable_${VERSION}_amd64.deb"; \
26-
apt-get install -y --no-install-recommends openbox jq unzip /tmp/opera.deb; \
27-
#
28-
# install libffmpeg
29-
LIBFFMPEG_URL="$(wget -O - "${LIBFFMPEG_API_URL}" 2>/dev/null | jq -r "[.assets[] | select(.browser_download_url | contains(\"linux-x64.zip\"))][-1] | .browser_download_url")"; \
30-
wget -O /tmp/libffmpeg.zip $LIBFFMPEG_URL; \
31-
unzip -o /tmp/libffmpeg.zip libffmpeg.so -d /usr/lib/x86_64-linux-gnu/opera/lib_extra; \
32-
echo '[]' > /usr/lib/x86_64-linux-gnu/opera/resources/ffmpeg_preload_config.json; \
27+
apt-get install -y --no-install-recommends openbox curl jq unzip /tmp/opera.deb; \
28+
/tmp/fix-ffmpeg-widevine.sh; \
29+
rm -f /tmp/opera.deb /tmp/fix-ffmpeg-widevine.sh; \
3330
#
3431
# clean up
35-
apt-get --purge autoremove -y unzip jq; \
32+
apt-get --purge autoremove -y curl jq unzip; \
3633
apt-get clean -y; \
3734
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
3835

apps/opera/fix-ffmpeg-widevine.sh

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/bin/bash
2+
# From https://github.com/Ld-Hagen/fix-opera-linux-ffmpeg-widevine.
3+
4+
# Config section
5+
readonly FIX_FFMPEG=true
6+
readonly FIX_WIDEVINE=true
7+
readonly FIX_DIR='/tmp/opera-fix'
8+
# readonly FFMPEG_SRC_MAIN='https://api.github.com/repos/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases'
9+
readonly FFMPEG_SRC_MAIN='https://api.github.com/repos/Ld-Hagen/nwjs-ffmpeg-prebuilt/releases'
10+
readonly FFMPEG_SRC_ALT='https://api.github.com/repos/Ld-Hagen/fix-opera-linux-ffmpeg-widevine/releases'
11+
readonly WIDEVINE_SRC='https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/main/toolkit/content/gmp-sources/widevinecdm.json'
12+
readonly FFMPEG_SO_NAME='libffmpeg.so'
13+
readonly WIDEVINE_SO_NAME='libwidevinecdm.so'
14+
readonly WIDEVINE_MANIFEST_NAME='manifest.json'
15+
16+
OPERA_VERSIONS=()
17+
if [ -x "$(command -v opera)" ]; then
18+
OPERA_VERSIONS+=("opera")
19+
fi
20+
if [ -x "$(command -v opera-beta)" ]; then
21+
OPERA_VERSIONS+=("opera-beta")
22+
fi
23+
24+
# Getting download links
25+
printf 'Getting download links...\n'
26+
## ffmpeg
27+
if $FIX_FFMPEG; then
28+
readonly FFMPEG_URL_MAIN=$(curl -sL4 $FFMPEG_SRC_MAIN | jq -rS 'sort_by(.published_at) | .[-1].assets[0].browser_download_url')
29+
readonly FFMPEG_URL_ALT=$(curl -sL4 $FFMPEG_SRC_ALT | jq -rS 'sort_by(.published_at) | .[-1].assets[0].browser_download_url')
30+
[[ $(basename $FFMPEG_URL_ALT) < $(basename $FFMPEG_URL_MAIN) ]] && readonly FFMPEG_URL=$FFMPEG_URL_MAIN || readonly FFMPEG_URL=$FFMPEG_URL_ALT
31+
if [[ -z $FFMPEG_URL ]]; then
32+
printf 'Failed to get ffmpeg download URL. Exiting...\n'
33+
exit 1
34+
fi
35+
fi
36+
## Widevine
37+
if $FIX_WIDEVINE; then
38+
readonly WIDEVINE_URL=$(curl -sL4 $WIDEVINE_SRC | jq -r '.vendors."gmp-widevinecdm".platforms."Linux_x86_64-gcc3".mirrorUrls[0]')
39+
fi
40+
41+
# Downloading files
42+
printf 'Downloading files...\n'
43+
mkdir -p "$FIX_DIR"
44+
## ffmpeg
45+
if $FIX_FFMPEG; then
46+
curl -L4 --progress-bar $FFMPEG_URL -o "$FIX_DIR/ffmpeg.zip"
47+
if [ $? -ne 0 ]; then
48+
printf 'Failed to download ffmpeg. Check your internet connection or try later\n'
49+
exit 1
50+
fi
51+
fi
52+
## Widevine
53+
if $FIX_WIDEVINE; then
54+
curl -L4 --progress-bar "$WIDEVINE_URL" -o "$FIX_DIR/widevine.zip"
55+
if [ $? -ne 0 ]; then
56+
printf 'Failed to download Widevine CDM. Check your internet connection or try later\n'
57+
exit 1
58+
fi
59+
fi
60+
61+
# Extracting files
62+
## ffmpeg
63+
if $FIX_FFMPEG; then
64+
echo "Extracting ffmpeg..."
65+
unzip -o "$FIX_DIR/ffmpeg.zip" -d $FIX_DIR > /dev/null
66+
fi
67+
## Widevine
68+
if $FIX_WIDEVINE; then
69+
echo "Extracting WidevineCDM..."
70+
unzip -oj "$FIX_DIR/widevine.zip" -d $FIX_DIR > /dev/null 2>/dev/null
71+
fi
72+
73+
for opera in ${OPERA_VERSIONS[@]}; do
74+
echo "Doing $opera"
75+
EXECUTABLE=$(command -v "$opera")
76+
OPERA_DIR=$(dirname $(readlink -f $EXECUTABLE))
77+
OPERA_LIB_DIR="$OPERA_DIR/lib_extra"
78+
OPERA_WIDEVINE_DIR="$OPERA_LIB_DIR/WidevineCdm"
79+
OPERA_WIDEVINE_SO_DIR="$OPERA_WIDEVINE_DIR/_platform_specific/linux_x64"
80+
OPERA_WIDEVINE_CONFIG="$OPERA_DIR/resources/widevine_config.json"
81+
82+
# Removing old libraries and preparing directories
83+
printf 'Removing old libraries & making directories...\n'
84+
## ffmpeg
85+
if $FIX_FFMPEG; then
86+
rm -f "$OPERA_LIB_DIR/$FFMPEG_SO_NAME"
87+
mkdir -p "$OPERA_LIB_DIR"
88+
fi
89+
## Widevine
90+
if $FIX_WIDEVINE; then
91+
rm -rf "$OPERA_WIDEVINE_DIR"
92+
mkdir -p "$OPERA_WIDEVINE_SO_DIR"
93+
fi
94+
95+
# Moving libraries to their place
96+
printf 'Moving libraries to their places...\n'
97+
## ffmpeg
98+
if $FIX_FFMPEG; then
99+
cp -f "$FIX_DIR/$FFMPEG_SO_NAME" "$OPERA_LIB_DIR"
100+
chmod 0644 "$OPERA_LIB_DIR/$FFMPEG_SO_NAME"
101+
fi
102+
## Widevine
103+
if $FIX_WIDEVINE; then
104+
cp -f "$FIX_DIR/$WIDEVINE_SO_NAME" "$OPERA_WIDEVINE_SO_DIR"
105+
chmod 0644 "$OPERA_WIDEVINE_SO_DIR/$WIDEVINE_SO_NAME"
106+
cp -f "$FIX_DIR/$WIDEVINE_MANIFEST_NAME" "$OPERA_WIDEVINE_DIR"
107+
chmod 0644 "$OPERA_WIDEVINE_DIR/$WIDEVINE_MANIFEST_NAME"
108+
printf "[\n {\n \"preload\": \"$OPERA_WIDEVINE_DIR\"\n }\n]\n" > "$OPERA_WIDEVINE_CONFIG"
109+
fi
110+
done
111+
112+
# Removing temporary files
113+
printf 'Removing temporary files...\n'
114+
rm -rf "$FIX_DIR"

apps/opera/openbox.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<applications>
1515
<!-- Match all windows and remove their decorations (obxprop | grep "^_OB_APP") -->
16-
<application class="Opera" name="Opera" role="browser">
16+
<application class="Opera" name="Opera" type="normal">
1717
<decor>no</decor>
1818
<maximized>true</maximized>
1919
<focus>yes</focus>

0 commit comments

Comments
 (0)