diff --git a/Makefile b/Makefile index 18ddd54..40c598b 100644 --- a/Makefile +++ b/Makefile @@ -2,20 +2,35 @@ # vi:set filetype=makefile NULL=0 exec make "CALL=$0" "EXE=`which $0`" -f "`which $0`" -- "$@" -D := / PREFIX := /usr/local BIN_PREFIX := $(PREFIX)/bin +CAVE_COMMANDS_PREFIX := /usr/libexec/cave/commands +SYS_CONF_DIR := /etc +PROFILE_DIR := $(SYS_CONF_DIR)/profile.d +SUDOERS_DIR := $(SYS_CONF_DIR)/sudoers.d +D += / all: truckle @echo 'Nothing to do :)' @echo 'Please run "make install" to install.' -install: truckle +install_truckle: truckle mkdir -p $(D)$(BIN_PREFIX) install -m 0755 truckle $(D)$(BIN_PREFIX)/truckle for c in `./truckle --list-commands`; do ln -fs truckle $(D)$(BIN_PREFIX)/truckle-$${c} ; done for c in trdo tresume tretry; do ln -fs truckle $(D)$(BIN_PREFIX)/$${c} ; done +install_cave_commands: + mkdir -p $(D)$(CAVE_COMMANDS_PREFIX) + install -m 0755 -o root -g root -t $(D)$(CAVE_COMMANDS_PREFIX) cave_commands/* + +install_configs: + mkdir -p $(D)$(PROFILE_DIR) $(D)$(SUDOERS_DIR) + install -m 0644 -o root -g root configs/profile.sh $(D)$(PROFILE_DIR)/cave.sh + install -m 0440 -o root -g root configs/sudoers $(D)$(SUDOERS_DIR)/cave + +install: install_truckle install_cave_commands install_configs + README.md: truckle README.pre.md ( cat README.pre.md ; ./truckle --help ) > README.md.tmp mv README.md.tmp README.md diff --git a/cave_commands/do b/cave_commands/do new file mode 100755 index 0000000..2764f5f --- /dev/null +++ b/cave_commands/do @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +exec ${CAVE} resume "${@}" diff --git a/cave_commands/retry b/cave_commands/retry new file mode 100755 index 0000000..76e9424 --- /dev/null +++ b/cave_commands/retry @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +exec ${CAVE} resume --retry-failed --retry-skipped "${@}" diff --git a/cave_commands/upgrade b/cave_commands/upgrade new file mode 100755 index 0000000..3367b7d --- /dev/null +++ b/cave_commands/upgrade @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +exec ${CAVE} resolve -c world "${@}" diff --git a/configs/profile.sh b/configs/profile.sh new file mode 100644 index 0000000..2325f40 --- /dev/null +++ b/configs/profile.sh @@ -0,0 +1,8 @@ +TRUCKLE_RESUME_FILE="/tmp/truckle-resume-pid-${$}" +CAVE_all_commands_OPTIONS="--resume-file ${TRUCKLE_RESUME_FILE}" +CAVE_RESOLVE_OPTIONS="${CAVE_all_commands_OPTIONS}" +CAVE_RESUME_OPTIONS="${CAVE_all_commands_OPTIONS}" +CAVE_FIX_LINKAGE_OPTIONS="${CAVE_all_commands_OPTIONS}" +CAVE_UNINSTALL_OPTIONS="${CAVE_all_commands_OPTIONS}" +export TRUCKLE_RESUME_FILE CAVE_all_commands_OPTIONS CAVE_RESOLVE_OPTIONS +export CAVE_RESUME_OPTIONS CAVE_FIX_LINKAGE_OPTIONS CAVE_UNINSTALL_OPTIONS diff --git a/configs/sudoers b/configs/sudoers new file mode 100644 index 0000000..5d30599 --- /dev/null +++ b/configs/sudoers @@ -0,0 +1 @@ +Defaults env_keep += "TRUCKLE_RESUME_FILE* CAVE_RESUME_OPTIONS CAVE_RESOLVE_OPTIONS CAVE_RESUME_OPTIONS CAVE_FIX_LINKAGE_OPTIONS CAVE_UNINSTALL_OPTIONS" diff --git a/truckle b/truckle index a34fa37..4d55d9c 100755 --- a/truckle +++ b/truckle @@ -183,8 +183,12 @@ class RunCave puts a.shelljoin 0 else - Kernel.system *a - $? && $?.exitstatus + begin + Kernel.system *a + $? && $?.exitstatus + rescue Interrupt + nil + end end end @@ -385,16 +389,12 @@ EOF cave.() } cmds.on :remove, &sudo_pagered {|cmd, *args| cave.resumable!.uninstall(*args).()} - cmds.on :upgrade, &sudo_pagered {|cmd, *args| - cave.resumable!.resolve( '-c', :world, *args).() - } + cmds.on :upgrade, &sudo_pagered {|*args| cave.resumable!.this( *args).() } cmds.on :install, &sudod {|cmd, *argv| cave.resumable!.resolve( '-x', *argv).() } cmds.on :uninstall, &sudod {|cmd, *argv| cave.resumable!.uninstall( '-x', *argv).() } cmds.on :do, :resume, &sudod {|cmd, *args| cave.resumable!.resume( *args).() } - cmds.on :retry, &sudod {|cmd, *args| - cave.resumable!.resume( '--retry-failed', '--retry-skipped', *args).() - } + cmds.on :retry, &sudod {|*args| cave.resumable!.this( *args).() } cmds.on '--list-commands', &pagered { puts cmds.map {|k,v| k } } end