顯示具有 setup 標籤的文章。 顯示所有文章
顯示具有 setup 標籤的文章。 顯示所有文章

2012年10月1日 星期一

Emacs for objective-c development

Emacs for obj-C development.md

To develop GNUStep program under Debian, we need 2 handy tools:

1. Auto complete for obj-c.
2. Source browsing.

For the first one, emacs has auto complete package support for after Emacs24. If you are using Debian wheezy, you have to build from source. Before compile, the pre-requisite packages are:

 $ sudo aptitude install build-essential libxpm-dev libgif-dev libtiff-dev libjpeg-dev libgtk2.0-dev libdbus-1-dev texinfo

Build with these pre-requisite packages can let your emacs customise the X fonts easily. And the build commands are :

$ ./configure --with-x-toolkit --with-xft
$ make
$ sudo make install

ps.: It seems that the default configuration does the same work.

The default install directory is /usr/local/bin.

Since Emacs24, in emacs package provides a convient way to install e-lisp plug-ins, add the following lines in your .emacs :

(require 'package)
(add-to-list 'package-archives 
    '("marmalade" .
    "http://marmalade-repo.org/packages/"))
(package-initialize)
(add-to-list 'load-path "~/.emacs.d")    ; This may not be appeared if you have already added.

Now open emacs, install the auto-complete package by :

M-x package-install [RET] auto-complete [RET]

After that, append the following lines in your .emacs

(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-1.4/dict")
(add-to-list 'ac-modes 'objc-mode) ;;here load the objc-mode

Note : Here the version is 1.4, modify the version if necessary.

OK, now we should have the emacs support auto-complete for obj-c.

For the second one: Source browsing, can be done with Gnu Global (gtags).

Since the Debian/Ubuntu currently provide Global-5.7.1, which does not support '--encode-path' option, the option will be used in the plug-in. We have to build Global-6.2.4 from source then "configure" "make install", and complete the setup by copying gtags.el to ~/.emacs.d and append :

(add-to-list 'load-path "~/.emacs.d")    ; This may not be appeared if you have already added.
(autoload 'gtags-mode "gtags" "" t)

After that, the gtags command will be setup correctly. #

2011年1月24日 星期一

Difference between .bash_profile and .bashrc Files

以下內容是從這裏節錄出來的:

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

就是說,當你使用 login console 或用 ssh login 時, .bash_profile 會被調用。
如果只是在 GNOME, KDE 或 emacs 裏面,打開一個 shell command 時, .bashrc 會被調用。

那麼作 global 設定時,就是這兩種情形分別對應到 /etc/profile /etc/bash.bashrc 啦!
其中,若是需要在 login 時,也希望 bashrc 被調用,就可以在 profile 裏面 source bashrc.

2011年1月23日 星期日

git 更改遠端資訊 的指令

為了轉移到新的伺服器,git 的 repository 要搬到新位置,所以 local 端的 repository 指標要換掉,下列指令依序就是轉換的步驟:

#> git remote -v
顯示目前指向哪些遠端的 repository? (URL 格式)

#> git remote rm origin
移除 URL 資訊

#> git remote add origin git@git-server:project_name
改變 URL 資訊,指向新位置 (若是用 gitosis ,就可以直接建立新的遠端 repository ,否則遠端的新增的 repository 必須先用 git init 或 git init --bare 處理過)
(目前為止,都還沒有對 remote repository 產生任何影響)

#> git push origin master
把 local repository 更新到 remote 端(這裡,才實際的更新了 remote repository)

Install sun-java5-* in debian squeeze

Debian Squeeze 已經把 sun-java5-* (亦即 java 1.5 )拿掉了,統統換成了 sun-java6-* (亦即 java 1.6)「註:這裡 * 代表 jre, bin, jdk, demo 等等部份」。
可是 Android 開發環境會檢查 java 環境,仍然需要 java 1.5 ,怎麼辦呢?
可以用 dpkg --force-depends 強制安裝 sun-java5-*  ,方法如下:

1. 首先下載 Lenny 版本的 package :
sun-java5-bin_1.5.0-22-0lenny1_i386.deb
sun-java5-jre_1.5.0-22-0lenny1_all.deb
sun-java5-demo_1.5.0-22-0lenny1_i386.deb
sun-java5-jdk_1.5.0-22-0lenny1_i386.deb

2  因為 bin 依賴於 jre , jre 依賴於 bin, jdk 依賴於 demo, demo 依賴於 jdk 。
所以用強制 depends 選項(把依賴關係列為 warning 而非 error )就可以順利安裝,指令為:
#> dpkg --force-depends -i  sun-java5-bin_1.5.0-22-0lenny1_i386.deb\
  sun-java5-jre_1.5.0-22-0lenny1_all.deb\
  sun-java5-demo_1.5.0-22-0lenny1_i386.deb\
  sun-java5-jdk_1.5.0-22-0lenny1_i386.deb

3. 切換內定 java version :
#> sudo update-java-alternatives -s java-1.5.0-sun
如果出現一堆跟 firefox plugin 的錯誤訊息,像這樣:
update-alternatives: error: alternative /usr/lib/jvm/java-1.5.0-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so for firefox-javaplugin.so not registered, not setting.
...
不用管它,因為我們 compile Android 時應該不會用到 firefox 的 java plugin。

4. 驗證 java version :
#> javac -version
應該就可以看到 java 1.5 的訊息了!
#


2010年11月26日 星期五

忽然想要列印 man page 怎麼辦?

老 Unix 玩家應該覺得很簡單,但對於新手的我還是要紀錄一下:
1. 先由命令查閱要列印的 man page 再哪裡? 例如 :
tom@glest:~/temp$ man -w groff
/usr/share/man/man1/groff.1.gz
2. 原來是有壓縮的,知道後就可以印了:
tom@glest:~/temp$ zcat `man -w groff` | groff -m man -T ps - | lpr

這裡 groff 是排版用的指令,輸入格式為 man page ,輸出格式為 ps 。
That's it !

p.s. 當然你的 lpr 要正確才行,如果有裝好 cups,下列命令就可以看到系統印表機狀態:
tom@glest:~/temp$ iceweasel http://localhost:631/admin



2010年8月26日 星期四

emacsclient font configurations

This text applies to version after Emacs 23.1
首先,我們可以把下列一行加入 ~/.bashrc
  alias ex='emacsclient -a "" -c "$@"'

解釋一下:
當我們使用 emacsclient 時,必須有一個 emacs server 啟動才可以用。
emacsclient 的參數有一個 -a "" 表示萬一 emacs server 沒有啟動,
就使用 `alternate editor' ,它可以是 vi, pico ... ,若是空字串 ("") ,表示 `那就叫一個 emacs server 起來好了'.
另外 參數 -c 表示 `create a new frame' 而不是用 server 的 frame.
至於後面要打開的檔案(可以一次指定開多個檔案來編輯),就用 bash 提供的 $@ 來代入即可。

第二,設定字型,因為 emacs server 可以在 X 之前就啟動了,因此,
很合理的,它不理會你指定在 X 環境下的字型。
現在的 X 環境下有兩種字體系統:核心字體系統與 Xft 字體系統。Xft 有許多優良的特性(向量,反鋸齒等),
所以 Emacs 23.1 開始支援 Xft as its font base. (see XftGnuEmacs).
只要在你的  ~/.Xresources 指定就好,例如,我們打算用 DejaVu Sans Mono 字型 :
    Emacs.FontBackend: xft
    Emacs.font: DejaVu Sans Mono-14

(謎:怎樣查出這個字型呢? M-x describe-font 然後給個 mono 讓它 match 出完整的字型敘述)

第三,設定 frame 的特性,我們希望打開 frame 時,是黑底白字,不要 tool bar, 不要 scroll bar ...
這些都與預設值不同,該怎麼設定呢?
emacs 的 default-frame-alist 裡面紀錄了 `新開一個 frame 所需的參數',設定這個就對了!
在你的 ~/.emacs 內這樣指定
(let ((frame '((left . 0)
               (top . 0)
               (width . 110)
               (height . 30)
               (tool-bar-lines . nil)
               (vertical-scroll-bars . nil)
               (background-color . "black")
               (foreground-color . "white")          
)))
  (setq default-frame-alist frame)
  (setq initial-frame-alist frame)

)

說明一下,[ GNU Emacs 手冊 ]查得到所有的 frame parameters。
第一次開啟的 frame(應該是 server frame)  參數會參考 `initial-frame-alist' ,往後開啟 frames(emacsclient frame)都會參考 `default-frame-alist' .

完工了!記得重新開啟 X 讓 .Xresources 生效啊啊~

2010年8月17日 星期二

lpr and cups troubleshooting

Bad situation encountered :
系統是 Debian/Testing.
透過 browser 瀏覽 http://localhost:631 可以透過 CUPS 管理印表機,目前我系統是安裝 CUPS 1.4.4。
使用其中的 Administration | Maintenance -> Print Self Test Page 可以順利印出測試頁面。
但是 emacs 裡面要列印時,就出問題了: 使用 print buffer 命令根本沒反應!

Troubleshooting :
因為 emacs 使用 `lpr' 指令作列印動作 --- 改用 `lpr' 指令試著列印一個文字檔 --- 也失效。
用 `lpq' 觀察 printing jobs 發現都在 spool 上,卻沒有送到 printer 。
觀察 debian 套件關係,原因是 cups-bsd-1.4.4-2 沒有裝,反倒是 lpr-2008.05 套件有裝上,這兩個是 conflict 的套件,因為都有提供 `lpr' 等指令。
但是前者提供 printing commands (i.e. `lpr') interactive with the CUPS. 必須裝這個套件而不是 `lpr-2008.05' 套件
這次裝錯套件的現象,可能是以前 upgrade 時沒有仔細看就同意用 lpr 套件來取代。
移除 `lpr-2008-05' 並裝上 `cups-bsd-1.4.4-2' ,重新啟動 cupsd 還不夠;可能是我還有 daemon 沒有重起,或是 debian 套件系統沒有正確的 post processing,就沒有去追究了。
試著重新開機, work !






2009年12月13日 星期日

Debian 升級 testing (sqeeze) 與 ATI X1450 的 driver 問題

Asus A8J 大約是兩三年前的華碩主流筆電之一,獨立顯卡採用  ATI X1450.
Debian Lenny 下有提供 ATI propietary driver (non-free) :
kernel driver(要 3D 加速,需要 kernel driver ) : fglrx-modules-2.6.26-* 等,driver source : fglrx-kernel-src
for openGL lib : fglrx-glx
根據這篇 [ arch linux ATI ] [ref 1] 知道,X1450 的 code name 為 (RV515, 即 r5xx  系列)

Debian 系統升級到  testing 後,kernel driver 套件變成 : fglrx-source , 且改為支援 r6xx-r7xx 而已,也就是說 ATI 官方 driver 不再支援 r5xx 系列,
但是這些不被支援的系列的 spec 已經  release 給 open source 社群。所以目前升級後的  xorg 7.4 裡面的  xserver-xorg-video-ati 套件,可以支援 r5xx 系列。
xorg.conf 已經不需要了,xorg 會自動偵測掛載  radeon driver。

glxgears 的數據為
1598 frames in 5.0 seconds = 319.450 FPS 
1613 frames in 5.0 seconds = 322.503 FPS  ( 本blog時間測)

6097 frames in 5.0 seconds = 1219.223 FPS 
6014 frames in 5.0 seconds = 1202.697 FPS  ( 2010年4月20測)

跟使用 ATI propietary ~1200 FPS 比較起來,稍稍等待 open source 社群是值得的,
時間會證明 open source community 提供的 code 效能,總會超越 propietary code 的,並且更穩定。
Technorati 標籤: , , ,

2009年11月18日 星期三

Emacs 捲動的設定

Emacs 內定的捲動方式為一次半頁,這樣看起來跳動很大,有些不習慣。修改 .emacs 加入下面設定,可以變成『自然捲』...
(setq scroll-margin 0 scroll-conservatively 10000 )

另外,想定義新的 macro 並且紀錄於 .emacs 以供下次使用,可以這樣作,
(以 scroll other window (up/down) one line 這個動作為例) :

C-x (      定義新的 macro
M 1 C-M-v   我們的新 command --- scroll other window down one line
C-x )     結束 macro 定義

給它取一個名字:
M-x name-last-kbd-macro [Enter]
打入自取名稱 ,例如 scroll-other-window-down-one-line [Enter]

打開 ~/.emacs 準備加入這個新定義:
M-x insert-kbd-macro
打入剛剛取的名稱  scroll-other-window-down-one-line [Enter] 就會出現
(fset 'scroll-other-window-down-one-line
   "\261\226")
然後定義一個 hotkey 例如 F11 給它:
(define-key global-map [f11] 'scroll-other-window-down-one-line)

以後按 F11 就會 scroll down other window.

為了對稱,做了一個 scroll other window up one line ,最後在 .emacs 裡長成這樣:

...
(fset 'scroll-other-window-up-one-line
   "\2551\226")
(define-key global-map [M-f11] 'scroll-other-window-up-one-line)
(fset 'scroll-other-window-down-one-line
   "\261\226")
(define-key global-map [f11] 'scroll-other-window-down-one-line)
...

Technorati 標籤:

2009年11月13日 星期五

eclipse + CDT for C++ Development

這篇說明 eclipse 的設定,為了怕設定的部份翻譯不好,乾脆用英文寫...

Since `cscope + ecb + emacs' is my favorite development tool, there is no need for "eclipse", while not all people get used to `emacs' conveniently. Here we introduce another good IDE for C/C++ developemnt --- Eclipse !!

1. From [ http://www.eclipse.org/downloads/ ] download `Eclipse IDE for Java EE...' or `Eclipse IDE for Java...' or `Eclipse IDE for C/C++...', I download the eclipse-jee-galileo-linux-gtk.tar.gz  , extract,  then add path (where you untar eclipse ) to ~/.bashrc such that when I type `eclipse' command so that it can be brought up (Yes, its green software).

2. Install the CDT plugin : (If you use `Eclipse IDE for C/C++' , please skip this step)
In eclipse menu, goto (Help | Install New Software ...) then type this html page:
http://download.eclipse.org/tools/cdt/releases/galileo
(note : CDT need > eclipse 3.5 or up )
then update. The CDT component will then be installed.

3. Create C++ project :
In eclipse menu, goto "File | New | Project...|C++":
   a. Fill "Project Name".
   b. Select Makefile Project | Empty Project.  <--- yes, choose `Empty Project' for the external Makefile case !!
   c. Select Linux GCC at the right side.
   d. Press the "Finish" button.
then you have created an empty project in eclipse.

4. Import external sources/Makefile to project:
Right click on the project name, select "import...":
choose "General | File System" , click "Next" button, then "browse" to your source path, (of,course, you can filter out unnecessary files ) then press "Finish".

5. Goto "Project | properties| C/C++ Build", in the right "Build Location" field, press the "workspace" button, and given your project path , for e.g. ${workspace_loc:/test/home/tom/external_open_source}. (I was fooling around here for 6 hours --- before I learn to press the "workspace" button)

Then press "OK", the project will be built. But in our `external_open_source' project, we need use `make opt' as the building command ---goto "Project |Proties" , in "C/C++ Build",
a. select the "Behavior" tab,
b. uncheck "Build on resource save(Auot build)",
c. modify "Build (Incremental build)" to "opt",
d. then press "OK" to finish.

Now, you should build the `external_open_source'  sucessfully, instead of the 'No rule to make target `opt' error message !

ps. In Debian Lenny, make sure to use

$update-alternatives --config java

to configure your default java to `java-6(5)-sun' instead of `java-gcj' , the Eclipse will NOT start with `java-gcj' as the default java environment:

  Selection    Alternative
-----------------------------------------------
              1    /usr/bin/gij-4.3
              2    /usr/lib/jvm/java-gcj/jre/bin/java
*+          3    /usr/lib/jvm/java-6-sun/jre/bin/java

Press enter to keep the default[*], or type selection number: 3
 
Technorati 標籤: ,

2009年10月16日 星期五

Tips for setup the android-x86 build system

Of course , you will find the [Android-x86 : Get Source] site useful..
On a newly install Debian Lenny machine, we may encounter the following situations:.

1. where is my "repo"?
Ans: the `repo' is not a Debian package, this [Android download] teach us how to download/setup the `repo' script.

2.  I want to built-in a module, how to do it ?
Ans: Take DM9601 network card as an example.
First copy my_defconfig under {android-x86}/kernel/arch/x86/configs/android-x86_defconfig, then
modify my_deconfig:
CONFIG_DM9601=y

Finally following the [customized kernel] to build android-x86:
#>make iso_img TARGET_PRODUCT=eeepc TARGET_KERNEL_CONFIG=my_defconfig

3. I want to use user account instead of root to build the source, how to do it without problem ?
Ans: During the build, there are 2 commands `e2fsck' `tune2fs' needs root privilege,
now let you user_account can also use them.
under the root:
#> link -s  /sbin/e2fsck  /usr/bin/e2fsck
#> link -s  /sbin/tune2fs  /usr/bin/tune2fs
#> visudo
let user `tom' to use these 2 commands
Cmnd_Alias FS=/sbin/tune2fs,\
       /sbin/e2fsck
tom     ALL=NOPASSWD: FS

4. During the build, compiler complain about the java , what happened?
Ans: This is probably caused by using the incorrect java compiler...
Please note that Android-1.6 can accept the java-6-sun as its compile environment, use
#>update-java-alternatives -s java-6-sun
to select the compiler environment provided by sun java.

That's all.Technorati 標籤: ,

2009年8月28日 星期五

使用 debootstrap 安裝 Debian 於 USB 大拇哥

網路上相關文章很多,但是多半有"手工"打許多指令的步驟,不適合懶人使用。
[ Install Debian on USB ]這篇Wiki前半部直到 Configure Locales 的部份做完,寫得很簡明,接下來是該作者自己的 Casper package 安裝,就不用再繼續 follow up 了。

所以歸納一下步驟如下:
1.  準備好 partition 以安裝 debian。這視個人的大拇哥規劃而定,以下假設裝在 /dev/sdb2(sda 是本機上的硬碟)
以下用 /dev/sd{D}{N} 表示,請自行代換之。

2.  準備好檔案系統 ,並且 mount 到 /mnt
#> mkfs.ext3 /dev/sd{D}{N}
#> mount /dev/sd{D}{N} /mnt

3.   重頭戲來了,從 /etc/apt/sources.list 找一個 mirror site 這裡用 http://debian.nctu.edu.tw/debian/ (要含有斜線)
#> debootstrap lenny /mnt http://debian.nctu.edu.tw/debian/
     接下來會一直抓 package 來安裝,泡盃咖啡去...

4   準備兩個設定檔,一個在裝 kernel 時會用到,另一個是 sources.list,可以直接使用 host 的 /etc/apt/sources.list
#> mkdir -p /mnt/etc/apt
#> echo "do_initrd=yes" > /mnt/etc/kernel-img.conf
#> cp /etc/apt/sources.list  /mnt/etc/apt/

5   準備 fstab 給新系統 (/etc/inittab 則不需煩惱,debootstrap 會 setup inittab)
#> echo "/dev/sd{D}{N}  /  ext3  defaults,errors=remount-ro 0" > /mnt/etc/fstab
#> echo "proc /mnt/proc  proc  none 0 0" >> /mnt/etc/fstab
#> mount proc /mnt/proc  -t  proc

6   接下來用 chroot 切換到新的系統去,
#> chroot /mnt
請注意:經過這步驟,接下來,所有的指令都是下給新系統的了!

7   先設定好 locale 並且把從 host 繼承的 locale 先設空
#> apt-get update
#> apt-get install locales
#> dpkg-reconfigure locales
#> export LANG=
#> export LANGUAGE=
localepurge 是個可裝可不裝的套件,若要省空間,可以這時候裝起來
#> apt-get install localepurge
將來裝套件時 localepurge 可幫忙 free 一些不需要的 locales 資料

8   然後安裝 kernel image,遇到問題都選 y
#> apt-get install linux-image-2.6.26-2-686

9 裝 grub package
#> apt-get install grub

10 將 grub 裝到 MBR :
#> exit
請注意:接下來,我們又回到 host 了!
#> grub-install --root-directory=/mnt --no-floppy --recheck /dev/sd{D}
#> cat > /mnt/boot/grub/menu.lst << EOF
title        Debian GNU/Linux, kernel 2.6.26-2-686
root        (hd0,1)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/sd{D}{N} ro
initrd        /boot/initrd.img-2.6.26-2-686
EOF
這裡把 (hd1,1) 換成了 (hd0,1)  。因為若是用  usb 開機的話,grub 把大拇哥當第一顆硬碟 (hd0), 直到進了 kernel 才又跟 host 所認知的一樣---回到 sdb。


11 打完收工
#> umount /mnt/proc
#> umount /mnt

這樣就有一個可用的 Debian on USB 了!
後記:grub 安裝時,如果抱怨找不到 grub drive 或 stage1 的問題,[這裡]有解答
Technorati 標籤: , ,