summaryrefslogtreecommitdiff
path: root/update.sh
diff options
context:
space:
mode:
authorseraphim <18ycm9tx@anonaddy.me>2026-08-23 13:48:20 +0700
committerseraphim <18ycm9tx@anonaddy.me>2026-08-23 13:48:20 +0700
commit9f12ea8a648fa6483b392dc9ba1d7dbf4e61057c (patch)
tree35ec7c12203114c9e47cebbdb634c174094913c8 /update.sh
parentb57f994aa7c74d1b4e17e3df31ddf94702a8f6de (diff)
-
Diffstat (limited to 'update.sh')
-rwxr-xr-xupdate.sh38
1 files changed, 23 insertions, 15 deletions
diff --git a/update.sh b/update.sh
index 8a7d108..1ead69b 100755
--- a/update.sh
+++ b/update.sh
@@ -23,17 +23,24 @@ EOF
while [[ $# -gt 0 ]]; do
case "$1" in
- -q|--quick) QUICK=yes ;;
- -c|--commit) DO_COMMIT=yes ;;
- -h|--hook-install) INSTALL_HOOK=yes ;;
- -n|--dry-run) DRY_RUN=yes ;;
- --help) usage; exit 0 ;;
- *) echo "unknown option: $1" >&2; usage >&2; exit 2 ;;
+ -q | --quick) QUICK=yes ;;
+ -c | --commit) DO_COMMIT=yes ;;
+ -h | --hook-install) INSTALL_HOOK=yes ;;
+ -n | --dry-run) DRY_RUN=yes ;;
+ --help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "unknown option: $1" >&2
+ usage >&2
+ exit 2
+ ;;
esac
shift
done
-log() { printf '\033[1;32m[sync]\033[0m %s\n' "$*"; }
+log() { printf '\033[1;32m[sync]\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m[warn]\033[0m %s\n' "$*"; }
root_cp() {
@@ -44,7 +51,7 @@ root_cp() {
if [[ $EUID -eq 0 ]]; then
cp "$1" "$2"
elif cp "$1" "$2" 2>/dev/null; then
- : # readable as current user — done
+ : # readable as current user — done
elif command -v sudo >/dev/null 2>&1; then
sudo cp "$1" "$2"
else
@@ -59,8 +66,8 @@ rsync_portage() {
# Broken symlinks are excluded (rsync -L aborts on dangling referents).
local exfile
exfile="$(mktemp)"
- printf '.gitkeep\nmake.profile\n' > "$exfile"
- find /etc/portage -type l ! -exec test -e {} \; -printf '%P\n' >> "$exfile"
+ printf '.gitkeep\nmake.profile\n' >"$exfile"
+ find /etc/portage -type l ! -exec test -e {} \; -printf '%P\n' >>"$exfile"
local -a opts=(-aL --delete "--exclude-from=$exfile")
[[ "$DRY_RUN" == "yes" ]] && opts+=(-n)
@@ -75,15 +82,15 @@ sync_portage() {
if [[ -e /etc/portage/make.profile ]]; then
log "profile: $(readlink /etc/portage/make.profile)"
if [[ "$DRY_RUN" != "yes" ]]; then
- printf '%s\n' "$(readlink /etc/portage/make.profile)" > "$REPO_DIR/portage/PROFILE"
+ printf '%s\n' "$(readlink /etc/portage/make.profile)" >"$REPO_DIR/portage/PROFILE"
else
log " would write: portage/PROFILE"
fi
fi
log "world /var/lib/portage/world -> repo"
- if [[ -L /var/lib/portage/world ]] \
- && [[ "$(readlink -f /var/lib/portage/world)" == "$REPO_DIR/portage/var/lib/portage/world" ]]; then
+ if [[ -L /var/lib/portage/world ]] &&
+ [[ "$(readlink -f /var/lib/portage/world)" == "$REPO_DIR/portage/var/lib/portage/world" ]]; then
log " already a symlink into the repo — no copy needed"
else
root_cp /var/lib/portage/world "$REPO_DIR/portage/var/lib/portage/world"
@@ -114,7 +121,7 @@ install_hook() {
log "writing $hook"
if [[ $EUID -eq 0 ]]; then
mkdir -p /etc/portage/postsync.d
- cat > "$hook" <<EOF
+ cat >"$hook" <<EOF
#!/usr/bin/env bash
# generated by update.sh --hook-install — keeps dotfiles fresh after each emerge
exec "$REPO_DIR/update.sh" --quick
@@ -164,4 +171,5 @@ main() {
fi
}
-main "$@" \ No newline at end of file
+main "$@"
+