#!/bin/bash quietInstall='no' function installPackages { shift while [ ! -z $1 ]; do pkg=$(find . -type f -name "$1--*.stupid" | tail -n 1 || grep -q '--' && find . -type f -name "$1.stupid") if [ -z $pkg ]; then echo "[$1] No package file!"; shift; continue fi ( source "$pkg" if [[ $(type -t stupidInstall) != "function" ]]; then echo "[$1] No install function found!"; exit fi if [[ $(type -t stupidRemove) != "function" ]]; then echo "[$1] No remove function found (required even when installing)!"; exit fi echo "[$1] Installing $title $version ..." mkdir -p "/tmp/stupid/$1"; cd "/tmp/stupid/$1" touch "$pkg.install-log" stupidInstall >"$pkg.install-log" 2>&1 echo "FINISHED" >> "$pkg.install-log" echo "[$1] Installed!" ) if (( $? != 0 )); then echo "[$1] Could not install! Log:" cat "/tmp/stupid/$1/$pkg.install-log" fi shift done } function removePackages { shift while [ ! -z $1 ]; do pkg=$(find . -type f -name "$1--*.stupid" | tail -n 1 || grep -q '--' && find . -type f -name "$1.stupid") if [ -z $pkg ]; then echo "[$1] No package file!"; shift; continue fi ( source "$pkg" if [[ $(type -t stupidRemove) != "function" ]]; then echo "[$1] No remove function found!"; exit fi echo "[$1] Removing $title $version ..." mkdir -p "/tmp/stupid/$1"; cd "/tmp/stupid/$1" touch "$pkg.remove-log" stupidRemove >"$pkg.remove-log" 2>&1 echo "FINISHED" >> "$pkg.remove-log" echo "[$1] Installed!" ) if (( $? != 0 )); then echo "[$1] Could not remove! Log:" cat "/tmp/stupid/$1/$pkg.remove-log" fi shift done } while [ ! -z $1 ]; do case $1 in -q|quiet) quietInstall='yes' ;; -i|install) installPackages $@ exit ;; -r|remove) removePackages $@ exit ;; *) echo '[Error] Invalid command!' ;; esac shift done