blob: f2e22982ff4227f9edfcd97a4079337b4bed93d8 (
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
88
89
90
91
92
93
94
95
96
97
|
pkgname="atostekid"
# colors
if command -v tput >/dev/null 2>&1; then
all_off="$(tput sgr0)"
bold="${all_off}$(tput bold)"
blue="${bold}$(tput setaf 4)"
red="${bold}$(tput setaf 1)"
yellow="${bold}$(tput setaf 3)"
fi
note() {
printf "${blue-}==>${yellow-} NOTE:${bold-} %s${all_off-}\n" "${1}"
}
warn() {
printf "${red-}==> WARN:${bold-} %s${all_off-}\n" "${1}"
}
is_update_from() {
local result="$(vercmp "${1}" "${2}")"
case $result in
'-1'|'0') return 0;;
'1') return 1;;
esac
}
filter_installed_packages() {
pacman -Qq "$@" 2>&1 | sed -n "s/^error: package '\([a-z0-9@._+-]\+\)' was not found$/\1/p"
}
check_pcscd_status() {
if ! systemctl --quiet is-active pcscd.socket 2>/dev/null; then
note "${pkgname} requires that the PC/SC Smart Card Daemon systemd socket (pcscd.socket) is active. Please ensure it is started before launching ${pkgname}."
fi
}
recommend_optional_packages() {
local optional_packages
local uninstalled_optional_packages
local desktop="${XDG_CURRENT_DESKTOP:-}"
case ${desktop,,} in
gnome)
optional_packages+=("libappindicator-gtk3" "gnome-shell-extension-appindicator")
readarray -t uninstalled_optional_packages < <(filter_installed_packages "${optional_packages[@]}")
if [[ "${#uninstalled_optional_packages[@]}" -gt 0 ]]; then
note "On ${desktop}, ${pkgname} relies on the optional packages: ${uninstalled_optional_packages[*]}. Please consider installing them."
fi
;;
*)
;;
esac
}
# Remove certs that were installed to system trust store and filesystem in
# previous versions of this package. These are not needed anymore.
deprecate_certificates() {
local legacy_ca_paths=(
"/etc/${pkgname:-atostekid}/scsca.cer"
"/usr/share/${pkgname:-atostekid}/certs/erasmartcard_ehoito_fi_ca.cer"
"/usr/share/${pkgname:-atostekid}/certs/scsca.cer"
)
for legacy_ca_path in "${legacy_ca_paths[@]}"; do
if [[ -f "${legacy_ca_path}" ]]; then
note "Removing trust for legacy CA file ${legacy_ca_path}"
trust anchor --remove "${legacy_ca_path}"
rm "${legacy_ca_path}"
fi
done
local legacy_dirs=(
"/etc/${pkgname:-atostekid}"
"/usr/share/${pkgname:-atostekid}/certs/"
"/usr/share/${pkgname:-atostekid}/"
)
for legacy_dir in "${legacy_dirs[@]}"; do
if [[ -d "${legacy_dir}" ]]; then
rmdir "${legacy_dir}"
fi
done
}
post_install() {
check_pcscd_status
recommend_optional_packages
note "Many features of ${pkgname} require user configuration. Please review the official documentation in /usr/share/doc/atostekid/. You may also wish to check the Arch Wiki: https://wiki.archlinux.org/title/Special:Search?search=${pkgname}"
}
post_upgrade() {
# local new_version="${1}"
local old_version="${2}"
if is_update_from "${old_version}" 4.3.1.0-2; then
deprecate_certificates
fi
check_pcscd_status
}
|