I am trying to write a shell script to build a custom kernel on Arch Linux.
I have succeeded to do write all the steps described in the Arch Linux kernel compilation page: https://wiki.archlinux.org/index.php/Kernels/Compilation/Traditional
But I am stuck on the last step to "Recompile VirtualBox guest module":
We need to do one more thing before we reboot to our new kernel. We have to recompile the VirtualBox guest module so that things like screen resizing will still work when we reboot to the new kernel. First, make sure you have the virtualbox-guest-dkms package installed: sudo pacman -S virtualbox-guest-dkms If you have it installed already, pacman will ask you if you want to reinstall. Say no, but note the version number of the module. Recompile the VirtualBox guest module by running: sudo dkms remove vboxguest/version-number -k kernel-version sudo dkms install vboxguest/version-number -k kernel-version Substitute your vboxguest version number and your kernel version string.
If I run
sudo pacman -S virtualbox-guest-dkms in the terminal, I would get following output:
warning: virtualbox-guest-dkms-4.3.26-2 is up to date -- reinstalling resolving dependencies... looking for conflicting packages... Packages (1) virtualbox-guest-dkms-4.3.26-2 Total Installed Size: 5.26 MiB Net Upgrade Size: 0.00 MiB :: Proceed with installation? [Y/n]
If I choose to install it, it will tell me to proceed installation by running the command --
dkms install vboxguest/version-number
Since I want to make the shell script as robust as possible, I would need to do the following:
- If the guest module has already been installed, just grap the version-number from the pacman query and exit.
Then I just need to run the following two commands:
sudo dkms remove vboxguest/version-number -k kernel-version sudo dkms install vboxguest/version-number -k kernel-version
- If guest module is not installed, do installation and grap the
dkms install vboxguest/version-numbercommand from the pacman query and exit.
sudo dkms install vboxguest/version-number.
The rest is the same as the scenario one above.
The first scenario is the most likely one.
Could someone please give me a hand on this?
Thanks in advance!