From 35d2140f91b61f74e239c5ac2bc5617ce934354c Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 16 Oct 2015 05:18:43 -0400 Subject: sbosrcarch: make dropbox links (mostly) work --- sbosrcarch | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'sbosrcarch') diff --git a/sbosrcarch b/sbosrcarch index c1b3276..b2ee6ea 100755 --- a/sbosrcarch +++ b/sbosrcarch @@ -5,14 +5,24 @@ # - the old openssl on slack 13.0 can't handle cloud.github.com. chokes # with 'sslv3 alert handshake failure'... or maybe it's wget that # can't handle it, as curl seems to be able to, using the same -# openssl. +# openssl. partially fixed this by building static openssl-1.0.x +# and a wget to use it, and making $wget a config option (the new +# wget isn't in $PATH). # - seriously considering switching to curl. # - another thought: do away with HEAD requests entirely. do something # like open a pipeline reading from wget, read the headers (like # wget_fake_head does now)... then decide whether to finish the # download or close the fh. if we finish it, read from the pipeline # and write to the target filename. -# - if a download fails, turds shouldn't be left behind in the git tree. + +# 20151016 bkw: behold: +# $ grep ^D libraries/p4api/*.info +# DOWNLOAD="ftp://ftp.perforce.com/perforce/r10.1/bin.linux26x86/p4api.tgz" +# DOWNLOAD_x86_64="ftp://ftp.perforce.com/perforce/r10.1/bin.linux26x86_64/p4api.tgz" +# notice that both URLs have the same filename (p4api.tgz)? this is +# exactly why we have a by-md5 tree. But right now, "add libraries/p4api" +# only adds one of them. other builds with the same issue: development/p4 +# and academic/ucsc-blat # TODO based on feedback from ttkp and pink_mist on IRC: # - IPC::Open3 instead of open my $fh, "wget ...|"? At least use @@ -20,6 +30,9 @@ # However, avoiding the shell means being unable to redirect # stderr & stdout to the same place. Hm. +# Also, stuff added with "add" sometimes ends up as separate files +# instead of hardlinks. + =pod =head1 NAME @@ -516,7 +529,7 @@ sub wget_fake_head { "--tries 1 --quiet -O- --save-headers " . user_agent($url) . " " . " $wgetargs " . - "'$url'"; + wget_quote_url($url); #print "real HEAD failed, trying fake HEAD request: $cmd\n"; @@ -542,6 +555,14 @@ sub wget_fake_head { return $size; } +sub wget_quote_url { + my $url = shift; + if($url =~ m,https?://(?:\w+\.)dropbox\.com/,) { + $url .= "?dl=1"; + } + return "'$url'"; +} + # wget() does a HEAD (or fake head, if HEAD fails), or GET (download), # using an external wget process. Return value is the file size in bytes, # or 0 for "too big", or undef for any error. @@ -592,7 +613,7 @@ sub wget { user_agent($url) . " " . ($head ? "--spider --tries 1" : "-O '" . url_to_filename($url) . "'") . " $wgetargs " . - "'$url' " . + wget_quote_url($url) . " " . ">$outfile 2>&1"; #" --referer='$url' " . # don't use, it breaks sourceforge -- cgit v1.2.3