Skip to content

Commit f35ceb3

Browse files
committed
support for downloading and installing .pkg on macOS
1 parent 2981c9a commit f35ceb3

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: blogdown
33
Title: Create Blogs and Websites with R Markdown
4-
Version: 1.22.1
4+
Version: 1.22.2
55
Authors@R: c(
66
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
77
person("Christophe", "Dervieux", role = "aut", email = "cderv@posit.co", comment = c(ORCID = "0000-0003-4474-2498")),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# CHANGES IN blogdown VERSION 1.23
22

3+
- Added support for installing Hugo's `*.pkg` installers on macOS. Hugo has changed the installer from a tarball (containing the `hugo` binary) to `.pkg` since v0.153.0. Please note that installing `.pkg` requires password input, so this cannot be automated on macOS that requires password for `sudo` commands.
4+
35
- `hugo_installers()` can deal with Hugo installers containing the `withdeploy` feature for Hugo >= v0.137.0 now.
46

57
# CHANGES IN blogdown VERSION 1.22

R/install.R

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ install_hugo = function(
6464
message('The latest Hugo version is ', version)
6565
} else {
6666
if (!is.null(local_file)) version = gsub(
67-
'^hugo(_extended)?_([0-9.]+)_.*', '\\2', basename(local_file)
67+
'^hugo(_extended)(_withdeploy)?_([0-9.]+)_.*', '\\2', basename(local_file)
6868
)
6969
}
7070

@@ -138,6 +138,14 @@ install_hugo = function(
138138
files = utils::untar(zipfile, list = TRUE)
139139
utils::untar(zipfile)
140140
files
141+
}, pkg = {
142+
if (interactive()) system2('open', shQuote(zipfile)) else {
143+
if (system2('sudo', c('installer', '-pkg', zipfile, '-target', '/')) != 0) stop(
144+
'The *.pkg installer requires password input. Please run this function ',
145+
'in the terminal or in an interactive R session and input password.'
146+
)
147+
}
148+
NULL
141149
})
142150
}
143151

@@ -146,11 +154,13 @@ install_hugo = function(
146154
} else if (is_macos()) {
147155
download_zip(
148156
if (v103) 'darwin' else if (version2 >= '0.18') 'macOS' else 'MacOS',
149-
if (version2 >= '0.20.3') 'tar.gz' else 'zip'
157+
if (version2 >= '0.153.0') 'pkg' else if (version2 >= '0.20.3') 'tar.gz' else 'zip'
150158
)
151159
} else {
152160
download_zip('Linux', 'tar.gz') # _might_ be Linux; good luck
153161
}
162+
# can't tell if .pkg was successfully installed at this point
163+
if (is.null(files)) return(invisible(NULL))
154164
# from a certain version of Hugo, the executable is no longer named
155165
# hugo_x.y.z, so exec could be NA here, but file.rename(NA_character) is fine
156166
exec = files[grep(sprintf('^hugo_%s.+', version), basename(files))][1]

0 commit comments

Comments
 (0)