-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchupdate
More file actions
executable file
·182 lines (150 loc) · 3.84 KB
/
archupdate
File metadata and controls
executable file
·182 lines (150 loc) · 3.84 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
# Update all parts of the system
# else, just run a normal update. Either way, clean up the pacman cache afterwards.
function check_plugged_in() {
plugged_in="1"
if [[ -d "/sys/class/power_supply/BAT0" ]]; then
# plugged_in=$(cat /sys/class/power_supply/AC0/online)
plugged_in=$(cat /sys/class/power_supply/ADP1/online)
fi
if [ "$plugged_in" -eq "0" ]; then
echo "not plugged in, exiting"
exit
fi
}
function info() {
# check how many days since last update
last_upgrade=$(tac /var/log/pacman.log |
grep -m 1 'upgraded' |
cut -d ' ' -f 1 | tr -d '[]')
t1=$(date +%s -d "$last_upgrade")
t2=$(date +%s)
days=$(((t2 - t1) / 86400))
echo "$days days since last upgrade"
# print any news from the archlinux news page
paru -Pw
}
function update_mirror_list() {
# save and update mirror list, firmware and this repo and nvim plugs if it's been a month
if [[ $(find /etc/pacman.d/mirrorlist -mtime +30 -print) ]]; then
echo -e "Updating: mirrorlist"
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
sudo reflector --country 'United States' --country 'Canada' --latest 200 \
--age 24 --sort rate --save /etc/pacman.d/mirrorlist
fi
}
function update_package_lists() {
# update package list
echo -e "Updating: package list"
dir=$CUSTOM_CONFIG_HOME/package_info/
host=$(hostnamectl | grep "Static hostname" | cut -d ':' -f 2 | tr -d ' ')
declare -a package_lists=("qne" "qme" "qnett" "qmett" "qtd" "qtdq")
for pacman_arg in "${package_lists[@]}"; do
pacman -Q${pacman_arg} >"${dir}"${pacman_arg}"_"${host}".txt"
done
}
function pre() {
check_plugged_in
update_mirror_list
info
}
function update_pacman() {
# update packages from prebuilt repos
echo -e "\nUpdating: Pacman\n"
sudo pacman -Syu
}
function update_paru() {
# update repo and AUR packages with full refresh
echo -e "\n"
echo -e "Updating: Arch Linux databases and packages"
echo -e "\n"
paru --gendb
paru -Syyu --sudoloop
}
function update_others() {
echo -e "\nUpdating: Liam's bashscripts\n"
git -C ~/bin/bashscripts pull
echo -e "\nUpdating: Rust\n"
rustup update
echo -e "\nUpdating: Firmware\n"
fwupdmgr refresh
fwupdmgr get-updates
echo -e "\nUpdating: Neovim Plugins\n"
nvim --headless +PlugUpdate +PlugUpgrade +qa
nvim --headless +CocUpdate +qa
nvim --headless +TSUpdate +qa
echo -e "\nUpdating: Tmux Plugins\n"
~/.tmux/plugins/tpm/bin/update_plugins all
echo -e "\nUpdating: Boot Loader\n"
sudo bootctl update
echo -e "\nUpdating: Anaconda\n"
conda update --all
# echo -e "\nUpdating: NPM\n"
# npm update -g
}
function clean_cache() {
echo -e "\nCleaning: Pacman Cache\n"
paccache -r -k 3
# echo -e "\nCleaning: AUR Cache\n"
# cd ~/.cache/paru/clone
# trash $(fd -I -e pkg.tar.zst --changed-before 14d)
# trash $(fd -I -e tar.gz --changed-before 14d)
# trash $(fd -I -e tar.xz --changed-before 14d)
# trash $(fd -I -e tar.bz2 --changed-before 14d)
# cd -
echo -e "\nCleaning: Unused Plugins\n"
~/.tmux/plugins/tpm/bin/clean_plugins
nvim --headless +PlugClean +qa
}
function diffs() {
sudo DIFFPROG="nvim -d $1" pacdiff
}
function post() {
update_package_lists
clean_cache
diffs
}
function full_update() {
pre
update_paru
update_others
post
}
function basic_update() {
pre
paru -Syu --sudoloop
}
while getopts ":hfbop" opt; do
case $opt in
h | help)
usage
exit 0
;;
f | full)
# Update and clean all supported system components
full_update
exit 0
;;
b | basic)
# perform preupdate functions then update only system level packages
basic_update
exit 0
;;
o | other)
# update nonssytem packages (those not included in basic update)
update_others
exit 0
;;
p | post)
# perform cleaning functions, included in full update but not basic
post
exit 0
;;
*)
echo -e "\n Option does not exist : $OPTARG\n"
usage
exit 1
;;
esac # --- end of case ---
done
shift $(($OPTIND - 1))