SHARE
TWEET

latest-proprietary.sh

a guest Apr 21st, 2019 134 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # Discourage Ubuntu users from using this script, since they can (and should) install chromium-codecs-ffmpeg-extra directly
  4. if [ -r /etc/os-release ] && grep -qx 'ID=ubuntu' /etc/os-release; then
  5.   echo "You should not use this script on Ubuntu, install chromium-codecs-ffmpeg-extra via apt instead." >&2
  6.   read -p "Do you wish to continue anyway? [y/N]: " YN
  7.   case "$YN" in
  8.     [Yy]*) : ;;
  9.     [Nn]*) echo "Exiting." ; exit ;;
  10.         *) echo 'Answer not recognised, assuming "No". Exiting.'; exit ;;
  11.   esac
  12. fi
  13.  
  14. # Make sure the user is not runing as superuser
  15. if [ "$UID" = "0" ]; then
  16.   echo 'Do not run this script as root or via sudo. Run it as your normal user.' >&2
  17.   exit 1
  18. fi
  19.  
  20. available () {
  21.   command -v "$1" >/dev/null 2>&1
  22. }
  23.  
  24. # Make sure we have wget or curl
  25. if available wget; then
  26.   SILENT_DL="wget -qO-"
  27.   LOUD_DL="wget"
  28. elif available curl; then
  29.   SILENT_DL="curl -sL"
  30.   LOUD_DL="curl -O"
  31. else
  32.   echo "Install Wget or cURL" >&2
  33.   exit 1
  34. fi
  35.  
  36. # Set temp dir
  37. TMP="${TMP:-/tmp}"
  38.  
  39. # Set staging dir
  40. STAGINGDIR="$TMP/chromium-codecs-ffmpeg-extra-staging"
  41.  
  42. # Setup Arch
  43. case `uname -m` in
  44.    x86_64) DEB_ARCH=amd64; REPO=http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ ;;
  45.      i?86) DEB_ARCH=i386; REPO=http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ ;;
  46.      arm*) DEB_ARCH=armhf; REPO=http://ports.ubuntu.com/ubuntu-ports/pool/universe/c/chromium-browser/ ;;
  47.   aarch64) DEB_ARCH=arm64; REPO=http://ports.ubuntu.com/ubuntu-ports/pool/universe/c/chromium-browser/ ;;
  48. esac
  49.  
  50. # Work out the VERSION
  51. # Limit the UBUNTU version to 16.04 to avoid the glibc bump in 18.04, so that this works for older distros
  52. UBUNTU_PACKAGE=`${SILENT_DL} "$REPO" | sed -rn "s/.*(chromium-codecs-ffmpeg-extra_([0-9]+\.){3}[0-9]+-[0-9]ubuntu[0-9]\.16\.04\.[1-9]_$DEB_ARCH.deb).*/\1/p" | sort | tail -n 1`
  53. ## The original match was
  54. ## UBUNTU_PACKAGE=`${SILENT_DL} "$REPO" | sed -rn "s/.*(chromium-codecs-ffmpeg-extra_([0-9]+\.){3}[0-9]+-[0-9]ubuntu[0-9]\.([0-9]{2}\.){2}[0-9\.]*_$DEB_ARCH.deb).*/\1/p" | sort | tail -n 1`
  55. VERSION=`echo "$UBUNTU_PACKAGE" | sed -rn "s/.*_(([0-9]+\.){3}[0-9]+)-.*/\1/p"`
  56.  
  57. # Error out if $VERISON is unset, e.g. because previous command failed
  58. if [ -z "$VERSION" ]; then
  59.   echo "Could not work out the latest version; exiting" >&2
  60.   exit 1
  61. fi
  62.  
  63. # Don't start repackaging if the same version is already installed
  64. if [ -r "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt" ]; then
  65.   . "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt"
  66.   if [ "$INSTALLED_VERSION" = "$VERSION" ]; then
  67.     echo "The latest chromium-codecs-ffmpeg-extra ($VERSION) is already installed"
  68.     exit 0
  69.   fi
  70. fi
  71.  
  72. # Now we could screw things up so exit on first error
  73. set -e
  74.  
  75. # If the staging directory is already present from the past, clear it down
  76. # and re-create it.
  77. if [ -d "$STAGINGDIR" ]; then
  78.   rm -fr "$STAGINGDIR"
  79. fi
  80.  
  81. mkdir "$STAGINGDIR"
  82. cd "$STAGINGDIR"
  83.  
  84. # Now get the deb package
  85. $LOUD_DL "$REPO$UBUNTU_PACKAGE"
  86.  
  87.  
  88. # Extract the contents of the chromium-codecs-ffmpeg-extra package
  89. if available bsdtar; then
  90.   DEB_EXTRACT_COMMAND='bsdtar xOf'
  91. elif available ar; then
  92.   DEB_EXTRACT_COMMAND='ar p'
  93. else
  94.   fallback_data_extract () {
  95.     dd status=none iflag=skip_bytes if="$1" skip=`grep -Fabom1 "\`printf \"\\\\\3757zXZ\"\`" "$1" | cut -d: -f1`
  96.   }
  97.   DEB_EXTRACT_COMMAND=fallback_data_extract
  98. fi
  99. $DEB_EXTRACT_COMMAND "$UBUNTU_PACKAGE" data.tar.xz | tar xJf - ./usr/lib/chromium-browser/libffmpeg.so --strip 4
  100.  
  101. # Check the libffmpeg.so dependencies are resolved
  102. if LANGUAGE=en ldd libffmpeg.so 2>&1 | grep -qm1 'not \(a dynamic executable\|found\)'; then
  103. cat <<EOF >&2
  104.  
  105. It is not possible to use this alternative libffmpeg on your system.
  106.  
  107. Let us know via a post in our forums, mentioning your distro and distro
  108. version:
  109.  
  110.   https://forum.vivaldi.net/category/35/vivaldi-browser-for-linux
  111.  
  112. EOF
  113.   exit 1
  114. fi
  115.  
  116. # Note the version number for future reference, during upgrades
  117. echo "INSTALLED_VERSION=$VERSION" > chromium-codecs-ffmpeg-extra-version.txt
  118.  
  119. # Install the files
  120. install -Dm644 libffmpeg.so "$HOME/.local/lib/vivaldi/libffmpeg.so"
  121. install -Dm644 chromium-codecs-ffmpeg-extra-version.txt "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt"
  122.  
  123. # Tell the user we are done
  124. cat <<EOF
  125.  
  126. The following files were installed onto your system:
  127.  
  128.   $HOME/.local/lib/vivaldi/libffmpeg.so
  129.   $HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt
  130.  
  131. Restart Vivaldi and test H.264/MP4 support via this page:
  132.  
  133.   http://www.quirksmode.org/html5/tests/video.html
  134.  
  135. EOF
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top