#!/usr/bin/env bash # This is Remmina bundle update script for Porteus # Version 2026-12-04 # 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. # Exit on undefined variables to catch typos set -u PRGNAM=${PRGNAM:-remmina} BOLD="\e[1m" CYAN="\e[96m" GREEN="\e[92m" RED="\e[31m" RESET="\e[0m" CWD=$(pwd) # Added $$ (PID) to avoid conflicts if multiple instances run WRKDIR=$(mktemp -d /tmp/portch-remmina-XXXXXX) PKG="$WRKDIR/package-$PRGNAM" PKGINFO="$PKG/var/lib/pkgtools/packages" OUTPUT=${OUTPUT:-/tmp} DEPS_DIR="$WRKDIR/deps" # Robust version fetching via curl and GitLab API VERSION=$(curl -sS --max-time 30 --retry 3 \ "https://gitlab.com/api/v4/projects/Remmina%2FRemmina/repository/tags?per_page=1" \ | grep -o '"name":"[^"]*"' | head -1 | cut -d'"' -f4 | sed 's/^v//') if [[ -z "$VERSION" ]]; then echo -e "\n${RED}Failed to fetch Remmina version. Check your internet connection.${RESET}\n" exit 1 fi # Download specific version tag, NOT master MASTER_URL="https://gitlab.com/Remmina/Remmina/-/archive/v${VERSION}/Remmina-v${VERSION}.tar.bz2" # Slackware version check (more robust) if grep -q "current" /etc/slackware-version 2>/dev/null; then AVAHI=${AVAHI:-ON} KWALLET=${KWALLET:-OFF} TELEPATHY=${TELEPATHY:-OFF} else AVAHI=${AVAHI:-OFF} 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 EXTRAFLAGS="-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration -Wno-return-mismatch" if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686 $EXTRAFLAGS" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686 $EXTRAFLAGS" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC $EXTRAFLAGS" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2 $EXTRAFLAGS" LIBDIRSUFFIX="" fi # --- Cleanup Trap --- cleanup() { cd "$CWD" 2>/dev/null || true if [[ -d "$WRKDIR" ]]; then rm -rf "$WRKDIR" fi } trap cleanup EXIT # Root check if [[ $(id -u) -ne 0 ]]; then echo -e "\n${RED}You need to be root to run this script.${RESET}\n" exit 1 fi ## functions to choose locale from a menu array_menu() { echo echo "$1" echo "$2" select CHOICE in "${RESULT[@]}"; do if [ -z "${CHOICE:-}" ]; then CHOICE="en_US" echo "English locale chosen." && echo else echo -e "${BOLD}${CYAN}${CHOICE}${RESET} locale chosen" fi break done } get_locale() { declare -a RESULT 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[@]}" } # Check if remmina installed in the system MYVER="" if [[ -f "/usr/bin/remmina" ]]; then PKG_FILE=$(ls -1 /var/lib/pkgtools/packages/remmina-* 2>/dev/null | tail -n1) if [[ -n "$PKG_FILE" ]]; then MYVER=$(basename "$PKG_FILE" | cut -d'-' -f2) fi fi if [[ "$MYVER" == "$VERSION" ]]; then echo -e "You already have the latest ${GREEN}$MYVER${RESET} version of $PRGNAM." exit 0 else echo -e "Current version: ${CYAN}${MYVER:-Not installed}${RESET}. Latest available: ${GREEN}$VERSION${RESET}." 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 exit 0 fi fi echo -e "\nDownloading dependencies for ${BOLD}$PRGNAM-$VERSION-$ARCH${RESET}" # Auto-detect Desktop Environment (for su/root cases) if [ -z "${XDG_CURRENT_DESKTOP:-}" ]; then if pgrep -x "cinnamon" > /dev/null; then XDG_CURRENT_DESKTOP="X-Cinnamon" elif pgrep -x "cosmic-session" > /dev/null; then XDG_CURRENT_DESKTOP="COSMIC" elif pgrep -x "gnome-session" > /dev/null || pgrep -x "gnome-shell" > /dev/null || pgrep -x "mutter" > /dev/null; then XDG_CURRENT_DESKTOP="GNOME" elif pgrep -x "ksmserver" > /dev/null || pgrep -x "plasmashell" > /dev/null || pgrep -x "kwin_wayland" > /dev/null; then XDG_CURRENT_DESKTOP="KDE" elif pgrep -x "lxsession" > /dev/null; then XDG_CURRENT_DESKTOP="LXDE" elif pgrep -x "lxqt-session" > /dev/null; then XDG_CURRENT_DESKTOP="LXQt" elif pgrep -x "mate-session" > /dev/null; then XDG_CURRENT_DESKTOP="MATE" elif pgrep -x "openbox" > /dev/null; then XDG_CURRENT_DESKTOP="openbox" elif pgrep -x "xfce4-session" > /dev/null; then XDG_CURRENT_DESKTOP="XFCE" fi fi export XDG_CURRENT_DESKTOP MOD_COMMON="cups freerdp libappindicator libdbusmenu libsodium libvncserver" MOD_EXTRA="" # add libindicator / json-glib based on DE DE_LOWER="${XDG_CURRENT_DESKTOP,,}" DE_SESSION_LOWER="${XDG_DESKTOP_SESSION:-unknown}" DE_SESSION_LOWER="${DE_SESSION_LOWER,,}" if [[ "$DE_LOWER" == "gnome" || "$DE_LOWER" == "kde" || "$DE_LOWER" == "lxqt" ]]; then MOD_EXTRA="libindicator" elif [[ "$DE_LOWER" != "x-cinnamon" && "$DE_LOWER" != "lxde" && "$DE_LOWER" != "mate" && "$DE_LOWER" != "xfce" && "$DE_LOWER" != "openbox" && "$DE_SESSION_LOWER" != "openbox" ]]; then MOD_EXTRA="json-glib libindicator" fi # SAFE DEPENDENCY HANDLING: Isolate downloads to DEPS_DIR mkdir -p "$DEPS_DIR" getmod -q $MOD_COMMON $MOD_EXTRA # Move ONLY the specific dependencies we just requested from $OUTPUT to $DEPS_DIR for pkg in $MOD_COMMON $MOD_EXTRA; do mv "$OUTPUT"/${pkg}-*.t[agx]z "$DEPS_DIR/" 2>/dev/null || true done echo -e "\nActivating dependencies for ${BOLD}$PRGNAM-$VERSION-$ARCH${RESET}" if compgen -G "$DEPS_DIR/*.xzm" > /dev/null; then activate "$DEPS_DIR"/*.xzm -q fi [ -e "$PKG" ] && rm -rf "$PKG" mkdir -p "$PKG" # build xzm module of remmina echo -e "\nCompiling ${BOLD}${PRGNAM}-${VERSION}-${ARCH}${RESET}" cd "$PKG" || exit 1 wget --show-progress --timeout=60 --tries=3 -O remmina-src.tar.bz2 "$MASTER_URL" || { echo -e "\n${RED}${BOLD}Failed to download Remmina sources.${RESET}\n" exit 1 } tar -xjf remmina-src.tar.bz2 && rm -f remmina-src.tar.bz2 || { echo -e "\n${RED}${BOLD}Failed to extract Remmina sources.${RESET}\n" exit 1 } # Find extracted directory dynamically (e.g., Remmina-v1.4.35) SRC_DIR=$(find "$PKG" -maxdepth 1 -type d -name "Remmina-*" | head -n1) if [[ -z "$SRC_DIR" ]]; then echo -e "\n${RED}Failed to find extracted Remmina source directory.${RESET}\n" exit 1 fi cd "$SRC_DIR" || exit 1 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 || exit 1 cmake \ -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \ -DCMAKE_BUILD_TYPE=Release \ -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 \ -Wno-dev \ .. || { echo -e "\n${RED}${BOLD}CMake configuration failed.${RESET}\n" exit 1 } # Use all CPU cores for faster compilation make -j"$(nproc)" || { echo -e "\n${RED}${BOLD}Compilation failed.${RESET}\n" exit 1 } make install DESTDIR="$PKG" || { echo -e "\n${RED}${BOLD}make install failed.${RESET}\n" exit 1 } cd "$PKG" || exit 1 rm -rf "$SRC_DIR" # Strip binaries safely find "$PKG" -type f -executable -exec file {} + | grep ELF | cut -d: -f1 | xargs -r strip --strip-unneeded 2> /dev/null || true ### fake Slackware type package info 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 for x in "$DEPS_DIR"/*.xzm; do [ -e "$x" ] || continue xzm2dir "$x" "$PKG" >/dev/null done for i in "$DEPS_DIR"/*.txz; do [ -f "$i" ] || continue ROOT="$PKG" installpkg "$i" >/dev/null done # SAFE CLEANUP: Deactivate and remove ONLY from our isolated DEPS_DIR if compgen -G "$DEPS_DIR/*.xzm" > /dev/null; then deactivate "$DEPS_DIR"/*.xzm -q fi rm -rf "$DEPS_DIR" # clean unusful stuff rm -rf "$PKG"/usr/{doc,man,include,info,src} rm -rf "$PKG"/usr/lib${LIBDIRSUFFIX}/{cmake,girepository-1.0,pkgconfig} rm -rf "$PKG"/usr/lib${LIBDIRSUFFIX}/python*/site-packages/*.egg-info rm -rf "$PKG"/usr/share/{doc,gir-1.0,gtk-doc,help,licenses,man,pkgconfig} rm -rf "$PKG"/var/lib/pkgtools/douninst.sh rm -f "$PKG"/var/log/scripts/* rm -f "$PKG"/{,usr/}lib${LIBDIRSUFFIX}/*.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 "LICENSE*" -delete get_locale echo "Removing locales ..." CHOICE="${CHOICE:-en_US}" # Safe locale removal using exact name matching, avoiding grep regex pitfalls find "$PKG/usr/share/locale/" -maxdepth 1 -type d \ -not -name 'locale' \ -not -name 'en_US' \ -not -name "$CHOICE" \ -exec rm -rf {} + 2>/dev/null || true # build remmina as xzm bundle cd "$CWD" || exit 1 dir2xzm "$PKG" "${OUTPUT}/$PRGNAM-$VERSION-$ARCH.xzm" # Check on remmina xzm file exists 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}Failed. Your $PRGNAM module is not built.${RESET}\n" fi