zzag / plasma5-wallpapers-dynamic

Dynamic wallpaper plugin for KDE Plasma
333 stars 18 forks source link

[Documentation]: Installation on openSuSE Tumbleweed #140

Open picharly opened 6 months ago

picharly commented 6 months ago

I have seen that openSuSE was missing and, because I use openSuSE Tumbleweed with Plasma 6, I wanted to install your component for having a dynamic wallpaper.

So, I found the different dependencies and wrote a very simple script to check, install, pull, build and install it automatically.

I would like to share this script with the community:

#!/bin/bash

# plasma5-wallpapers-dynamic (https://github.com/zzag/plasma5-wallpapers-dynamic)
# Compilation script for SuSE Tumbleweed (could works with other SuSE versions)

# List of dependencies
dependencies=(  avif-tools libavif-devel
                exif libexif-devel
                libplasma6-devel libplasma6 libplasma6-desktoptheme libPlasma5Support6
                qt6-base-devel qt6-base-private-devel
                qt6-declarative-devel qt6-declarative-tools qt6-declarative-imports
                qt6-location qt6-location-devel
                cmake cmake-extras cmake-full kf6-extra-cmake-modules
                geoclue2 geoclue2-devel
                git
)
# Missing dependencies - must be empty
missing=()

# Temporary folder
tmpFolder="/tmp/dynamic-wallpapers"

# Colors used for terminal ouput
red='\033[0;31m'
green='\033[0;32m'
normal='\033[0m'

# Check if a package has already been installed or not
check_package() {
    if ! [ "$1" == "" ]; then
        result=$(zypper se -xi $1 > /dev/null && echo $?)
        if ! [ "$result" == "0" ]; then
            missing+=( $1 )
            return 1
        fi
    fi
    return 0
}

# Check if the pattern devel_basis (build essentials) has been installed.
check_build-essentials() {
    result=$(zypper se -xi devel_basis > /dev/null && echo $?)
    if ! [ "$result" == "0" ]; then
        echo ""
        reply=y
        read -p "\nBuild essentials seems to be missing. Do you want to install devel_basis pattern first? [y/n]: " reply
        case $reply in
            [Yy])
                echo -e "Installing pattern devel_basis...\n"
                sudo zypper in patterns-devel-base-devel_basis
                ;;
            [Nn])
                echo "This build could failed if a package is missing."
                exit
                ;;
            *)
                check_build-essentials
                ;;
        esac
        return 1
    fi
}

# Install packages marked as 'missing'
install_missing_packages() {
    if [ ${#missing[@]} -gt 0 ]; then
        echo "Need to install ${#missing[@]} missing package(s):"
        for package in ${missing[@]}
        do
            echo "    - $package"
        done
        echo ""
        reply=y
        read -p "Do you want to continue? [y/n]: " reply
        case $reply in
            [Yy])
                echo -e "Installing missing dependencies...\n"
                sudo zypper in "${missing[@]}"
                ;;
            [Nn])
                echo "Cannot continue without these dependencies."
                exit
                ;;
            *)
                install_missing_packages
                ;;
        esac
    fi
}

# Checking is all dependencies hve been installed
echo "Checking dependencies:"
for package in ${dependencies[@]}
do
    echo -ne "- $package: "
    check_package $package
    if [ "$?" -eq 0 ]; then
        echo -e "${green}installed${normal}"
    else
        echo -e "${red}missing${normal}"
    fi
done

# Install missing packages (if needed)
install_missing_packages

# Check temporary folder
if ! [ -d "$tmpFolder" ]; then
    mkdir -p "$tmpFolder"
fi
cd "$tmpFolder"

# Clean existing git folder
if [ -d "plasma5-wallpapers-dynamic" ]; then
    echo "Deleting existing folder..."
    rm -fr "plasma5-wallpapers-dynamic"
fi

# Pull repository
echo "Cloning repository..."
git clone https://github.com/zzag/plasma5-wallpapers-dynamic.git

# Build and install
echo "Preparing build environment..."
cd plasma5-wallpapers-dynamic
mkdir build
cd build

echo "Building..."
cmake .. -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DBUILD_TESTING=OFF

if [ "$?" -eq 0 ]; then
   clear
   echo "Compiling..."
   make
   if [ "$?" -eq 0 ]; then
       clear
       echo "Installing..."
       sudo make install
   fi
fi
echo -e "\nEnd.\n"

This script could probably be improved, but it works for me. ;-)