diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-11-11 20:32:03 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-11-11 20:32:03 -0200 |
commit | 247a5ff3827d574e74c7df4b31dca643ef122649 (patch) | |
tree | 522f18b5269cd61293a5ffefbb8d1aa9482c8cd6 | |
parent | 53358cef686ccdac63083068fd53a2b61cd6e2aa (diff) | |
download | trashman-247a5ff3827d574e74c7df4b31dca643ef122649.tar.gz trashman-247a5ff3827d574e74c7df4b31dca643ef122649.tar.bz2 |
Renames 'test' action to 'check', adds misc functions
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | share/trashman/trashman/functions | 19 | ||||
-rwxr-xr-x | share/trashman/trashman/unix/check | 25 | ||||
-rwxr-xr-x | share/trashman/trashman/unix/test | 16 | ||||
-rwxr-xr-x | trashman | 4 |
6 files changed, 56 insertions, 15 deletions
@@ -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. @@ -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 @@ -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 |