Implements #24024, incorporating changes to the spkg-install for R originally from #22509 as well as #23733.
CC: @dimpase
Component: build
Author: Erik Bray
Branch/Commit: dc342ae
Reviewer: Julian Rüth, Dima Pasechnik
Issue created by migration from https://trac.sagemath.org/ticket/25049