aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-11-11 20:32:03 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-11-11 20:32:03 -0200
commit247a5ff3827d574e74c7df4b31dca643ef122649 (patch)
tree522f18b5269cd61293a5ffefbb8d1aa9482c8cd6
parent53358cef686ccdac63083068fd53a2b61cd6e2aa (diff)
downloadtrashman-247a5ff3827d574e74c7df4b31dca643ef122649.tar.gz
trashman-247a5ff3827d574e74c7df4b31dca643ef122649.tar.bz2
Renames 'test' action to 'check', adds misc functions
-rw-r--r--README.md6
-rw-r--r--TODO.md1
-rw-r--r--share/trashman/trashman/functions19
-rwxr-xr-xshare/trashman/trashman/unix/check25
-rwxr-xr-xshare/trashman/trashman/unix/test16
-rwxr-xr-xtrashman4
6 files changed, 56 insertions, 15 deletions
diff --git a/README.md b/README.md
index 6d32ac1..89c8aee 100644
--- a/README.md
+++ b/README.md
@@ -127,13 +127,13 @@ packages are simply as having the following files:
* `share/trashman/<package>/<ancestor>/<family>/<action>`: script that runs on a given action, fallback.
* `share/trashman/<package>/<ancestor>/<action>`: script that runs on a given action, fallback.
-Where actions can be like `install`, `test`, `remove` or `upgrade`. You don't have
+Where actions can be like `install`, `check`, `remove` or `upgrade`. You don't have
to implement all actions. Actually, no action is required to create a package, but
having no action makes it useless.
-### Test action
+### Check action
-The test action may return the following exit codes:
+The `check` action may return the following exit codes:
* 0: the package is installed system-wide.
* 1: the package is not installed system-wide.
diff --git a/TODO.md b/TODO.md
index 9a033bb..32424c9 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,6 +1,7 @@
TODO
====
+* Multi-licensing and note on the lack of licensing for some scripts.
* Support more OSes at `__trashman_distro()`.
* Argument passing to distro/action scripts as `--param=value`.
* Packages:
diff --git a/share/trashman/trashman/functions b/share/trashman/trashman/functions
index 52dbfc6..62eed03 100644
--- a/share/trashman/trashman/functions
+++ b/share/trashman/trashman/functions
@@ -36,6 +36,13 @@ __trashman_distro() {
fi
}
+# Distro release version
+__trashman_distro_release() {
+ if [ -e "/etc/os-release" ]; then
+ grep "^VERSION=" /etc/os-release | cut -d '(' -f 2 | cut -d ')' -f 1
+ fi
+}
+
# Return the folder where actions are available for a package
__trashman_actions_folder() {
local package="$1"
@@ -139,3 +146,15 @@ __trashman_merge() {
$GIT submodule update --init --recursive
)
}
+
+__trashman_install_apt_key() {
+ local orig="$1"
+ local dest="$2"
+
+ if [ ! -e "$orig" ]; then
+ exit 1
+ fi
+
+ cp $orig /etc/apt/trusted.gpg.d/$dest || exit 1
+ chown root.root /etc/apt/trusted.gpg.d/$dest && chmod 644 /etc/apt/trusted.gpg.d/$dest || exit 1
+}
diff --git a/share/trashman/trashman/unix/check b/share/trashman/trashman/unix/check
new file mode 100755
index 0000000..1614d20
--- /dev/null
+++ b/share/trashman/trashman/unix/check
@@ -0,0 +1,25 @@
+#!/usr/bin/env sh
+#
+# Test if trashman is installed system-wide.
+#
+
+# Parameters
+SHARE="$1"
+BASE="$SHARE/../.."
+FOLDER="/usr/local"
+
+# Include basic functions
+. $SHARE/trashman/functions || exit 1
+
+# Check if it is installed
+if [ -x "$FOLDER/bin/trashman" ] && [ -x "$FOLDER/share/trashman/trashman" ]; then
+ exit 0
+fi
+
+# Check if it is not installed
+if [ ! -x "$FOLDER/bin/trashman" ] && [ ! -x "$FOLDER/share/trashman/trashman" ]; then
+ exit 1
+fi
+
+# It is partially installed
+exit 2
diff --git a/share/trashman/trashman/unix/test b/share/trashman/trashman/unix/test
index 1614d20..98cb368 100755
--- a/share/trashman/trashman/unix/test
+++ b/share/trashman/trashman/unix/test
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
#
-# Test if trashman is installed system-wide.
+# Test suite for trashman.
#
# Parameters
@@ -11,15 +11,11 @@ FOLDER="/usr/local"
# Include basic functions
. $SHARE/trashman/functions || exit 1
-# Check if it is installed
-if [ -x "$FOLDER/bin/trashman" ] && [ -x "$FOLDER/share/trashman/trashman" ]; then
+# Run test suite
+if trashman | grep -q "^trashman:"; then
+ __trashman_echo "trashman seems to be working"
exit 0
-fi
-
-# Check if it is not installed
-if [ ! -x "$FOLDER/bin/trashman" ] && [ ! -x "$FOLDER/share/trashman/trashman" ]; then
+else
+ __trashman_echo "trashman not working correctly"
exit 1
fi
-
-# It is partially installed
-exit 2
diff --git a/trashman b/trashman
index 29dc450..3e9859d 100755
--- a/trashman
+++ b/trashman
@@ -79,14 +79,14 @@ else
folder="`__trashman_actions_folder $package`"
if [ -x "$SHARE/$package/$folder/$ACTION" ]; then
- if [ "$ACTION" != "test" ]; then
+ if [ "$ACTION" != "check" ] && [ "$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 [ "$ACTION" = "check" ]; then
if [ "$status" = "0" ]; then
__trashman_echo "Package trashman is installed system-wide"
elif [ "$status" = "1" ]; then