approx

まえおき

自宅環境ではapt-mirrorを以前から使っていたのだけど、普段使わないパッケージもダウンロードしてしまうことと、ubuntu の multiverse, universeもmirrorすると、結構ダウンロードする量が多くなってしまう(自宅はADSLとはいえ、3Mbpsしかない)ので、apt-mirrorじゃなくて、apt-proxyでもいいのではないか、という気が最近してました。
サーバはamd64で、サーバ上の仮想マシンや、WindowsPC上のVMwareで使ってるubuntui386だったりするので、二つのarchをmirrorするのもさすがに無駄が多い。

ということで、apt-proxyを利用してみようかと思ったところ、apt-proxyと同様な機能の実装って、

$ apt-cache search apt-proxy
apt-cacher - Caching proxy for Debian package and source files
apt-cacher-ng - Caching proxy for distribution of software packages
apt-p2p - apt helper for peer-to-peer downloads of Debian packages
apt-proxy - Debian archive proxy and partial mirror builder
debtorrent - bittorrent proxy for downloading Debian packages
approx - Debian アーカイブファイル用キャッシュプロキシサーバ

のように、いくつかあるみたいです。

そこで今回は、approxってのを使ってみることにしました。

インストール

$ sudo aptitude install approx

これだけで TCP 9999 port でapt用の接続を待ち受け始める。

approxの設定

/etc/approx/approx.conf に下記の内容を追記しておく。

ubuntu      http://jp.archive.ubuntu.com/ubuntu/
security    http://security.ubuntu.com/ubuntu/

そして、approxを再起動。

$ sudo /etc/init.d/approx restart
 * Stopping proxy server for Debian archive files approx         [ OK ]
 * Starting proxy server for Debian archive files approx         [ OK ]

source.listの変更

approxを使うのにaptのsource.listを変更するので、あわせて整理する。

$ sed -e '/^$/d' -e '/^#/d' -e 's/^deb-src/#deb-src/' sources.list | sort
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid main restricted
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid multiverse
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid universe
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates multiverse
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates universe
#deb-src http://security.ubuntu.com/ubuntu intrepid-security main restricted
#deb-src http://security.ubuntu.com/ubuntu intrepid-security multiverse
#deb-src http://security.ubuntu.com/ubuntu intrepid-security universe
deb http://jp.archive.ubuntu.com/ubuntu/ intrepid main restricted
deb http://jp.archive.ubuntu.com/ubuntu/ intrepid multiverse
deb http://jp.archive.ubuntu.com/ubuntu/ intrepid universe
deb http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted
deb http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates multiverse
deb http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates universe
deb http://security.ubuntu.com/ubuntu intrepid-security main restricted
deb http://security.ubuntu.com/ubuntu intrepid-security multiverse
deb http://security.ubuntu.com/ubuntu intrepid-security universe

ソースパッケージは普段使わないので、aptitude updateするとき時間かかるのでコメントアウトしてます。
この内容を下記の様に整理して、/etc/apt/source.listを変更する。

deb http://jp.archive.ubuntu.com/ubuntu/ intrepid main restricted multiverse universe
deb http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted multiverse universe
deb http://security.ubuntu.com/ubuntu/ intrepid-security main restricted multiverse universe
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid main restricted multiverse universe
#deb-src http://jp.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted multiverse universe
#deb-src http://security.ubuntu.com/ubuntu/ intrepid-security main restricted multiverse universe


これをベースにして、approxに向けるように設定を変更する。

deb http://server:9999/ubuntu/ intrepid main restricted multiverse universe
deb http://server:9999/ubuntu/ intrepid-updates main restricted multiverse universe
deb http://server:9999/security/ intrepid-security main restricted multiverse universe
#deb-src http://server:9999/ubuntu/ intrepid main restricted multiverse universe
#deb-src http://server:9999/ubuntu/ intrepid-updates main restricted multiverse universe
#deb-src http://server:9999/security/ intrepid-security main restricted multiverse universe

これで、aptitude updateを実行して、正常に接続できることを確認。

これでしばらく運用。