debian
2009年02月28日
さくらレンタルサーバでDebianを使うの続き
chroot環境構築時の方針は下記のものとする
- host環境は可能な限り手をつけない
- デーモンプロセスはdaemontoolsで管理する物とする
- host環境用sshとguest環境用sshをそれぞれ用意する
作業内容
作業対象を明確化するため、プロンプトで示す
| プロンプト | 内用 |
|---|---|
| debian | Debianがインストールされている別サーバ |
| host | chroot呼び出し元 |
| guest | chroot環境下 |
chroot環境構築下準備
debian環境にてchrootツリーを作っておく
debian$ mkdir sid debian$ sudo /usr/sbin/debootstrap sid sid debian$ sudo tar zcvpf sid.tar.gz sid debian$ scp sid.tar.gz admin@192.0.2.205:~/
host環境にてchroot用ディレクトリ作成
host$ su host# cd /home host# mkdir -p chroot/debian host# cd chroot/debian
debianツリーを伸長
host# tar zxvpf sid.tar.gz
子環境用に必要な物をマウント
host# mount -t proc proc /home/chroot/debian/sid/proc host# mount -t devpts devpts /home/chroot/debian/sid/dev/pts host# mount -o bind /dev /home/chroot/debian/sid/dev host# mount -o bind / /home/chroot/debian/sid/mnt
リゾルバ設定
host# cp -pi /etc/resolv.conf sid/etc/.
パッケージを更新
guest# export PATH=/bin:/usr/bin:/sbin:/usr/sbin guest# apt-get update guest# apt-get dist-upgrade
daemontools起動設定
guest# apt-get install daemontools guest# exit
host# vi /etc/inittab SV:123456:respawn:/usr/sbin/chroot /home/chroot/debian/sid /usr/bin/svscanboot
host# /sbin/telinit q
親環境のhttpdを停止
host# /sbin/chkconfig --list httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off host# /sbin/chkconfig --del httpd host# /sbin/chkconfig --list httpd service httpd supports chkconfig, but is not referenc
OpenSSH設定
guest# apt-get install openssh-server guest# apt-get install ucspi-tcp
guest# cd /etc/service guest# ./addsv.sh ssh guest# cd .ssh; pwd guest# vi run
※addsv.shはdaemontoolsの/service/に、サービスを追加するスクリプト「addsv.sh」 を参照。
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
export PATH
exec 2>&1
sleep 3
exec envdir ./env sh -c '
/usr/bin/tcpserver -HRDl0 -x ./tcp.ssh.cdb \
-u 0 -g 0 0 ${PORT:-2022} /usr/sbin/sshd -i -e
'
guest# mkdir env guest# echo 2022 > env/PORT
guest# echo :allow > tcp.ssh guest# tcprule ./tcp.ssh.cdb ./tcp.ssh.tmp < ./tcp.ssh guest# cd ../; pwd guest# mv -i .ssh ssh
これ以降の作業は2022番ポートを指定してssh接続。
必要に応じてパッケージをインストールして行く。
まとめ
- hostのinittabにてguestのsvscanを実行するのがポイント
- chrootのツリーを他サーバへ持っていけば簡単に論理移転可能と言うメリットがある
2009年02月15日
2008年10月02日
coLinuxでDebian
先日、OSをクリーンインストールした。
それに伴いcoLinuxの環境構築。
Debianのイメージを改めてダウンロードして環境構築。
どうもUTF-8の表示処理が上手くいかない。
最初はlocaleの設定が何もない事を思い出す。
久し振りの作業なので、すっかり忘れていた。
設定作業
localesインストール
$ sudo apt-get install localeslocale対象リスト作成
$ sudo vi /etc/locale.gen ja_JP.UTF-8 UTF-8locale生成
$ sudo /usr/sbin/locale-gen環境変数設定
$ export LC_ALL=ja_JP.EUC-JP
2008年07月18日
IPアドレスから位置情報を取得したい
GeoIP City Geolocationを使うとIPアドレスから位置情報を取得可能。
無料版と有料版があり、無料版は位置情報の精度が低い。
今回は無料版で実験。
環境構築
必要なパッケージをインストール
$ sudo apt-get install libgeoip1 libgeoip-devGeo::IPをダウンロードしてdebパッケージ化
※etchでは1.33のbuildに失敗したので1.27を採用。
$ wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz $ tar zxvf Geo-IP-1.27.tar.gz $ dh-make-perl --build Geo-IP-1.27 $ sudo dpkg -i libgeo-ip-perl_1.27-1_i386.debGeoLiteCity.datをダウンロード
$ wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz $ gunzip GeoLiteCity.dat.gzサンプルプログラム
#!/usr/bin/perl
use strict;
use warnings;
use Geo::IP;
my $name = shift;
my $geo = Geo::IP->open('./GeoLiteCity.dat', GEOIP_STANDARD);
my $geoip = $geo->record_by_name($name);
exit 1 unless $geoip;
map { print $_ .":\t". $geoip->$_ ."\n" }
qw/country_code country_name city region postal_code
latitude longitude dma_code area_code/;
1;
実行例$ ./geoip-lookup.pl www.google.com country_code: US country_name: United States city: Mountain View region: CA postal_code: 94043 latitude: 37.4192 longitude: -122.0574 dma_code: 807 area_code: 650
位置情報を取得した後、どうする?
Google Maps APIで位置情報を指定して地図を表示する。
これをやりたかった。
Google Maps Hacks 第2版 ―地図検索サービスをもっと活用するテクニック
posted with amazlet at 08.07.18
Rich Gibson Schuyler Erle
オライリー・ジャパン
売り上げランキング: 53996
オライリー・ジャパン
売り上げランキング: 53996
2008年06月23日
DebianにCentOS4の仮想環境を作ろう
コマンドが異常終了した。
$ sudo xen-create-image --install-method rinse --dist centos-4 --hostname centos4
早速ログ確認すると、
何てこった…参照先が存在しない。
どこかに設定ファイルがあるはずなので探してみる。
debian$ cd /etc/ debian$ grep http://anorien.csc.warwick.ac.uk/ -r . -l 2>/dev/null ./rinse/rinse.confなるほど。
ミラーサイト設定を変更
$ cd /etc/rinse $ sudo cp -pi rinse.conf rinse.conf.0 $ sudo vi rinse.conf
$ diff rinse.conf.0 rinse.conf 14,15c14,15 < mirror = http://anorien.csc.warwick.ac.uk/mirrors/centOS/4.6/os/i386/CentOS/RPMS/ < mirror.amd64 = http://anorien.csc.warwick.ac.uk/mirrors/CentOS/4.6/os/x86_64/CentOS/RPMS/ --- > mirror = http://ftp.riken.jp/Linux/centos/4.6/os/i386/CentOS/RPMS/ > mirror.amd64 = http://ftp.riken.jp/Linux/centos/4.6/os/x86_64/CentOS/RPMS/ 19,20c19,20 < mirror = http://anorien.csc.warwick.ac.uk/mirrors/centos/5/os/i386/CentOS/ < mirror.amd64 = http://anorien.csc.warwick.ac.uk/mirrors/centos/5/os/x86_64/CentOS/ --- > mirror = http://ftp.riken.jp/Linux/centos/5/os/i386/CentOS/ > mirror.amd64 = http://ftp.riken.jp/Linux/centos/5/os/x86_64/CentOS/これで上手く行った。
まとめ
環境
- Domain0がDebian
- DomainUをCentOSとする場合
- つまり、install-methodをrinseとする場合
解決方法
- /var/log/xen-tools/を確認
- ミラー先に問題がある場合は/etc/rinse/rinse.confを変更
- 再度xen-create-imageを実行して確認
2008年05月28日
2008年05月21日
WindowsとcoLinux間のファイルやり取りが多い
作業の都合で
coLinux上のファイルをWindowsへの移動が何度も行われている。
WinSCPでファイル操作してみたけど、どうも効率が悪い。
そこで考えた解決の1つがSambaの利用。
環境整理
| Debian | lenny/sid | |
| colinux | IPアドレス | 192.168.0.10 |
| 作業アカウント | colinux | |
| ホームディレクトリ | /home/user/colinux/ | |
$ sudo apt-get install samba $ sudo vi /etc/samba/smb.conf [global] > security = share > [colinux] > comment = colinux home > path = /home/user/colinux > read only = no > guest ok = yes $ sudo /etc/init.d/samba restartあとはエクスプローラーで「\\192.168.0.10\」へアクセス。
フォルダ名「colinux」が現れていれば成功。
作業効率が上がった。
2008年05月06日
開発環境は主にDebian
毎日の準備体操のようなもの。
$ sudo apt-get update && sudo apt-get dist-upgrade
すると…
あれ…?
$ /usr/sbin/apachectl configtest Syntax error on line 15 of /etc/apache/sites-enabled/app.config: Invalid command '', perhaps mis-spelled or defined by a module not included in the server configuration
おや…?
作業内容
どうも変だぞ。
- apt-getを実行しただけ
- Perlが5.8→8.10になった
- libapache-mod-perlがPerl5.8依存
- Perl5.10がインストールされた為、依存関係が崩れてmod-perlが消えた
しかし、Perl5.10よりもSledgeが動かない。
こっちがまずい。
大急ぎでPerl関連パッケージを元に戻す
$ sudo apt-get install /var/cache/apt/archive/.......deb
やっと戻ったつもりが、まだ動かない。
[Tue May 6 15:08:53 2008] [error] This method is abstract at /usr/share/perl5/S ledge/Pages/Base.pm line 46.\n
何だなんだ…?
前にもハマッタ気がする。
冷静に考える。
Apache関連Perlモジュール不足。
$ sudo apt-get install libapache-reload-perl libapache-request-perl
やっと戻った…。
とりあえずPerlモジュールはholdにしておいた。
今後
- sidを使う
- Perl5.10依存のlibapache-mod-perlを作る
- Perl5.8系でholdしておく
- Sledgeを卒業する
- sargeを使う
- libapache-mod-perl環境用の為にsargeを使う
2008年04月08日
それは余りにも突然の要望
「別の検証用サーバとして使いたい」whois.hansode.orgとcert.hansode.orgを動かしているサーバの事だ。
正直面倒くさい。しかし、自分が引越させるのが最もコストが低い。
晩御飯を食べ終え、
気合を入れて引越作業に取り掛かった。
やはりDebian!
どのパッケージが入っているのか。
$ dpkg --get-selections | awk '$2 == "install" {print $1}'
これで出て来る。このリストを上手く利用すれば、
Debianパッケージレベルのレプリカ作成は容易な作業。
old$ dpkg --get-selections | awk '$2 == "install" {print $1}' > tee dpkg-list.txt
old$ scp dpkg-list.txt $(new-server):~/
old$ ssh new
new$ sudo apt-get install `cat dpkg-list.txt`
下記前提条件を満たせば、あっと言う間に作業が終わる。
- Debianのバージョンが同じ
- 全てが公式パッケージ
時間がかかったのはMySQLのデータ移項。
Debianは引越作業が楽。
2008年03月08日
2007年10月03日
まっさらなサーバで作業すると、いつもこの作業。
■VirtualHostの追加と有効化
■rewriteを有効化
■VirtualHostの追加と有効化
# cd /etc/apache2/sites-available # vi foo.example.com # a2ensite foo.example.com Site foo.example.com installed; run /etc/init.d/apache2 reload to enable.
■rewriteを有効化
# /usr/sbin/apache2ctl configtest Syntax error on line 9 of /etc/apache2/sites-enabled/foo.example.com: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration # a2enmod rewrite Module rewrite installed; run /etc/init.d/apache2 force-reload to enable. # /usr/sbin/apache2ctl configtest Syntax OK
2007年09月15日
$ dh-make-perl --build --cpan Web::Scraper
Found: Web-Scraper 0.13 (libweb-scraper-perl arch=all)
======================================================================
Could not find the dependencies for the requested module
Module::Depends::Intrusive reports: syntax error at /home/user/hansode/work/debian/Web-Scraper-0.13/Makefile.PL line 2, near "name 'Web-Scraper'"
syntax error at /home/user/hansode/work/debian/Web-Scraper-0.13/Makefile.PL line 15, near "install_script 'bin/scraper'"
Compilation failed in require at /usr/share/perl5/Module/Depends/Intrusive.pm line 76.
Generated error: Error: syntax error at /home/user/hansode/work/debian/Web-Scraper-0.13/Makefile.PL line 2, near "name 'Web-Scraper'"
syntax error at /home/user/hansode/work/debian/Web-Scraper-0.13/Makefile.PL line 15, near "install_script 'bin/scraper'"
Compilation failed in require at /usr/share/perl5/Module/Depends/Intrusive.pm line 76.
Please check if your module depends on Module::Install
for its build process - Automatically finding its
dependencies is unsupported, please specify them manually
using the 'depends' option.
======================================================================
あらららら
$ cd Web-Scraper-0.13/
$ perl Makefile.PL
$ make test
All tests successful, 2 tests skipped.
こっちは問題ない。
比較的新しいCPANモジュールをdh-make-perlすると、
上手く行かない事が良くある。
いつもそれが悩みの種。
2007年08月27日
■サーバ統計情報
普段、統計情報の必要性はさほど無い。
長期間サーバを管理する場合、統計は重要となって来る。
▼サーバ統計情報
・負荷観察
・負荷予測
・スケールアップ,スケールアウトの検討材料
サーバの統計情報を記録する手段の1つがMRTG。
■初心に帰る
久々に初心に帰って統計情報を取得,記録する設定をした。
振り返りを兼ねて、ここに作業記録を残す。
作業記録は下記の通り
続きを読む
普段、統計情報の必要性はさほど無い。
長期間サーバを管理する場合、統計は重要となって来る。
▼サーバ統計情報
・負荷観察
・負荷予測
・スケールアップ,スケールアウトの検討材料
サーバの統計情報を記録する手段の1つがMRTG。
■初心に帰る
久々に初心に帰って統計情報を取得,記録する設定をした。
振り返りを兼ねて、ここに作業記録を残す。
作業記録は下記の通り
続きを読む
■特殊な環境で起きる
同様の現象に遭遇する事は滅多にない。
しかし、今度遭遇した時にすぐ解決出来る様にしたい。
ここに作業記録を残しておく。未来の自分へのラブレター。
▼環境
・Debian GNU/Linux (etch)
・tinydnsで内部コンテンツNS
・プライベートネットワークは内部コンテンツNSを参照
▼背景
【図1: 外部ネットワークからの接続】


【図2: 内部ネットワークからの接続】


ルーターのグローバルIPアドレスが返って来てしまう。
▼背景2
解決策の選択しを幾つか列挙し、
議論の結果、内部コンテンツNSを立ち上げて解決する事となた。
【図3: 内部ネットワーク内で解決した名前解決】


しかし、hostコマンドだけでは足りなかったのだ…
■hostコマンド v.s. telnetコマンド
▼ある日
hostコマンドで確認すると問題ない。
しかし、telnetコマンドを使うと確かにルーターのIPアドレスが返って来る。
何だコレは?!
▼仮説
・hostコマンドとtelnetコマンドでは名前解決ロジックが違う
・telnetを実行したサーバのリゾルバが設定不十分
・nsswitchの設定で、検索優先順位が意図しない物を最優先にしている
▼検証: straceコマンド
コマンドの挙動を確認する時に使うのがstraceコマンド。
straceコマンドを使う事で、システムコールをトレース出来る。
この2つのコマンドを実行し、
どのファイルをopenしているのかを観察してみた。
▼新たな疑惑
そしてnscdのキャッシュ疑惑が生まれた。
どうもnscdがあやしいぞ?
■容疑者nscd
▼/etc/nscd.conf
nscdの設定ファイルは/etc/nscd.conf。
こいつの設定項目を確認していった。
その中で日と際目立つヤツを発見。
▼仮説
enable-cache hostに違いない。
▼検証
yesをnoへ変更
▼結果
成功だ
■まとめ
▼発生する環境
・内部コンテンツNSを立てている
・nscdを使っている
▼解決策
・『enable-cache hosts no』にする
『何故nscd使うの?』と言う突っ込みは今回の議論の対象外。
■関連リンク
・やむにやまれず: Air Stationに変えたらLAN側自社サービスにアクセスできなくなった
・tech memo: cached
同様の現象に遭遇する事は滅多にない。
しかし、今度遭遇した時にすぐ解決出来る様にしたい。
ここに作業記録を残しておく。未来の自分へのラブレター。
▼環境
・Debian GNU/Linux (etch)
・tinydnsで内部コンテンツNS
・プライベートネットワークは内部コンテンツNSを参照
▼背景
・外部からの接続にはプライベートネットワークのサーバへ、
ルーターがルーティングしてくれる。
・内部からFQDNで接続しようとすると、ルーターに割り当てられている
グローバルIPアドレスへ接続し、プライベートネットワークのサーバへ
ルーティングしてくれない
ルーターがルーティングしてくれる。
・内部からFQDNで接続しようとすると、ルーターに割り当てられている
グローバルIPアドレスへ接続し、プライベートネットワークのサーバへ
ルーティングしてくれない
【図1: 外部ネットワークからの接続】

【図2: 内部ネットワークからの接続】

ルーターのグローバルIPアドレスが返って来てしまう。
▼背景2
解決策の選択しを幾つか列挙し、
議論の結果、内部コンテンツNSを立ち上げて解決する事となた。
tinydns, dnscacheを設定
↓
hostコマンドで名前解決出来る事を確認
↓
hostコマンドで名前解決出来る事を確認
【図3: 内部ネットワーク内で解決した名前解決】

しかし、hostコマンドだけでは足りなかったのだ…
■hostコマンド v.s. telnetコマンド
▼ある日
やむ:『telnet web.example.com 80 とすると、ルーターに接続してしまうよ』
hostコマンドで確認すると問題ない。
しかし、telnetコマンドを使うと確かにルーターのIPアドレスが返って来る。
何だコレは?!
▼仮説
・hostコマンドとtelnetコマンドでは名前解決ロジックが違う
・telnetを実行したサーバのリゾルバが設定不十分
・nsswitchの設定で、検索優先順位が意図しない物を最優先にしている
▼検証: straceコマンド
コマンドの挙動を確認する時に使うのがstraceコマンド。
straceコマンドを使う事で、システムコールをトレース出来る。
$ strace host web.examle.com
$ strace telnet web.examle.com 80
$ strace telnet web.examle.com 80
この2つのコマンドを実行し、
どのファイルをopenしているのかを観察してみた。
▼新たな疑惑
そしてnscdのキャッシュ疑惑が生まれた。
どうもnscdがあやしいぞ?
■容疑者nscd
▼/etc/nscd.conf
nscdの設定ファイルは/etc/nscd.conf。
こいつの設定項目を確認していった。
その中で日と際目立つヤツを発見。
enable-cache hosts yes
▼仮説
enable-cache hostに違いない。
enable-cache hosts yes
▼検証
yesをnoへ変更
$ sudo cp -pi /etc/nscd.conf /etc/nscd.conf.0
$ sudo vi /etc/nscd.conf
$ diff /etc/nscd.conf.0 /etc/nscd.conf
enable-cache hosts no
$ sudo /etc/init.d/nscd restart
$ sudo vi /etc/nscd.conf
$ diff /etc/nscd.conf.0 /etc/nscd.conf
enable-cache hosts no
$ sudo /etc/init.d/nscd restart
▼結果
$ telnet web.examle.com 80
Trying 192.168.0.80...
Connected to web.example.com.
Escape character is '^]'.
^]
telnet> close
Connection closed.
Trying 192.168.0.80...
Connected to web.example.com.
Escape character is '^]'.
^]
telnet> close
Connection closed.
成功だ
■まとめ
▼発生する環境
・内部コンテンツNSを立てている
・nscdを使っている
▼解決策
・『enable-cache hosts no』にする
『何故nscd使うの?』と言う突っ込みは今回の議論の対象外。
■関連リンク
・やむにやまれず: Air Stationに変えたらLAN側自社サービスにアクセスできなくなった
・tech memo: cached
2007年08月02日
しばらく使ってないうちにオプションが増えていた。
Usage:
/usr/bin/dh-make-perl [ --build ] [ --install ] [ SOURCE_DIR | --cpan MODULE ]
Other options: [ --desc DESCRIPTION ] [ --arch all|any ] [ --version VERSION ]
[ --depends DEPENDS ] [ --bdepends BUILD-DEPENDS ]
[ --bdependsi BUILD-DEPENDS-INDEP ] [ --cpan-mirror MIRROR ]
[ --exclude|-i [REGEX] ] [ --notest ] [ --nometa ]
[ --requiredeps ] [ --core-ok ]
オプションを見る限り、コマンドラインオプションで依存パッケージ
を指定出来るようになったみたいだ。manで調べてみる。
$ man dh-make-perl
--depends DEPENDS
Manually specify the string to be used for the module's dependen-
cies. This should be used when building modules where dh-make-perl
cannot guess the Perl dependencies (such as modules built using
Module::Install), or when the Perl code depends on non-Perl bina-
ries or libraries. Usually, dh-make-perl will figure out the depen-
dencies by itself.
なるほど。
依存ライブラリの数だけ --depends オプションを使うのかと思ったらそうではない。
--dependsは一回だけ使える。
$ dh-make-perl --build --cpan [module] --depends '[package], [package], [package]...'
例としてPlaggerのdebパッケージ作成時のオプション
依存パッケージ多過ぎ。依存しているパッケージはさらに何かに依
存しているので、それぞれのパッケージを作るのは多大な時間が費
やされる。今までにどれくらい費やしたか覚えて居ない…。
dh-make-perl --build --cpan Plagger --depends '${perl:Depends}, ${misc:Depends}, libcache-cache-perl(>=1.04), libcache-fastmmap-perl, libclass-accessor-perl, libconfig-ini-simple-perl, libdata-ical-perl, libdata-serializer-perl, libdatetime-format-epoch-perl, libdatetime-format-ical-perl, libdatetime-format-mail-perl, libdatetime-format-strptime-perl, libdatetime-format-w3cdtf-perl, libdatetime-locale-perl, libdatetime-locale-perl(>=0.32), libdatetime-perl(>=0.35), libdatetime-timezone-perl(>=0.56), libdbix-class-perl, libemail-address-perl, libencode-detect-perl(>=1), libencode-perl(>=2.1), libfile-copy-recursive-perl, libfile-find-rule-perl, libfile-grep-perl, libfile-homedir-perl, libflickr-api-perl, libhatena-keyword-perl, libhtml-format-perl, libhtml-parser-perl, libhtml-parser-perl(>=3.51), libhtml-resolvelink-perl, libhtml-resolvelink-perl(>=0.02), libhtml-scrubber-perl, libhtml-tidy-perl(>=1.07), libhtml-tree-perl, libhtml-treebuilder-xpath-perl, libhttp-cookies-mozilla-perl, libimage-info-perl, libip-country-perl, libipc-run-perl, libkinosearch-perl, liblingua-en-summarize-perl, liblingua-ja-summarize-extract-perl, liblingua-zh-handetect-perl, libmail-imapclient-perl, libmailtools-perl, libmime-lite-perl, libmime-types-perl(>=1.16), libmodule-pluggable-fast-perl, libnet-delicious-perl, libnet-dns-perl, libnet-movabletype-perl, libnet-netsend-perl, libnet-smtp-tls-perl, libpalm-palmdoc-perl, libpoe-component-client-dns-perl, libpoe-component-client-http-perl, libpoe-component-ikc-perl, libpoe-component-irc-perl, libpoe-perl, libregexp-common-profanity-us-perl, libsearch-estraier-perl, libsoap-lite-perl, libspreadsheet-writeexcel-perl, libsvn-core-perl, libswf-builder-perl, libtemplate-perl(>=2.13), libtemplate-plugin-javascript-perl, libtemplate-provider-encoding-perl(>=0.04), libterm-encoding-perl, libtest-pod-coverage-perl, libtest-pod-perl, libtext-csv-pp-perl, libtext-emoticon-perl, libtext-hatena-perl, libtext-kakasi-perl, libtext-language-guess-perl, libtext-markdown-perl, libtext-original-perl, libtext-tags-perl, libtext-wrapi18n-perl, libtime-duration-parse-perl, libtimedate-perl, libuniversal-require-perl(>=0.1), liburi-fetch-perl(>=0.07), liburi-find-perl, libwebservice-bloglines-perl(>=0.11), libwww-babelfish-perl, libwww-mechanize-perl, libwww-mixi-perl(>=0.48), libwww-perl, libxango-perl(>=1.04), libxml-atom-perl(>=0.20), libxml-atom-perl(>=0.23), libxml-feed-perl(>=0.09), libxml-feed-perl(>=0.12), libxml-foaf-perl, libxml-liberal-perl(>=0.14), libxml-libxml-perl, libxml-rss-liberal-perl, libxml-rss-libxml-perl(>=0.23), libyaml-perl(>=0.39), libyaml-syck-perl, libyaml-syck-perl(>=0.1), perl, perl(>=2.1), perl-base, spamassassin'
Usage:
/usr/bin/dh-make-perl [ --build ] [ --install ] [ SOURCE_DIR | --cpan MODULE ]
Other options: [ --desc DESCRIPTION ] [ --arch all|any ] [ --version VERSION ]
[ --depends DEPENDS ] [ --bdepends BUILD-DEPENDS ]
[ --bdependsi BUILD-DEPENDS-INDEP ] [ --cpan-mirror MIRROR ]
[ --exclude|-i [REGEX] ] [ --notest ] [ --nometa ]
[ --requiredeps ] [ --core-ok ]
オプションを見る限り、コマンドラインオプションで依存パッケージ
を指定出来るようになったみたいだ。manで調べてみる。
$ man dh-make-perl
--depends DEPENDS
Manually specify the string to be used for the module's dependen-
cies. This should be used when building modules where dh-make-perl
cannot guess the Perl dependencies (such as modules built using
Module::Install), or when the Perl code depends on non-Perl bina-
ries or libraries. Usually, dh-make-perl will figure out the depen-
dencies by itself.
なるほど。
依存ライブラリの数だけ --depends オプションを使うのかと思ったらそうではない。
--dependsは一回だけ使える。
$ dh-make-perl --build --cpan [module] --depends '[package], [package], [package]...'
例としてPlaggerのdebパッケージ作成時のオプション
依存パッケージ多過ぎ。依存しているパッケージはさらに何かに依
存しているので、それぞれのパッケージを作るのは多大な時間が費
やされる。今までにどれくらい費やしたか覚えて居ない…。
dh-make-perl --build --cpan Plagger --depends '${perl:Depends}, ${misc:Depends}, libcache-cache-perl(>=1.04), libcache-fastmmap-perl, libclass-accessor-perl, libconfig-ini-simple-perl, libdata-ical-perl, libdata-serializer-perl, libdatetime-format-epoch-perl, libdatetime-format-ical-perl, libdatetime-format-mail-perl, libdatetime-format-strptime-perl, libdatetime-format-w3cdtf-perl, libdatetime-locale-perl, libdatetime-locale-perl(>=0.32), libdatetime-perl(>=0.35), libdatetime-timezone-perl(>=0.56), libdbix-class-perl, libemail-address-perl, libencode-detect-perl(>=1), libencode-perl(>=2.1), libfile-copy-recursive-perl, libfile-find-rule-perl, libfile-grep-perl, libfile-homedir-perl, libflickr-api-perl, libhatena-keyword-perl, libhtml-format-perl, libhtml-parser-perl, libhtml-parser-perl(>=3.51), libhtml-resolvelink-perl, libhtml-resolvelink-perl(>=0.02), libhtml-scrubber-perl, libhtml-tidy-perl(>=1.07), libhtml-tree-perl, libhtml-treebuilder-xpath-perl, libhttp-cookies-mozilla-perl, libimage-info-perl, libip-country-perl, libipc-run-perl, libkinosearch-perl, liblingua-en-summarize-perl, liblingua-ja-summarize-extract-perl, liblingua-zh-handetect-perl, libmail-imapclient-perl, libmailtools-perl, libmime-lite-perl, libmime-types-perl(>=1.16), libmodule-pluggable-fast-perl, libnet-delicious-perl, libnet-dns-perl, libnet-movabletype-perl, libnet-netsend-perl, libnet-smtp-tls-perl, libpalm-palmdoc-perl, libpoe-component-client-dns-perl, libpoe-component-client-http-perl, libpoe-component-ikc-perl, libpoe-component-irc-perl, libpoe-perl, libregexp-common-profanity-us-perl, libsearch-estraier-perl, libsoap-lite-perl, libspreadsheet-writeexcel-perl, libsvn-core-perl, libswf-builder-perl, libtemplate-perl(>=2.13), libtemplate-plugin-javascript-perl, libtemplate-provider-encoding-perl(>=0.04), libterm-encoding-perl, libtest-pod-coverage-perl, libtest-pod-perl, libtext-csv-pp-perl, libtext-emoticon-perl, libtext-hatena-perl, libtext-kakasi-perl, libtext-language-guess-perl, libtext-markdown-perl, libtext-original-perl, libtext-tags-perl, libtext-wrapi18n-perl, libtime-duration-parse-perl, libtimedate-perl, libuniversal-require-perl(>=0.1), liburi-fetch-perl(>=0.07), liburi-find-perl, libwebservice-bloglines-perl(>=0.11), libwww-babelfish-perl, libwww-mechanize-perl, libwww-mixi-perl(>=0.48), libwww-perl, libxango-perl(>=1.04), libxml-atom-perl(>=0.20), libxml-atom-perl(>=0.23), libxml-feed-perl(>=0.09), libxml-feed-perl(>=0.12), libxml-foaf-perl, libxml-liberal-perl(>=0.14), libxml-libxml-perl, libxml-rss-liberal-perl, libxml-rss-libxml-perl(>=0.23), libyaml-perl(>=0.39), libyaml-syck-perl, libyaml-syck-perl(>=0.1), perl, perl(>=2.1), perl-base, spamassassin'
[入門] Debian パッケージ
posted with amazlet on 07.08.02
やまだ あきら 鵜飼 文敏
技術評論社 (2006/05/11)
売り上げランキング: 122770
技術評論社 (2006/05/11)
売り上げランキング: 122770
『知り合いが使ってるよ』
その一言がやる気を起こさせた。
久々に更新。
・前回 Plagger-0.7.13
・今回 Plagger-0.7.17
DebianでPlaggerの詳細は下記サイト
http://debian.hansode.org/
その一言がやる気を起こさせた。
久々に更新。
・前回 Plagger-0.7.13
・今回 Plagger-0.7.17
DebianでPlaggerの詳細は下記サイト
http://debian.hansode.org/
2007年08月01日
Postfixとpostfix-policyd-spf-perlを使用し、
メールヘッダーに"Received-SPF"を追加する。
■環境
・OS: Debian GNU/Linux (etch)
・MTA: Postfix 2.3.8-2
■概要
・libmail-spf-perlをインストール
・postfix-policyd-spf-perlをインストール
・postfixの設定(/etc/postfix/master.cf編集)
▼Mail::SPF (libmail-spf-perl)
postfix-policyd-spfはMail::SPFに依存する。
debパッケージには存在しない。探してみたらubuntuにあった。
http://packages.ubuntu.com/feisty/perl/libmail-spf-perl
$ wget http://..../libmail-spf-perl_2.004-0ubuntu1_all.deb
$ sudo dpkg -i libmail-spf-perl_2.004-0ubuntu1_all.deb
▼postfix-policyd-spf-perlをdeb化する
postfix-policyd-spf-perlはdeb化される事を想定しているのだろう。
debian/ と言うディレクトリがある。まずはdebパッケージ作り
$ wget http://www.openspf.org/source/software/postfix-policyd-spf-perl/tags/2.004.tar.gz?view=tar -O postfix-policyd-spf-perl-2.0004.tar.gz
$ tar zxvf postfix-policyd-spf-perl-2.0004.tar.gz
$ cd 2.004/
$ chmod +x debian/rules
$ fakeroot dpkg-buildpackage -uc -us
$ ls -1 ../postfix-policyd-spf-perl*
../postfix-policyd-spf-perl-2.0004.tar.gz
../postfix-policyd-spf-perl_2.004-0ubuntu1.dsc
../postfix-policyd-spf-perl_2.004-0ubuntu1.tar.gz
../postfix-policyd-spf-perl_2.004-0ubuntu1_all.deb
../postfix-policyd-spf-perl_2.004-0ubuntu1_i386.changes
$ sudo dpkg -i ../postfix-policyd-spf-perl_2.004-0ubuntu1_all.deb
0utunbu1となっているけど気にしない
$ dpkg -L postfix-policyd-spf-perl
/.
/usr
/usr/sbin
/usr/sbin/postfix-policyd-spf-perl
/usr/share
/usr/share/doc
/usr/share/doc/postfix-policyd-spf-perl
/usr/share/doc/postfix-policyd-spf-perl/copyright
/usr/share/doc/postfix-policyd-spf-perl/changelog.gz
/usr/share/doc/postfix-policyd-spf-perl/changelog.Debian.gz
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/postfix-policyd-spf-perl.8p.gz
▼/etc/postfix/master.cfを修正
$ sudo vi /etc/postfix/master.cf
------------------------------
policy unix - n n - - spawn
user=nobody argv=/usr/bin/perl /usr/sbin/postfix-policyd-spf-perl
------------------------------
追記したらreload
$ sudo /etc/init.d/postfix reload
▼テスト
実際に対してメールを送信し、
メールヘッダーにReceived-SPFが追加されているかを確認
メールヘッダーに"Received-SPF"を追加する。
■環境
・OS: Debian GNU/Linux (etch)
・MTA: Postfix 2.3.8-2
■概要
・libmail-spf-perlをインストール
・postfix-policyd-spf-perlをインストール
・postfixの設定(/etc/postfix/master.cf編集)
▼Mail::SPF (libmail-spf-perl)
postfix-policyd-spfはMail::SPFに依存する。
debパッケージには存在しない。探してみたらubuntuにあった。
http://packages.ubuntu.com/feisty/perl/libmail-spf-perl
$ wget http://..../libmail-spf-perl_2.004-0ubuntu1_all.deb
$ sudo dpkg -i libmail-spf-perl_2.004-0ubuntu1_all.deb
▼postfix-policyd-spf-perlをdeb化する
postfix-policyd-spf-perlはdeb化される事を想定しているのだろう。
debian/ と言うディレクトリがある。まずはdebパッケージ作り
$ wget http://www.openspf.org/source/software/postfix-policyd-spf-perl/tags/2.004.tar.gz?view=tar -O postfix-policyd-spf-perl-2.0004.tar.gz
$ tar zxvf postfix-policyd-spf-perl-2.0004.tar.gz
$ cd 2.004/
$ chmod +x debian/rules
$ fakeroot dpkg-buildpackage -uc -us
$ ls -1 ../postfix-policyd-spf-perl*
../postfix-policyd-spf-perl-2.0004.tar.gz
../postfix-policyd-spf-perl_2.004-0ubuntu1.dsc
../postfix-policyd-spf-perl_2.004-0ubuntu1.tar.gz
../postfix-policyd-spf-perl_2.004-0ubuntu1_all.deb
../postfix-policyd-spf-perl_2.004-0ubuntu1_i386.changes
$ sudo dpkg -i ../postfix-policyd-spf-perl_2.004-0ubuntu1_all.deb
0utunbu1となっているけど気にしない
$ dpkg -L postfix-policyd-spf-perl
/.
/usr
/usr/sbin
/usr/sbin/postfix-policyd-spf-perl
/usr/share
/usr/share/doc
/usr/share/doc/postfix-policyd-spf-perl
/usr/share/doc/postfix-policyd-spf-perl/copyright
/usr/share/doc/postfix-policyd-spf-perl/changelog.gz
/usr/share/doc/postfix-policyd-spf-perl/changelog.Debian.gz
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/postfix-policyd-spf-perl.8p.gz
▼/etc/postfix/master.cfを修正
$ sudo vi /etc/postfix/master.cf
------------------------------
policy unix - n n - - spawn
user=nobody argv=/usr/bin/perl /usr/sbin/postfix-policyd-spf-perl
------------------------------
追記したらreload
$ sudo /etc/init.d/postfix reload
▼テスト
実際に対してメールを送信し、
メールヘッダーにReceived-SPFが追加されているかを確認
2007年07月31日
久々にdh-make-perlを使ったのでメモ
tar玉からCPANモジュールを何度もインストールしていると、
そのうちインストールするのにも飽きて来る。
以前『CPANモジュールをDebianパッケージに出来ないものか?』と考えたら、
まさにその変換コマンドがあった。
$ sudo apt-get install dh-make-perl
$ dh-make-perl --build --cpan [module-name]
Debian使っているなら、色々なものをパッケージ管理したくなる。
便利だけど問題が1つある
依存関係を考慮してくれないと言う事。
Debianパッケージでありながらも中に浮いた独立したパッケージとなる。
頑張って依存関係を作る方法はある。
そのネタはまた今度。
tar玉からCPANモジュールを何度もインストールしていると、
そのうちインストールするのにも飽きて来る。
以前『CPANモジュールをDebianパッケージに出来ないものか?』と考えたら、
まさにその変換コマンドがあった。
$ sudo apt-get install dh-make-perl
$ dh-make-perl --build --cpan [module-name]
Debian使っているなら、色々なものをパッケージ管理したくなる。
便利だけど問題が1つある
依存関係を考慮してくれないと言う事。
Debianパッケージでありながらも中に浮いた独立したパッケージとなる。
頑張って依存関係を作る方法はある。
そのネタはまた今度。
2007年06月08日
▼env.
OS : Debian GNU/Linux 4.0
repos : debu
trac : /home/svn/tracs http://svn.example.com/trac/debu/
svn : /home/svn/repos http://svn.example.com/repos/debu/
▼subversion
# apt-get install subversion
# mkdir /home/svn
# cd /home/svn
# mkdir repos
# svnadmin create /home/svn/repos/debu
# chown -R www-data /home/svn/repos
▼trac
# apt-get install trac
# cd /home/svn
# mkdir tracs
# trac-admin /home/svn/tracs/debu initenv
# chown -R www-data /home/svn/tracs/debu
▼apache2, apache2-modules
# apt-get install apache2 libapache2-mod-fcgid libapache2-svn
# a2enmod fcgi rewrite
# /etc/init.d/apache2 force-reload
# htpasswd -c htpasswd $(username)
▼apache namevirtual
# cd /etc/apache2/sites-available
# cat > svn.example.com
--------------------------------------------------
<VirtualHost *>
ServerName svn.example.com
DocumentRoot /home/svn/tracs
Options -Indexes
RewriteEngine On
<IfModule mod_fcgid.c>
DefaultInitEnv TRAC_ENV_PARENT_DIR /home/svn/tracs
</IfModule>
ScriptAlias /trac /usr/share/trac/cgi-bin/trac.fcgi
RedirectMatch ^/$ /trac/
<Location /repos>
DAV svn
SVNParentPath /home/svn/repos
</Location>
<Location />
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /home/svn/htpasswd
Require valid-user
Order Deny,Allow
Deny from All
Allow from 192.0.2.0/24
</Location>
</VirtualHost>
--------------------------------------------------
# /usr/sbin/a2ensite svn.example.com
# /usr/sbin/apache2ctl configtest
# /etc/init.d/apache2 reload
----------------------------------------------------------------------
2006年12月05日
/etc/init.d/spamassassinを参考にrunスクリプト作成。
起動オプションは/etc/default/spamassassinに集約。
#!/bin/sh
exec 2>&1
sleep 3
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/spamd
NAME=spamd
SNAME=spamassassin
DESC="SpamAssassin Mail Filter Daemon"
PNAME="spamd"
export TMPDIR=/tmp
# Apparently people have trouble if this isn't explicitly set...
# Defaults - don't touch, edit /etc/default/spamassassin
ENABLED=0
OPTIONS=""
NICE=
test -f /etc/default/spamassassin && . /etc/default/spamassassin
DOPTIONS=""
if [ "$ENABLED" = "0" ]; then
echo "$DESC: disabled, see /etc/default/spamassassin"
exit 0
fi
test -f $DAEMON || exit 0
set -e
exec $DAEMON -- $OPTIONS $DOPTIONS
$ sudo mv /service/.spamassassin /service/spamassassin
$ sudo svstat /service/spamassassin/
/service/spamassassin/: up (pid 2617) 218 seconds
$ ps awx | egrep '[s]pamd'
2617 ? S 0:03 /usr/bin/perl -T -w /usr/sbin/spamd -- -u spamd --create-prefs --max-children 5 --helper-home-dir
2622 ? S 0:00 spamd child
2623 ? S 0:00 spamd child
上手く行った。
起動オプションは/etc/default/spamassassinに集約。
#!/bin/sh
exec 2>&1
sleep 3
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/spamd
NAME=spamd
SNAME=spamassassin
DESC="SpamAssassin Mail Filter Daemon"
PNAME="spamd"
export TMPDIR=/tmp
# Apparently people have trouble if this isn't explicitly set...
# Defaults - don't touch, edit /etc/default/spamassassin
ENABLED=0
OPTIONS=""
NICE=
test -f /etc/default/spamassassin && . /etc/default/spamassassin
DOPTIONS=""
if [ "$ENABLED" = "0" ]; then
echo "$DESC: disabled, see /etc/default/spamassassin"
exit 0
fi
test -f $DAEMON || exit 0
set -e
exec $DAEMON -- $OPTIONS $DOPTIONS
$ sudo mv /service/.spamassassin /service/spamassassin
$ sudo svstat /service/spamassassin/
/service/spamassassin/: up (pid 2617) 218 seconds
$ ps awx | egrep '[s]pamd'
2617 ? S 0:03 /usr/bin/perl -T -w /usr/sbin/spamd -- -u spamd --create-prefs --max-children 5 --helper-home-dir
2622 ? S 0:00 spamd child
2623 ? S 0:00 spamd child
上手く行った。
2006年11月17日
canna 3.7p3-3.1にきをつけろの続き
3.7p3-4で解消した。
$ dpkg --get-selections | grep canna
canna hold
canna-utils install
jvim-canna install
libcanna1g install
$ echo canna install | sudo dpkg --set-selections
$ dpkg --get-selections | grep canna
canna install
canna-utils install
jvim-canna install
libcanna1g install
$ sudo apt-get dist-upgrade
$ dpkg -l canna
ii canna 3.7p3-4 Japanese input system (server and dictionary
3.7p3-4で解消した。
$ dpkg --get-selections | grep canna
canna hold
canna-utils install
jvim-canna install
libcanna1g install
$ echo canna install | sudo dpkg --set-selections
$ dpkg --get-selections | grep canna
canna install
canna-utils install
jvim-canna install
libcanna1g install
$ sudo apt-get dist-upgrade
$ dpkg -l canna
ii canna 3.7p3-4 Japanese input system (server and dictionary
apache2-mpm-preforkとlibapache2-mod-php5の駄目な組合せの続編
ii apache2-mpm-prefork 2.2.3-3.1 Traditional model for Apache HTTPD 2.1
ii libapache2-mod-php5 5.2.0-3 server-side, HTML-embedded scripting languag
このバージョンの組合せで解消された。
ii apache2-mpm-prefork 2.2.3-3.1 Traditional model for Apache HTTPD 2.1
ii libapache2-mod-php5 5.2.0-3 server-side, HTML-embedded scripting languag
このバージョンの組合せで解消された。
Apacheハンドブック
posted with amazlet on 06.11.17
Ben Laurie Peter Laurie 大川 佳織 田辺 茂也
オライリージャパン
売り上げランキング: 5545
オライリージャパン
売り上げランキング: 5545

![[入門] Debian パッケージ](http://ec1.images-amazon.com/images/I/21P2PEMKRML.jpg)


