Ubuntu の日本APTリポジトリが壊れてる

Ubuntu 12.04.5 LTS の server をサーバの位置を日本にしてインストールすると
apt-get update がエラーになるわ apt-get install build-essential がまともに動かない状態…

なので回避策は /etc/apt/sources.list で jp.archive.ubuntu.com から
別の APTリポジトリへ変更 orz

現状

apt-get update で APT リポジトリの情報を最新に更新しようとすると

Hit http://jp.archive.ubuntu.com precise Release.gpg
Hit http://jp.archive.ubuntu.com precise-updates Release.gpg
Hit http://jp.archive.ubuntu.com precise-backports Release.gpg
Hit http://jp.archive.ubuntu.com precise Release
Hit http://jp.archive.ubuntu.com precise-updates Release
Hit http://jp.archive.ubuntu.com precise-backports Release
Get:1 http://jp.archive.ubuntu.com precise/main Sources [934 kB]
Get:2 http://jp.archive.ubuntu.com precise/restricted Sources [5,470 B]
Get:3 http://jp.archive.ubuntu.com precise/universe Sources [5,019 kB]
Get:4 http://jp.archive.ubuntu.com precise/multiverse Sources [155 kB]
Get:5 http://jp.archive.ubuntu.com precise/main amd64 Packages [1,273 kB]
Get:6 http://jp.archive.ubuntu.com precise/restricted amd64 Packages [8,452 B]
Get:7 http://security.ubuntu.com precise-security Release.gpg [198 B]
Get:8 http://jp.archive.ubuntu.com precise/universe amd64 Packages [4,786 kB]
Get:9 http://jp.archive.ubuntu.com precise/multiverse amd64 Packages [119 kB]
Get:10 http://jp.archive.ubuntu.com precise/main i386 Packages [1,274 kB]
Get:11 http://jp.archive.ubuntu.com precise/restricted i386 Packages [8,431 B]
Get:12 http://security.ubuntu.com precise-security Release [53.0 kB]
Get:13 http://jp.archive.ubuntu.com precise/universe i386 Packages [4,796 kB]
Get:14 http://jp.archive.ubuntu.com precise/multiverse i386 Packages [121 kB]
Hit http://jp.archive.ubuntu.com precise/main TranslationIndex
Hit http://jp.archive.ubuntu.com precise/multiverse TranslationIndex
Hit http://jp.archive.ubuntu.com precise/restricted TranslationIndex
Hit http://jp.archive.ubuntu.com precise/universe TranslationIndex
Hit http://jp.archive.ubuntu.com precise-updates/main Sources
Hit http://jp.archive.ubuntu.com precise-updates/restricted Sources
Hit http://jp.archive.ubuntu.com precise-updates/universe Sources
Hit http://jp.archive.ubuntu.com precise-updates/multiverse Sources
Hit http://jp.archive.ubuntu.com precise-updates/main amd64 Packages
Hit http://jp.archive.ubuntu.com precise-updates/restricted amd64 Packages
Hit http://jp.archive.ubuntu.com precise-updates/universe amd64 Packages
Hit http://jp.archive.ubuntu.com precise-updates/multiverse amd64 Packages
Hit http://jp.archive.ubuntu.com precise-updates/main i386 Packages
Hit http://jp.archive.ubuntu.com precise-updates/restricted i386 Packages
Hit http://jp.archive.ubuntu.com precise-updates/universe i386 Packages
Hit http://jp.archive.ubuntu.com precise-updates/multiverse i386 Packages
Hit http://jp.archive.ubuntu.com precise-updates/main TranslationIndex
Hit http://jp.archive.ubuntu.com precise-updates/multiverse TranslationIndex
Hit http://jp.archive.ubuntu.com precise-updates/restricted TranslationIndex
Hit http://jp.archive.ubuntu.com precise-updates/universe TranslationIndex
Hit http://jp.archive.ubuntu.com precise-backports/main Sources
Hit http://jp.archive.ubuntu.com precise-backports/restricted Sources
Hit http://jp.archive.ubuntu.com precise-backports/universe Sources
Hit http://jp.archive.ubuntu.com precise-backports/multiverse Sources
Hit http://jp.archive.ubuntu.com precise-backports/main amd64 Packages
Hit http://jp.archive.ubuntu.com precise-backports/restricted amd64 Packages
Hit http://jp.archive.ubuntu.com precise-backports/universe amd64 Packages
Hit http://jp.archive.ubuntu.com precise-backports/multiverse amd64 Packages
Hit http://jp.archive.ubuntu.com precise-backports/main i386 Packages
Hit http://jp.archive.ubuntu.com precise-backports/restricted i386 Packages
Hit http://jp.archive.ubuntu.com precise-backports/universe i386 Packages
Hit http://jp.archive.ubuntu.com precise-backports/multiverse i386 Packages
Hit http://jp.archive.ubuntu.com precise-backports/main TranslationIndex
Hit http://jp.archive.ubuntu.com precise-backports/multiverse TranslationIndex
Hit http://jp.archive.ubuntu.com precise-backports/restricted TranslationIndex
Hit http://jp.archive.ubuntu.com precise-backports/universe TranslationIndex
Hit http://jp.archive.ubuntu.com precise/main Translation-en
Hit http://jp.archive.ubuntu.com precise/multiverse Translation-en
Hit http://jp.archive.ubuntu.com precise/restricted Translation-en
Hit http://jp.archive.ubuntu.com precise/universe Translation-en
Hit http://jp.archive.ubuntu.com precise-updates/main Translation-en
Hit http://jp.archive.ubuntu.com precise-updates/multiverse Translation-en
Hit http://jp.archive.ubuntu.com precise-updates/restricted Translation-en
Hit http://jp.archive.ubuntu.com precise-updates/universe Translation-en
Hit http://jp.archive.ubuntu.com precise-backports/main Translation-en
Hit http://jp.archive.ubuntu.com precise-backports/multiverse Translation-en
Hit http://jp.archive.ubuntu.com precise-backports/restricted Translation-en
Hit http://jp.archive.ubuntu.com precise-backports/universe Translation-en
Get:15 http://security.ubuntu.com precise-security/main Sources [115 kB]
Get:16 http://security.ubuntu.com precise-security/restricted Sources [2,494 B]
Get:17 http://security.ubuntu.com precise-security/universe Sources [33.5 kB]
Get:18 http://security.ubuntu.com precise-security/multiverse Sources [1,805 B]
Get:19 http://security.ubuntu.com precise-security/main amd64 Packages [448 kB]
Get:20 http://security.ubuntu.com precise-security/restricted amd64 Packages [4,627 B]
Get:21 http://security.ubuntu.com precise-security/universe amd64 Packages [101 kB]
Get:22 http://security.ubuntu.com precise-security/multiverse amd64 Packages [2,441 B]
Get:23 http://security.ubuntu.com precise-security/main i386 Packages [482 kB]
Get:24 http://security.ubuntu.com precise-security/restricted i386 Packages [4,620 B]
Get:25 http://security.ubuntu.com precise-security/universe i386 Packages [108 kB]
Get:26 http://security.ubuntu.com precise-security/multiverse i386 Packages [2,634 B]
Hit http://security.ubuntu.com precise-security/main TranslationIndex
Hit http://security.ubuntu.com precise-security/multiverse TranslationIndex
Hit http://security.ubuntu.com precise-security/restricted TranslationIndex
Hit http://security.ubuntu.com precise-security/universe TranslationIndex
Hit http://security.ubuntu.com precise-security/main Translation-en
Hit http://security.ubuntu.com precise-security/multiverse Translation-en
Hit http://security.ubuntu.com precise-security/restricted Translation-en
Hit http://security.ubuntu.com precise-security/universe Translation-en
Fetched 1,360 kB in 8s (170 kB/s)
W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_main_source_Sources  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_restricted_source_Sources  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_universe_source_Sources  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_multiverse_source_Sources  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_main_binary-amd64_Packages  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_restricted_binary-amd64_Packages  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_universe_binary-amd64_Packages  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_multiverse_binary-amd64_Packages  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_main_binary-i386_Packages  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_restricted_binary-i386_Packages  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_universe_binary-i386_Packages  Hash Sum mismatch

W: Failed to fetch bzip2:/var/lib/apt/lists/partial/jp.archive.ubuntu.com_ubuntu_dists_precise_multiverse_binary-i386_Packages  Hash Sum mismatch

E: Some index files failed to download. They have been ignored, or old ones used instead.

とまあ、ハッシュが違うエラーになる

apt-get install build-essential だと

Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 build-essential : Depends: gcc (>= 4:4.4.3) but it is not installable
                   Depends: g++ (>= 4:4.4.3) but it is not installable
E: Unable to correct problems, you have held broken packages.

と、依存関係エラーとなってまともに動かない状態…

apt リポジトリを別ミラーへ切り替え

apt を別のミラーに切り替えるのに /etc/apt/sources.list を編集

オリジナルを保存

sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
sudo chmod 444 /etc/apt/sources.list.orig

jp.archive.ubuntu.com (富山大学?)から JAIST へ変更

sudo sed -i".back" -e "s,//jp.archive.ubuntu.com,//ftp.jaist.ac.jp/pub/Linux,g" /etc/apt/sources.list

あとは apt-get update で APT リポジトリのインデック更新が正常に働くようになります。

Get:1 http://ftp.jaist.ac.jp precise Release.gpg [198 B]
Get:2 http://ftp.jaist.ac.jp precise-updates Release.gpg [198 B]
Get:3 http://ftp.jaist.ac.jp precise-backports Release.gpg [198 B]
Get:4 http://ftp.jaist.ac.jp precise Release [49.6 kB]
Get:5 http://ftp.jaist.ac.jp precise-updates Release [194 kB]
Get:6 http://ftp.jaist.ac.jp precise-backports Release [53.1 kB]
Get:7 http://ftp.jaist.ac.jp precise/main Sources [934 kB]
Get:8 http://ftp.jaist.ac.jp precise/restricted Sources [5,470 B]
Get:9 http://ftp.jaist.ac.jp precise/universe Sources [5,019 kB]
Hit http://security.ubuntu.com precise-security Release.gpg
Get:10 http://ftp.jaist.ac.jp precise/multiverse Sources [155 kB]
Get:11 http://ftp.jaist.ac.jp precise/main amd64 Packages [1,273 kB]
Hit http://security.ubuntu.com precise-security Release
Hit http://security.ubuntu.com precise-security/main Sources
Get:12 http://ftp.jaist.ac.jp precise/restricted amd64 Packages [8,452 B]
Get:13 http://ftp.jaist.ac.jp precise/universe amd64 Packages [4,786 kB]
Hit http://security.ubuntu.com precise-security/restricted Sources
Hit http://security.ubuntu.com precise-security/universe Sources
Hit http://security.ubuntu.com precise-security/multiverse Sources
Hit http://security.ubuntu.com precise-security/main amd64 Packages
Hit http://security.ubuntu.com precise-security/restricted amd64 Packages
Hit http://security.ubuntu.com precise-security/universe amd64 Packages
Hit http://security.ubuntu.com precise-security/multiverse amd64 Packages
Hit http://security.ubuntu.com precise-security/main i386 Packages
Hit http://security.ubuntu.com precise-security/restricted i386 Packages
Hit http://security.ubuntu.com precise-security/universe i386 Packages
Hit http://security.ubuntu.com precise-security/multiverse i386 Packages
Hit http://security.ubuntu.com precise-security/main TranslationIndex
Hit http://security.ubuntu.com precise-security/multiverse TranslationIndex
Hit http://security.ubuntu.com precise-security/restricted TranslationIndex
Hit http://security.ubuntu.com precise-security/universe TranslationIndex
Hit http://security.ubuntu.com precise-security/main Translation-en
Hit http://security.ubuntu.com precise-security/multiverse Translation-en
Hit http://security.ubuntu.com precise-security/restricted Translation-en
Hit http://security.ubuntu.com precise-security/universe Translation-en
Get:14 http://ftp.jaist.ac.jp precise/multiverse amd64 Packages [119 kB]
Get:15 http://ftp.jaist.ac.jp precise/main i386 Packages [1,274 kB]
Get:16 http://ftp.jaist.ac.jp precise/restricted i386 Packages [8,431 B]
Get:17 http://ftp.jaist.ac.jp precise/universe i386 Packages [4,796 kB]
Get:18 http://ftp.jaist.ac.jp precise/multiverse i386 Packages [121 kB]
Get:19 http://ftp.jaist.ac.jp precise/main TranslationIndex [3,706 B]
Get:20 http://ftp.jaist.ac.jp precise/multiverse TranslationIndex [2,676 B]
Get:21 http://ftp.jaist.ac.jp precise/restricted TranslationIndex [2,596 B]
Get:22 http://ftp.jaist.ac.jp precise/universe TranslationIndex [2,922 B]
Get:23 http://ftp.jaist.ac.jp precise-updates/main Sources [480 kB]
Get:24 http://ftp.jaist.ac.jp precise-updates/restricted Sources [8,000 B]
Get:25 http://ftp.jaist.ac.jp precise-updates/universe Sources [112 kB]
Get:26 http://ftp.jaist.ac.jp precise-updates/multiverse Sources [8,914 B]
Get:27 http://ftp.jaist.ac.jp precise-updates/main amd64 Packages [848 kB]
Get:28 http://ftp.jaist.ac.jp precise-updates/restricted amd64 Packages [13.2 kB]
Get:29 http://ftp.jaist.ac.jp precise-updates/universe amd64 Packages [250 kB]
Get:30 http://ftp.jaist.ac.jp precise-updates/multiverse amd64 Packages [15.3 kB]
Get:31 http://ftp.jaist.ac.jp precise-updates/main i386 Packages [879 kB]
Get:32 http://ftp.jaist.ac.jp precise-updates/restricted i386 Packages [13.2 kB]
Get:33 http://ftp.jaist.ac.jp precise-updates/universe i386 Packages [257 kB]
Get:34 http://ftp.jaist.ac.jp precise-updates/multiverse i386 Packages [15.5 kB]
Get:35 http://ftp.jaist.ac.jp precise-updates/main TranslationIndex [10.6 kB]
Get:36 http://ftp.jaist.ac.jp precise-updates/multiverse TranslationIndex [7,613 B]
Get:37 http://ftp.jaist.ac.jp precise-updates/restricted TranslationIndex [7,297 B]
Get:38 http://ftp.jaist.ac.jp precise-updates/universe TranslationIndex [8,333 B]
Get:39 http://ftp.jaist.ac.jp precise-backports/main Sources [5,371 B]
Get:40 http://ftp.jaist.ac.jp precise-backports/restricted Sources [14 B]
Get:41 http://ftp.jaist.ac.jp precise-backports/universe Sources [40.6 kB]
Get:42 http://ftp.jaist.ac.jp precise-backports/multiverse Sources [5,737 B]
Get:43 http://ftp.jaist.ac.jp precise-backports/main amd64 Packages [5,477 B]
Get:44 http://ftp.jaist.ac.jp precise-backports/restricted amd64 Packages [14 B]
Get:45 http://ftp.jaist.ac.jp precise-backports/universe amd64 Packages [42.9 kB]
Get:46 http://ftp.jaist.ac.jp precise-backports/multiverse amd64 Packages [5,405 B]
Get:47 http://ftp.jaist.ac.jp precise-backports/main i386 Packages [5,470 B]
Get:48 http://ftp.jaist.ac.jp precise-backports/restricted i386 Packages [14 B]
Get:49 http://ftp.jaist.ac.jp precise-backports/universe i386 Packages [42.7 kB]
Get:50 http://ftp.jaist.ac.jp precise-backports/multiverse i386 Packages [5,399 B]
Get:51 http://ftp.jaist.ac.jp precise-backports/main TranslationIndex [202 B]
Get:52 http://ftp.jaist.ac.jp precise-backports/multiverse TranslationIndex [202 B]
Get:53 http://ftp.jaist.ac.jp precise-backports/restricted TranslationIndex [193 B]
Get:54 http://ftp.jaist.ac.jp precise-backports/universe TranslationIndex [205 B]
Get:55 http://ftp.jaist.ac.jp precise/main Translation-en [726 kB]
Get:56 http://ftp.jaist.ac.jp precise/multiverse Translation-en [93.4 kB]
Get:57 http://ftp.jaist.ac.jp precise/restricted Translation-en [2,395 B]
Get:58 http://ftp.jaist.ac.jp precise/universe Translation-en [3,341 kB]
Get:59 http://ftp.jaist.ac.jp precise-updates/main Translation-en [372 kB]
Get:60 http://ftp.jaist.ac.jp precise-updates/multiverse Translation-en [9,010 B]
Get:61 http://ftp.jaist.ac.jp precise-updates/restricted Translation-en [3,008 B]
Get:62 http://ftp.jaist.ac.jp precise-updates/universe Translation-en [145 kB]
Get:63 http://ftp.jaist.ac.jp precise-backports/main Translation-en [4,911 B]
Get:64 http://ftp.jaist.ac.jp precise-backports/multiverse Translation-en [4,838 B]
Get:65 http://ftp.jaist.ac.jp precise-backports/restricted Translation-en [14 B]
Get:66 http://ftp.jaist.ac.jp precise-backports/universe Translation-en [34.2 kB]
Fetched 26.6 MB in 20s (1,287 kB/s)
Reading package lists... Done

プロバイダが IIJ 系の方は

sudo sed -i".back" -e "s,//jp.archive.ubuntu.com,//ftp.iij.ad.jp/pub/linux/ubuntu/archive/,g" /etc/apt/sources.list

も使用できます。

This entry was posted in Linux, Linux kernel, Linux Ubuntu, raspbian. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>