#!/bin/bash # Copyright 2016-2020 Jay Flood, SP, Brasil # 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. # # Author: brokenman@porteus.org # mangled by: ncmprhnsbl # version: 20200209 # # This is a script to update basilisk # Source porteus-functions . /usr/share/porteus/porteus-functions get_colors txtbld=$(tput bold) txtred=${txtbld}$(tput setaf 1) txtgreen=${txtbld}$(tput setaf 2) txtwhite=${txtbld}$(tput setaf 7) txtcyan=${txtbld}$(tput setaf 6) rst=$(tput sgr0) function bold(){ echo -e $txtbld "$1" $rst; } function green() { echo -e $txtgreen "$1" $rst; } function red(){ echo $txtred "$1" $rst; } function cyan(){ echo $txtcyan "$1" $rst; } saypass(){ echo "[${txtbold}${txtgreen}PASS$rst] $1"; } sayfail(){ echo "[${txtbold}${txtred}FAIL$rst] $1"; } # Check for root if [ `whoami` != "root" ]; then echo "Only root can run this." exit 1 fi # functions set work directory(default is /tmp) to current work directory set_tmp() { WRKDIR=/tmp } set_pwd() { WRKDIR=`pwd` } # echo usage show_help() { echo " options: -d : do operations in the present directory, instead of /tmp . " echo " -h : show this usage. " } while getopts ":-d:-h:" o; do case "$1" in -d) set_pwd;; -h) show_help exit 0;; *) show_help exit 1;; esac done case "$1" in "") set_tmp;; esac # tell us where the work will be done echo "Work will be done in: $WRKDIR " ## Check if there's enough working space [ `df -l --output=avail $WRKDIR | tail -1` -lt 384000 ] && { red "There's not enough space to run this script"; exit 1; } # Check if basilisk is currently installed bold "Checking if basilisk is installed ..." command -pv basilisk >/dev/null && ISINSTALLED=0 # Get current basilisk version if installed if [ "$ISINSTALLED" ]; then sayok "basilisk is installed" CVER=`ls /var/lib/pkgtools/packages/basilisk* | sort | tail -n1 | awk -F- '{print$2}'` [ "$CVER" ] || CVER=`basilisk --version | cut -d"." -f3-5` [ "$CVER" ] && sayok "installed basilisk version: $txtgreen $CVER $rst" || echo "No basilisk version found" else echo "basilisk is not installed" fi # Set variables RELURL=http://www.basilisk-browser.org/releasenotes.shtml USE_SYSTEM_SPELLCHECK=yes CWD=`pwd` ARCH=${ARCH:-$(uname -m)} SERVER=`awk -F= '/SERVER=/{print$NF}' /etc/porteus.conf` case "$ARCH" in i?86) PARCH="i586" ; LIBDIRSUFFIX="" ; ARCH=i686 ;; x86_64) PARCH="x86_64" ; LIBDIRSUFFIX="64" ; ARCH=x86_64 ;; *) echo "Package for $(uname -m) architecture is not available." ; exit 1 ;; esac ## Check for basilisk file in $WRKDIR ## If it exists then ask to build from it. if [ `ls $WRKDIR/basilisk-* 2>/dev/null | wc -l` -ge 1 ]; then # Make sure it is a tarball(xz) cfile=( `ls -1 $WRKDIR/basilisk-*.xz 2>/dev/null | awk -F/ '{print$NF}'` ) if [ ${#cfile[@]} -gt 0 ]; then RESULT=${cfile[@]} echo green "A basilisk tarball was found in $WRKDIR" echo " We will use this archive to create basilisk." menu_from_array "Choose the basilisk file you want to process." echo "CHOICE:$CHOICE" fi fi bold "Checking for Porteus ..." is_porteus && saypass "Distro is Porteus" || { sayfail "Distro is not Porteus"; cleanup; } echo "Getting latest version ..." ## sometimes there is inconsistancy in the webpage or version formatting #VER=`wget release -q -O - $RELURL | sed -n '/ $PKG/opt/basilisk/distribution/distribution.ini } get_home_page(){ HOMEPAGE="https://forum.porteus.org" bold "Set your home page." echo " Leave blank for: https://forum.porteus.org and press Enter to continue." read -p "> " answ if [ `wc -c <<<$answ` -gt 1 ]; then HOMEPAGE=$answ unset answ echo "Verifying home page ..." if is_online_url $HOMEPAGE; then saypass "Homepage is online." else sayfail "This homepage is not available." echo $FUNCNAME fi else saypass "Homepage is available" fi } # Special checksum check .. for some reason, matching sums fail?? checksum () { echo "Verifying download integrity.." echo "Server : $SUM1" echo "Download: $SUM2" if [ "$SUM1" = "$SUM2" ]; then echo "Download verified." else read -p "Integrity check failed. Would you like to continue anyway? [y/n]" -n 1 -r -s && echo if [[ $REPLY =~ ^[Nn]$ ]]; then cleanup fi fi } trap cleanup SIGHUP SIGINT SIGTERM if [ -z $CHOICE ]; then echo echo "The latest version is:" $txtgreen "basilisk-$VER" $rst echo "The porteus server module version is:" $txtgreen "basilisk-$SERVER_LATVER" $rst read -p " Would you like to download the porteus server module? [y/n]" -n 1 -r -s && echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo download $SERVER/$PARCH/current/modules/$SERVER_LATFILE $WRKDIR ## Check that we have a module in $WRKDIR if [ ! -f $WRKDIR/$SERVER_LATFILE ]; then echo sayerror "Download of the basilisk module failed." cleanup else echo echo "Your file is at:" $txtcyan "$WRKDIR/$SERVER_LATFILE" $rst echo "Please move it to your modules folder to survive a reboot." echo cleanup fi else read -p " Would you like to create a module of the latest version? [y/n]" -n 1 -r -s && echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then cleanup; fi fi fi get_home_page get_mirror TMPDIR=$WRKDIR/.bask.$$ PRGNAM=basilisk XZURL=http://$MIRROR.basilisk-browser.org/release/basilisk-latest.linux64.tar.xz PFILE=${XZURL##*/} PKG=$TMPDIR/package-$PRGNAM OUTPUT=${OUTPUT:-$WRKDIR} SERVER=`awk -F= '/SERVER=/{print$NF}' /etc/porteus.conf` ## Create temp dir [ ! -d $TMPDIR ] && mkdir -p $TMPDIR || rm -rf $TMPDIR/* ## Download tarball if [ ! -e $WRKDIR/$PFILE ]; then download $XZURL $TMPDIR else cp -a $WRKDIR/$PFILE $TMPDIR fi ## Check that we have an archive in TMPDIR if [ ! -f $TMPDIR/$PFILE ]; then echo sayerror "File $PFILE not found" cleanup fi ## Get and check checksum for tarball SHAURL=https://www.basilisk-browser.org/download.shtml SUM1=`wget release -q -O - $SHAURL | sed -n '/latest.linux64.tar.xz:/{n;p}'` SUM2=`sha256sum $TMPDIR/basilisk* | cut -d" " -f1` checksum ## Make the package and module mkdir -p $PKG cd $PKG tar xvf ../$PFILE || { red "Failed to decompress tarball."; exit 1; } chown -R root:root $PRGNAM 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 {} \; # use system hunspell if user wants it if [[ $USE_SYSTEM_SPELLCHECK == "yes" ]]; then rm -rf basilisk/dictionaries ln -sv /usr/share/hunspell basilisk/dictionaries fi # create directories mkdir -p $PKG/opt mkdir -p $PKG/usr/bin mkdir -p $PKG/usr/share/icons/hicolor/{16x16,32x32,48x48,128x128}/apps mkdir -p $PKG/usr/share/applications #mkdir -p $PKG/install # install basilisk into /opt cp -vr basilisk $PKG/opt rm -rf basilisk # create settings directory for distribution.ini for homepage setting mkdir -p $PKG/opt/basilisk/distribution # link stuff ## binary ln -s /opt/basilisk/basilisk $PKG/usr/bin/basilisk ## icons ln -s /opt/basilisk/browser/chrome/icons/default/default16.png $PKG/usr/share/icons/hicolor/16x16/apps/basilisk.png ln -s /opt/basilisk/browser/chrome/icons/default/default32.png $PKG/usr/share/icons/hicolor/32x32/apps/basilisk.png ln -s /opt/basilisk/browser/chrome/icons/default/default48.png $PKG/usr/share/icons/hicolor/48x48/apps/basilisk.png ln -s /opt/basilisk/browser/icons/mozicon128.png $PKG/usr/share/icons/hicolor/128x128/apps/basilisk.png ## Add distribution.ini to set homepage echo "Setting Porteus Forum to Homepage" create_default_homepage # Add home page echo "Adding home page ..." sed -i 's@https://forum.porteus.org@'$HOMEPAGE'@g' $PKG/opt/basilisk/distribution/distribution.ini ## Install desktop file mkdir -p $PKG/usr/share/applications 2>/dev/null echo "W0Rlc2t0b3AgRW50cnldCkV4ZWM9YmFzaWxpc2sgJXUKSWNvbj1iYXNpbGlzawpUeXBlPU FwcGxpY2F0aW9uCkNhdGVnb3JpZXM9TmV0d29yazsKTmFtZT1CYXNpbGlzawpNaW1lVHlwZT10ZX h0L2h0bWw7dGV4dC94bWw7YXBwbGljYXRpb24veGh0bWwreG1sO2FwcGxpY2F0aW9uL3ZuZC5tb3 ppbGxhLnh1bCt4bWw7dGV4dC9tbWw7eC1zY2hlbWUtaGFuZGxlci9odHRwO3gtc2NoZW1lLWhhbm RsZXIvaHR0cHM7ClgtS0RFLVN0YXJ0dXBOb3RpZnk9dHJ1ZQo=" | base64 -d > $PKG/usr/share/applications/$PRGNAM.desktop cp -a $PKG/usr/share/applications/$PRGNAM.desktop $PKG/usr/share/applications/browser.desktop echo "NoDisplay=true" >> $PKG/usr/share/applications/browser.desktop sed -i 's/MimeType/#MimeType/' $PKG/usr/share/applications/browser.desktop echo "Fixing permissions ..." find $PKG -type d | xargs -i chmod 755 {} find $PKG -type f | xargs -i chmod 644 {} chmod +x $PKG/opt/basilisk/{mozilla*,basilisk*} for a in `find $PKG -type f`; do if [[ `file $a | grep -o ELF` ]]||[[ `file $a | grep -o "shell"` ]]; then echo "Setting ${a##*/} as executable ..." chmod +x $a fi done if [ -d $PKG/home/guest ]; then echo "Setting guest permsissions ..."; chown -R guest: $PKG/home/guest; fi chmod 755 $PKG/opt/basilisk/{mozilla*,plugin*,basilisk*,run*} #echo "Copying config files ..." #cp -a $CWD/files/* $PKG #chown -R guest: $PKG/home/guest 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 cd $PKG ### fake slackware type package info: super dumb version PKGINFO=var/lib/pkgtools/packages #FILES=`find *` mkdir -p $PKGINFO echo "PACKAGE NAME: $PRGNAM-$VER-$ARCH" > $PKGINFO/$PRGNAM-$VER-$ARCH cat >> $PKGINFO/$PRGNAM-$VER-$ARCH << EOM PACKAGE DESCRIPTION: basilisk: basilisk (Web browser) basilisk: basilisk: Basilisk is a free and Open Source XUL-based web browser, basilisk: featuring the Firefox-style "Australis" interface and operation. basilisk: It is based on the Goanna rendering engine(a fork of Gecko) basilisk: and builds on the Unified XUL Platform, which in turn is a fork basilisk: of the Mozilla code base without Servo or Rust. basilisk: basilisk: Homepage: http://www.basilisk.org/ basilisk: FILE LIST: EOM find * | grep -v var >> $PKGINFO/$PRGNAM-$VER-$ARCH #/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VER-$ARCH-1.txz || { red "Failed to create slackware package."; exit 1; } #txz2xzm $OUTPUT/$PRGNAM-$VER-$ARCH-1.txz || { red "Failed to create porteus module."; exit 1; } cd $WRKDIR && dir2xzm $PKG $OUTPUT/$PRGNAM-$VER-$ARCH.xzm echo echo "Your file is at:" $txtgreen "$OUTPUT/$PRGNAM-$VER-$ARCH.xzm" $rst cyan "Please copy it to your modules folder to survive a reboot." echo cleanup