You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.7 KiB

#!/bin/sh
# Acknowledgements:
# - Eric Hameleers (AlienBOB) - https://alien.slackbook.org/
set -e
retrieve() {
mkdir -p tmp
printf "Downloading 'versions.txt'...\n"
# Each zip contains a CDM binary, manifest.json file, and LICENSE.txt file.
# Current version can be read online (last line):
# https://dl.google.com/widevine-cdm/versions.txt
if [ ! -f "tmp/versions.txt" ]; then
curl --fail -o "tmp/versions.txt" \
"https://dl.google.com/widevine-cdm/versions.txt"
fi
# Set the latest version if not otherwise stated (last entry in the txt)
pkgver="${pkgver:-$(tail --quiet -n1 "tmp/versions.txt")}"
printf "Downloading '%s'...\n" "${pkgver}-linux-${pkgarch}.zip"
# The place where Mozilla Firefox downloads these ZIP files is documented here:
# https://github.com/mozilla/gecko-dev/blob/master/toolkit/content/gmp-sources/widevinecdm.json
if [ ! -f "tmp/${pkgver}-linux-${pkgarch}.zip" ]; then
curl --fail -o "tmp/${pkgver}-linux-${pkgarch}.zip" \
"https://dl.google.com/widevine-cdm/${pkgver}-linux-${pkgarch}.zip"
fi
}
prepare() {
# Test archve files
unzip -t "tmp/${pkgver}-linux-${pkgarch}.zip"
mkdir tmp/archive
unzip "tmp/${pkgver}-linux-${pkgarch}.zip" -d "tmp/archive/." 2>/dev/null
# Prepare the final dirtree structure, ready to be packaged
mkdir "${pkgdir}"
install -D -m755 "tmp/archive/libwidevinecdm.so" \
"${pkgdir}/usr/lib/chromium/WidevineCdm/_platform_specific/linux_${pkgarch}/libwidevinecdm.so"
# The manifest.json file is now used by Chromium to determine the features
# that are supported by the Widevine CDM:
install -m644 "tmp/archive/manifest.json" \
"${pkgdir}/usr/lib/chromium/WidevineCdm/"
# Enable for chromium
ln -sr "${pkgdir}/usr/lib/chromium/WidevineCdm/_platform_specific/linux_${pkgarch}/libwidevinecdm.so" \
"${pkgdir}/usr/lib/chromium/libwidevinecdm.so"
# Enable for chromium-ungoogled
install -d "${pkgdir}/usr/lib/chromium-ungoogled/"
ln -sr "${pkgdir}/usr/lib/chromium/WidevineCdm" \
"${pkgdir}/usr/lib/chromium-ungoogled/WidevineCdm"
ln -sr "${pkgdir}/usr/lib/chromium/WidevineCdm/_platform_specific/linux_${pkgarch}/libwidevinecdm.so" \
"${pkgdir}/usr/lib/chromium-ungoogled/libwidevinecdm.so"
sed -i '1s/^/Copyright 2022 Google Inc. <widevine@google.com>\n\n/' "tmp/archive/LICENSE.txt"
# Update the license in case it changes
if ! cmp --silent "debian/copyright" "tmp/archive/LICENSE.txt"; then
cp "tmp/archive/LICENSE.txt" "debian/copyright"
fi
# Update the changelog
dch \
--newversion "${pkgver}" \
--distribution unstable \
--controlmaint "New release."
}
#pkgver=4.10.2449.0
pkgarch=x64
pkgdir="tree"
retrieve
prepare
dpkg-buildpackage