-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathetcdiff
More file actions
executable file
·107 lines (96 loc) · 3.39 KB
/
etcdiff
File metadata and controls
executable file
·107 lines (96 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
set -eu
# Originally meant to diff /etc only, now just diffs anything relevant between
# ROOT and BROOT
BROOT="${2:-/}"
ROOT="${1:-$PWD/root}"
echo --- World diff:
diff --color=always "$BROOT/var/lib/portage/world" "$ROOT/var/lib/portage/world" || true
diff --color=always "$BROOT/var/lib/portage/world_sets" "$ROOT/var/lib/portage/world_sets" || true
echo
tmp="$(mktemp -d -t etcdiff.XXXXXXXXXX)"
echo --- Package diff:
qlist --root "$BROOT" -Iv > "$tmp/pkgs.broot.txt"
qlist --root "$ROOT" -Iv > "$tmp/pkgs.root.txt"
diff --color=always "$tmp/pkgs.broot.txt" "$tmp/pkgs.root.txt" || true
echo
( cd "$BROOT" && find etc \! -type d -printf '/%p\0' | sort -z > "$tmp/broot.txt" )
( cd "$ROOT" && find etc \! -type d -printf '/%p\0' | sort -z > "$tmp/root.txt" )
# Find files that exist only in BROOT but aren't part of a package
comm -z23 "$tmp/broot.txt" "$tmp/root.txt" | xargs -0 qfile -o | tr '\n' '\0' > "$tmp/uniq.txt"
# This allows me to ignore files from packages that aren't installed in ROOT
# Aggregate that with the files that exist in ROOT
cat "$tmp/uniq.txt" "$tmp/root.txt" | sort -z | uniq -z > "$tmp/files.txt"
# Filter and diff
cat "$tmp/files.txt" | grep -zxv \
-e '/etc/adjtime' \
-e '/etc/bind/rndc.key' \
-e '/etc/conf.d/net' \
-e '/etc/config-archive/.*' \
-e '/etc/cron.hourly/updates' \
-e '/etc/csh.env' \
-e '/etc/cups/classes.conf' \
-e '/etc/cups/classes.conf.O' \
-e '/etc/cups/ppd/.*' \
-e '/etc/cups/printers.conf' \
-e '/etc/cups/printers.conf.O' \
-e '/etc/dhcpcd.exit-hook' \
-e '/etc/dnsmasq-conf.conf' \
-e '/etc/dnsmasq-resolv.conf' \
-e '/etc/dracut.conf' \
-e '/etc/env.d/rust/last-set' \
-e '/etc/environment.d/10-gentoo-env.conf' \
-e '/etc/eselect/wine/.*' \
-e '/etc/fstab' \
-e '/etc/fusee-launcher/.*' \
-e '/etc/gitconfig' \
-e '/etc/group' \
-e '/etc/group-' \
-e '/etc/gshadow' \
-e '/etc/gshadow-' \
-e '/etc/hostname' \
-e '/etc/hosts' \
-e '/etc/init.d/binfmt' \
-e '/etc/init.d/net\..*' \
-e '/etc/init.d/procfs' \
-e '/etc/init.d/sysfs' \
-e '/etc/kernel' \
-e '/etc/ld.so.cache' \
-e '/etc/ld.so.conf' \
-e '/etc/local.d/efivars.start' \
-e '/etc/local.d/podman.start' \
-e '/etc/machine-id' \
-e '/etc/modprobe.d/alsa.conf' \
-e '/etc/mpv/scripts/.*' \
-e '/etc/mtab' \
-e '/etc/passwd' \
-e '/etc/passwd-' \
-e '/etc/portage/.*' \
-e '/etc/printcap' \
-e '/etc/profile.csh' \
-e '/etc/profile.d/\.keep' \
-e '/etc/profile.env' \
-e '/etc/resolv.conf' \
-e '/etc/runlevels/default/tailscale' \
-e '/etc/runlevels/default/tlp' \
-e '/etc/runlevels/default/waydroid' \
-e '/etc/sgml/catalog' \
-e '/etc/sgml/sgml-docbook.cat' \
-e '/etc/shadow' \
-e '/etc/shadow-' \
-e '/etc/ssh/ssh_host_[^_]*_key' \
-e '/etc/ssh/ssh_host_[^_]*_key.pub' \
-e '/etc/ssh/sshd_config' \
-e '/etc/ssl/certs/java/cacerts' \
-e '/etc/subgid-' \
-e '/etc/subuid-' \
-e '/etc/sudoers.d/mid-kid' \
-e '/etc/tlp.d/my.conf' \
-e '/etc/udev/rules.d/50-plugdev.rules' \
-e '/etc/udev/rules.d/70-persistent-net.rules' \
-e '/etc/wpa_supplicant/wpa_supplicant.conf' \
-e '/etc/xml/catalog' \
-e '/etc/xml/docbook' \
| xargs -0 -I% diff -q "$BROOT%" "$ROOT%" || true
# FUTURE: Reconsider choices wrt /etc/init.d/{binfmt,procfs,sysfs}
rm -rf "$tmp"