How to keep mac awake while updating
The easy way at the command line is to call software update.
softwareupdate -a -i -r

The command prevents sleep, checks for all updates and then installs them. If the install requires a reboot, that happens immediately as well once the install is done.