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
File backups
Extract authorization command to top level

View file

@ -14,7 +14,6 @@ package_manager() {
if [ "$OS" = "FreeBSD" ]; then
manager="pkg"
args__get_manually_installed='query -e "%a = 0" "%n"'
args__get_status='' # TODO
args__install='install'
args__uninstall='delete'
args__update='update'
@ -24,8 +23,6 @@ package_manager() {
# shellcheck disable=SC2086
if [ "$command" = 'get_manually_installed' ]; then
eval $manager "$args__get_manually_installed"
elif [ "$command" = 'get_status' ]; then
echo unimplemented: eval $manager "$args__get_status" # TODO
elif [ "$command" = 'install' ]; then
$AUTHORIZE_COMMAND $manager $args__install $args__user_args
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() {
local packages="$1"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
if query_packages "$package"; then
log info "Package $package was not tracked because it is already tracked"
else
echo "$package" >> "$CONFIG_ROOT/packages"
fi
echo "$package" >> "$CONFIG_ROOT/packages"
done
}

View file

@ -149,13 +149,9 @@ prepare_directories() {
}
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 "\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 "\n"
printf "\tversion\t\tprint current version with release date\n"

34
tori
View file

@ -2,7 +2,7 @@
main() {
# paths
VERSION="0.7.0 2024-09-13"
VERSION="0.6.0 2024-09-03"
TORI_ROOT="$HOME/.local/share/tori"
CONFIG_ROOT="$HOME/.config/tori"
BACKUP_ROOT="$HOME/.local/state/tori/backup"
@ -15,8 +15,8 @@ main() {
DEBUG_DISABLED_WARNING=
## user input
command="$1"
argument="$2"
argument="$1"
parameter="$2"
# import source
check_core_paths
@ -38,33 +38,13 @@ main() {
# entry point
if [ "$command" = check ] || [ "$command" = c ]; then
if [ "$argument" = check ]; then
check
elif [ "$command" = install ] || [ "$command" = i ]; 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
elif [ "$argument" = cache ]; then
update_package_cache --force
elif [ "$command" = version ] || [ "$command" = -v ] || [ "$command" = --version ]; then
elif [ "$argument" = version ] || [ "$argument" = -v ] || [ "$argument" = --version ]; then
echo "$VERSION"
elif [ "$command" = help ] || [ "$command" = -h ] || [ "$command" = --help ]; then
elif [ "$argument" = help ] || [ "$argument" = -h ] || [ "$argument" = --help ]; then
print_help
else
echo "Use 'tori help' for usage instructions"