#!/bin/bash # This is Remmina bundle update script for Porteus # Version 2024-10-26 # Copyright 2024-2030, Blaze, Dankov, 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. # Root check if [ `whoami` != "root" ]; then echo -e "\nYou need to be root to run this script.\n" exit 1 fi PRGNAM=${PRGNAM:-remmina} VERSION=$(lynx -source "https://gitlab.com/Remmina/Remmina/-/tags" | grep "Release v" | head -n1 | cut -d'v' -f2 | cut -d'<' -f1) MASTER=$(echo https://gitlab.com/Remmina/Remmina/-/archive/master/Remmina-master.tar.bz2) BOLD=${BOLD:-"\e[1m"} CYAN=${CYAN:-"\e[96m"} GREEN=${GREEN:-"\e[92m"} RED=${RED:-"\e[31m"} RESET=${RESET:-"\e[0m"} CWD=$(pwd) TMPDIR=/tmp/portch PKG=$TMPDIR/package-$PRGNAM PKGINFO=$PKG/var/lib/pkgtools/packages OUTPUT=${OUTPUT:-/tmp} systemFullVersion=$(cat /etc/slackware-version) if [[ ${systemFullVersion//* } != *"+" ]]; then # options for Slackware-stable AVAHI=${AVAHI:-OFF} KWALLET=${KWALLET:-OFF} TELEPATHY=${TELEPATHY:-OFF} else # options for Slackware-current AVAHI=${AVAHI:-ON} KWALLET=${KWALLET:-OFF} TELEPATHY=${TELEPATHY:-OFF} fi if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2" LIBDIRSUFFIX="" fi set -e ## cleanup function cleanup(){ [ -d $TMPDIR ] && rm -rf $TMPDIR [ -d $PKG ] && rm -rf $PKG exit } ## functions to choose locale from a menu array_menu(){ echo echo "$1" echo "$2" select CHOICE in ${RESULT[@]}; do if [ -z "$CHOICE" ]; then echo "English locale chosen." && echo else echo "$CHOICE locale chosen" fi break done } get_locale(){ # Set locales in array for a in ar ast be ber bg bn ca 'ca\@valencia' ckb cs da de el en_AU en_GB en_US es es_VE et eu fa fr gl he hi hr hu id ie it ja ka kab kk km kn ko lt lv mk mr ms my nb nl oc pl pt_BR pt-PT ro ru shn si sk sl sq sr sv te th tr ug uk uz 'uz\@cyrillic' vi zh_CN zh_TW; do RESULT+=( $a ) done array_menu "Choose a locale from the list." "All other locales will be removed." ${RESULT[@]} unset RESULT } # Check if remmina installed in the system if [[ -f "/usr/bin/remmina" ]]; then MYVER=${MYVER:-`ls /var/lib/pkgtools/packages/*remmina* | cut -d'-' -f2`} fi if [ "$MYVER" == "$VERSION" ]; then echo -e "You have the latest ${GREEN}$MYVER${RESET} version of $PRGNAM" sleep 5 exit else read -p "$(echo -e Would you like to build $PRGNAM ${GREEN}$VERSION${RESET} xzm module? [y/n])" -n 1 -r -s && echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "We continue the execution of the $0 script" &>/dev/null else exit fi fi echo -e "\nDownloading dependencies for ${BOLD}$PRGNAM-$VERSION-$ARCH${RESET}" rm -f ${OUTPUT}/*.txz ${OUTPUT}/*.xzm if [[ "$XDG_CURRENT_DESKTOP" == "X-Cinnamon" || "$XDG_CURRENT_DESKTOP" == "LXDE" || "$XDG_CURRENT_DESKTOP" == "MATE" || "$XDG_DESKTOP_SESSION" == "openbox" || "$XDG_CURRENT_DESKTOP" == "XFCE" ]]; then getpkg -q cups freerdp libappindicator libdbusmenu libsodium libvncserver elif [[ "$XDG_CURRENT_DESKTOP" == "GNOME" || "$XDG_CURRENT_DESKTOP" == "KDE" || "$XDG_CURRENT_DESKTOP" == "LXQt" ]]; then getpkg -q cups freerdp libappindicator libdbusmenu libindicator libsodium libvncserver else getpkg -q cups freerdp json-glib libappindicator libdbusmenu libindicator libsodium libvncserver fi echo -e "\nActivating dependencies for ${BOLD}$PRGNAM-$VERSION-$ARCH${RESET}" deactivate ${OUTPUT}/*.xzm -q && activate ${OUTPUT}/*.xzm -q [ -e $TMPDIR ] && rm -rf $TMPDIR mkdir -p $PKG # build xzm module of remmina echo -e "\nCompiling ${BOLD}${PRGNAM}-${VERSION}-${ARCH}${RESET}" cd $PKG && wget -q $MASTER tar -xjf Remmina-master.tar.bz2 && rm -f Remmina-master.tar.bz2 cd Remmina-master 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 {} \; mkdir -p build cd build cmake \ -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS -Wno-error=incompatible-pointer-types" \ -D CMAKE_BUILD_TYPE=None \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_LIBDIR=/usr/lib${LIBDIRSUFFIX} \ -DWITH_AVAHI=${AVAHI} \ -DWITH_TELEPATHY=${TELEPATHY} \ -DWITH_VTE=ON \ -DWITH_APPINDICATOR=ON \ -DWITH_NEWS=OFF \ -DWITH_WWW=OFF \ -DWITH_KF5WALLET=${KWALLET} \ -DWITH_X2GO=ON \ -DWITH_GVNC=ON \ -W no-dev \ -DCMAKE_BUILD_TYPE=Release .. make VERBOSE=1 make install DESTDIR=$PKG cd $PKG && rm -rf $PKG/Remmina-master 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 ### fake Slackware type package info: super dumb version mkdir -p $PKGINFO echo "PACKAGE NAME: $PRGNAM-$VERSION-$ARCH" > $PKGINFO/$PRGNAM-$VERSION-$ARCH cat >> $PKGINFO/$PRGNAM-$VERSION-$ARCH << EOM PACKAGE DESCRIPTION: remmina: remmina (GTK+ Remote Desktop Client) remmina: remmina: Remmina is a remote desktop client written in GTK+, aiming to be remmina: useful for system administrators and travellers, who need to work remmina: with lots of remote computers in front of either large monitors or remmina: tiny netbooks. Remmina supports multiple network protocols in an remmina: integrated and consistant user interface. Currently RDP, VNC, SPICE, remmina: and SSH are supported. remmina: remmina: homepage: https://remmina.org/ remmina: FILE LIST: EOM deactivate ${OUTPUT}/*.xzm -q && rm -rf ${OUTPUT}/*.xzm ${OUTPUT}/cups*.txz if [[ "$XDG_CURRENT_DESKTOP" == "X-Cinnamon" || "$XDG_CURRENT_DESKTOP" == "LXDE" || "$XDG_CURRENT_DESKTOP" == "MATE" || "$XDG_DESKTOP_SESSION" == "openbox" || "$XDG_CURRENT_DESKTOP" == "XFCE" ]]; then rm -rf ${OUTPUT}/{*indicator*,libdbusmenu*}.txz fi for i in $(find ${OUTPUT} -type f | grep ".txz" | sort); do ROOT=$PKG installpkg $i >/dev/null; done rm -rf ${OUTPUT}/*.txz # clean unusful stuff rm -rf $PKG/usr/{doc,man,include,info,src} rm -rf $PKG/usr/lib{,64}/{cmake,girepository-1.0,pkgconfig} rm -rf $PKG/usr/lib{,64}/python*/site-packages/*.egg-info rm -rf $PKG/usr/share/{doc,gir-1.0,gtk-doc,help,licenses,man,pkgconfig} rm -rf $PKG/usr/share/locale/{ab,af,as,az,bn_IN,fur,ky,ml,ne,or,pa,sr@latin,tg,zh_HK} rm -rf $PKG/var/lib/pkgtools/douninst.sh rm -f $PKG/var/log/scripts/* rm -f $PKG/{,usr/}lib{,64}/*.la find $PKG -type f -name "*.la" -delete find $PKG -type f -name "*.a" -delete find $PKG -type f -name "*.h" -delete find $PKG -type f -iname "README" -delete find $PKG -type f -iname "README*.txt" -delete find $PKG -type f -iname "LICENSE*.txt" -delete find $PKG/usr/share/locale -type f ! -name 'remmina.mo' -delete get_locale echo "Removing locales ..." find $PKG/usr/share/locale/ -maxdepth 1 -type d ! -name 'locale' | grep -Ev "${CHOICE}|en_US" | xargs -i rm -rf {} # build remmina as xzm bundle dir2xzm $PKG ${OUTPUT}/$PRGNAM-$VERSION-$ARCH.xzm # Check on remmina xzm file exists in /tmp if [ -f "${OUTPUT}/$PRGNAM-$VERSION-$ARCH.xzm" ]; then echo -e "\n${BOLD}Your $PRGNAM module is at: ${GREEN}${BOLD}${OUTPUT}/$PRGNAM-$VERSION-$ARCH.xzm${RESET}\n${BOLD}Please copy it to your modules folder to survive a reboot.${RESET}\n" else echo -e "\n${RED}${BOLD}Faile. Your $PRGNAM module is not built.${RESET}\n" fi cleanup