Implement "Add/remove all from configuration" package conflict resolution strategy #1

Merged
jutty merged 5 commits from all-in-configuration-strategy into main 2024-07-14 12:27:51 +02:00
4 changed files with 30 additions and 1 deletions
Showing only changes of commit 6e18c205e9 - Show all commits

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

@ -48,6 +48,12 @@ not_on_configuration_dialog() {
else
not_on_configuration_dialog "$conflicted_packages"
fi
elif [ "$strategy" = 3 ]; then
track_packages "$conflicted_packages"
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"
track_packages "$input_packages"
else
log debug "[resolve_packages] Unexpected input: $strategy"
not_on_configuration_dialog "$conflicted_packages"
@ -81,6 +87,12 @@ not_installed_dialog() {
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"

View file

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

View file

@ -0,0 +1,17 @@
track_packages() {
local packages="$1"
validate_input_packages "$packages"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
echo "$package" >> "$CONFIG_ROOT/packages"
done
}
untrack_packages() {
local packages="$1"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
sed -i '' "/^$package$/d" "$CONFIG_ROOT/packages"
done
}