zt日記

書いているのは Kazuhiro NISHIYAMA a.k.a. ZnZです。
2001|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|
2012|04|05|06|09|

この日記にはツッコミを入れられます。 ツッコミを入れたい日付をクリックすると、フォームが現れます。

xreaでtDiaryを使う方法はxrea.com で tDiary を使う方法インストールメモXREA + tDiary + Namazuをどうぞ。


2009年05月05日(Tue)

NetBSD 5.0

連休を利用してBSD系のOSをVMware Server 2の環境にインストールしてchkbuildを動かしてみた。

インストール

% wget -N ftp://iso.jp.netbsd.org/pub/NetBSD/iso/5.0/i386cd-5.0.iso
  • Create Virtual Machine
    • Other (32-bit)
    • Memory: 512MB
    • Disk: 8G, SCSI (LSI Logic) のまま
    • Network: NAT
    • CD/DVD: IDE, さっきダウンロードしたISO
    • Floppy, USB なし

タイムゾーンを Japan にした以外はほぼデフォルト。

インストール後

http://www.netbsd.org/docs/guide/en/chap-boot.html を参考にして一般ユーザの追加やsshの設定など。

useradd -m -G wheel user1
passwd user1
echo rtclocaltime=YES >> /etc/rc.conf
sh /etc/rc.d/rtclocaltime restart
echo sshd=yes >> /etc/rc.conf
/etc/rc.d/sshd start
echo dhclient=yes >> /etc/rc.conf
reboot

pkgsrc

.profile に

export PKG_PATH=ftp://ftp.jp.netbsd.org/pub/pkgsrc/packages/NetBSD/$(uname -m)/5.0/All

を設定。

pkg_add subversion
pkg_add bison
pkg_add autoconf
pkg_add ruby18-base
pkg_add pkg_alternatives
pkg_alternatives -gs rebuild
pkg_add lv
pkg_add sudo
visudo

user1 にも許可。

「pkg_alternatives -gs rebuild」は http://www.tunagu.gr.jp/cgi-bin/fswiki/wiki.cgi/isihara?page=pkgsrc%A4%E1%A4%E2#p40 を参考にした。

sshで入るときにIPアドレスで指定しなくてもいいようにするためにavahiを入れる。

pkg_add avahi
ln -s /usr/pkg/share/examples/rc.d/avahidaemon /etc/rc.d/
echo avahidaemon=yes >> /etc/rc.conf
ln -s /usr/pkg/share/examples/rc.d/dbus /etc/rc.d/
echo dbus=yes >> /etc/rc.conf
/etc/rc.d/dbus start
/etc/rc.d/avahidaemon start

/etc/rc.conf

# Add local overrides below
#
wscons=YES
rtclocaltime=YES
sshd=yes
dhclient=yes
avahidaemon=yes
dbus=yes

chkbuild

$ cvs -d :pserver:anonymous@cvs.m17n.org:/cvs/ruby co chkbuild
$ cd ./chkbuild/
$ lv ./README.ja.rd
(文字化け)
$ locale
LANG=""
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=""
$ export LANG=ja_JP.UTF-8
$ lv ./README.ja.rd
$ ruby ./start-build
sbrk: grow 1048576 failed, error = 12
$ uname -a
NetBSD  5.0 NetBSD 5.0 (GENERIC) #0: Sun Apr 26 18:50:08 UTC 2009  builds@b6.netbsd.org:/home/builds/ab/netbsd-5-0-RELEASE/i386/200904260229Z-obj/home/builds/ab/netbsd-5-0-RELEASE/src/sys/arch/i386/compile/GENERIC i386
$

気になった点

  • ホスト名の設定をしなかった。
  • start-buildを動かしたときの「sbrk: grow 1048576 failed, error = 12」って何?

2009年05月06日(Wed)

OpenBSD 4.5

OpenBSD 4.5 も VMware Server 2の環境にインストールしてchkbuildを動かしてみた。

インストール

% wget -N ftp://ftp.kddlabs.co.jp/OpenBSD/4.5/i386/install45.iso
  • Create Virtual Machine
    • Other (32-bit)
    • Memory: 512MB
    • Disk: 8G, SCSI (LSI Logic) のまま
    • Network: NAT
    • CD/DVD: IDE, さっきダウンロードしたISO
    • Floppy, USB なし

インストール中の設定。

  • hostname: openbsd
  • DNS domain name: v.test
  • install sets: デフォルトのまま
  • timezone: Japan
  • halt

インストール後

http://www.openbsd.org/faq/faq8.html#TimeZone を参考にしてタイムゾーンの設定。

  • config -ef /bsd
    • timezone -540
    • quit
  • halt

.profile に

 export PKG_PATH=ftp://ftp.jaist.ac.jp/pub/OpenBSD/4.5/packages/`machine -a`/

を設定。

pkg_add subversion
pkg_add bison
pkg_add autoconf-2.62
pkg_add ruby

autoconfは後で autoconf-2.61p3 を入れてそっちを使った。

http://blogs.dion.ne.jp/yamaga/archives/8342277.html を参考にして avahi はなかったので howl をインストール。

pkg_add howl
echo multicast_host=YES >> /etc/rc.conf.local
echo /usr/local/bin/mDNSResponder >> /etc/rc.local
vi /etc/rc.local
reboot

http://www.openbsd.org/faq/faq10.html を参考にして adduser で user1 を追加。

chkbuild

$ cvs -d :pserver:anonymous@cvs.m17n.org:/cvs/ruby co chkbuild
$ cd chkbuild/
$ vi start-build
$ cvs diff -u start-build
cvs diff: failed to open /home/user1/.cvspass for reading: No such file or directory
Index: start-build
===================================================================
RCS file: /cvs/ruby/chkbuild/start-build,v
retrieving revision 1.3
diff -u -r1.3 start-build
--- start-build 12 Aug 2006 06:14:27 -0000      1.3
+++ start-build 6 May 2009 01:08:07 -0000
@@ -1,6 +1,7 @@
 #!/usr/bin/env ruby

 #ENV['PATH'] = "/usr/local/bin:#{ENV['PATH']}"
+ENV['AUTOCONF_VERSION'] = '2.62'

 require 'chkbuild'

$ ruby ./start-build
$

autoconf 2.62 だと SIZEOF_VOIDP がなくて SIZEOF_VOID_ になってしまって、ビルドできていなかったので、autoconf-2.61p3 を入れて、AUTOCONF_VERSION も 2.61 にして start-build を実行し直したらうまくいった。


2009年05月11日(Mon)

notify-send なしで notification を送れるか

先に結論だけ。 dbus-send コマンドでは無理。

Debian や Ubuntu では libnotify-bin パッケージに /usr/bin/notify-send コマンドが入っていて、「notify-send title message」などでデスクトップに通知メッセージが表示できる。

通知の仕組みについては Desktop Notifications Specification で決まっていて、 D-BUS Protocol を参考にすれば dbus-send コマンドで送信出来そうに思えたので調べてみた。

以下 Jaunty での例。

まず引数のいらない簡単なメソッドを呼び出してみる。

% dbus-send --session --dest=org.freedesktop.Notifications --type=method_call --print-reply /org/freedesktop/Notifications org.freedesktop.Notifications.GetCapabilities
method return sender=:1.57 -> dest=:1.133 reply_serial=2
   array [
      string "body"
      string "body-markup"
      string "icon-static"
      string "image/svg+xml"
      string "x-canonical-private-synchronous"
      string "x-canonical-append"
      string "x-canonical-private-icon-only"
      string "x-canonical-truncation"
      string "private-synchronous"
      string "append"
      string "private-icon-only"
      string "truncation"
   ]
% dbus-send --session --dest=org.freedesktop.Notifications --type=method_call --print-reply /org/freedesktop/Notifications org.freedesktop.Notifications.GetServerInformation
method return sender=:1.57 -> dest=:1.132 reply_serial=2
   string "notify-osd"
   string "Canonical Ltd"
   string "1.0"
   string "0.9"
%

なぜか D-BUS Protocol に比べて返ってくる string が 1 個多いが、NotifyOSD - Ubuntu Wiki に 4 個で書いているので、意図した挙動のようだ。

使えるメソッドの種類やその引数などを調べるために org.freedesktop.DBus.Introspectable.Introspect を使う。

% dbus-send --session --dest=org.freedesktop.Notifications --type=method_call --print-reply /org/freedesktop/Notifications org.freedesktop.DBus.Introspectable.Introspect
method return sender=:1.57 -> dest=:1.142 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg name="data" direction="out" type="s"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg name="interface" direction="in" type="s"/>
      <arg name="propname" direction="in" type="s"/>
      <arg name="value" direction="out" type="v"/>
    </method>
    <method name="Set">
      <arg name="interface" direction="in" type="s"/>
      <arg name="propname" direction="in" type="s"/>
      <arg name="value" direction="in" type="v"/>
    </method>
    <method name="GetAll">
      <arg name="interface" direction="in" type="s"/>
      <arg name="props" direction="out" type="a{sv}"/>
    </method>
  </interface>
  <interface name="org.freedesktop.Notifications">
    <method name="GetServerInformation">
      <arg name="return_name" type="s" direction="out"/>
      <arg name="return_vendor" type="s" direction="out"/>
      <arg name="return_version" type="s" direction="out"/>
      <arg name="return_spec_version" type="s" direction="out"/>
    </method>
    <method name="GetCapabilities">
      <arg name="return_caps" type="as" direction="out"/>
    </method>
    <method name="CloseNotification">
      <arg name="id" type="u" direction="in"/>
    </method>
    <method name="Notify">
      <arg name="app_name" type="s" direction="in"/>
      <arg name="id" type="u" direction="in"/>
      <arg name="icon" type="s" direction="in"/>
      <arg name="summary" type="s" direction="in"/>
      <arg name="body" type="s" direction="in"/>
      <arg name="actions" type="as" direction="in"/>
      <arg name="hints" type="a{sv}" direction="in"/>
      <arg name="timeout" type="i" direction="in"/>
      <arg name="return_id" type="u" direction="out"/>
    </method>
  </interface>
</node>
"
%

arg の type については Type Signatures を参照。

ここで dbus-send で array や variant の指定方法を調べてみたところ、dbus-send(1) に

 dbus-send  does not permit empty containers or nested containers
 (e.g. arrays of variants).

とあるので、 dbus-send では org.freedesktop.Notifications.Notify を送れないことがわかった。 (hints の a{sv} のところで dict の value の型が variant なので)

Python スクリプトなどなら送れそうだが、コマンドラインやシェルスクリプトからなら素直に notify-send コマンドを使った方が良さそうという結論になった。


2009年05月12日(Tue)

[ruby] OpenSolaris で Ruby 1.9.1-p129 を make してみた

全ログは http://gist.github.com/110445 に。

まず osol-0811.iso という ISO イメージからインストールした OpenSolaris に wget や GNU tar や bzip2 は入っていたので、ruby-1.9.1-p129.tar.bz2 をとってきて configure してみると、Cコンパイラがないと言われた。

http://journal.mycom.co.jp/special/2008/opensolaris/007.html を参考にして、make は入っていたので「pkg install SUNWgcc」で gcc を入れた。

configure と make は問題なく通ったように見えたが、「make test」で FAIL がでたり、「make test-all」の途中で止まってどうしようかと思ったりしたが、 kill で TERM シグナルを送ったら続きが動き出して何とか結果は見ることが出来た。

test-all の結果は kill で止めた 1E を含めて 3F8E だった。


2009年05月15日(Fri)

lenny と VMware Tools

debian の lenny で module-assistant を使って「sudo m-a a-i open-vm」のように VMware Tools のオープンソース版である open-vm-tools のカーネルモジュールをインストールしようとしても hgfs のところでリンクに失敗するので調べてみた。

エラーの内容は以下のような感じ。

% tail -n20 $(ls /var/cache/modass/open-vm-source.buildlog.*|tail -n1)
  CC [M]  /usr/src/modules/open-vm/modules/linux/vmhgfs/staticEscape.o
  CC [M]  /usr/src/modules/open-vm/modules/linux/vmhgfs/stubs.o
  CC [M]  /usr/src/modules/open-vm/modules/linux/vmhgfs/super.o
  LD [M]  /usr/src/modules/open-vm/modules/linux/vmhgfs/vmhgfs.o
/usr/src/modules/open-vm/modules/linux/vmhgfs/hgfsEscapeLinux.o: In function `HgfsEscape_Undo':
hgfsEscapeLinux.c:(.text+0x0): multiple definition of `HgfsEscape_Undo'
/usr/src/modules/open-vm/modules/linux/vmhgfs/hgfsEscape.o:hgfsEscape.c:(.text+0xe0): first defined here
/usr/src/modules/open-vm/modules/linux/vmhgfs/hgfsEscapeLinux.o: In function `HgfsEscape_Do':
hgfsEscapeLinux.c:(.text+0xf): multiple definition of `HgfsEscape_Do'
/usr/src/modules/open-vm/modules/linux/vmhgfs/hgfsEscape.o:hgfsEscape.c:(.text+0x2b2): first defined here
make[5]: *** [/usr/src/modules/open-vm/modules/linux/vmhgfs/vmhgfs.o] エラー 1
make[4]: *** [_module_/usr/src/modules/open-vm/modules/linux/vmhgfs] エラー 2
make[4]: ディレクトリ `/usr/src/linux-headers-2.6.26-2-amd64' から出ます
make[3]: *** [vmhgfs.ko] エラー 2
make[3]: ディレクトリ `/usr/src/modules/open-vm/modules/linux/vmhgfs' から出ます
make[2]: *** [build] エラー 2
make[2]: ディレクトリ `/usr/src/modules/open-vm' から出ます
make[1]: *** [binary-modules] エラー 2
make[1]: ディレクトリ `/usr/src/modules/open-vm' から出ます
make: *** [kdist_build] エラー 2
%

まず、出来れば debian の方が都合がいいので、 sid の方も調べてみると同様に失敗した。

次に VMware Server 2.0.1 で VMwareTools-7.7.5-156745.tar.gz を試してみた。 gcc コマンドは gcc 4.3 になっていて、カーネルのビルドに使われているのは gcc 4.1 らしいので、環境変数 CC を指定して「sudo env CC=gcc-4.1 ./vmware-install.pl」で試すと vsock はダメだったが他は大丈夫だった。別途調べてみると vsock はなくても問題ないらしい。

VMware Workstation 6.5.2 の方にも lenny を入れて、 module-assistant を入れて、「sudo m-a prepare」でカーネルモジュールのビルドに必要な環境を整えた後、 VMware-Tools-7.8.5-156735.tar.gz を環境変数 CC を指定して「sudo env CC=gcc-4.1 ./vmware-install.pl」で試すと vsock の問題もなく使えた。

まとめ

入手元 バージョンなど 結果
debian lenny open-vm-source 2008.11.18-130226-1lenny2 NG
debian sid open-vm-source 2009.03.18-154848-2 NG
VMware Server 2.0.1 VMwareTools-7.7.5-156745.tar.gz ほぼOK
VMware Workstation 6.5.2 VMware-Tools-7.8.5-156735.tar.gz OK

2009年05月18日(Mon)

XML と制御文字

XML には US-ASCII の範囲内であってもすべての文字を入れることが出来ない。

理由は 2.2 Characters で #x20 未満は #x9 | #xA | #xD しかないから。 だから、たとえば GPL2 の原文は改ページが入っているので、そのまま XML に入れることは出来ない。

それなら数値文字参照にすればいいんじゃないの、というとそれも 4.1 Character and Entity References に「Characters referred to using character references MUST match the production for Char.」などと書かれていて無理。

CDATA も 2.7 CDATA Sections をみると中身が Char になっているので無理。

ゆるいパーサーだと文字の範囲をチェックしていないけど、厳密なパーサーだとチェックしていて、はまることがありそうです。


copyright © 2001-2013 ZnZ
Key fingerprint = 6E14 2C9C DBD7 874D 8B3C CAA8 9B58 5538 ED7E 1B73