Add package tracking functions

This commit is contained in:
Juno Takano 2024-07-14 06:16:56 -03:00
parent 45e299cc90
commit 6e18c205e9
4 changed files with 30 additions and 1 deletions

View file

@ -5,5 +5,6 @@
. "$TORI_ROOT/src/package/package_manager.sh" . "$TORI_ROOT/src/package/package_manager.sh"
. "$TORI_ROOT/src/package/package_conflict_resolution.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/validate_input_packages.sh"
. "$TORI_ROOT/src/package/update_package_cache.sh" . "$TORI_ROOT/src/package/update_package_cache.sh"

View file

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

View file

@ -1,6 +1,5 @@
package_manager() { package_manager() {
local command="$1" local command="$1"
local output
local manager local manager
local authorizer="sudo" 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
}