blob: 2f162a5c9ba00d78f9599a636cad3c920f747ec7 (
plain)
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
|
#!/bin/bash
# Backup package-user-dir, update packages, compute diffs.
#
# Might be worth re-implementing as advice for package.el commands:
# would avoid the "sacrificial" Emacs sessions…
set -euo pipefail
test "${DEBUG:-}" && set -x
BKPDIR=.elpa.$(date +%F-%T)
read-packages ()
{
local -n pkgarray=$1
local pkgel name version
for pkgel in elpa/*/*-pkg.el
do
# Extract NAME & VERSION out of elpa/NAME-VERSION/NAME-pkg.el.
pkgel=${pkgel#elpa/}
name=${pkgel}
name=${name##*/}
name=${name%-pkg.el}
version=${pkgel}
version=${version%/${name}-pkg.el}
version=${version#${name}-}
pkgarray[${name}]=${version}
done
}
enum-packages ()
{
IFS=$'\n' eval '
echo "${!OLDPACKAGES[*]}"
echo "${!NEWPACKAGES[*]}"
' | sort -u
}
compare-packages ()
{
local pkg oldv newv
while read pkg
do
oldv=${OLDPACKAGES[${pkg}]:-}
newv=${NEWPACKAGES[${pkg}]:-}
test "${oldv}" = "${newv}" &&
# No changes, skip.
continue
test "${oldv}" -a "${newv}" &&
# Make a patch for later review.
(
set +e
diff > ${BKPDIR}/update-${pkg}.patch \
-ru ${BKPDIR}/${pkg}-${oldv} elpa/${pkg}-${newv}
diffstatus=$?
case ${diffstatus}
in
0|1) exit 0 ;;
*) exit ${diffstatus} ;;
esac
)
echo -e "${pkg}\t${oldv:-[NEW]}\t${newv:-[REMOVED]}"
done
}
(
cd ~/.config/emacs
cp -a elpa ${BKPDIR}
declare -A OLDPACKAGES NEWPACKAGES
read-packages OLDPACKAGES
emacs -f package-upgrade-all -f package-autoremove
read-packages NEWPACKAGES
enum-packages | compare-packages | column -ts$'\t'
)
|