<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/e5a420ccf2ea47e8264ca8a68d899369370317bb">https://github.com/macports/macports-base/commit/e5a420ccf2ea47e8264ca8a68d899369370317bb</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new e5a420c portfetch.tcl: Add option fetch.user_agent.
</span>e5a420c is described below
<span style='display:block; white-space:pre;color:#808000;'>commit e5a420ccf2ea47e8264ca8a68d899369370317bb
</span>Author: Andrew L. Moore <slewsys@gmail.com>
AuthorDate: Sat May 19 08:49:23 2018 +0000
<span style='display:block; white-space:pre;color:#404040;'> portfetch.tcl: Add option fetch.user_agent.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> When MacPorts attempts to fetch from DropBox, it gets HTML instead
</span><span style='display:block; white-space:pre;color:#404040;'> of the requested file. This is because MacPorts sets libcurl's User-Agent
</span><span style='display:block; white-space:pre;color:#404040;'> header in curl.c to "MacPorts/MP_VERSION libcurl/LC_VERSION", which DropBox
</span><span style='display:block; white-space:pre;color:#404040;'> responds to as a web brower. The problem was first reported in
</span><span style='display:block; white-space:pre;color:#404040;'> https://trac.macports.org/ticket/53942 with regard to port
</span><span style='display:block; white-space:pre;color:#404040;'> audio/generaluser-soundfont.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This PR adds an option `fetch.user_agent' which can be set in Portfile
</span><span style='display:block; white-space:pre;color:#404040;'> as needed. For example, in audio/generaluser-soundfont/Portfile, adding:
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> fetch.user_agent curl/MacPorts/4.xx
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> allows fetch to work without a custom fetch block. If `fetch.user_agent'
</span><span style='display:block; white-space:pre;color:#404040;'> is not set, UserAgent as defined in curl.c is used instead.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> In the particular case of DropBox, setting the User-Agent header to
</span><span style='display:block; white-space:pre;color:#404040;'> "libcurl/..." doesn't work as one might hope, otherwise swapping the
</span><span style='display:block; white-space:pre;color:#404040;'> order of values in curl.c UserAgent variable would be suggested as an
</span><span style='display:block; white-space:pre;color:#404040;'> alternative.
</span>---
src/port1.0/portfetch.tcl | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portfetch.tcl b/src/port1.0/portfetch.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 2a58241..a24fc54 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portfetch.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portfetch.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -49,7 +49,7 @@ namespace eval portfetch {
</span> options master_sites patch_sites extract.suffix distfiles patchfiles use_tar \
use_bzip2 use_lzma use_xz use_zip use_7z use_lzip use_dmg dist_subdir \
fetch.type fetch.user fetch.password fetch.use_epsv fetch.ignore_sslcert \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- master_sites.mirror_subdir patch_sites.mirror_subdir \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ fetch.user_agent master_sites.mirror_subdir patch_sites.mirror_subdir \
</span> bzr.url bzr.revision \
cvs.module cvs.root cvs.password cvs.date cvs.tag cvs.method \
svn.url svn.revision svn.method \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -115,6 +115,7 @@ default fetch.use_epsv "yes"
</span> default fetch.ignore_sslcert "no"
# Use remote timestamps
default fetch.remote_time "no"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+default fetch.user_agent ""
</span>
default global_mirror_site "macports_distfiles"
default mirror_sites.listfile {"mirror_sites.tcl"}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -510,7 +511,7 @@ proc portfetch::hgfetch {args} {
</span> proc portfetch::fetchfiles {args} {
global distpath all_dist_files UI_PREFIX \
fetch.user fetch.password fetch.use_epsv fetch.ignore_sslcert fetch.remote_time \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- portverbose
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ fetch.user_agent portverbose
</span> variable fetch_urls
variable urlmap
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -528,6 +529,10 @@ proc portfetch::fetchfiles {args} {
</span> if {${fetch.remote_time} ne "no"} {
lappend fetch_options "--remote-time"
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {${fetch.user_agent} ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend fetch_options "--user-agent"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend fetch_options "${fetch.user_agent}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> if {$portverbose eq "yes"} {
lappend fetch_options "--progress"
lappend fetch_options "builtin"
</pre><pre style='margin:0'>
</pre>