From 182ff6697087300e59a8007c61190cf6286903b3 Mon Sep 17 00:00:00 2001 From: Sergei Eremenko Date: Thu, 18 Jan 2018 18:37:25 +0200 Subject: [PATCH] Add new installation script --- README.md | 9 +-- install-papirus-home-gtk.sh | 69 ----------------------- install-papirus-home-kde.sh | 63 --------------------- install-papirus-root.sh | 76 ------------------------- install.sh | 93 +++++++++++++++++++++++++++++++ remove-papirus.sh => uninstall.sh | 0 6 files changed, 98 insertions(+), 212 deletions(-) delete mode 100755 install-papirus-home-gtk.sh delete mode 100755 install-papirus-home-kde.sh delete mode 100755 install-papirus-root.sh create mode 100755 install.sh rename remove-papirus.sh => uninstall.sh (100%) diff --git a/README.md b/README.md index 2b021a0fce..c4b8f4f12d 100644 --- a/README.md +++ b/README.md @@ -58,18 +58,19 @@ Use the scripts to install the latest version directly from this repo (independe #### ROOT directory (recommended) ``` -wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/install-papirus-root.sh | sh +wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/install.sh | sh ``` + #### HOME directory for GTK ``` -wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/install-papirus-home-gtk.sh | sh +wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/install.sh | DESTDIR="$HOME/.icons" sh ``` #### HOME directory for KDE ``` -wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/install-papirus-home-kde.sh | sh +wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/install.sh | DESTDIR="$HOME/.local/share/icons" sh ``` **NOTE:** Qt4 apps require `libqt4-svg` to work correctly. @@ -77,7 +78,7 @@ wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon- #### Remove ``` -wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/remove-papirus.sh | sh +wget -qO- https://raw.githubusercontent.com/PapirusDevelopmentTeam/papirus-icon-theme/master/uninstall.sh | sh ``` ### Unofficial packages diff --git a/install-papirus-home-gtk.sh b/install-papirus-home-gtk.sh deleted file mode 100755 index 2ddc0368c4..0000000000 --- a/install-papirus-home-gtk.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -set -e - -gh_repo="papirus-icon-theme" -gh_desc="Papirus icon theme GTK" - -cat <<- EOF - - - - ppppp ii - pp pp aaaaa ppppp rr rrr uu uu sssss - ppppp aa aa pp pp ii rrrr uu uu ssss - pp aa aa pp pp ii rr uu uu ssss - pp aaaaa ppppp ii rr uuuuu sssss - pp - pp - - - $gh_desc - https://github.com/PapirusDevelopmentTeam/$gh_repo - - -EOF - -temp_dir=$(mktemp -d) - -echo "=> Getting the latest version from GitHub ..." -wget -O "/tmp/$gh_repo.tar.gz" \ - https://github.com/PapirusDevelopmentTeam/$gh_repo/archive/master.tar.gz - -echo "=> Unpacking archive ..." -tar -xzf "/tmp/$gh_repo.tar.gz" -C "$temp_dir" - -echo "=> Deleting old $gh_desc ..." -rm -rf ~/.icons/ePapirus -rm -rf ~/.icons/Papirus -rm -rf ~/.icons/Papirus-Adapta -rm -rf ~/.icons/Papirus-Adapta-Nokto -rm -rf ~/.icons/Papirus-Dark -rm -rf ~/.icons/Papirus-Light - -echo "=> Installing ..." -mkdir -p ~/.icons -cp -R \ - "$temp_dir/$gh_repo-master/ePapirus" \ - "$temp_dir/$gh_repo-master/Papirus" \ - "$temp_dir/$gh_repo-master/Papirus-Adapta" \ - "$temp_dir/$gh_repo-master/Papirus-Adapta-Nokto" \ - "$temp_dir/$gh_repo-master/Papirus-Dark" \ - "$temp_dir/$gh_repo-master/Papirus-Light" ~/.icons/ - -# Try to restore the color of folders from a config -if which papirus-folders > /dev/null 2>&1; then - papirus-folders -R || true -fi - -gtk-update-icon-cache -q ~/.icons/ePapirus || true -gtk-update-icon-cache -q ~/.icons/Papirus || true -gtk-update-icon-cache -q ~/.icons/Papirus-Adapta || true -gtk-update-icon-cache -q ~/.icons/Papirus-Adapta-Nokto || true -gtk-update-icon-cache -q ~/.icons/Papirus-Dark || true -gtk-update-icon-cache -q ~/.icons/Papirus-Light || true - -echo "=> Clearing cache ..." -rm -rf "/tmp/$gh_repo.tar.gz" "$temp_dir" - -echo "=> Done!" diff --git a/install-papirus-home-kde.sh b/install-papirus-home-kde.sh deleted file mode 100755 index b19fd05685..0000000000 --- a/install-papirus-home-kde.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -set -e - -gh_repo="papirus-icon-theme" -gh_desc="Papirus icon theme KDE" - -cat <<- EOF - - - - ppppp ii - pp pp aaaaa ppppp rr rrr uu uu sssss - ppppp aa aa pp pp ii rrrr uu uu ssss - pp aa aa pp pp ii rr uu uu ssss - pp aaaaa ppppp ii rr uuuuu sssss - pp - pp - - - $gh_desc - https://github.com/PapirusDevelopmentTeam/$gh_repo - - -EOF - -temp_dir=$(mktemp -d) - -echo "=> Getting the latest version from GitHub ..." -wget -O "/tmp/$gh_repo.tar.gz" \ - https://github.com/PapirusDevelopmentTeam/$gh_repo/archive/master.tar.gz - -echo "=> Unpacking archive ..." -tar -xzf "/tmp/$gh_repo.tar.gz" -C "$temp_dir" - -echo "=> Deleting old $gh_desc ..." -rm -rf ~/.local/share/icons/ePapirus -rm -rf ~/.local/share/icons/Papirus -rm -rf ~/.local/share/icons/Papirus-Adapta -rm -rf ~/.local/share/icons/Papirus-Adapta-Nokto -rm -rf ~/.local/share/icons/Papirus-Dark -rm -rf ~/.local/share/icons/Papirus-Light - -echo "=> Installing ..." -mkdir -p ~/.local/share/icons -cp -R \ - "$temp_dir/$gh_repo-master/ePapirus" \ - "$temp_dir/$gh_repo-master/Papirus" \ - "$temp_dir/$gh_repo-master/Papirus-Adapta" \ - "$temp_dir/$gh_repo-master/Papirus-Adapta-Nokto" \ - "$temp_dir/$gh_repo-master/Papirus-Dark" \ - "$temp_dir/$gh_repo-master/Papirus-Light" ~/.local/share/icons/ - -# Try to restore the color of folders from a config -if which papirus-folders > /dev/null 2>&1; then - papirus-folders -R || true -fi - -echo "=> Clearing cache ..." -rm -f ~/.cache/icon-cache.kcache -rm -rf "/tmp/$gh_repo.tar.gz" "$temp_dir" - -echo "=> Done!" diff --git a/install-papirus-root.sh b/install-papirus-root.sh deleted file mode 100755 index ea2445c425..0000000000 --- a/install-papirus-root.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh - -set -e - -gh_repo="papirus-icon-theme" -gh_desc="Papirus icon theme" - -cat <<- EOF - - - - ppppp ii - pp pp aaaaa ppppp rr rrr uu uu sssss - ppppp aa aa pp pp ii rrrr uu uu ssss - pp aa aa pp pp ii rr uu uu ssss - pp aaaaa ppppp ii rr uuuuu sssss - pp - pp - - - $gh_desc - https://github.com/PapirusDevelopmentTeam/$gh_repo - - -EOF - - -temp_dir=$(mktemp -d) - -if [ -d "/usr/local/share/icons/hicolor" ]; then - # is a BSD system - data_dir="/usr/local" -else - data_dir="/usr" -fi - -echo "=> Getting the latest version from GitHub ..." -wget -O "/tmp/$gh_repo.tar.gz" \ - https://github.com/PapirusDevelopmentTeam/$gh_repo/archive/master.tar.gz - -echo "=> Unpacking archive ..." -tar -xzf "/tmp/$gh_repo.tar.gz" -C "$temp_dir" - -echo "=> Deleting old $gh_desc ..." -sudo rm -rf "$data_dir/share/icons/ePapirus" -sudo rm -rf "$data_dir/share/icons/Papirus" -sudo rm -rf "$data_dir/share/icons/Papirus-Adapta" -sudo rm -rf "$data_dir/share/icons/Papirus-Adapta-Nokto" -sudo rm -rf "$data_dir/share/icons/Papirus-Dark" -sudo rm -rf "$data_dir/share/icons/Papirus-Light" - -echo "=> Installing ..." -sudo cp -R \ - "$temp_dir/$gh_repo-master/ePapirus" \ - "$temp_dir/$gh_repo-master/Papirus" \ - "$temp_dir/$gh_repo-master/Papirus-Adapta" \ - "$temp_dir/$gh_repo-master/Papirus-Adapta-Nokto" \ - "$temp_dir/$gh_repo-master/Papirus-Dark" \ - "$temp_dir/$gh_repo-master/Papirus-Light" $data_dir/share/icons/ - -# Try to restore the color of folders from a config -if which papirus-folders > /dev/null 2>&1; then - sudo papirus-folders -R || true -fi - -sudo gtk-update-icon-cache -q "$data_dir/share/icons/ePapirus" || true -sudo gtk-update-icon-cache -q "$data_dir/share/icons/Papirus" || true -sudo gtk-update-icon-cache -q "$data_dir/share/icons/Papirus-Adapta" || true -sudo gtk-update-icon-cache -q "$data_dir/share/icons/Papirus-Adapta-Nokto" || true -sudo gtk-update-icon-cache -q "$data_dir/share/icons/Papirus-Dark" || true -sudo gtk-update-icon-cache -q "$data_dir/share/icons/Papirus-Light" || true - -echo "=> Clearing cache ..." -rm -rf "/tmp/$gh_repo.tar.gz" "$temp_dir" - -echo "=> Done!" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000000..89f99061b6 --- /dev/null +++ b/install.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +set -e + +gh_repo="papirus-icon-theme" +gh_desc="Papirus icon theme" + +cat <<- EOF + + + + ppppp ii + pp pp aaaaa ppppp rr rrr uu uu sssss + ppppp aa aa pp pp ii rrrr uu uu ssss + pp aa aa pp pp ii rr uu uu ssss + pp aaaaa ppppp ii rr uuuuu sssss + pp + pp + + + $gh_desc + https://github.com/PapirusDevelopmentTeam/$gh_repo + + +EOF + +DESTDIR="${DESTDIR:-/usr/share/icons}" +THEMES="${THEMES:-ePapirus Papirus Papirus-Dark Papirus-Light Papirus-Adapta Papirus-Adapta-Nokto}" +BRANCH="${BRANCH:-master}" +uninstall="${uninstall:-false}" + +_msg() { + echo "=>" "$@" >&2 +} + +_rm() { + # removes parent directories if empty + _sudo rm -rf "$1" + _sudo rmdir -p "$(dirname "$1")" 2>/dev/null || true +} + +_sudo() { + if [ -w "$DESTDIR" ] || [ -w "$(dirname "$DESTDIR")" ]; then + "$@" + else + sudo "$@" + fi +} + +_download() { + _msg "Getting the latest version from GitHub ..." + wget -O "$temp_file" \ + "https://github.com/PapirusDevelopmentTeam/$gh_repo/archive/$BRANCH.tar.gz" + _msg "Unpacking archive ..." + tar -xzf "$temp_file" -C "$temp_dir" +} + +_uninstall() { + for theme in "$@"; do + _msg "Deleting '$theme' ..." + _rm "$DESTDIR/$theme" + done +} + +_install() { + _sudo mkdir -p "$DESTDIR" + + for theme in "$@"; do + _msg "Installing '$theme' ..." + _sudo cp -R "$temp_dir/$gh_repo-$BRANCH/$theme" "$DESTDIR" + _sudo gtk-update-icon-cache -q "$DESTDIR/$theme" || true + done +} + +_cleanup() { + _msg "Clearing cache ..." + rm -rf "$temp_file" "$temp_dir" + rm -f "$HOME/.cache/icon-cache.kcache" + _msg "Done!" +} + +trap _cleanup EXIT HUP INT TERM + +temp_file="$(mktemp -u)" +temp_dir="$(mktemp -d)" + +if [ "$uninstall" = "false" ]; then + _download + _uninstall $THEMES + _install $THEMES +else + _uninstall $THEMES +fi diff --git a/remove-papirus.sh b/uninstall.sh similarity index 100% rename from remove-papirus.sh rename to uninstall.sh