diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-11-12 09:55:51 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-11-12 09:55:51 -0200 |
commit | 99423aac98175e1b4ee0a03090017b51bd99ca40 (patch) | |
tree | 0c3e0cd7db54bfcd4070edc7d001beda98518749 | |
parent | 247a5ff3827d574e74c7df4b31dca643ef122649 (diff) | |
download | trashman-99423aac98175e1b4ee0a03090017b51bd99ca40.tar.gz trashman-99423aac98175e1b4ee0a03090017b51bd99ca40.tar.bz2 |
Adds custom debian functions and minor fixes
-rw-r--r-- | share/trashman/trashman/debian | 50 | ||||
-rw-r--r-- | share/trashman/trashman/functions | 5 | ||||
-rwxr-xr-x | trashman | 6 |
3 files changed, 58 insertions, 3 deletions
diff --git a/share/trashman/trashman/debian b/share/trashman/trashman/debian new file mode 100644 index 0000000..bcc0e6b --- /dev/null +++ b/share/trashman/trashman/debian @@ -0,0 +1,50 @@ +#!/usr/bin/env sh +# +# Custom functions for debian-like systems. +# + +__trashman_apt_install() { + if [ -z "$1" ]; then + return + fi + + LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y $* +} + +# Machine architecture +__trashman_debian_arch() { + local arch="`uname -m`" + + # Fix arch + if [ "$arch" = "x86_64" ]; then + arch="amd64" + fi + + echo $arch +} + +# Check if package is installed +__trashman_apt_check() { + if [ -z "$1" ]; then + return + fi + + dpkg -s $1 > /dev/null 2>&1 + return $? +} + +# Install a package +__trashman_apt_install_packages() { + if [ -z "$1" ]; then + return + fi + + for package in $*; do + dpkg -s $package > /dev/null 2>&1 + + if [ "$?" == "1" ]; then + __trashman_echo "Installing package $package..." + DEBIAN_FRONTEND=noninteractive $SUDO apt-get install $package -y || exit 1 + fi + done +} diff --git a/share/trashman/trashman/functions b/share/trashman/trashman/functions index 62eed03..5f655de 100644 --- a/share/trashman/trashman/functions +++ b/share/trashman/trashman/functions @@ -43,6 +43,11 @@ __trashman_distro_release() { fi } +# Machine architecture +__trashman_arch() { + uname -m +} + # Return the folder where actions are available for a package __trashman_actions_folder() { local package="$1" @@ -88,11 +88,11 @@ else if [ "$ACTION" = "check" ]; then if [ "$status" = "0" ]; then - __trashman_echo "Package trashman is installed system-wide" + __trashman_echo "Package $package is installed system-wide" elif [ "$status" = "1" ]; then - __trashman_echo "Package trashman is not installed system-wide" + __trashman_echo "Package $package is not installed system-wide" elif [ "$status" = "2" ]; then - __trashman_echo "Package trashman is partially installed system-wide" + __trashman_echo "Package $package is partially installed system-wide" fi fi else |