ubuntu 是通过 /usr/lib/update-notifier/package-data-downloader 完成这件事的,它是个 python 脚本,里面用到了urllib,但是这个库不支持 proxy,所以会导致 deb 安装失败。
等 ubuntu 解决这类问题之前,需要自己先找个 workaround 的办法:
打开 /usr/lib/update-notifier/package-data-downloader 找到下面这段:
Python代码:
- for i in range(len(files)):
- print "%s: downloading %s" % (relfile, files[i])
- dest_file = urllib.urlretrieve(files[i])[0]
- output = subprocess.check_output(["sha256sum", dest_file])
- output = output.split(' ')[0]
- if output == sums[i]:
- command.append(dest_file)
- else:
- record_failure(relfile)
- break
将 urllib.urlretrieve 改成 wget,改之后如下:
Python代码:
- for i in range(len(files)):
- print "%s: downloading %s" % (relfile, files[i])
- #dest_file = urllib.urlretrieve(files[i])[0]
- dest_file = files[i].split("/")[-1]
- dest_file = '/tmp/' + dest_file
- downf = "/usr/bin/wget %s -O %s" % (files[i], dest_file)
- subprocess.call(downf, shell=True)
- output = subprocess.check_output(["sha256sum", dest_file])
- output = output.split(' ')[0]
- if output == sums[i]:
- command.append(dest_file)
- else:
- record_failure(relfile)
- break
剩下的事情就是在 /etc/wgetrc 里面配置代理(略)