forked from ivan-hc/Opera-appimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopera-snap.sh
More file actions
96 lines (81 loc) · 3.69 KB
/
opera-snap.sh
File metadata and controls
96 lines (81 loc) · 3.69 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
#!/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
chmod a+x ./appimagetool
fi
# CREATE CHROMIUM BROWSER APPIMAGES
_create_opera_appimage() {
# DOWNLOAD THE SNAP PACKAGE
SNAP_PKG=$(curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/opera$BRANCH --silent | sed 's/\[{/\n/g; s/},{/\n/g' | grep -i "stable" | head -1 | sed 's/[()",{} ]/\n/g' | tr ' ' '\n' | grep "^http.*snap$")
if ! test -f ./*.snap; then
if wget --version | head -1 | grep -q ' 1.'; then
wget -q --no-verbose --show-progress --progress=bar "$SNAP_PKG" || exit 1
else
wget "$SNAP_PKG" || exit 1
fi
fi
# EXTRACT THE SNAP PACKAGE AND CREATE THE APPIMAGE
unsquashfs -f ./*.snap
mkdir -p "$APP".AppDir
VERSION=$(cat ./squashfs-root/meta/*.yaml | grep "^version" | head -1 | cut -c 10-)
mv ./squashfs-root/etc ./"$APP".AppDir/
mv ./squashfs-root/lib ./"$APP".AppDir/
mv ./squashfs-root/usr ./"$APP".AppDir/
mv ./squashfs-root/bin ./"$APP".AppDir/
mv ./libffmpeg.so ./"$APP".AppDir/usr/lib/x86_64-linux-gnu/oper*/ || exit 1
cp -r ./"$APP".AppDir/usr/share/icons/hicolor/256x256/apps/*.png ./"$APP".AppDir/
cp -r ./"$APP".AppDir/usr/share/applications/*.desktop ./"$APP".AppDir/
sed -i 's#${SNAP}/usr/share/icons/hicolor/256x256/apps/opera#opera#g' ./"$APP".AppDir/*.desktop
sed -i 's/\.png//g' ./"$APP".AppDir/*.desktop
sed -i 's/TargetEnvironment/X-TargetEnvironment/g' ./"$APP".AppDir/*.desktop
cat <<-'HEREDOC' >> ./"$APP".AppDir/AppRun
#!/bin/sh
APP=CHROME
HERE="$(dirname "$(readlink -f "${0}")")"
export UNION_PRELOAD="${HERE}"
exec "${HERE}"/usr/lib/x86_64-linux-gnu/$APP/$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
}
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")"
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")"
fi
fi
unsquashfs -f ./*.snap
chromium_dir=$(ls squashfs-root/ | sort | grep "^chromium" | head -1)
BRANCH=""
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 ..
mv ./"$CHANNEL"/*.AppImage* ./
BRANCH="-developer"
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 ..
mv ./"$CHANNEL"/*.AppImage* ./
BRANCH="-beta"
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 ..
mv ./"$CHANNEL"/*.AppImage* ./
cd ..
mv ./tmp/*.AppImage* ./