Skip to content

Commit a0f3e0f

Browse files
authored
Add Vulkan support + code refactoring in the AppRun
fix #28
1 parent c0e42bb commit a0f3e0f

File tree

1 file changed

+64
-59
lines changed

1 file changed

+64
-59
lines changed

virtualbox-kvm-junest.sh

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
APP=virtualbox-kvm
44
BIN="virtualbox" #CHANGE THIS IF THE NAME OF THE BINARY IS DIFFERENT FROM "$APP" (for example, the binary of "obs-studio" is "obs")
5-
DEPENDENCES="alsa-lib alsa-oss alsa-plugins alsa-tools alsa-utils dbus flac jack2 lame libasyncns libogg libpipewire libpulse libsndfile libvorbis mpg123 opus pipewire pipewire-alsa pipewire-audio procps-ng pulseaudio pulseaudio-alsa qt6-base vulkan-icd-loader" #SYNTAX: "APP1 APP2 APP3 APP4...", LEAVE BLANK IF NO OTHER DEPENDENCIES ARE NEEDED
5+
audio_pkgs="alsa-lib alsa-oss alsa-plugins alsa-tools alsa-utils flac jack2 lame libogg libpipewire libpulse libvorbis mpg123 opus pipewire pipewire-alsa pipewire-audio pulseaudio pulseaudio-alsa"
6+
vulkan_pkgs="libdisplay-info libdrm libxcb libxshmfence llvm-libs spirv-tools vulkan-asahi vulkan-gfxstream vulkan-icd-loader vulkan-intel vulkan-mesa-implicit-layers vulkan-nouveau vulkan-radeon vulkan-swrast vulkan-tools vulkan-virtio"
7+
DEPENDENCES=$(echo "$audio_pkgs $vulkan_pkgs dbus libasyncns libsndfile procps-ng qt6-base" | tr ' ' '\n' | sort -u | xargs) #SYNTAX: "APP1 APP2 APP3 APP4...", LEAVE BLANK IF NO OTHER DEPENDENCIES ARE NEEDED
68
BASICSTUFF="binutils debugedit gzip"
79
COMPILERS="base-devel"
810

@@ -152,81 +154,84 @@ export NVIDIA_ON=1
152154
cat <<-'HEREDOC' >> AppDir/AppRun
153155
154156
if command -v sudo >/dev/null 2>&1; then
155-
export SUDOCMD="sudo"
157+
export SUDOCMD="sudo"
156158
elif command -v doas >/dev/null 2>&1; then
157-
export SUDOCMD="doas"
159+
export SUDOCMD="doas"
158160
else
159-
echo 'ERROR: No sudo or doas found'
160-
exit 1
161+
echo 'ERROR: No sudo or doas found'
162+
exit 1
161163
fi
162164
163165
Show_help_message() {
164-
printf " Available options:\n"
165-
printf "\n --vbox-usb-enable\n"
166-
printf "\n Enable USB support in Virtual Machines. Requires \"sudo\" password.\n"
167-
printf "\n The above option does the following:\n"
168-
printf "\n - Creates the \"vboxusers\" group"
169-
printf "\n - Adds your \$USER to the \"vboxusers\" group"
170-
printf "\n - Creates the /usr/lib/virtualbox directory on the host system"
171-
printf "\n - Installs the \"VBoxCreateUSBNode.sh\" script in /usr/lib/virtualbox"
172-
printf "\n - Creates the /etc/udev/rules.d directory"
173-
printf "\n - Creates and installs the \"60-vboxusb.rules\" file in /etc/udev/rules.d\n"
174-
printf "\n VirtualBoxVM\n"
175-
printf "\n A VirtualBox command to handle Virtual Machines via command line\n\n"
166+
printf " Available options:\n"
167+
printf "\n --vbox-usb-enable\n"
168+
printf "\n Enable USB support in Virtual Machines. Requires \"sudo\" password.\n"
169+
printf "\n The above option does the following:\n"
170+
printf "\n - Creates the \"vboxusers\" group"
171+
printf "\n - Adds your \$USER to the \"vboxusers\" group"
172+
printf "\n - Creates the /usr/lib/virtualbox directory on the host system"
173+
printf "\n - Installs the \"VBoxCreateUSBNode.sh\" script in /usr/lib/virtualbox"
174+
printf "\n - Creates the /etc/udev/rules.d directory"
175+
printf "\n - Creates and installs the \"60-vboxusb.rules\" file in /etc/udev/rules.d\n"
176+
printf "\n VirtualBoxVM\n"
177+
printf "\n A VirtualBox command to handle Virtual Machines via command line\n\n"
176178
}
177179
178180
VBoxUSB_enable() {
179-
printf "\n The above option does the following:\n"
180-
printf "\n - Creates the \"vboxusers\" group"
181-
printf "\n - Adds your \$USER to the \"vboxusers\" group"
182-
printf "\n - Creates the /usr/lib/virtualbox directory on the host system"
183-
printf "\n - Installs the \"VBoxCreateUSBNode.sh\" script in /usr/lib/virtualbox"
184-
printf "\n - Creates the /etc/udev/rules.d directory"
185-
printf "\n - Creates and installs the \"60-vboxusb.rules\" file in /etc/udev/rules.d\n"
186-
printf "\n See also https://github.com/cyberus-technology/virtualbox-kvm#usb-pass-through\n"
187-
printf "\nAuthentication is required\n"
188-
if ! test -f /usr/lib/virtualbox/VBoxCreateUSBNode.sh; then
189-
# Create the "vboxusers" group and add $USER
190-
$SUDOCMD groupadd -r vboxusers -U "$USER"
191-
# Create the directory /usr/lib/virtualbox on the host system
192-
$SUDOCMD mkdir -p /usr/lib/virtualbox
193-
# Install the "VBoxCreateUSBNode.sh" script in /usr/lib/virtualbox
194-
_JUNEST_CMD -- cp /usr/share/virtualbox/VBoxCreateUSBNode.sh ./
195-
chmod a+x VBoxCreateUSBNode.sh
196-
$SUDOCMD mv VBoxCreateUSBNode.sh /usr/lib/virtualbox/
197-
$SUDOCMD chown -R root:vboxusers /usr/lib/virtualbox
198-
fi
199-
if ! test -f /etc/udev/rules.d/60-vboxusb.rules; then
200-
# Create the directory /etc/udev/rules.d
201-
$SUDOCMD mkdir -p /etc/udev/rules.d
202-
# Create and install the 60-vboxusb.rules file in /etc/udev/rules.d
203-
_JUNEST_CMD -- cp /etc/udev/rules.d/60-vboxusb.rules ./
204-
$SUDOCMD mv 60-vboxusb.rules /etc/udev/rules.d/
205-
# Reload the udev rules
206-
$SUDOCMD systemctl reload systemd-udevd
207-
fi
208-
printf "\nIt is recommended that you reboot for the changes to take effect.\n"
181+
printf "\n The above option does the following:\n"
182+
printf "\n - Creates the \"vboxusers\" group"
183+
printf "\n - Adds your \$USER to the \"vboxusers\" group"
184+
printf "\n - Creates the /usr/lib/virtualbox directory on the host system"
185+
printf "\n - Installs the \"VBoxCreateUSBNode.sh\" script in /usr/lib/virtualbox"
186+
printf "\n - Creates the /etc/udev/rules.d directory"
187+
printf "\n - Creates and installs the \"60-vboxusb.rules\" file in /etc/udev/rules.d\n"
188+
printf "\n See also https://github.com/cyberus-technology/virtualbox-kvm#usb-pass-through\n"
189+
printf "\nAuthentication is required\n"
190+
if ! test -f /usr/lib/virtualbox/VBoxCreateUSBNode.sh; then
191+
# Create the "vboxusers" group and add $USER
192+
$SUDOCMD groupadd -r vboxusers -U "$USER"
193+
# Create the directory /usr/lib/virtualbox on the host system
194+
$SUDOCMD mkdir -p /usr/lib/virtualbox
195+
# Install the "VBoxCreateUSBNode.sh" script in /usr/lib/virtualbox
196+
_JUNEST_CMD -- cp /usr/share/virtualbox/VBoxCreateUSBNode.sh ./
197+
chmod a+x VBoxCreateUSBNode.sh
198+
$SUDOCMD mv VBoxCreateUSBNode.sh /usr/lib/virtualbox/
199+
$SUDOCMD chown -R root:vboxusers /usr/lib/virtualbox
200+
fi
201+
if ! test -f /etc/udev/rules.d/60-vboxusb.rules; then
202+
# Create the directory /etc/udev/rules.d
203+
$SUDOCMD mkdir -p /etc/udev/rules.d
204+
# Create and install the 60-vboxusb.rules file in /etc/udev/rules.d
205+
_JUNEST_CMD -- cp /etc/udev/rules.d/60-vboxusb.rules ./
206+
$SUDOCMD mv 60-vboxusb.rules /etc/udev/rules.d/
207+
# Reload the udev rules
208+
$SUDOCMD systemctl reload systemd-udevd
209+
fi
210+
printf "\nIt is recommended that you reboot for the changes to take effect.\n"
209211
}
210212
211213
case "$1" in
212214
'')
213-
_JUNEST_CMD -- /usr/bin/virtualbox
214-
;;
215+
_JUNEST_CMD -- /usr/bin/virtualbox
216+
;;
215217
'VirtualBoxVM')
216-
_JUNEST_CMD -- /usr/bin/VirtualBoxVM "$@"
217-
;;
218+
_JUNEST_CMD -- /usr/bin/VirtualBoxVM "$@"
219+
;;
218220
'-h'|'--help')
219-
Show_help_message
220-
;;
221+
Show_help_message
222+
;;
221223
'--vbox-usb-enable')
222-
VBoxUSB_enable
223-
;;
224+
VBoxUSB_enable
225+
;;
224226
'-v'|'--version')
225-
echo "VirtualBox VERSION KVM"
226-
;;
227+
echo "VirtualBox VERSION KVM"
228+
;;
227229
'virtualbox'|*)
228-
_JUNEST_CMD -- /usr/bin/VirtualBox "$@"
229-
;;
230+
_JUNEST_CMD -- /usr/bin/VirtualBox "$@"
231+
;;
232+
'vulkaninfo')
233+
_JUNEST_CMD -- vulkaninfo "$@"
234+
;;
230235
esac
231236
232237
HEREDOC

0 commit comments

Comments
 (0)