Skip to content

Commit 0b6e64b

Browse files
author
kalibera
committed
Allow instaling binary package on Windows from an archive with a
non-standard name (PR#18319). git-svn-id: https://svn.r-project.org/R/trunk@88501 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent c4b2889 commit 0b6e64b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/library/tools/R/install.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ if(FALSE) {
333333
if (pkglock)
334334
lock <- "pkglock"
335335
utils:::unpackPkgZip(pkg, pkg_name, lib, libs_only, lock,
336-
reuse_lockdir = reuse_lockdir)
336+
reuse_lockdir = reuse_lockdir,
337+
name_from_dir = TRUE)
337338
return()
338339
}
339340

src/library/utils/R/windows/install.packages.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File src/library/utils/R/windows/install.packages.R
22
# Part of the R package, https://www.R-project.org
33
#
4-
# Copyright (C) 1995-2022 The R Core Team
4+
# Copyright (C) 1995-2025 The R Core Team
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -18,7 +18,8 @@
1818

1919
## Unexported helper
2020
unpackPkgZip <- function(pkg, pkgname, lib, libs_only = FALSE,
21-
lock = FALSE, quiet = FALSE, reuse_lockdir = FALSE)
21+
lock = FALSE, quiet = FALSE, reuse_lockdir = FALSE,
22+
name_from_dir = FALSE)
2223
{
2324
.zip.unpack <- function(zipname, dest)
2425
{
@@ -46,6 +47,12 @@ unpackPkgZip <- function(pkg, pkgname, lib, libs_only = FALSE,
4647
on.exit(unlink(tmpDir, recursive=TRUE), add = TRUE)
4748
res <- .zip.unpack(pkg, tmpDir)
4849
setwd(tmpDir)
50+
if (name_from_dir) {
51+
pkgname <- dir(".")
52+
if (length(pkgname) != 1)
53+
stop(gettextf("cannot extract package from %s", sQuote(pkg)),
54+
domain = NA, call. = FALSE)
55+
}
4956
res <- tools::checkMD5sums(pkgname, file.path(tmpDir, pkgname))
5057
if(!quiet && !is.na(res) && res) {
5158
cat(gettextf("package %s successfully unpacked and MD5 sums checked\n",

0 commit comments

Comments
 (0)