Setup Laconica on SAMP stack

Basically the similar steps as described in Quick Start Guide on Ubuntu 8.04.

  1. Install amp-dev (or webstack packages) on OpenSolaris (or Solaris production release), and install SunStudio and GNU autotools (JDS CBE toolset is recommended).
  2. Download the latest laconica archive file, and extract to apache2/2.2/htdocs, and edit the httpd.conf to enable "AllowOverride All" for htdocs directory.
  3. Edit config.php, setup mysql databases, configure fancy URL, as described in above document.
  4. Download sphinx- and apply this patch for sunstudio C++ compiler, build and install it as following,
  5. $ export PATH=$PATH:/path/to/mysql/bin
    $ ./configure; make; pfexec make install
    $ cd api/libsphinxclient; ./configure LDFLAGS="-lsocket -lnsl"; \
    > make; pfexec make install

  6. Use pecl(1) to install sphinx php extension, while you need export CC to SunStudio, otherwise, it would uses gcc even it's not in your $PATH. (Thanks to Sriram Natarajan for this tip, I used to download and build it manually.)
  7. $ export CC=/opt/SUNWspro/bin/cc
    $ pecl install sphinx

  8. Enable DNS and set it prior to NIS, otherwise email validation would fail.

A simple python script to backup your roller blog.

I tried to find some backup tools for jroller, some only backs up the recent 30 entries in RSS feed, some does not handul unicode characters. By referring the python/xmlrpclib and MetaWeblog API documents, I wrote a simple backup tool, you could download it here. (But I did not find a good way to get tags for entries.) You may need to modify the global variables, like blogid/user/passwd.

import xmlrpclib
blogid = 'yongsun'
user = ''
passwd = '**********'
host = ''
server = xmlrpclib.ServerProxy(host+'/roller-services/xmlrpc', use_datetime=True)
num = 1000
... ...
... ...

Please note that the passwd is the "Weblog Client API Password", it's probably your original login password, anyway, you could set it in your profile page.

what's the 'chash' in ips manifest?

chash: the sha1 hash of the compressed file.

While if you manually compress the file with gzip -n -9, you would find the sha1 value is still different with the one in the manifest file. By looking into ips/pkg's source code, it turns out that the head used in ips/pkg is a little different with the one gzip(1) generated,

-0000000 1f 8b 08 00 00 00 00 00 02 ff
+0000000 1f 8b 08 00 00 00 00 00 02 03

The last byte is to indicate the OS type, '03' stands for 'Unix', 'ff' means 'Unknown', refer to RFC1952. After you change the OS type to 'ff' in your manually compressed file, you would see the sha hash values are just the same.

localization and gettext in python

import gettext
gettext module will use the encoding specified in Content-Type header for
Gnu mo files, and convert the message strings to unicode. Here you could
sepcify the *output* encoding to others.
gettext.bind_textdomain_codeset('gedit', codeset='UTF-8')
gettext module will try to retrieve messages from /usr/share/locale by
default, otherwise you need to explicitly set it.
gettext.bindtextdomain ('gedit', '/usr/share/locale')
_ = lambda msg: gettext.dgettext ('gedit', msg)
N_ = lambda msg: msg
print _("Save")

Enable "suspend to RAM" on my laptop

原来一直错怪了Solaris的电源管理。我的Dell笔记本型号是Latitude D620, 这个型号的S3-support缺省并没有打开。在/platform/i86pc/kernel/drv/ppm.conf中可以看到,D630缺省是打开的(当然Sun大部分的x86/64工作站缺省也是打开的)。

可以手工编辑/etc/power.conf,添加S3-support enable,来开启这个功能。然后执行下面的命令,

$ /usr/sbin/pmconfig
$ /usr/sbin/svcadm restart hal

这样,Gnome在你退出时会提供suspend的选项,也可以使用gnome-power-manager来配置何时执行suspend的选项。我尝试了在打开compiz 3D特效的情况下执行suspend操作,也是可以安全唤醒的。唤醒后无线网络也依然可用。


build matplotlib-0.98.3 on Solaris with SunStudio 12

1. Set the CBE environment (/opt/jdsbld/bin/, and export CC=$CXX, so that /usr/lib/python2.4/pycc would eventually use the C++ compiler in SunStudio.

2. Download the source code from, then apply the following patch,

---	2008-08-04 02:15:22.000000000 +0800
+++	2008-11-03 17:08:41.387138200 +0800
@@ -218,6 +218,8 @@ def get_win32_compiler():
 win32_compiler = get_win32_compiler()
 if sys.platform == 'win32' and win32_compiler == 'msvc':
     std_libs = []
+elif sys.platform == 'sunos5':
+    std_libs = ['Crun', 'Cstd']
     std_libs = ['stdc++', 'm']

@@ -298,6 +300,7 @@ def check_for_freetype():
         for d in basedirs:
             module.include_dirs.append(os.path.join(d, 'freetype2'))

+    module.include_dirs.append('/usr/include')
     print_status("freetype2", get_pkgconfig_version('freetype2'))
     if not find_include_file(module.include_dirs, 'ft2build.h'):
--- src/_backend_gdk.c	2008-08-04 02:14:18.000000000 +0800
+++ src/_backend_gdk.c	2008-11-03 17:31:32.896210699 +0800
@@ -62,6 +62,7 @@ static PyMethodDef _backend_gdk_function
     { NULL, NULL, 0 }

+extern "C"

3. Then build and install,

$ python build
$ pfexec python install

Note: this version of matplotlib requires numpy-1.1 or higher version, you need build and install a newer one since solaris only has 1.0.4.

build scipy-0.6.0 on Solaris with SunStudio 12

I finally got some clues about how to build scipy with SunStudio and Sun Performance library from this discussion thread. And here are the steps I sumerized:

1. Download the source tar file of scipy, SciPy 0.6.0 tarball, and extract it to anywhere. Apply the following changes to /usr/lib/python2.4/vendor-packages/numpy/distutils/fcompiler/, since f77compat library is not available on x86/x64 platform,

---	2008-10-31 18:30:17.519425733 +0800
+++	2008-10-31 18:30:23.842495794 +0800
@@ -38,7 +38,7 @@
         return ['-xtarget=generic']
     def get_libraries(self):
         opt = []
-        opt.extend(['fsu','sunmath','mvec','f77compat'])
+        opt.extend(['fsu','sunmath','mvec'])
         return opt

 if __name__ == '__main__':

and apply the following patch,

--- scipy/sparse/sparsetools/sparsetools.h    2007-09-22 15:55:25.000000000 +0800
+++ scipy/sparse/sparsetools/sparsetools.h    2008-10-31 17:54:47.317379521 +0800
@@ -22,6 +22,7 @@

 #include <vector>
 #include <algorithm>
+#include <functional>


2. Set CBE environment (/opt/jdsbld/bin/, and the following environment variables,

$ export LDFLAGS="-lCrun -lCstd"
$ export LAPACK=/opt/SUNWspro/lib/
$ export BLAS=/opt/SUNWspro/lib/

3. Then build, install, and test

$ python build
$ pfexec install
$ cd ~ # don't run the test under the source directory
$ python
>>> import scipy
>>> scipy.test()

Though, you would see several errors, most of the tests passed.

调整 OpenSolaris nVIDIA 显卡外接投影仪的分辨率

我所使用的是Dell的一款笔记本,配备了nVIDIA的显卡。当外接投影仪的时候,用nvidia-settings(1)自动检测(Detect Displays),可以发现有另一个model(因为是VGA输出,所以通常是CRT-0),但是这个screen的分辨率不能调整、且仅为640x480。这对进行演讲来说非常不方便。可以用如下方法来解决:

  • 先点击“Save to X Configuration File”将这个设置保存到X的配置文件中,即/etc/X11/xorg.conf,
  • 然后编辑该配置文件,定位到ModelName为“CRT-0”的那个Monitor Section,调整水平和垂直刷新,例如:

        HorizSync 31.5 - 64.3
        VertRefresh 40.0 - 150.0

  • 然后退出并重启X,再运行nvidia-settings,就可以看到CRT-0有更多的分辨率可以选择了,不过好像只有4:3的分辨率可选。