Compare commits

..

No commits in common. "019acbcb454671b86f66f18888805eb2432812d6" and "67de45f5ba53e7fb61902e96c6fd4ea4a4c52579" have entirely different histories.

5 changed files with 9 additions and 55 deletions

View file

@ -1,4 +1,3 @@
0.7.0 2024-09-13: Imperative commands install, uninstall, track and forget
0.6.0 2024-09-03: File management with the tree strategy 0.6.0 2024-09-03: File management with the tree strategy
File backups File backups
Extract authorization command to top level Extract authorization command to top level

View file

@ -14,7 +14,6 @@ package_manager() {
if [ "$OS" = "FreeBSD" ]; then if [ "$OS" = "FreeBSD" ]; then
manager="pkg" manager="pkg"
args__get_manually_installed='query -e "%a = 0" "%n"' args__get_manually_installed='query -e "%a = 0" "%n"'
args__get_status='' # TODO
args__install='install' args__install='install'
args__uninstall='delete' args__uninstall='delete'
args__update='update' args__update='update'
@ -24,8 +23,6 @@ package_manager() {
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if [ "$command" = 'get_manually_installed' ]; then if [ "$command" = 'get_manually_installed' ]; then
eval $manager "$args__get_manually_installed" eval $manager "$args__get_manually_installed"
elif [ "$command" = 'get_status' ]; then
echo unimplemented: eval $manager "$args__get_status" # TODO
elif [ "$command" = 'install' ]; then elif [ "$command" = 'install' ]; then
$AUTHORIZE_COMMAND $manager $args__install $args__user_args $AUTHORIZE_COMMAND $manager $args__install $args__user_args
elif [ "$command" = 'uninstall' ]; then elif [ "$command" = 'uninstall' ]; then

View file

@ -1,26 +1,8 @@
# functions to track, untrack and query tracked state of packages
# returns 0 if all packages are tracked, 1 if any is untracked
query_packages() {
local packages="$1"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
if ! cat "$CONFIG_ROOT/packages" | grep -q "^$package$"; then
return 1
fi
return 0
done
}
track_packages() { track_packages() {
local packages="$1" local packages="$1"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
if query_packages "$package"; then echo "$package" >> "$CONFIG_ROOT/packages"
log info "Package $package was not tracked because it is already tracked"
else
echo "$package" >> "$CONFIG_ROOT/packages"
fi
done done
} }

View file

@ -149,13 +149,9 @@ prepare_directories() {
} }
print_help() { print_help() {
printf "\n tori: configuration management and system replication tool\n" printf "\n tori: configuration managent and system replication tool\n"
printf "\n Options:\n\n" printf "\n Options:\n\n"
printf "\tcheck\t\tcompare configuration to system state\n" printf "\tcheck\t\tcompare configuration to system state\n"
printf "\tinstall\t\tinstall packages\n"
printf "\tuninstall\tuninstall packages\n"
printf "\ttrack\t\tadd a file to your configuration\n"
printf "\tforget\t\tremove a file from your configuration\n"
printf "\tcache\t\trefresh the local package cache\n" printf "\tcache\t\trefresh the local package cache\n"
printf "\n" printf "\n"
printf "\tversion\t\tprint current version with release date\n" printf "\tversion\t\tprint current version with release date\n"

34
tori
View file

@ -2,7 +2,7 @@
main() { main() {
# paths # paths
VERSION="0.7.0 2024-09-13" VERSION="0.6.0 2024-09-03"
TORI_ROOT="$HOME/.local/share/tori" TORI_ROOT="$HOME/.local/share/tori"
CONFIG_ROOT="$HOME/.config/tori" CONFIG_ROOT="$HOME/.config/tori"
BACKUP_ROOT="$HOME/.local/state/tori/backup" BACKUP_ROOT="$HOME/.local/state/tori/backup"
@ -15,8 +15,8 @@ main() {
DEBUG_DISABLED_WARNING= DEBUG_DISABLED_WARNING=
## user input ## user input
command="$1" argument="$1"
argument="$2" parameter="$2"
# import source # import source
check_core_paths check_core_paths
@ -38,33 +38,13 @@ main() {
# entry point # entry point
if [ "$command" = check ] || [ "$command" = c ]; then if [ "$argument" = check ]; then
check check
elif [ "$command" = install ] || [ "$command" = i ]; then elif [ "$argument" = cache ]; then
if package_manager install "$argument"; then
track_packages "$argument"
else
log warn "Package installation failed for $argument, no action taken"
fi
elif [ "$command" = uninstall ] || [ "$command" = u ]; then
if package_manager uninstall "$argument"; then
if package_manager; then
log warn "Package uninstallation failed for $argument, no action taken"
else
untrack_packages "$argument"
fi
else
log warn "Package uninstallation failed for $argument, no action taken"
fi
elif [ "$command" = track ] || [ "$command" = t ]; then
echo unimplemented: track "$argument" # TODO
elif [ "$command" = forget ] || [ "$command" = f ]; then
echo unimplemented: untrack "$argument" # TODO
elif [ "$command" = cache ]; then
update_package_cache --force update_package_cache --force
elif [ "$command" = version ] || [ "$command" = -v ] || [ "$command" = --version ]; then elif [ "$argument" = version ] || [ "$argument" = -v ] || [ "$argument" = --version ]; then
echo "$VERSION" echo "$VERSION"
elif [ "$command" = help ] || [ "$command" = -h ] || [ "$command" = --help ]; then elif [ "$argument" = help ] || [ "$argument" = -h ] || [ "$argument" = --help ]; then
print_help print_help
else else
echo "Use 'tori help' for usage instructions" echo "Use 'tori help' for usage instructions"