blob: 9114d975659322515fc1973ee4be7ba8f965d7b3 (
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
|
#!/usr/bin/env bash
set -eu
user="${SUDO_USER:-$USER}"
function initialised {
grep -q '^Include = /etc/pacman.d/aurto$' /etc/pacman.conf
}
post_install() {
if initialised; then
echo 'Already initialised' >&2
exit 0
fi
echo "aurto: Initialising for user: $user"
echo "$user" > /usr/lib/aurto/user
chmod 700 /usr/lib/aurto/user
install -d /var/cache/pacman/aurto -o "$user"
sudo -u "$user" repo-add /var/cache/pacman/aurto/aurto.db.tar 2>/dev/null
echo 'aurto: Adding include /etc/pacman.d/aurto >> pacman.conf' >&2
if ! test -f /etc/pacman.conf.aurto-backup; then
cp /etc/pacman.conf /etc/pacman.conf.aurto-backup
fi
echo -e "# aurto repo\\nInclude = /etc/pacman.d/aurto" >> /etc/pacman.conf
if ! test -f /etc/aurto/trusted-users; then
echo 'aurto: Adding default trusted users -> /etc/aurto/trusted-users' >&2
install -Dm640 -o "$user" /usr/lib/aurto/default-trusted-users.txt /etc/aurto/trusted-users
fi
echo 'aurto: Adding & enabling systemd timer update tasks' >&2
systemctl enable --now /usr/lib/systemd/system/check-aurto-git-trigger.timer
systemctl enable --now /usr/lib/systemd/system/update-aurto.timer
systemctl enable /usr/lib/systemd/system/update-aurto-startup.timer
echo "aurto: Passwordless usage available for \`wheel\` group"
}
post_upgrade() {
old_version=$2
update_from_before_0_7_8_1=$(vercmp "$old_version" "0.7.8-1")
if [ "$update_from_before_0_7_8_1" = "-1" ] \
&& ! systemctl is-enabled /usr/lib/systemd/system/update-aurto-startup.timer 2>/dev/null
then
systemctl enable /usr/lib/systemd/system/update-aurto-startup.timer
fi
}
pre_remove() {
if ! initialised; then
exit 0
fi
echo 'aurto: Removing systemd timer update tasks' >&2
systemctl disable --now check-aurto-git-trigger.timer || true
systemctl disable --now update-aurto.timer || true
}
post_remove() {
if ! initialised; then
exit 0
fi
echo 'aurto: Removing include from pacman.conf' >&2
sed -i '/^Include = \/etc\/pacman.d\/aurto$/d' /etc/pacman.conf
sed -i '/^# aurto repo$/d' /etc/pacman.conf
echo 'aurto: Removing /var/cache/pacman/aurto' >&2
rm -rf /var/cache/pacman/aurto 2>/dev/null || true
rm -f /usr/lib/aurto/user 2>/dev/null || true
rm -f /etc/aurto/trusted-users 2>/dev/null || true
rm -d /etc/aurto 2>/dev/null || true
}
|