]> gitweb.fluxo.info Git - trashman.git/commitdiff
Renames 'test' action to 'check', adds misc functions
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 11 Nov 2017 22:32:03 +0000 (20:32 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 11 Nov 2017 22:32:03 +0000 (20:32 -0200)
README.md
TODO.md
share/trashman/trashman/functions
share/trashman/trashman/unix/check [new file with mode: 0755]
share/trashman/trashman/unix/test
trashman

index 6d32ac12fe9d4b391a3239561119123338c4a793..89c8aee81391acb556eaf76b8581d55a737b8c3c 100644 (file)
--- 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 9a033bbc499c594e3ec0825758c0840fbe34901d..32424c9c1a9184aca15800008625fc7d3bce4ec2 100644 (file)
--- 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:
index 52dbfc67f4060029cc6549fb98673f717142cc32..62eed03d74625957131a8c4c22ef1fd57f606830 100644 (file)
@@ -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 (executable)
index 0000000..1614d20
--- /dev/null
@@ -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
index 1614d20f6a2a789a0f9be89fcfcbb0c29e1074e2..98cb368fff0d6a04ecbbb00c64ec933b5129149a 100755 (executable)
@@ -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
index 29dc450fdc0a21de6b6ff862e726604be7e8c714..3e9859d362c8f6d4753017c2c9ed599b4e115d7e 100755 (executable)
--- 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