2011年4月11日星期一

通过kernel Makefile 生成 cscope ctags

在kernel 中使用cscope 经常会出现很多的数据是没有用,比如一个函数被不同版本的驱动定义了很多次,而这些版本是我们不需要的,查找定义是会出现很多的选项,看得眼睛都花了 T.T
于是写了一个脚本,通过kernel makefile 来生成这些数据库,这样查找就能很精确,一步到位 ^_^

source_file=/tmp/source.list
include_file=/tmp/include.list
output_file=cscope.files
source_file_temp=/tmp/source_file_temp
output_file_temp=/tmp/output.temp
make clean
make ARCH=arm CROSS_COMPILE=arm-eabi- CFLAGS_KERNEL=-H -j4 1>$source_file 2>$include_file

#for test
#source_file=source.list
#include_file=include.list
#output_file=cscope.files
#source_file_temp=/tmp/source_file_temp

# generate the include file
grep "^\.\+\ " $include_file | awk '{print $NF}' | sort -u >$output_file

# generate the source file
grep "\(\<CC\>\|\<AS\>\|LOGO\)" $source_file | awk '{print $NF}' >$source_file_temp
for i in $(cat $source_file_temp)
        do
                cc_source=${i%.o}.c
                as_source=${i%.o}.S
                if [ -f $cc_source ]; then
                        echo $cc_source >>$output_file
                        else
                        if [ -f $as_source ]; then
                                echo $as_source >>$output_file
                        fi
                fi
        done

mv $output_file $output_file_temp
for i in $(cat $output_file_temp)
        do
                if [ -f $i ]; then
                        echo $i >>$output_file
                fi
        done

rm $output_file_temp $source_file_temp $source_file $include_file
rm cscope.*out*
cscope -bkq -i $output_file
ctags -L $output_file

使用方法:先配置好.config, 使内核能正常编译。然后,在kernel 的目录下运行该脚本,就会自动生成。
通过这个脚本,还可以生成一个文件列表 output.temp, 可以加快以后更新cscope 数据库的速度。

2011年4月1日星期五

wine 中文路径问题

在Ubuntu下,把语言切换到英文模式下,用wine 程序保存的文件,如果路径中有中文,就会提示invalid name,文件保存不了,而在中文环境下可以保存。这个应该是由于跟语言有关的环境变量造成的。为了不影响以前的设置,可以采用以下办法:


先对wine进行一下备份,建立一个脚本:
sudo cp /usr/bin/wine /usr/bin/wine-run
sudo rm /usr/bin/wine
sudo touch /usr/bin/wine
sudo chmod a+x /usr/bin/wine
然后编辑/usr/bin/wine,加入一下内容:

#!/bin/bash

export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN:zh
export LC_CTYPE="zh_CN.UTF-8"
export LC_NUMERIC="zh_CN.UTF-8"
export LC_TIME="zh_CN.UTF-8"
export LC_COLLATE="zh_CN.UTF-8"
export LC_MONETARY="zh_CN.UTF-8"
export LC_MESSAGES="zh_CN.UTF-8"
export LC_PAPER="zh_CN.UTF-8"
export LC_NAME="zh_CN.UTF-8"
export LC_ADDRESS="zh_CN.UTF-8"
export LC_TELEPHONE="zh_CN.UTF-8"
export LC_MEASUREMENT="zh_CN.UTF-8"
export LC_IDENTIFICATION="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"

/usr/bin/wine-run "$@"
注意:wine-run 后的$@必须要有引号,否则不能处理带有空格的文件。

考虑到更新时候,wine会被覆盖掉,因此,下面一个脚本可以自动检测,并生成脚本:

#!/bin/bash
function create_wine_script()
{
        echo '#!/bin/bash

        export LANG=zh_CN.UTF-8
        export LANGUAGE=zh_CN:zh
        export LC_CTYPE="zh_CN.UTF-8"
        export LC_NUMERIC="zh_CN.UTF-8"
        export LC_TIME="zh_CN.UTF-8"
        export LC_COLLATE="zh_CN.UTF-8"
        export LC_MONETARY="zh_CN.UTF-8"
        export LC_MESSAGES="zh_CN.UTF-8"
        export LC_PAPER="zh_CN.UTF-8"
        export LC_NAME="zh_CN.UTF-8"
        export LC_ADDRESS="zh_CN.UTF-8"
        export LC_TELEPHONE="zh_CN.UTF-8"
        export LC_MEASUREMENT="zh_CN.UTF-8"
        export LC_IDENTIFICATION="zh_CN.UTF-8"
        export LC_ALL="zh_CN.UTF-8"

        /usr/bin/wine-run "$@" ' > $1
}

file /usr/bin/wine | grep ELF 1>/dev/null
if [ $? -eq 0 ]
        then
                cp /usr/bin/wine /usr/bin/wine-run
                rm /usr/bin/wine
                touch /usr/bin/wine
                chmod a+x /usr/bin/wine
                create_wine_script  /usr/bin/wine
fi

2011年3月24日星期四

[转载]Ubuntu设置"位置(Places)"菜单、"应用程序"菜单

"位置"菜单:
打开一个文件夹窗口(随便一个),在菜单拦打开"书签"-"编辑书签",然后就可以增加活删除"位置"(Places)菜单的项目了。
或者你可以编辑用户目录下的.gtk-bookmarks文件。
用命令 gedit ~/.gtk-bookmarks
"应用程序"菜单:
右键-编辑菜单

在64位系统中安装lightning

从thunderbird 的官网下的lightning 插件是不能用于x86_64 系统的.
可以通过软件源安装:
sudo apt-get install xul-ext-lightning
重启thunderbird就可以用了.

ref: https://lists.ubuntu.com/archives/ubuntu-users/2010-October/230200.html

2011年3月22日星期二

[转载]ubuntu 的文件关联

 
PS:如果你要修改文件的打开方式,请选择右键=>属性=>打开方式=>删除
和Windows一样,在Gnome的文件管理器(nautilus)里,双击一个文件的时候,
系统会自动调用相应的程序去打开这个文件。前提是能打开这个文件的软件已经安装
并且配置完毕了。

在Nautilus里通过右键菜单固然可以修改默认的打开方式,但是缺乏灵活性和可
操作性,比如,不能删除一些候选的打开方式,不能批量增加一些打开方式等等。

经过反复的摸索,终于被我发现了GNMOE的打开方式的配置方式。
这里需要涉及到以下几个目录和文件

~/.local/share/applications
/etc/gnome/defaults.list
/usr/share/applications
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
去这几个目录看一下,就会发现很多以 desktop 为后缀的文件。
这些文件是多功能的,第一,它们是组成GNMOE的“开始”菜单的一部分,即“开始”
菜单里的一些应用程序项,在这里都能找到。你可以运行 alacarte, 这里会
列出整个菜单的结构,你可以编辑它,但是很多项你没法删除,因为没有权限,
你试着用root权限去运行 alacarte ,抱歉,你还是没有权限删除,要删除它们,
只有在/usr/share/applications下面找到对应的文件,直接删除这个文件即可。

从总体上讲
/etc/gnome/defaults.list保存了全局的打开方式
~/.local/share/applications/defaults.list保存了个人的打开方式
当两着不一致是,优先采用局部的个人设置。

~/.local/share/applications
/usr/share/applications
这两个分别是局部的desktop项和全局的desktop项

/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
这两个分别是全局的和局部的打开方式缓存

先看一下/etc/gnome/defaults.list的结构

[DefaultApplications]
application/csv=gnumeric.desktop
application/excel=ooo-calc.desktop
application/msexcel=ooo-calc.desktop
application/msword=ooo-writer.desktop
application/ogg=mplayer.desktop
application/pdf=evince.desktop
application/postscript=evince.desktop
.................
text/x-chdr=vim.desktop
text/x-csrc=vim.desktop
text/x-dtd=vim.desktop
text/x-java=vim.desktop
text/mathml=vim.desktop
text/x-python=vim.desktop
text/x-sql=vim.desktop
text/xml=firefox.desktop
video/dv=mplayer.desktop
video/mp4=mplayer.desktop
video/mpeg=mplayer.desktop
video/msvideo=mplayer.desktop
video/quicktime=mplayer.desktop
video/vnd.rn-realvideo=mplayer.desktop
video/x-anim=mplayer.desktop
video/x-avi=mplayer.desktop
video/x-flc=mplayer.desktop
......................

不难发现
是这样的一种形式
程序的类型/文件类型=打开这个文件的项[;项2]...[;项n]
候选打开方式可以有好几种
中间用;隔开,不留其余字符


要修改一个文件的打开方式,需要先确定这个文件的类型
以纯文本文件为例类型是plain打开方式默认为vim.desktop
候选的是firefox.desktop
text/plain=vim.desktop;firefox.desktop

可以直接编辑
~/.local/share/applications/defaults.list
/etc/gnome/defaults.list
编辑完之后,手工修改
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
这两个cache文件。
这样就立即生效了

下面看一下desktop文件的结构

[DesktopEntry]
Encoding=UTF-8//字符编码
Name=vim  //现实的名字
MimeType=text/plain;//类型
Exec=vim%f//运行的程序%f表示一个参数
Type=Application //类型
Terminal=true//是否使用终端
NoDisplay=true//是否显示在gnome菜单里

知道这些
就可以很方便的定制“开始”菜单 和 文件的打开方式了

2011年3月20日星期日

ubuntu 桌面几个问题的解决方法

1.  底部的面板不能显示打开的程序, 即无论打开多少程序, 底部面板始终是空的, 但是Alt+Tab 却能切换程序.
     解决方法: 貌似是gnome-panel的错误, 重新载入面板就可以了.
                       具体可以猛击这里.
2. 在安装完touchpad-indicator后, 有一次切换鼠标和触摸板时, 鼠标好像卡住了, 一直显示"拖拽"状态, 鼠标能移动, 就是不能点击, 左右键都不行.
     解决方法: 这个是nautilus的问题. 要是还能运行terminal的话, 直接运行:
                        kill `pgrep nautilus`

2011年3月8日星期二

在Ubuntu上安装coin3d

  coin3d是 open invertor 的一种开发包, 有SIM 公司开发. 这是一个开放源码的OIV开发包,使用协议采用的是GPL协议,在linux和windows下都能用. 
    官方源里已经有coin3d的库了, libcoin40 对应的是2.x 版本的, libcoin60 对应的是3.x 版本的.我这里用3.x的版本
apt-get install libcoin60 libcoin60-dev libcoin60-runtime
 然后是编译SoXt:
     先搞定一些依赖:
sudo ln /usr/lib.so.1 /usr/lib.so
sudo apt-get install libmotif-dev libmotif3
     从官方下载SoXt源码包, 解压之后:
./configure
make
make install

NOTE: 安装好, 编译coin3d程序的时候要加上 -lSoXt 不然会找不到 SoXt库.

NOTE: 在使用纹理贴图时,会出现Coin warning in SbImage::readFile(): The simage library is not available, can not import any images from disk.
这是因为libsimage没有装。
sudo apt-get install libsimage-dev