-
Notifications
You must be signed in to change notification settings - Fork 8
/
widevine-installer
executable file
·148 lines (127 loc) · 5.1 KB
/
widevine-installer
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
# SPDX-License-Identifier: MIT
set -e
# Set to 0 if packaged and the configs are pre-installed
: ${COPY_CONFIGS=1}
: ${DESTDIR:=/}
: ${CONFDIR:=/etc}
: ${LIBDIR:=/usr/lib64}
: ${BINDIR:=/usr/bin}
: ${LIBEXECDIR:=/usr/libexec}
: ${STATEDIR:=/var/lib}
: ${SCRIPT_BASE:=$LIBEXECDIR/widevine-installer}
: ${INSTALL_BASE:=$STATEDIR/widevine}
: ${DISTFILES_BASE:=https://commondatastorage.googleapis.com/chromeos-localmirror/distfiles}
: ${LACROS_NAME:=chromeos-lacros-arm64-squash-zstd}
: ${LACROS_VERSION:=120.0.6098.0}
: ${WIDEVINE_VERSION:=4.10.2662.3}
: ${CHROME_WIDEVINE_BASE:=$LIBDIR/chromium-browser}
: ${MOZ_PREF_BASE:=$LIBDIR/firefox/defaults/pref}
[ -e $(dirname "$0")/widevine_fixup.py ] && SCRIPT_BASE="$(realpath "$(dirname "$0")")"
install_configs() {
cd "$SCRIPT_BASE"
echo "Copying config files..."
install -d -m 0755 "$DESTDIR/$INSTALL_BASE"
install -p -m 0644 -t "$DESTDIR/$INSTALL_BASE" ./conf/README
install -d -m 0755 "$DESTDIR/$CONFDIR/profile.d/"
install -p -m 0644 -t "$DESTDIR/$CONFDIR/profile.d/" ./conf/gmpwidevine.sh
install -d -m 0755 "$DESTDIR/$CHROME_WIDEVINE_BASE"
ln -sf "$INSTALL_BASE/WidevineCdm" "$DESTDIR/$CHROME_WIDEVINE_BASE/WidevineCdm"
install -d -m 0755 "$DESTDIR/$MOZ_PREF_BASE"
install -p -m 0644 -t "$DESTDIR/$MOZ_PREF_BASE" ./conf/gmpwidevine.js
}
if [ "$1" = "--distinstall" ]; then
install_configs
install -d -m 0755 "$DESTDIR/$LIBEXECDIR/widevine-installer"
install -p -m 0644 -t "$DESTDIR/$LIBEXECDIR/widevine-installer" ./widevine_fixup.py
install -d -m 0755 "$DESTDIR/$BINDIR"
install -p -m 0755 -t "$DESTDIR/$BINDIR" ./widevine-installer
exit 0
fi
if [ "$(uname -m)" != "aarch64" ]; then
echo "This tool is only supported on aarch64 (ARM64) systems."
exit 1
fi
if [ "$(whoami)" != "root" ]; then
echo "This tool needs to be run as root."
exit 1
fi
verchk() {
(
echo "2.36"
ldd --version | head -1 | cut -d" " -f4
) | sort -CV
}
if ! verchk; then
echo "Your glibc version is too old. Widevine requires glibc 2.36 or newer."
exit 1
fi
echo "This script will download, adapt, and install a copy of the Widevine"
echo "Content Decryption Module for aarch64 systems."
echo
echo "Widevine is a proprietary DRM technology developed by Google."
echo "This script uses ARM64 builds intended for ChromeOS images and is"
echo "not supported nor endorsed by Google. The Asahi Linux community"
echo "also cannot provide direct support for using this proprietary"
echo "software, nor any guarantees about its security, quality,"
echo "functionality, nor privacy. You assume all responsibility for"
echo "usage of this script and of the installed CDM."
echo
echo "This installer will only adapt the binary file format of the CDM"
echo "for interoperability purposes, to make it function on vanilla"
echo "ARM64 systems (instead of just ChromeOS). The CDM software"
echo "itself will not be modified in any way."
echo
echo "Widevine version to be installed: $WIDEVINE_VERSION"
echo
echo "Press enter to proceed, or Ctrl-C to cancel."
read dummy
workdir="$(mktemp -d /tmp/widevine-installer.XXXXXXXX)"
[ -z "$workdir" ] && exit 1 # sanity check
[ ! -d "$workdir" ] && exit 1 # sanity check
cd "$workdir"
echo "Downloading LaCrOS (Chrome) image..."
URL="$DISTFILES_BASE/$LACROS_NAME-$LACROS_VERSION"
echo "URL: $URL"
curl -# -o lacros.squashfs "$URL"
echo
echo "Extracting Widevine..."
unsquashfs -q lacros.squashfs 'WidevineCdm/*'
echo
echo "The Widevine license agreement follows:"
echo
echo ===================================================================================
cat squashfs-root/WidevineCdm/LICENSE
echo ===================================================================================
echo
echo "Press enter to proceed, or Ctrl-C to cancel."
read dummy
python3 "$SCRIPT_BASE/widevine_fixup.py" squashfs-root/WidevineCdm/_platform_specific/cros_arm64/libwidevinecdm.so libwidevinecdm.so
echo
echo "Installing..."
install -d -m 0755 "$INSTALL_BASE"
install -p -m 0755 -t "$INSTALL_BASE" libwidevinecdm.so
install -p -m 0644 -t "$INSTALL_BASE" squashfs-root/WidevineCdm/manifest.json
install -p -m 0644 -t "$INSTALL_BASE" squashfs-root/WidevineCdm/LICENSE
echo "Setting up plugin for Firefox and Chromium-based browsers..."
mkdir -p "$INSTALL_BASE"/gmp-widevinecdm/system-installed
ln -sf ../../manifest.json "$INSTALL_BASE"/gmp-widevinecdm/system-installed/
ln -sf ../../libwidevinecdm.so "$INSTALL_BASE"/gmp-widevinecdm/system-installed/
mkdir -p "$INSTALL_BASE"/WidevineCdm/_platform_specific/linux_{arm64,x64}
# Hack because Chromium hardcodes a check for this right now...
touch "$INSTALL_BASE"/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so
ln -sf ../manifest.json "$INSTALL_BASE"/WidevineCdm
ln -sf ../../../libwidevinecdm.so "$INSTALL_BASE"/WidevineCdm/_platform_specific/linux_arm64/
if [ "$COPY_CONFIGS" = 1 ]; then
install_configs
fi
echo "Cleaning up..."
cd /
rm -rf "$workdir"
echo
echo "Installation complete!"
if [ "$COPY_CONFIGS" = 1 ]; then
echo "You may need to log out and back in for the changes to take effect."
else
echo "Please restart your browser for the changes to take effect."
fi