blob: 67d3e8988e85a0fc444d61c3f49cb05c8bf4b24e (
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
98
99
100
101
102
103
104
|
note() {
printf "${BLUE}==>${YELLOW} $1 ${WHITE}$2${ALL_OFF}\n"
}
msg1() {
printf "${BLUE}==>${WHITE} $1${ALL_OFF}\n"
}
msg2() {
printf " ${WHITE} $1${ALL_OFF}\n"
}
ALL_OFF="$(tput sgr0)"
BOLD="${ALL_OFF}$(tput bold)"
BLACK="${BOLD}$(tput setaf 0)"
RED="${BOLD}$(tput setaf 1)"
GREEN="${BOLD}$(tput setaf 2)"
YELLOW="${BOLD}$(tput setaf 3)"
BLUE="${BOLD}$(tput setaf 4)"
MAGENTA="${BOLD}$(tput setaf 5)"
CYAN="${BOLD}$(tput setaf 6)"
WHITE="${BOLD}$(tput setaf 7)"
_builders=(
builder
builduser
main-builder
)
_groups=(
flutter
flutteruser
)
post_install() {
# primary flutter group
groupadd -f flutter
for i in "${_groups[@]}"; do
if grep -q "$i" /etc/passwd > /dev/null; then
setfacl -R -m "g:$i:rwX" /opt/flutter
fi
done
# clean chroot/container builders
for i in "${_builders[@]}"; do
if grep -q "$i" /etc/passwd > /dev/null; then
setfacl -R -m "u:$i:rwX" /opt/flutter
fi
done
note 'Warning:' "'/opt/flutter' will be wiped on upgrade and uninstall."
echo
msg2 "Flutter requires write permission to the install directory."
echo
msg2 "This package redirects writes to '~/.cache/flutter_*'."
msg2 "Users should unmount and clear the cache after upgrades."
echo
msg2 " fusermount -uq ~/.cache/flutter_sdk"
msg2 " rm -rf ~/.cache/{flutter_sdk,flutter_local}"
echo
msg2 "Optionally, adding users to the 'flutter' group would"
msg2 "give them direct access to '/opt/flutter':"
echo
msg2 " sudo usermod -a -G flutter [username]"
}
post_upgrade() {
post_install
}
pre_install() {
pre_remove
}
pre_upgrade() {
pre_remove
}
pre_remove() {
if [ ! -e opt/flutter ]; then
return
fi
# remove extra permissions
for i in ${_builders[@]} ${_groups[@]}; do
if grep -q "group:$i" <<< $(getfacl -ac /opt/flutter 2> /dev/null); then
setfacl -R -x "g:$i" /opt/flutter
fi
if grep -q "user:$i" <<< $(getfacl -ac /opt/flutter 2> /dev/null); then
setfacl -R -x "u:$i" /opt/flutter
fi
done
chmod -R u+rwX,go+rX,go-w opt/flutter
}
post_remove() {
rm -rf opt/flutter
msg1 "If no longer needed, remove the 'flutter' group:"
echo
msg2 " sudo groupdel flutter"
}
|