Upgrading to Ubuntu 10.04 Behind a Proxy

If you do a update-manager -d under Ubuntu 9.10 and happen to be behind a firewall, you might notice that it appears to freeze as soon as you click on the Upgrade button. This is caused by a known bug in Ubuntu where the start of the upgrade process doesn't take your proxy settings into account.

It's been fixed in 10.04, but that doesn't help you if you're using 9.10 or 9.04.

So how do you fix it?

Well, you're going to need to edit /usr/lib/python2.6/dist-packages/UpdateManager/Core/utils.py. You'll need to do that as root, so open a Terminal and "sudo nano /usr/lib/python2.6/dist-packages/UpdateManager/Core/utils.py."

Press Ctrl-W and then Ctrl-T and type in "104" to jump to the problem lines:

      c = httplib.HTTPConnection(netloc)
      c.request("HEAD", path)

Change those lines to read:

      c = httplib.HTTPConnection("your.proxy.host:80")
      c.request("HEAD", scheme + netloc + path)

Where your.proxy.host:80 is the proxy host name followed by its port number. Press Ctrl-O and then press Enter to save, then Ctrl-X to exit.

You should now be able to click Upgrade and everything should go smoothly.

If you want the actual patch used (in case you don't know your proxy settings, I guess), go to line 103 and insert the following before it:

    proxy = os.getenv("http_proxy")
    if (proxy):
      path = scheme + netloc + path
      netloc = proxy

The new version should read something like:

  if scheme == "http":
    import httplib
    proxy = os.getenv("http_proxy")
    if (proxy):
      path = scheme + netloc + path
      netloc = proxy
    try:
      c = httplib.HTTPConnection(netloc)
      c.request("HEAD", path)

Since this is Python, whitespace counts.

Topics: 

Comments

Hi!

Thanks, your post saved my day :)

Hey thank you very much!

You're a hero !