Compare commits

...

5 commits

6 changed files with 45 additions and 6 deletions

View file

@ -1,3 +1,6 @@
0.4.1 2024-07-14: Fixes "Cancel" option not exiting on package resolution
Fixes whitespace preventing package list matches on "remove all"
0.4.0 2024-07-14: "Add/remove all from configuration" resolution strategy
0.3.1 2024-07-13: Refactor, new docs page, make cache refresh lazier
0.3.0 2024-07-11: "Enter packages to install/uninstall" resolution strategy
0.2.1 2024-07-10: Rename package_resolution.sh, document package conflicts

View file

@ -5,5 +5,6 @@
. "$TORI_ROOT/src/package/package_manager.sh"
. "$TORI_ROOT/src/package/package_conflict_resolution.sh"
. "$TORI_ROOT/src/package/package_tracking.sh"
. "$TORI_ROOT/src/package/validate_input_packages.sh"
. "$TORI_ROOT/src/package/update_package_cache.sh"

View file

@ -38,6 +38,7 @@ not_on_configuration_dialog() {
if [ "$strategy" = 6 ]; then
log debug "[resolve_packages] User choice: Cancel or empty"
return 0
elif [ "$strategy" = 1 ]; then
package_manager uninstall "$conflicted_packages"
elif [ "$strategy" = 2 ]; then
@ -45,13 +46,23 @@ not_on_configuration_dialog() {
log debug "Input: input_packages = $input_packages"
if validate_input_packages "$input_packages"; then
package_manager uninstall "$input_packages"
else
not_on_configuration_dialog "$conflicted_packages"
fi
elif [ "$strategy" = 3 ]; then
if validate_input_packages "$conflicted_packages"; then
track_packages "$conflicted_packages"
fi
elif [ "$strategy" = 4 ]; then
read -r -p "Enter space-separated packages to add to the configuation: " input_packages
log debug "Input: input_packages = $input_packages"
if validate_input_packages "$input_packages"; then
track_packages "$input_packages"
fi
else
log debug "[resolve_packages] Unexpected input: $strategy"
not_on_configuration_dialog "$conflicted_packages"
fi
check
}
not_installed_dialog() {
@ -71,6 +82,7 @@ not_installed_dialog() {
if [ "$strategy" = 6 ]; then
log debug "[resolve_packages] User choice: Cancel or empty"
return 0
elif [ "$strategy" = 1 ]; then
package_manager install "$conflicted_packages"
elif [ "$strategy" = 2 ]; then
@ -78,11 +90,17 @@ not_installed_dialog() {
log debug "Input: input_packages = $input_packages"
if validate_input_packages "$input_packages"; then
package_manager install "$input_packages"
else
not_on_configuration_dialog "$conflicted_packages"
fi
elif [ "$strategy" = 3 ]; then
untrack_packages "$conflicted_packages"
elif [ "$strategy" = 4 ]; then
read -r -p "Enter space-separated packages to remove from the configuation: " input_packages
log debug "Input: input_packages = $input_packages"
untrack_packages "$input_packages"
else
log debug "[resolve_packages] Unexpected input: $strategy"
not_installed_dialog "$conflicted_packages"
fi
check
}

View file

@ -1,6 +1,5 @@
package_manager() {
local command="$1"
local output
local manager
local authorizer="sudo"

View file

@ -0,0 +1,18 @@
track_packages() {
local packages="$1"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
echo "$package" >> "$CONFIG_ROOT/packages"
done
}
untrack_packages() {
local packages="$1"
log debug "[untrack_packages] Removing packages: $packages"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
sed -i '' "/^[[:space:]]*$package[[:space:]]*$/d" "$CONFIG_ROOT/packages"
log debug "[untrack_packages] Executed removal for $package with exit code $?"
done
}

2
tori
View file

@ -2,7 +2,7 @@
main() {
# paths
VERSION="0.3.1 2024-07-13"
VERSION="0.4.1 2024-07-14"
TORI_ROOT="$HOME/.local/share/tori"
CONFIG_ROOT="$HOME/.config/tori"
TMP_DIR="/tmp/tori"