Downloading latest version from sourceforge

2.2k views Asked by At

I am trying to download latest version of graphicsmagick from Sourceforge in my bash script

wget -q https://sourceforge.net/projects/graphicsmagick/files/latest/download?source=files -O GraphicsMagick-LATEST.tar.gz
tar -xzvf GraphicsMagick-LATEST.tar.gz

The problem is that when I try to extract the tar.gz I get the following error

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

This means that the script is not downloading the latest tar.gz but rather another filetype?

Why is that happening and what I am missing here?

3

There are 3 answers

2
King Midas On

Forget about my prevoius answer. The issue is not in the file. When you use wget with your current link, you are pointing to a sourceforge page. You are not downloading the file, but you are downloading the HTML page. Rename your file to .html and you can see all code of the sourceforge page.

wget -q https://sourceforge.net/projects/graphicsmagick/files/latest/download?source=files -O file.html --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0"

Will download an HTML.

The link you provide has a javascript redirect to the correct link depending in your operating system (as I have described in my other answer). But wget cannot execute this javascript code, therefore is not redirected. Still the link is inside the HTML. Search for the the next string:

Problems with the download?  Please use this

And after this string, you can find the direct link to the last version:

http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.25/GraphicsMagick-1.3.25.tar.gz?r=&ts=1482426819&use_mirror=vorboss

(Note about that if you use the --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0", the link is for the tar.gz not for the .rpm)

You must therefore download the HTML file each time, search for the download link inside the HTML (with the currently latest version), and use it in a new wget command.

4
King Midas On

You are forcing the file to be renamed as a tar.gz extension. But the file is in a different format. In fact, when you download directly the link, the file is not a gz file, but a rpm file.

You need to download directly the file you want:

 wget https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.25/GraphicsMagick-1.3.25.tar.gz/download -O GraphicsMagick-LATEST.tar.gz

But here, you are predefining the version of the file you want to download.

2
Cyrus On

I suggest:

wget -q -O - ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.gz | tar -xzvf -