-
Notifications
You must be signed in to change notification settings - Fork 0
/
doom_upgrade
82 lines (64 loc) · 2.28 KB
/
doom_upgrade
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
#!/bin/bash
for diff_file in ~/.doom.d/diffs/*; do
if [[ $diff_file == *'.bk' ]]; then
continue
fi
echo $diff_file
package=$((basename $diff_file) | sed 's/.diff//')
echo $package
if [ -d ~/.emacs.d/.local/straight/repos/${package} ]; then
cd ~/.emacs.d/.local/straight/repos/${package}
echo ~/.emacs.d/.local/straight/repos/${package}
git diff > ${diff_file}.bk
if [ -s ${diff_file}.bk ]; then
if cmp -s ${diff_file}.bk ${diff_file}; then
echo "No changes"
rm ${diff_file}.bk
else
diff ${diff_file}.bk ${diff_file}
read -r -p "Apply changes? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]];then
echo "Applying changes"
mv ${diff_file}.bk ${diff_file}
else
echo "No changes"
rm ${diff_file}.bk
fi
fi
else
rm ${diff_file}.bk
fi
git stash save --keep-index --include-untracked
cd -
fi
done
VER=`emacs --version | head -n 1 | awk '{print $3}'`
if [[ $1 == 'not_upgrade' ]]; then
echo "Not upgrading packages"
else
echo "Upgrading packages"
export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export ALL_PROXY=socks5://127.0.0.1:1080
STASH_NAME=$(date '+%Y-%m-%d-%H:%M:%S')
cd ~/.emacs.d
#git stash push -m $STASH_NAME
~/.emacs.d/bin/doom upgrade --force
#git stash apply stash@{0}
# delete package
for package in $(git diff | grep "package\!" | grep "^+" | sed "s/^.*e! \(.*\) :pin.*/\1/")
do
echo $package
rm -rf ~/.emacs.d/.local/straight/repos/${package}
rm -rf ~/.emacs.d/.local/straight/build-${VER}/${package}
done
~/.emacs.d/bin/doom sync
cd -
fi
rm -rf ~/.emacs.d/.local/straight/build-${VER}/eaf ~/.emacs.d/.local/straight/build-${VER}/jupyter
for diff_file in ~/.doom.d/diffs/*; do
echo $diff_file
cd ~/.emacs.d/.local/straight/repos/$((basename $diff_file) | sed 's/.diff//')
rm -rf ~/.emacs.d/.local/straight/build-${VER}/$((basename $diff_file) | sed 's/.diff//')
git apply ${diff_file}
cd -
done
~/.emacs.d/bin/doom sync