Sorry, I misread your question when posting my previous answer, though I'll leave it up in the hopes perhaps it is useful to someone. switchr can also install exact historical versions of packages.
Make sure you have switchr version 0.12.9 (currently only available from http://github.com/gmbecker/switchr) or higher (I just commited this and it fixes a bug that would have bitten you) and BiocInstaller installed (a future version will support BiocManager). then do the following:
> man = PkgManifest(name = c("IRanges", "S4Vectors", "XVector"), type = "bioc", dep_repos = biocReposForVers("3.4"))
> vers = c(IRanges= "2.8.1", S4Vectors = "0.12.1", XVector = "0.14.0")
> install_packages(names(vers), repos = man, versions = vers)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.r-project.org/src/contrib/Archive/IRanges/IRanges_2.8.1.tar.gz'
Cloning into 'IRanges'...
remote: Counting objects: 21987, done.
remote: Compressing objects: 100% (6601/6601), done.
remote: Total 21987 (delta 17258), reused 19495 (delta 15337)
Receiving objects: 100% (21987/21987), 4.13 MiB | 200.00 KiB/s, done.
Resolving deltas: 100% (17258/17258), done.
Switched to a new branch 'RELEASE_3_4'
Note: checking out '3c3880cb42a1bff3c123d7343376df1eeeaf763b'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 3c3880c... port setdiff,CompressedIRangesList fix from devel
* checking for file ‘/var/folders/79/l_n_5qr152d2d9d9xs0591lh0000gn/T//RtmpikpcwH/IRanges/DESCRIPTION’ ... OK
* preparing ‘IRanges’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘IRanges_2.8.1.tar.gz’
<snip, retrieves the other two requested packages>
Installing packages into ‘/Users/beckerg4/Rlib/3.4.4-current’
(as ‘lib’ is unspecified)
* installing *source* package ‘S4Vectors’ ...
** preparing package for lazy loading
*** installing help indices
** building package indices
** installing vignettes
‘RleTricks.Rnw’ using ‘UTF-8’
‘S4QuickOverview.Rnw’ using ‘UTF-8’
** testing if installed package can be loaded
Warning: replacing previous import ‘stats::sd’ by ‘BiocGenerics::sd’ when loading ‘S4Vectors’
Warning: replacing previous import ‘stats::var’ by ‘BiocGenerics::var’ when loading ‘S4Vectors’
* DONE (S4Vectors)
<snip, installs other two>
The downloaded source packages are in
IRanges S4Vectors XVector
"IRanges" "S4Vectors" "XVector"
1: In download.file(url, destfile, method, ...) :
cannot open URL 'http://cran.r-project.org/src/contrib/Archive/IRanges/IRanges_2.8.1.tar.gz': HTTP status was '404 Not Found'
2: In download.file(url, destfile, method, ...) :
cannot open URL 'http://cran.r-project.org/src/contrib/Archive/S4Vectors/S4Vectors_0.12.1.tar.gz': HTTP status was '404 Not Found'
3: In download.file(url, destfile, method, ...) :
cannot open URL 'http://cran.r-project.org/src/contrib/Archive/XVector/XVector_0.14.0.tar.gz': HTTP status was '404 Not Found'
R version 3.4.4 Patched (2018-03-19 r74581)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
attached base packages:
 stats4 parallel stats graphics grDevices utils datasets
 methods base
other attached packages:
 XVector_0.14.0 IRanges_2.8.1 S4Vectors_0.12.1
 BiocGenerics_0.24.0 switchr_0.12.8
loaded via a namespace (and not attached):
 zlibbioc_1.24.0 compiler_3.4.4 BiocInstaller_1.28.0
 tools_3.4.4 RCurl_1.95-4.10 bitops_1.0-6
There are ways to control where the checkouts are put so that they are not in a temporary location, but please see the docs for the details on that.