summaryrefslogtreecommitdiffstats
path: root/network/qutebrowser-tox/qutebrowser-tox.SlackBuild
blob: 9575126d072191856bfed80333283ad589218e75 (plain)
#!/bin/sh

# Slackware build script for qutebrowser-tox

# Copyright 2019, Alexander Verbovetsky, Moscow, Russia
# 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.

PRGNAM=qutebrowser-tox
VERSION=${VERSION:-1.8.2}
SSLVERSION=${SSLVERSION:-1.1.1d}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

if [ "$ARCH" != "x86_64" ]; then
  echo "Only x86_64 is supported."
  exit 1
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

set -e

rm -rf $PKG
mkdir -p $TMP $PKG/opt $OUTPUT
cd $PKG/opt
tar xvf $CWD/qutebrowser-$VERSION.tar.gz
mv qutebrowser-$VERSION qutebrowser
cd qutebrowser
sed -i "/\[testenv:mkvenv-pypi\]/ a \
install_command = pip install --no-index --find-links $CWD/ {opts} {packages}"\
  tox.ini

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 {} \;

tox -e mkvenv-pypi

find ./ -type f -name '*.pyc' -delete
find ./ -type d -name '__pycache__' -delete
find ./ -type f -exec sed -i -e "s|$PKG||" {} \;
sed -i "/\[testenv:mkvenv-pypi\]/ {n;d;}" tox.ini
find ./ -type f -exec sed -i -e \
  '1,2 s|^#!/usr/bin/env python.*$|#!/opt/qutebrowser/.venv/bin/python3|' {} \;
.venv/bin/python3 -m compileall scripts/__init__.py \
  scripts/setupcommon.py scripts/utils.py -fq
.venv/bin/python3 -m compileall .venv/lib -fq

.venv/bin/python3 scripts/asciidoc2html.py
a2x -f manpage doc/qutebrowser.1.asciidoc
gzip -9 doc/qutebrowser.1
mkdir -p $PKG/usr/man/man1
mv doc/qutebrowser.1.gz $PKG/usr/man/man1

mkdir -p $PKG/usr/share/{metainfo,applications,icons/hicolor/scalable/apps,pixmaps,qutebrowser/pdf.js}
install -m 0644 misc/org.qutebrowser.qutebrowser.appdata.xml \
  $PKG/usr/share/metainfo/
install -m 0644 misc/org.qutebrowser.qutebrowser.desktop \
  $PKG/usr/share/applications
for res in 16 24 32 48 64 96 128 256 512; do
  mkdir -p $PKG/usr/share/icons/hicolor/${res}x${res}/apps/;
  install -m 0644 "icons/qutebrowser-${res}x${res}.png" \
"$PKG/usr/share/icons/hicolor/${res}x${res}/apps/qutebrowser.png"
done
install -m 0644 "icons/qutebrowser.svg" \
  $PKG/usr/share/icons/hicolor/scalable/apps/
install -m 0644 "icons/qutebrowser.xpm" $PKG/usr/share/pixmaps/

cp -a misc/userscripts $PKG/usr/share/qutebrowser
cp -a scripts $PKG/usr/share/qutebrowser
rm -rf $PKG/usr/share/qutebrowser/scripts/{__pycache__,dev,testbrowser,__init__.py,asciidoc2html.py,setupcommon.py,link_pyqt.py}

mkdir -p $PKG/usr/bin
install -m 0755 -o root -g root $CWD/wrapper.qutebrowser \
  $PKG/usr/bin/qutebrowser

find ./ -type f -exec sed -i -e \
  's|/usr/share/pdf.js|/usr/share/qutebrowser/pdf.js|' {} \;
cd $PKG/usr/share/qutebrowser/pdf.js
unzip $CWD/pdfjs-*-dist.zip
chown -R root:root $PKG/usr/share/qutebrowser/pdf.js
find ./ -type f -exec chmod 644 {} \;

cd $TMP
rm -rf openssl-$SSLVERSION
tar xvf $CWD/openssl-$SSLVERSION.tar.gz
cd openssl-$SSLVERSION
./config \
 zlib \
 enable-camellia \
 enable-seed \
 enable-rfc3779 \
 enable-cms \
 enable-md2 \
 enable-rc5 \
 enable-ssl3 \
 enable-ssl3-method \
 no-weak-ssl-ciphers \
 no-mdc2 \
 no-ec2m \
 no-idea \
 no-sse2 \
 shared

make

mv libcrypto.so.1.1 libssl.so.1.1 $PKG/opt/qutebrowser
cd $PKG/opt/qutebrowser

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

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README.asciidoc $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}