A script to simplify maintaining the SBo version of Vivaldi for Slackware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
TMP="${TMP:-/tmp}" | |
REPACKDIR="$TMP/vivaldi-sbo-tar/vivaldi" | |
mkdir -p "$REPACKDIR" | |
cd "$REPACKDIR" | |
# Find out Vivaldi stable version and calculate md5sums | |
VERSION="${VERSION:-$(wget -qO- http://repo.vivaldi.com/archive/deb/dists/stable/main/binary-amd64/Packages.gz | gzip -d | grep -A6 -x 'Package: vivaldi-stable' | sed -n '/Version/s/.* //p' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1 | cut -d- -f1)}" | |
if [ ! -e "vivaldi-stable_$VERSION-1_amd64.deb" ]; then | |
wget "https://downloads.vivaldi.com/stable/vivaldi-stable_$VERSION-1_amd64.deb" | |
fi | |
VIV_SUM="$(md5sum "vivaldi-stable_$VERSION-1_amd64.deb" | cut '-d ' -f1)" | |
if [ ! -e "$VERSION.html" ]; then | |
wget "https://update.vivaldi.com/update/1.0/relnotes/$VERSION.html" | |
fi | |
CHL_SUM="$(md5sum "$VERSION.html" | cut '-d ' -f1)" | |
# Create SlackBuild and other meta data | |
cat <<EOF>README | |
vivaldi (web browser). | |
Experience the web in a whole new way with Vivaldi. | |
Vivaldi is a browser that has the features you need, a style that fits | |
and values you can stand by. Your browser matters. Take control with | |
Vivaldi. | |
EOF | |
# Add a note about uninstall and the lib fetched by update-ffmpeg | |
cat <<EOF>README.SBo | |
# Proprietary media support | |
Vivaldi does not directly bundle any library with support for | |
"proprietary media" (H.264/AAC), since this would make redistribution of | |
the output package difficult (due to software patent licensing). | |
Instead, the script '/opt/vivaldi/update-ffmpeg' fetches a suitable lib | |
from a third party (and verifies it). This can be run in two ways. | |
## System-wide install | |
The recommended method is for the user to run it as root (with no | |
arguments) immediately after installing (or upgrading) Vivaldi, but | |
before first run. The file will then be placed in '/var/opt/vivaldi' and | |
found by Vivaldi when you launch it afterwards. | |
Files installed this way will even be cleaned up automatically on | |
uninstall by 'douninst.sh'. Alternatively running 'update-ffmpeg' again | |
(as root) with '--undo' will also remove the lib and associated | |
directories. | |
## Per-user install | |
If you do not run the 'update-ffmpeg' as root before first run, Vivaldi | |
will call this script itself, automatically on first launch (with the | |
option '--user'). In this case the lib will be installed into | |
'~/.local/lib/vivaldi' (for each user who launches Vivaldi) and will | |
then be available, from the next restart (of the browser). | |
If you wish to remove the file from '~/.local/lib/vivaldi', you can run | |
'update-ffmpeg' as follows: | |
/opt/vivaldi/update-ffmpeg --user --undo | |
Alternatively look in '~/.local/lib/vivaldi' and remove the files | |
manually. | |
NOTE: Keep in mind the lib will be automatically reinstalled in | |
'~/.local/lib/vivaldi' if any user on the system launches Vivaldi again. | |
EOF | |
cat <<EOF>doinst.sh | |
if [ -x /usr/bin/update-desktop-database ]; then | |
/usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1 | |
fi | |
if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then | |
if [ -x /usr/bin/gtk-update-icon-cache ]; then | |
/usr/bin/gtk-update-icon-cache -f usr/share/icons/hicolor >/dev/null 2>&1 | |
fi | |
fi | |
EOF | |
cat <<EOF>douninst.sh | |
# Remove any lib fetched by '/opt/vivaldi/update-ffmpeg' that was | |
# installed system-wide into '/var/opt' | |
rm -f /var/opt/vivaldi/media-codecs-*/libffmpeg.so | |
if [ -d /var/opt/vivaldi ]; then | |
# This removes directory trees that are empty or only populated by other | |
# empty directories. | |
find /var/opt/vivaldi -depth -type d -empty -exec rmdir {} \; | |
# '/var/opt' is not part of the default Slackware install, so we will | |
# remove it, if it is now empty (following the above). | |
rmdir --ignore-fail-on-non-empty /var/opt | |
fi | |
EOF | |
cat <<EOF>slack-desc | |
# HOW TO EDIT THIS FILE: | |
# The "handy ruler" below makes it easier to edit a package description. | |
# Line up the first '|' above the ':' following the base package name, and | |
# the '|' on the right side marks the last column you can put a character in. | |
# You must make exactly 11 lines for the formatting to be correct. It's also | |
# customary to leave one space after the ':' except on otherwise blank lines. | |
|-----handy-ruler------------------------------------------------------| | |
vivaldi: vivaldi (web browser) | |
vivaldi: | |
vivaldi: Experience the web in a whole new way with Vivaldi. | |
vivaldi: | |
vivaldi: Vivaldi is a browser that has the features you need, a style that fits | |
vivaldi: and values you can stand by. Your browser matters. Take control with | |
vivaldi: Vivaldi. | |
vivaldi: | |
vivaldi: Home Page: https://vivaldi.com | |
vivaldi: | |
vivaldi: | |
EOF | |
cat <<EOF>vivaldi.SlackBuild | |
#!/bin/bash | |
# | |
# Slackware build script for vivaldi. | |
# | |
# Copyright 2015-2017 Edinaldo P. Silva, Rio de Janeiro, Brazil. | |
# Copyright 2017-2019, Alexander Verbovetsky, Moscow, Russia | |
# Copyright 2019-$(date +%Y), Ruari Oedegaard, Oslo, Norway | |
# All rights reserved. | |
# | |
# Redistribution and use of this script, with or without modification, is | |
# permitted provided that the following conditions are met: | |
# | |
# 1. Redistributions of this script must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# | |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED | |
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
cd \$(dirname \$0) ; CWD=\$(pwd) | |
PRGNAM=vivaldi | |
VERSION=\${VERSION:-$VERSION} | |
BUILD=\${BUILD:-1} | |
TAG=\${TAG:-_SBo} | |
PKGTYPE=\${PKGTYPE:-tgz} | |
if [ -z "\$ARCH" ]; then | |
case "\$( uname -m )" in | |
arm*) ARCH=arm ;; | |
*) ARCH=\$( uname -m ) ;; | |
esac | |
fi | |
if [ ! -z "\${PRINT_PACKAGE_NAME}" ]; then | |
echo "\$PRGNAM-\$VERSION-\$ARCH-\$BUILD\$TAG.\$PKGTYPE" | |
exit 0 | |
fi | |
TMP=\${TMP:-/tmp/SBo} | |
PKG=\$TMP/package-\$PRGNAM | |
OUTPUT=\${OUTPUT:-/tmp} | |
set -e | |
rm -rf \$PKG \$TMP/\$PRGNAM | |
mkdir -p \$TMP/\$PRGNAM \$PKG \$OUTPUT | |
cd \$TMP/\$PRGNAM | |
ar p \$CWD/\${PRGNAM}-stable_\${VERSION}-*.deb data.tar.xz | tar xJ ./opt ./usr | |
chown -R root:root . | |
find -L . \\ | |
\\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \\ | |
-o -perm 511 \) -exec chmod 755 {} \; -o \\ | |
\\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \\ | |
-o -perm 440 -o -perm 400 \\) -exec chmod 644 {} \; | |
rm -r opt/vivaldi/cron usr/share/doc | |
mv opt usr \$PKG/ | |
find \$PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \\ | |
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true | |
# Create relative symlinks (first removing any potentially non-relative | |
# ones). | |
rm -f \$PKG/usr/bin/vivaldi* \$PKG/opt/vivaldi/WidevineCdm | |
ln -s ../../opt/vivaldi/vivaldi \$PKG/usr/bin/vivaldi | |
ln -s ../../opt/vivaldi/vivaldi \$PKG/usr/bin/vivaldi-stable | |
# This following may appear as a broken/dangling symlink but it actually | |
# can be used by Vivaldi as a fallback source for Widevine in cases | |
# where, Google Chrome is also installed (it bundles Widevine at the | |
# linked location) and the components system in the browser | |
# (vivaldi://components) is non-functional. | |
ln -s ../google/chrome/WidevineCdm \$PKG/opt/vivaldi/WidevineCdm | |
for res in 16 22 24 32 48 64 128 256; do | |
install -Dm644 "\$PKG/opt/vivaldi/product_logo_\${res}.png" \\ | |
"\$PKG/usr/share/icons/hicolor/\${res}x\${res}/apps/vivaldi.png" | |
done | |
sed \\ | |
-e "s|vivaldi-stable|vivaldi|" \\ | |
\$PKG/usr/share/applications/vivaldi-stable.desktop \\ | |
> \$PKG/usr/share/applications/vivaldi.desktop | |
rm \$PKG/usr/share/applications/vivaldi-stable.desktop | |
for doc in README README.SBo \$PRGNAM.SlackBuild; do | |
install -Dm644 \$CWD/\$doc \$PKG/usr/doc/\$PRGNAM-\$VERSION/\$doc | |
done | |
lynx -dump file://\$CWD/\${VERSION}.html > \$PKG/usr/doc/\$PRGNAM-\$VERSION/ChangeLog | |
mkdir -p \$PKG/install | |
cat \$CWD/slack-desc > \$PKG/install/slack-desc | |
cat \$CWD/doinst.sh > \$PKG/install/doinst.sh | |
cat \$CWD/douninst.sh > \$PKG/install/douninst.sh | |
cd \$PKG | |
/sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-\$ARCH-\$BUILD\$TAG.\$PKGTYPE | |
EOF | |
chmod 755 vivaldi.SlackBuild | |
cat <<EOF>vivaldi.info | |
PRGNAM="vivaldi" | |
VERSION="$VERSION" | |
HOMEPAGE="https://vivaldi.com" | |
DOWNLOAD="UNSUPPORTED" | |
MD5SUM="" | |
DOWNLOAD_x86_64="https://downloads.vivaldi.com/stable/vivaldi-stable_$VERSION-1_amd64.deb \\ | |
https://update.vivaldi.com/update/1.0/relnotes/$VERSION.html" | |
MD5SUM_x86_64="$VIV_SUM \\ | |
$CHL_SUM" | |
REQUIRES="" | |
MAINTAINER="Ruari Oedegaard" | |
EMAIL="sbo@ruari.com" | |
EOF | |
cd .. | |
chmod -R u+w,go+r-w,a-s . | |
# Package it all up and inform user | |
cat <<EOF | cpio --quiet -R0:0 -oHustar | gzip -9 > vivaldi.tar.gz | |
vivaldi | |
vivaldi/README | |
vivaldi/README.SBo | |
vivaldi/doinst.sh | |
vivaldi/douninst.sh | |
vivaldi/slack-desc | |
vivaldi/vivaldi.SlackBuild | |
vivaldi/vivaldi.info | |
EOF | |
printf "\n Created: $PWD/vivaldi.tar.gz\n\n" | |
echo "Test this and if ok, upload to https://slackbuilds.org/submit/ with the category 'Network'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment