+ d("github tarball url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/github.com\/.*\/(.*)\/archive\//) {
+ gsub("\/archive\/.*", "/tags", url)
+ d("github archive url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/bitbucket.org\/.*\/get\/.*/) {
+ # https://bitbucket.org/logilab/pylint/get/tip.tar.bz2 -> https://bitbucket.org/logilab/pylint/downloads
+ gsub("\/get\/.*", "/downloads", url)
+ d("github bitbucket url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/cgit\..*\/(.*)\/snapshot\//) {
+ gsub("\/snapshot\/.*", "/", url)
+ d("cgit snapshot tarball url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/www2\.aquamaniac\.de\/sites\/download\//) {
+ url = "http://www2.aquamaniac.de/sites/download/packages.php"
+ d("aquamaniac.de tarball url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/www.process-one.net\/downloads\/ejabberd\//) {
+ url = "http://www.process-one.net/en/ejabberd/archive/"
+ d("ejabberd tarball url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/llvm.org\/releases\//) {
+ url = "http://llvm.org/releases/download.html"
+ d("llvm tarball url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/download\.owncloud\.org\/community\//) {
+ url = "http://owncloud.org/changelog/"
+ d("owncloud tarball url, mungled url to: " url)
+
+ } else if (url ~ /^(http|https):\/\/hackage\.haskell\.org\/packages\/archive\//) {
+ gsub("\/packages\/archive","/package",url)
+ d("hackage haskell tarball url, mungled url to: " url)
+
+ } else if (url ~ /^http:\/\/www.taskwarrior.org\/download\//) {
+ url = "http://taskwarrior.org/projects/taskwarrior/wiki/Download"
+ d("taskwarrior tarball url, mungled url to: " url)
+ } else if (url ~/^http:\/\/www.rarlab.com\/rar\// && filename ~ /^unrarsrc/) {
+ url = "http://www.rarlab.com/rar_add.htm"
+ d("unrar tarball url, mungled url to: " url)
+ } else if (url ~/^http:\/\/www.rarlab.com\/rar\//) {
+ url = "http://www.rarlab.com/download.htm"
+ d("rar tarball url, mungled url to: " url)
+ }
+
+ d("Retrieving: " url)
+ user_agent = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100129 PLD/3.0 (Th) Iceweasel/3.6"
+ cmd = "wget -t 2 -T 45 --user-agent \"" user_agent "\" -nv -O - \"" url "\" --passive-ftp --no-check-certificate > " tmpfile " 2> " tmpfileerr
+ d("Execute: " cmd)