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
#!/bin/bash
[ "$1" != "--run" ] && echo "Install and configure Waydroid" && exit
. $(dirname $0)/common.sh
[ "$(epm print info -s)" = "alt" ] || fatal "Only ALTLinux are supported"
epm assure lspci pciutils || exit
display_help()
{
echo "
Use: epm prescription waydroid [option]
--gpu
Select GPU for Waydroid
--init
Initialize Waydroid
--integrate
Enable desktop window integration for Waydroid
--software-render
Use software render in Waydroid (maybe fix work in Nvidia)
--help
Display this page
"
exit
}
# TODO: fix used_kflavour export in epm update-kernel --check-run-kernel
used_kflavour () {
if [ $(uname -r | grep "def") ] ; then
USED_KFLAVOUR=$(uname -r | awk -F'-' '{print $2 "-" $3}')
else
USED_KFLAVOUR=$(uname -r | awk -F'-' '{print $2}')
fi
}
waydroid_install () {
epm update-kernel --add-kernel-options psi1
epm update || fatal
epm update-kernel || fatal
if ! epm update-kernel --check-run-kernel ; then
fatal
fi
used_kflavour
epm install --skip-installed kernel-modules-anbox-$USED_KFLAVOUR libgbinder1 waydroid || fatal
a= update-grub
echo "Waydroid has been installed"
}
waydroid_select_gpu () {
echo "Select GPU for Waydroid"
gpu_info=$(lspci -nn | grep '\[03')
gpu_number=$(echo "$gpu_info" | awk '{print $1}')
gpu_name=$(echo "$gpu_info" | grep -oP '(?<=: ).*')
if [ -z "$gpu_info" ]; then
echo "No GPU devices found."
exit 1
fi
echo "Available GPU device"
for i in "${!gpu_number[@]}"; do
echo "$((i)). ${gpu_number[$i]} ${gpu_name}"
done
# Prompt the user to select a device ID
while true; do
read -p "Enter the number of the GPU device to use: " selected_gpu_num
if ! [[ "$selected_gpu_num" =~ ^[0-9]+$ ]]; then
echo "Invalid entry: $selected_gpu_num is not a number."
continue
fi
if (( selected_gpu_num < 0 || selected_gpu_num >= ${#gpu_number[@]} )); then
echo "Invalid entry: $selected_gpu_num is not a valid option."
continue
fi
selected_gpu=${gpu_number[$selected_gpu_num]}
break
done
card=$(ls -l /dev/dri/by-path/ | grep -i $selected_gpu | grep -o "card[0-9]")
rendernode=$(ls -l /dev/dri/by-path/ | grep -i $selected_gpu | grep -o "renderD[1-9][1-9][1-9]")
cp /var/lib/waydroid/lxc/waydroid/config_nodes /var/lib/waydroid/lxc/waydroid/config_nodes.bak
sed -i '/dri/d' /var/lib/waydroid/lxc/waydroid/config_nodes
echo "lxc.mount.entry = /dev/dri/$card dev/dri/card0 none bind,create=file,optional 0 0" >> /var/lib/waydroid/lxc/waydroid/config_nodes
echo "lxc.mount.entry = /dev/dri/$rendernode dev/dri/renderD128 none bind,create=file,optional 0 0" >> /var/lib/waydroid/lxc/waydroid/config_nodes
}
waydroid_init () {
serv on waydroid-container
waydroid init -c 'https://ota.waydro.id/system' -v 'https://ota.waydro.id/vendor'
}
waydroid_integrate () {
waydroid prop set persist.waydroid.multi_windows true
}
waydroid_software_rendering () {
sed -i "s/ro.hardware.gralloc=.*/ro.hardware.gralloc=default/g" /var/lib/waydroid/waydroid_base.prop
sed -i "s/ro.hardware.egl=.*/ro.hardware.egl=swiftshader/g" /var/lib/waydroid/waydroid_base.prop
}
case "${3}" in
'--gpu' )
assure_root
waydroid_select_gpu ;;
'--init')
assure_root
waydroid_init ;;
'--integrate')
assure_root
waydroid_integrate ;;
'--software-render')
assure_root
waydroid_software_rendering ;;
'--help')
display_help;;
*)
assure_root
waydroid_install ;;
esac