Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1551578
  • 博文数量: 61
  • 博客积分: 472
  • 博客等级: 下士
  • 技术积分: 548
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-26 11:52
文章分类
文章存档

2018年(1)

2017年(2)

2016年(6)

2015年(3)

2014年(19)

2013年(10)

2012年(20)

分类: LINUX

2015-01-26 12:05:12

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