Compare commits

..

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

5 changed files with 13 additions and 29 deletions

View file

@ -1,7 +1,3 @@
0.6.0 2024-09-03: File management with the tree strategy
File backups
Extract authorization command to top level
ask and tildify utility functions
0.5.0 2024-07-18: "Decide in editor" package conflict resolution strategy 0.5.0 2024-07-18: "Decide in editor" package conflict resolution strategy
Drop pipefail shell option for dash compatibility Drop pipefail shell option for dash compatibility
Add numerical debug levels to the log utility function Add numerical debug levels to the log utility function

View file

@ -2,7 +2,7 @@
tori is a tool to track your personal systems' configurations and replicate them. tori is a tool to track your personal systems' configurations and replicate them.
If you'd like a more detailed description of what it is, its purpose, origins and goals, see the [announcement blog post](https://blog.jutty.dev/posts/introducing-tori/). If you'd like a more detailed description of what it is, its purpose, origins and goals, see the [announcement blog post](https://blog.jutty.dev/posts/introducing-tori.html).
Refer to the [project website](https://tori.jutty.dev) for updates and access to [documentation](https://tori.jutty.dev/docs). Refer to the [project website](https://tori.jutty.dev) for updates and access to [documentation](https://tori.jutty.dev/docs).

View file

@ -1,4 +1,4 @@
# takes a list of newline-separated absolute paths # takes a list of space-separated absolute paths
# backs each path up, creating canonical or ephemeral copies as needed # backs each path up, creating canonical or ephemeral copies as needed
backup_paths() { backup_paths() {
local paths="$1" local paths="$1"
@ -15,26 +15,14 @@ backup_paths() {
mkdir -p "$(dirname "$ephemeral_path")" mkdir -p "$(dirname "$ephemeral_path")"
if [ -f "$ephemeral_path" ]; then if [ -f "$ephemeral_path" ]; then
log debug "[backup] Overwriting ephemeral copy for $path" log debug "[backup] Overwriting ephemeral copy for $path"
if [ -r "$path" ]; then cp -f "$path" "$ephemeral_path"
cp -f "$path" "$ephemeral_path"
else
$AUTHORIZE_COMMAND cp -f "$path" "$ephemeral_path"
fi
else else
if [ -r "$path" ]; then cp "$path" "$ephemeral_path"
cp "$path" "$ephemeral_path"
else
$AUTHORIZE_COMMAND cp "$path" "$ephemeral_path"
fi
fi fi
else else
log debug "[backup] Creating canonical copy for $path" log debug "[backup] Creating canonical copy for $path"
mkdir -p "$(dirname "$canonical_path")" mkdir -p "$(dirname "$canonical_path")"
if [ -r "$path" ]; then cp "$path" "$canonical_path"
cp "$path" "$canonical_path"
else
$AUTHORIZE_COMMAND cp "$path" "$canonical_path"
fi
fi fi
done done
} }

View file

@ -28,7 +28,7 @@ file_scan_tree() {
file_merge_tree() { file_merge_tree() {
local base_files="$1" local base_files="$1"
local overwrite_choice= local strategy=
for file in $base_files; do for file in $base_files; do
log debug "[merge_tree] Processing $file" log debug "[merge_tree] Processing $file"
@ -47,12 +47,12 @@ file_merge_tree() {
local prompt_verb="In configuration only" local prompt_verb="In configuration only"
local prompt_options="Copy to system" local prompt_options="Copy to system"
fi fi
overwrite_choice="$(ask "$prompt_verb: $(tildify "$absolute_path")" "$prompt_options")" strategy="$(ask "$prompt_verb: $(tildify "$absolute_path")" "$prompt_options")"
log debug "[merge_tree] Overwrite choice: $overwrite_choice" log debug "[merge_tree] Chosen strategy: $strategy"
if [ "$overwrite_choice" -eq 0 ]; then if [ "$strategy" -eq 0 ]; then
return 0 return 0
elif [ "$overwrite_choice" -eq 1 ]; then elif [ "$strategy" -eq 1 ]; then
backup_paths "$absolute_path" backup_paths "$absolute_path"
if [ -r "$config_path" ] && [ -w "$absolute_path" ]; then if [ -r "$config_path" ] && [ -w "$absolute_path" ]; then
cp -vi "$config_path" "$absolute_path" cp -vi "$config_path" "$absolute_path"
@ -60,7 +60,7 @@ file_merge_tree() {
$AUTHORIZE_COMMAND cp -vi "$config_path" "$absolute_path" $AUTHORIZE_COMMAND cp -vi "$config_path" "$absolute_path"
fi fi
return 1 return 1
elif [ "$overwrite_choice" -eq 2 ]; then elif [ "$strategy" -eq 2 ]; then
backup_paths "$config_path" backup_paths "$config_path"
if [ -r "$absolute_path" ] && [ -w "$config_path" ]; then if [ -r "$absolute_path" ] && [ -w "$config_path" ]; then
cp -vi "$absolute_path" "$config_path" cp -vi "$absolute_path" "$config_path"
@ -68,7 +68,7 @@ file_merge_tree() {
$AUTHORIZE_COMMAND cp -vi "$absolute_path" "$config_path" $AUTHORIZE_COMMAND cp -vi "$absolute_path" "$config_path"
fi fi
return 1 return 1
elif [ "$overwrite_choice" -eq 3 ]; then elif [ "$strategy" -eq 3 ]; then
echo "< $(tildify "$absolute_path") | $(echo "$config_path" | sed "s*$CONFIG_ROOT/**") >" echo "< $(tildify "$absolute_path") | $(echo "$config_path" | sed "s*$CONFIG_ROOT/**") >"
if [ -r "$absolute_path" ] && [ -r "$config_path" ]; then if [ -r "$absolute_path" ] && [ -r "$config_path" ]; then
diff "$absolute_path" "$config_path" diff "$absolute_path" "$config_path"

2
tori
View file

@ -2,7 +2,7 @@
main() { main() {
# paths # paths
VERSION="0.6.0 2024-09-03" VERSION="0.5.0 2024-07-18"
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"