For several days I've been struggling to get drush make to reliably download library packages from Sourceforge by rearranging the .make files. I wanted to create a getid3.make.inc which would download and install the latest getid3 module and the getID3 library from "https://sourceforge.net/projects/getid3/files/latest/download?source=files". Frustratingly, it would sometimes work and other times not. Finally I realized that when the download failed, it had actually downloaded the zip file correctly, but improperly named it "download?source=files". When I started experimenting with wget, I found that it was exhibiting the same behavior. After unsuccessfully Googling for help, I took a long hard look at the wget man page. There I found the following:
--trust-server-names
If this is set to on, on a redirect the last component of the redirection URL will be used as the local file name. By default it is used the last component in the original URL.
When I tried this option with the above URL, it correctly determined the filename as getid3-1.9.3-20111213.zip. I didn't want to try patching drush_make, so instead I defined the following alias as a workaround.
alias wget='wget --trust-server-names'
Drush make now seems to work reliably. Surprisingly I found little mention of this option, not even on the Sourceforge forums
I recommend you consider adding the option '--trust-server-names' whenever drush make calls wget.
Comments
Comment #1
dude4linux commentedIt seems I was a bit premature in concluding that adding an alias for wget would help drush_make download from a redirected url. Further experimentation shows that the download works correctly only about 60% of the attempts. I just happened to hit a series of tests that were lucky, in fact I'm now surprised it worked at all.
Analyzing the code for drush and drush_make shows they both make the assumption that you can determine the name of the downloaded file from the initial $url using something like:
Of course, this is not true when redirection is used to return the latest version from a mirrored site e.g. the Sourceforge url, "https://sourceforge.net/projects/getid3/files/latest/download?source=files". Additional code is required to handle the possibility that the initial url will be redirected to another url.
Comment #2
dude4linux commentedFixed in 5.0-dev.