forked from ivan-hc/Opera-appimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopera-builder.sh
More file actions
108 lines (89 loc) · 4.47 KB
/
Copy pathopera-builder.sh
File metadata and controls
108 lines (89 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
APP=opera
# TEMPORARY DIRECTORY
mkdir -p tmp
cd ./tmp || exit 1
# DOWNLOAD APPIMAGETOOL
if ! test -f ./appimagetool; then
wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool || exit 1
chmod a+x ./appimagetool
fi
# DOWNLOAD WIDEVINE
if ! test -f ./*.deb; then
if wget --version | head -1 | grep -q ' 1.'; then
wget -q --no-verbose --show-progress --progress=bar https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb || exit 1
else
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb || exit 1
fi
ar x ./*.deb
tar xf ./data.tar.xz
mv ./opt/google/chrome/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so ./libwidevinecdm.so || exit 1
fi
# DOWNLOAD A WORKING VERSION OF FFMPEG (THE ONE IN OPERA IS BROKEN...FROM YEARS)
if ! test -f ./*.snap; then
if wget --version | head -1 | grep -q ' 1.'; then
wget -q --no-verbose --show-progress --progress=bar "$(curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/chromium-ffmpeg --silent | sed 's/\[{/\n/g; s/},{/\n/g' | grep -i "stable" | head -1 | sed 's/[()",{} ]/\n/g' | grep "^http")" || exit 1
else
wget "$(curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/chromium-ffmpeg --silent | sed 's/\[{/\n/g; s/},{/\n/g' | grep -i "stable" | head -1 | sed 's/[()",{} ]/\n/g' | grep "^http")" || exit 1
fi
fi
unsquashfs -f ./*.snap
echo "----------------------------------------------------------------------------"
echo "List of the chromium-ffmpeg directories"
ls squashfs-root/ | sort --version-sort | grep "chromium-ffmpeg"
chromium_dir=$(ls squashfs-root/ | sort --version-sort | grep "chromium-ffmpeg-[0-9]" | tail -1)
echo "Selected: $chromium_dir"
echo "----------------------------------------------------------------------------"
# CREATE OPERA BROWSER APPIMAGES
_create_opera_appimage(){
if wget --version | head -1 | grep -q ' 1.'; then
wget -q --no-verbose --show-progress --progress=bar "https://deb.opera.com/opera-stable/pool/non-free/o/$APP-$CHANNEL/$(wget -q https://deb.opera.com/"$APP"-"$CHANNEL"/pool/non-free/o/"$APP"-"$CHANNEL"/ -O - | grep deb | grep -i "x86_64\|amd64" | tail -1 | grep -o -P '(?<=.deb">).*(?=</a>)')" || exit 1
else
wget "https://deb.opera.com/opera-stable/pool/non-free/o/$APP-$CHANNEL/$(wget -q https://deb.opera.com/opera-stable/pool/non-free/o/"$APP"-"$CHANNEL"/ -O - | grep deb | grep -i "x86_64\|amd64" | tail -1 | grep -o -P '(?<=.deb">).*(?=</a>)')" || exit 1
fi
ar x ./*.deb
tar xf ./data.tar.xz
mkdir "$APP".AppDir
mv ./usr/lib/x86_64-linux-gnu/oper*/* ./"$APP".AppDir/ || exit 1
mv ./usr/share/applications/*.desktop ./"$APP".AppDir/ || exit 1
sed -i -e '/TargetEnvironment/d' ./"$APP".AppDir/*.desktop
mv ./usr/share/pixmaps/* ./"$APP".AppDir/ || exit 1
cp ../libwidevinecdm.so ./"$APP".AppDir/ || exit 1
mv ./"$APP".AppDir/libffmpeg.so ./"$APP".AppDir/libffmpeg.so.old || exit 1
cp ./libffmpeg.so ./"$APP".AppDir/ || exit 1
tar xf ./control.tar.xz
VERSION=$(cat control | grep Version | cut -c 10-)
cat <<-'HEREDOC' >> ./"$APP".AppDir/AppRun
#!/bin/sh
APP=CHROME
HERE="$(dirname "$(readlink -f "${0}")")"
export UNION_PRELOAD="${HERE}"
exec "${HERE}"/$APP "$@"
HEREDOC
chmod a+x ./"$APP".AppDir/AppRun
if [ "$CHANNEL" = "stable" ]; then
sed -i "s/CHROME/$APP/g" ./"$APP".AppDir/AppRun
else
sed -i "s/CHROME/$APP-$CHANNEL/g" ./"$APP".AppDir/AppRun
fi
ARCH=x86_64 ./appimagetool --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 20 \
-u "gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|Opera-appimage|continuous|*-$CHANNEL-*x86_64.AppImage.zsync" \
./"$APP".AppDir Opera-Web-Browser-"$CHANNEL"-"$VERSION"-x86_64.AppImage || exit 1
}
CHANNEL="stable"
mkdir -p "$CHANNEL" && cp ./appimagetool ./"$CHANNEL"/appimagetool && cp -r ./squashfs-root/"$chromium_dir"/chromium-ffmpeg/* ./"$CHANNEL"/ && cd "$CHANNEL" || exit 1
_create_opera_appimage
cd .. || exit 1
mv ./"$CHANNEL"/*.AppImage* ./
CHANNEL="beta"
mkdir -p "$CHANNEL" && cp ./appimagetool ./"$CHANNEL"/appimagetool && cp -r ./squashfs-root/"$chromium_dir"/chromium-ffmpeg/* ./"$CHANNEL"/ && cd "$CHANNEL" || exit 1
_create_opera_appimage
cd .. || exit 1
mv ./"$CHANNEL"/*.AppImage* ./
CHANNEL="developer"
mkdir -p "$CHANNEL" && cp ./appimagetool ./"$CHANNEL"/appimagetool && cp -r ./squashfs-root/"$chromium_dir"/chromium-ffmpeg/* ./"$CHANNEL"/ && cd "$CHANNEL" || exit 1
_create_opera_appimage
cd .. || exit 1
mv ./"$CHANNEL"/*.AppImage* ./
cd ..
mv ./tmp/*.AppImage* ./