通常同一台機器是不會出現win可以聯網但ubuntu不可以聯網的情況的, 但是在中國特色的校園網環境中, 這種請況很常見. 雖然有本地源的解決方案, 但需要有聯網的linux, 和巨大的硬盤空間(還有快的網絡速度), apt的優勢不能體現出來.
下面介紹一種比較迂回的方法:
首先, 下載源上面的包信息, 下載列表見附件. 這裡以cn99源和gutsy為例(我還沒看建源的手冊, 所以只是下載了pool文件夾外的跟gutsy有關的東西, 其他請況請自己類比).
注意要使用能重建目錄結構的下載軟件來下載, 就像是 wget 的 -x 選項
代碼:
wget -B -i cn99_gutsy.lst -w 2 -x
做人要厚道,下載請用單線程+延時, 封ip自負
下載完後, 看起來應該像這樣
代碼:
autumncat@autumncat-host:~/apt-source/ubuntu.cn99.com
$ find
.
./ubuntu
./ubuntu/dists
./ubuntu/dists/gutsy
./ubuntu/dists/gutsy/Contents-amd64.gz
./ubuntu/dists/gutsy/Contents-i386.gz
./ubuntu/dists/gutsy/Release
./ubuntu/dists/gutsy/Release.gpg
./ubuntu/dists/gutsy/main
./ubuntu/dists/gutsy/main/binary-amd64
./ubuntu/dists/gutsy/main/binary-amd64/Packages.bz2
./ubuntu/dists/gutsy/main/binary-amd64/Packages.gz
./ubuntu/dists/gutsy/main/binary-amd64/Release
./ubuntu/dists/gutsy/main/binary-i386
./ubuntu/dists/gutsy/main/binary-i386/Packages.bz2
./ubuntu/dists/gutsy/main/binary-i386/Packages.gz
./ubuntu/dists/gutsy/main/binary-i386/Release
./ubuntu/dists/gutsy/main/debian-installer
./ubuntu/dists/gutsy/main/debian-installer/binary-amd64
./ubuntu/dists/gutsy/main/debian-installer/binary-amd64/Packages.bz2
....
然後就可以把整個目錄復制到linux下的某個目錄
接著修改源列表, 就像這樣
代碼:
$ cat /etc/apt/sources.list
deb file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse
deb file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-security main restricted universe multiverse
deb file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-proposed main restricted universe multiverse
deb file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-backports main restricted universe multiverse
deb-src file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse
deb-src file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-security main restricted universe multiverse
deb-src file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb-src file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-proposed main restricted universe multiverse
deb-src file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/ gutsy-backports main restricted universe multiverse
最後
代碼:
sudo apt-get update
但此時 apt-get install 是沒用的, 因為巨大的pool目錄沒有下載
下一步就是獲得包的地址, 方法有很多, 例如使用apt-get
代碼:
$ apt-get install --print-uris -y gedit|cut -d\' -s -f 2-2
file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/pool/main/g/gtksourceview2/libgtksourceview2.0-common_2.0.1-0ubuntu1_all.deb
file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/pool/main/g/gtksourceview2/libgtksourceview2.0-0_2.0.1-0ubuntu1_i386.deb
file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/pool/main/g/gedit/gedit-common_2.20.3-0ubuntu1_all.deb
file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/pool/main/p/pygtksourceview/python-pygtksourceview_2.0.0-0ubuntu3_i386.deb
file:///home/autumncat/apt-source/ubuntu.cn99.com/ubuntu/pool/main/g/gedit/gedit_2.20.3-0ubuntu1_i386.deb
或者新立得
但是大家可以看到, URL是錯誤的, 我們把它修正一下(把前面那部分用正確的來替換):
代碼:
$ apt-get install --print-uris -y gedit|cut -d\' -s -f 2-2|sed 's|file:///home/autumncat/apt-source/|http://|g'
http://ubuntu.cn99.com/ubuntu/pool/main/g/gtksourceview2/libgtksourceview2.0-common_2.0.1-0ubuntu1_all.deb
http://ubuntu.cn99.com/ubuntu/pool/main/g/gtksourceview2/libgtksourceview2.0-0_2.0.1-0ubuntu1_i386.deb
http://ubuntu.cn99.com/ubuntu/pool/main/g/gedit/gedit-common_2.20.3-0ubuntu1_all.deb
http://ubuntu.cn99.com/ubuntu/pool/main/p/pygtksourceview/python-pygtksourceview_2.0.0-0ubuntu3_i386.deb
http://ubuntu.cn99.com/ubuntu/pool/main/g/gedit/gedit_2.20.3-0ubuntu1_i386.deb
最後就可以到windows下下載需要的deb包了.
需要的deb包下載完後, 就可以 dpkg -i 或者放到 cache 目錄安裝
cn99_gutsy.lst.gz :http://bbs.chinaitlab.com/thread-306620-1-1.html