aboutsummaryrefslogtreecommitdiff
path: root/trashman
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-11-10 19:33:33 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-11-10 19:33:33 -0200
commit53358cef686ccdac63083068fd53a2b61cd6e2aa (patch)
tree087b47bb668943ed9945c38124a56f0c38ba84d5 /trashman
parent2984eee82b89f7b2e86f291f0a73818904d18f43 (diff)
downloadtrashman-53358cef686ccdac63083068fd53a2b61cd6e2aa.tar.gz
trashman-53358cef686ccdac63083068fd53a2b61cd6e2aa.tar.bz2
Initial operation
Diffstat (limited to 'trashman')
-rwxr-xr-xtrashman109
1 files changed, 109 insertions, 0 deletions
diff --git a/trashman b/trashman
new file mode 100755
index 0000000..29dc450
--- /dev/null
+++ b/trashman
@@ -0,0 +1,109 @@
+#!/usr/bin/env sh
+#
+# Provision: install stuff using scripts.
+#
+# Copyright (C) 2017 Silvio Rhatto - rhatto at riseup.net
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation, either version 3 of the License,
+# or any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Parameters
+NAME="trashman"
+PROGRAM="$0"
+BASENAME="`basename $0`"
+ACTION="$1"
+CWD="`pwd`"
+
+# Set shared files location
+if [ -e "`dirname $(readlink -f $0)`/share/$NAME" ]; then
+ # Development or local installation layout
+ SHARE="`dirname $(readlink -f $0)`/share/$NAME"
+else
+ # System installation layout
+ SHARE="`dirname $(readlink -f $0)`/../share/$NAME"
+fi
+
+# Include basic functions
+. $SHARE/trashman/functions || exit 1
+
+# Display usage
+__trashman_usage() {
+ echo "$BASENAME: package ports tree and heterodox configuration provisioner"
+ echo ""
+ echo "usage: $BASENAME <fetch|merge>"
+ echo "usage: $BASENAME <action> [<package1> ... <packageN>] [<--param1=value1> ... <--paramM=valueM>]"
+ echo ""
+ echo "available packages:"
+ echo ""
+
+ for package in `__trashman_implementations`; do
+ if [ -e "$SHARE/$package/info" ]; then
+ echo "\t $package: `cat $SHARE/$package/info` (`__trashman_actions $package | sed -e 's/ /|/g'`)"
+ fi
+ done
+
+ echo ""
+ exit 1
+}
+
+# Dispatch
+if [ -z "$ACTION" ]; then
+ __trashman_usage
+elif [ "$ACTION" = "fetch" ]; then
+ __trashman_$ACTION
+elif [ "$ACTION" = "merge" ]; then
+ __trashman_$ACTION
+elif [ "$ACTION" = "version" ]; then
+ __trashman_$ACTION
+else
+ # Get packages param
+ shift
+ PACKAGES="$*"
+
+ # Setup packages
+ if [ -z "$PACKAGES" ]; then
+ __trashman_usage
+ else
+ for package in $PACKAGES; do
+ if [ ! -z "`__trashman_actions $package`" ]; then
+ folder="`__trashman_actions_folder $package`"
+
+ if [ -x "$SHARE/$package/$folder/$ACTION" ]; then
+ if [ "$ACTION" != "test" ]; then
+ __trashman_echo "Dumpsterizing your system: action $ACTION for $package ($folder)..."
+ fi
+
+ $SHARE/$package/$folder/$ACTION $SHARE
+ status="$?"
+
+ if [ "$ACTION" = "test" ]; then
+ if [ "$status" = "0" ]; then
+ __trashman_echo "Package trashman is installed system-wide"
+ elif [ "$status" = "1" ]; then
+ __trashman_echo "Package trashman is not installed system-wide"
+ elif [ "$status" = "2" ]; then
+ __trashman_echo "Package trashman is partially installed system-wide"
+ fi
+ fi
+ else
+ __trashman_echo "No such action $ACTION for package $package, skipping"
+ fi
+ else
+ __trashman_echo "No such package $package, skipping"
+ fi
+ done
+
+ # Exit with the latest return status
+ exit $status
+ fi
+fi