跳到網頁內文區。

:::

Debian 安裝 wine 或 ttf-mscorefonts-installer 的問題(Ubuntu 同解)

在 Debian 下,安裝 wine 或 ttf-mscorefonts-installer 的時候,若你在台灣,會碰到以下的錯誤:

root@rinse:~# apt-get install wine
…
正在設定 ttf-mscorefonts-installer (3.0) ...

These fonts were provided by Microsoft "in the interest of cross-
platform compatibility".  This is no longer the case, but they are
still available from third parties.

You are free to download these fonts and use them for your own use,
but you may not redistribute them in modified form, including changes
to the file name or packaging format.

--2009-11-11 00:45:02--  http://downloads.sourceforge.net/corefonts/andale32.exe
正在查找主機 downloads.sourceforge.net... 216.34.181.59
正在連接 downloads.sourceforge.net|216.34.181.59|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 302 Found
位置:http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/andale32.exe [跟隨連結]
--2009-11-11 00:45:03--  http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/andale32.exe
正在查找主機 ncu.dl.sourceforge.net... 140.115.17.45
正在連接 ncu.dl.sourceforge.net|140.115.17.45|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 198384 (194K) [application/octet-stream]
Saving to: `./andale32.exe'

100%[======================================>] 198,384     40.8K/s   in 4.7s

2009-11-11 00:45:08 (40.8 KB/s) -- 已儲存 ‘./andale32.exe’ [198384/198384])

--2009-11-11 00:45:08--  http://downloads.sourceforge.net/corefonts/arialb32.exe
正在查找主機 downloads.sourceforge.net... 216.34.181.59
正在連接 downloads.sourceforge.net|216.34.181.59|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 302 Found
位置:http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/arialb32.exe [跟隨連結]
--2009-11-11 00:45:09--  http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/arialb32.exe
正在查找主機 ncu.dl.sourceforge.net... 140.115.17.45
正在連接 ncu.dl.sourceforge.net|140.115.17.45|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 168176 (164K) [application/octet-stream]
Saving to: `./arialb32.exe'

100%[======================================>] 168,176     40.0K/s   in 4.1s

2009-11-11 00:45:13 (40.0 KB/s) -- 已儲存 ‘./arialb32.exe’ [168176/168176])

--2009-11-11 00:45:13--  http://downloads.sourceforge.net/corefonts/arial32.exe
正在查找主機 downloads.sourceforge.net... 216.34.181.59
正在連接 downloads.sourceforge.net|216.34.181.59|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 302 Found
位置:http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/arial32.exe [跟隨連結]
--2009-11-11 00:45:14--  http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/arial32.exe
正在查找主機 ncu.dl.sourceforge.net... 140.115.17.45
正在連接 ncu.dl.sourceforge.net|140.115.17.45|:80... 失敗:連線超過時間。
已放棄。

--2009-11-11 00:45:19--  http://switch.dl.sourceforge.net/sourceforge/corefonts/arial32.exe
正在查找主機 switch.dl.sourceforge.net... 130.59.138.21, 2001:620:0:1b::21
正在連接 switch.dl.sourceforge.net|130.59.138.21|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 302 Found
位置:http://downloads.sourceforge.net/sourceforge/corefonts/arial32.exe?download&failedmirror=switch.dl.sourceforge.net [跟隨連結]
--2009-11-11 00:45:21--  http://downloads.sourceforge.net/sourceforge/corefonts/arial32.exe?download&failedmirror=switch.dl.sourceforge.net
正在查找主機 downloads.sourceforge.net... 216.34.181.59
正在連接 downloads.sourceforge.net|216.34.181.59|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 302 Found
位置:http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/arial32.exe [跟隨連結]
--2009-11-11 00:45:21--  http://ncu.dl.sourceforge.net/project/corefonts/the%20fonts/final/arial32.exe
正在查找主機 ncu.dl.sourceforge.net... 140.115.17.45
正在連接 ncu.dl.sourceforge.net|140.115.17.45|:80... 失敗:連線超過時間。
已放棄。
…

從 ncu.dl.sourceforge.net 下載到第三個字型後就掛掉了,沒辦法繼續下載後面的字型,安裝會失敗。從訊息中看起來,要下載字型的時候,透過 SourceForge.net 的鏡像站切換伺服器,自動依使用者在台灣,轉到中央大學的鏡像站。而中央大學的鏡像站又有防抓站,只要連續抓超過兩個檔案,就會丟掉封包,無法繼續下載。所以當 ttf-mscorefonts-installer 要下載一連串的字型時,下載到第三個字型就會被擋住了。因為選取哪一個鏡像站是 SourceForge.net 的鏡像站切換伺服器決定的,也沒辦法去改掉。

不過,倒有一個簡單的 Hack 解法。

因為下載用的程式還是 wget , wget 還是透過系統解析取得 ncu.dl.sourceforge.net 的 IP 去下載的。只要騙 wget 到另一個 IP 下載,就可以了。台灣有另外一個頻寬更大的 SourceForge.net 鏡像站在國網中心 nchc.dl.sourceforge.net ,只要能騙 wget 去國網中心下載即可。

root@rinse:~# host ncu.dl.sourceforge.net
ncu.dl.sourceforge.net has address 140.115.17.45
root@rinse:~# host nchc.dl.sourceforge.net
nchc.dl.sourceforge.net has address 211.79.60.17
nchc.dl.sourceforge.net has IPv6 address 2001:e10:ffff:1f02::17
root@rinse:~# echo "211.79.60.17 ncu.dl.sourceforge.net" >> /etc/hosts
root@rinse:~# apt-get install wine

其中 echo "211.79.60.17 ncu.dl.sourceforge.net" >> /etc/hosts 是把 ncu.dl.sourceforge.net 這個主機的 IP 寫死在 211.79.60.17 。這不是正確的做法,只是一個簡單的 Hack ,騙過 wget 而已。安裝完畢後最好把那一行刪掉,以免日後網域名稱解析出問題。

依瑪貓,初稿 2009-11-11 ,上次更新日期 2009-11-11