fix: New README, new documentation for developpers, and many install.sh and update.sh fixes

This commit is contained in:
Gu://em_ 2026-05-04 22:57:12 +02:00
parent 38d2572e84
commit 6b92f7a0a0
5 changed files with 282 additions and 45 deletions

View file

@ -15,6 +15,8 @@ STATE_DIR="$DOTFILES_DIR/.state"
PKG_STATE_DIR="$STATE_DIR/packages"
STATE_FILE="$STATE_DIR/update.state"
PACKAGES_DIR="$DOTFILES_DIR/packages"
STOW_DIR="$DOTFILES_DIR"
STOW_PKG="config"
STOW_TARGET="$HOME"
# ── Colours ──────────────────────────────────────────────────────────────────
@ -188,20 +190,32 @@ git_fetch_and_check() {
OLD_HASH="$local_hash"
}
# ── Conflict detection ────────────────────────────────────────────────────────
collect_changed_files() {
# Files changed inside the config/ stow package between old and new commit.
# Strip the leading "config/" prefix so paths are relative to $HOME,
# matching what stow creates as symlink targets.
# ── Change detection ────────────────────────────────────────────────────────────────
# Files changed inside config/ (stow package) — used for conflict detection.
# Paths are stripped of the "config/" prefix so they match $HOME-relative targets.
collect_changed_config_files() {
git -C "$DOTFILES_DIR" diff --name-only "${OLD_HASH}" "${NEW_HASH}" \
| grep '^config/' \
| sed 's|^config/||' \
|| true
}
# Returns 0 (true) if any file under packages/ changed between the two commits.
packages_changed() {
git -C "$DOTFILES_DIR" diff --name-only "${OLD_HASH}" "${NEW_HASH}" \
| grep -q '^packages/'
}
# Returns 0 (true) if any file under scripts/ changed between the two commits.
scripts_changed() {
git -C "$DOTFILES_DIR" diff --name-only "${OLD_HASH}" "${NEW_HASH}" \
| grep -q '^scripts/'
}
handle_conflicts() {
local repo_changed_files
mapfile -t repo_changed_files < <(collect_changed_files)
mapfile -t repo_changed_files < <(collect_changed_config_files)
if (( ${#repo_changed_files[@]} == 0 )); then
return
@ -502,10 +516,37 @@ main() {
if [[ $HAS_UPDATE == true ]]; then
handle_conflicts
apply_git_update
# Re-stow config/ whenever dotfiles changed
apply_stow
# Re-stow scripts/ when it changed (keeps ~/.local/bin helpers up to date)
if scripts_changed; then
info "scripts/ changed — re-linking binaries"
local err_file; err_file=$(mktemp)
if stow --dir="$DOTFILES_DIR" --target="$HOME" --restow scripts \
2>"$err_file"; then
ok "stow: scripts"
else
warn "stow: scripts (errors below)"
while IFS= read -r line; do
echo " ${DIM}${line}${RESET}"
done < "$err_file"
fi
rm -f "$err_file"
fi
state_set "last_commit" "$NEW_HASH"
# Re-process packages whenever packages/ changed, even if no git update
# produced new dotfiles — package lists are independent of stowed files.
if packages_changed; then
info "packages/ changed — running full package sync"
fi
fi
# Package sync runs on every invocation (diff vs saved state catches changes).
# This also handles the case where a previous run partially failed.
process_packages
process_aur_group