old blog,

Hacks: Replace yum's downloader with Axel

Izhar Firdaus Izhar Firdaus Follow Support Nov 16, 2008 · 1 min read
Hacks: Replace yum's downloader with Axel
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.
/!\ This is an ugly hack, use it at your own risk, 
I am not responsible for any breakage

P/S, your sysadmin might not gonna like this

Disclaimer aside, I really love Python.

So, I'm behind such a bad network which keep timing out, and downloading stuff using yum in this network is a real PITA. And so, I had enough of it and decided to hack around.

Axel is a CLI download accelerator thats lightweight and pretty fast. I've been using it quite frequently to get a bit more speed for my downloads. I think, why not just replace this urllib2 grabber with axel, so, I did. (I am such an evil guy)

After a few hours looking through yum code to find what to modify, I ended up with this

# file: /usr/lib/python2.5/site-packages/urlgrabber/customgrabber.py

import grabber
import os

class AxelGrabber(grabber.URLGrabber):
def urlgrab(self, url, filename=None, **kwargs):
"""grab the file at and make a local copy at
If filename is none, the basename of the url is used.
urlgrab returns the filename of the local file, which may be
different from the passed-in filename if copy_local == 0.

opts = self.opts.derive(**kwargs)
(url,parts) = opts.urlparser.parse(url, opts)
(scheme, host, path, parm, query, frag) = parts

def retryfunc(opts, url, filename):
if os.environ.has_key('http_proxy'):
os.environ['HTTP_PROXY'] = os.environ['http_proxy']
os.system('/usr/bin/axel -a -o %s %s' % (filename,url))
return filename

return self._retry(opts, retryfunc, url, filename)

Make sure you put the file above at its path unless you are sure what you are doing. To make it usable with yum, some modification is needed in one of yum's source file.


from urlgrabber.grabber import URLGrabber

from urlgrabber.customgrabber import AxelGrabber as URLGrabber

and you are good to go. Do it at YOUR own risk remember.
Written by Izhar Firdaus Follow Support
I'm a system architect, data engineer and developer advocate with passion in Free / Open Source software, entrepreneurship, community building, education and martial art. I take enjoyment in bridging and bringing together different FOSS technologies to help businesses and organizations utilize IT infrastructure to aid and optimize their business and organizational process.

FOSS.my 2008 Ended!

Everything has its end :). and FOSS.my 2008, ended a great SUCCESS!!.It's been a fun roller coaster ride being a FOSS.my 2008 crew. A...

In old blog, Nov 09, 2008

« Previous Post

UTP's new course registration system not cross browsers compatible

Sometimes I wonder why I'm such a freetard. http://n2.nabble.com/UTP-Prism-is-NOT-Cross-Browser-Compliant-td1594436.html- Izhar Firda...

In old blog, Nov 30, 2008

Next Post »