2012年3月23日 星期五

Automake 的測試套件 make check-TESTS

在寫程式的時候會想要寫一些測試套件來驗證程式的功能是否正常,Automake 支援了這種需求。

一般來說寫一個給 Hello World 程式的 Makefile.am 會長得像以下這樣:
bin_PROGRAMS = hello
hello_SOURCES = hello.c
如果說希望能夠在編譯完程式後,順便執行一下來檢查,就可以加一行:
bin_PROGRAMS = hello
hello_SOURCES = hello.c
TESTS = $(bin_PROGRAMS)
這樣一來就可以執行 make check 來自動編譯並且執行測試; 只是通常不會想要把測試程式釋出給一般人使用,所以就會改寫成:
check_PROGRAMS = hello
hello_SOURCES = hello.c
TESTS = $(check_PROGRAMS)
這樣就只會在 make check 的時候,編譯 hello 這隻程式並且自動執行它來做測試。

如果想要看到彩色的測試結果,就要修改 configure.ac 加上 color-tests 像是以下這樣:
AC_PREREQ([2.68])
AC_INIT([hello], [0.1], [foo@bar.com])
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign color-tests])                                                                                                                        
AM_MAINTAINER_MODE([enable])
其實 GNU Build System 很好用的,只是要多看 info Automake 的文件來理解它的使用方法。:)
對以上內容不太瞭解的,可以先看看簡報 GNU Build System (aka Autotools) 入門一下。

2012年1月18日 星期三

要求 Ubuntu 開發中版本同步 Debian 上面的套件

Ubuntu 是個每半年釋出一個版本的 GNU/Linux 發行套件,因此每次正式版本釋出的同時代表的是下一個版本開發的開始,因此每個 Ubuntu 版本的開發總是依循著同樣的步調跟大同小異的規則。

Ubuntu 開發中版本上面的套件大多是來是 Debian testing/unstable 的自動同步,不過等到 DebianImportFreeze 之後跟 FeatureFreeze 之前,如果還有新版本的套件在 Debian testing/unstable 上面出現時,就要透過 SyncRequestProcess 來要求 Ubuntu 開發中版本同步 Debian 上面的套件,FeatureFreeze 之後就不能再要求同步套件了,只能夠修正程式的錯誤。

以下示範三種情況。

狀況一: Ubuntu 開發中版本的套件並沒有包含 Ubuntu 社群的錯誤修正

使用 ubuntu-dev-tools 套件底下的 requestsync 指令
$ requestsync -C -d unstable --lp betaradio precise

然後會看到以下內容:
Summary (one line):
Sync betaradio 1.4-1 (universe) from Debian unstable (main)

Description:
Please sync betaradio 1.4-1 (universe) from Debian unstable (main)

Changelog entries since current precise version 1.3-1:

XXX FIXME: add changelog here XXX                                 

要將最後一行改掉,加上 Debian testing/unstable 套件裡面的訊息,所以就變成了:
Summary (one line):
Sync betaradio 1.4-1 (universe) from Debian unstable (main)

Description:
Please sync betaradio 1.4-1 (universe) from Debian unstable (main)

Changelog entries since current precise version 1.3-1:

betaradio (1.4-1) unstable; urgency=low

  * New upstream release.
  * debian/patches/00_dont_install_header: Don't install header file into the
    system.

 -- Shih-Yuan Lee (FourDollars) <fourdollars[at]gmail.com> Sat, 14 Jan 2012 20:58:32 +0800

最後就會產生一個 Launchpad Bug 像是 Bug #918059 in betaradio (Ubuntu): “Sync betaradio 1.4-1 (universe) from Debian unstable (main)” 這樣就做好了,之後就是去注意這個 Bug 的變化,適時的去回應 Ubuntu Developer 提出的問題(如果有的話)。

狀況二: Ubuntu 開發中版本的套件已經有包含了一些 Ubuntu 社群的錯誤修正

在這種情況底下 Ubuntu 不會自動去同步 Debian testing/unstable 上面的套件,以防有些 Ubuntu 社群所做的錯誤修正遺失。

使用跟上面一樣的指令:
$ requestsync -C -d unstable --lp ibus-chewing precise

然後會看到以下內容:
Summary: Sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)
Description:
Please sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)

Explanation of the Ubuntu delta and why it can be dropped:
  * debian/patches/IBusChewingEngine-def-fix-SIGSEGV-on-preference-save.patch:
    Fix misuse of g_value_get_gtype in g_value_to_g_variant. (LP: #874028)
  * debian/patches/escape-to-close-candidate-window-on-plain-
     zhuyin.patch: Fix plain zhuyin with space as selection problem.
     (https://github.com/definite/ibus-chewing/pull/8/) (LP: #843619)
[這邊有一行我忘了原本寫些什麼了,總之要你改掉寫上你的解釋]

Changelog entries since current precise version 1.3.9.2-3ubuntu2:

XXX FIXME: add changelog here XXX                                 

跟前面一樣加上 Debian testing/unstable 套件裡面的訊息,還有解釋一下為什麼 Ubuntu 社群的錯誤修正都被拿掉了,然後就變成了:
Please sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)

Explanation of the Ubuntu delta and why it can be dropped:
  * debian/patches/IBusChewingEngine-def-fix-SIGSEGV-on-preference-save.patch:
    Fix misuse of g_value_get_gtype in g_value_to_g_variant. (LP: #874028)
  * debian/patches/escape-to-close-candidate-window-on-plain-
     zhuyin.patch: Fix plain zhuyin with space as selection problem.
     (https://github.com/definite/ibus-chewing/pull/8/) (LP: #843619)
These patches are already included in ibus-chewing 1.3.10+clean-1.

Changelog entries since current precise version 1.3.9.2-3ubuntu2:

ibus-chewing (1.3.10+clean-1) unstable; urgency=low

  * New upstream release.
  * All Debian patcheds dropped.
  * Add Osamu as uploaders.
  * Repackaged upstream tar with normal tar and removing .swo

 -- Osamu Aoki <osamu[at]debian.org> Mon, 26 Dec 2011 00:17:58 +0900

最後就會產生一個 Launchpad Bug 像是 Bug #918061 in ibus-chewing (Ubuntu): “Sync ibus-chewing 1.3.10+clean-1 (main) from Debian unstable (main)” ,之後就是去注意這個 Bug 的變化,適時的去回應 Ubuntu Developer 提出的問題(如果有的話)。

狀況三: Ubuntu 開發中版本並沒有包含這個套件

在這種情況下應該是最單純的,應該不會有額外的動作要做,都是按下 Enter 就可以做到完。

使用跟上面一樣的指令:
$ requestsync -C -d unstable --lp hime precise

然後會看到以下內容:
'hime' doesn't exist in 'Ubuntu precise'.
Do you want to sync a new package?
Press [Enter] to continue or [Ctrl-C] to abort.

當然是按下 Enter 到下一步
Your sync request shall require an approval by a member of the appropriate
sponsorship team, who shall be subscribed to this bug report.
This must be done before it can be processed by a member of the Ubuntu Archive
team.
If the above is correct please press [Enter] 

再按下 Enter 到下一步
Currently the report looks as follows:
Summary (one line):
Sync hime 0.9.9-1 (universe) from Debian unstable (main)

Description:
Please sync hime 0.9.9-1 (universe) from Debian unstable (main)

All changelog entries:

hime (0.9.9-1) unstable; urgency=low

  * Initial release (Closes: #652022)

 -- Yao Wei (魏銘廷) <mwei[at]lxde.org>  Sat, 14 Jan 2012 00:24:08 +0800

Do you want to edit the report [y/N]?
並沒有修改的必要,所以還是按下 Enter 到下一步
The final report is:
Summary: Sync hime 0.9.9-1 (universe) from Debian unstable (main)
Description:
Please sync hime 0.9.9-1 (universe) from Debian unstable (main)

All changelog entries:

hime (0.9.9-1) unstable; urgency=low

  * Initial release (Closes: #652022)

 -- Yao Wei (魏銘廷) <mwei[at]lxde.org>  Sat, 14 Jan 2012 00:24:08 +0800


Press [Enter] to continue or [Ctrl-C] to abort.
最後的確認,還是按下 Enter 於是就會產生一個 Launchpad Bug 像是 Bug #923637 in Ubuntu: “Sync hime 0.9.9-1 (universe) from Debian unstable (main)”,之後就是去注意這個 Bug 的變化,適時的去回應 Ubuntu Developer 提出的問題(如果有的話)。

2012年1月16日 星期一

Genie 程式語言

Genie 程式語言是 GNOME 計畫下的一個新的程式語言,跟 Vala 一起開發的,語法類似 Python,跟 Vala 一樣都是借助 GObject 來實現物件導向程式設計,也跟 Vala 一樣都是產生出 C 的程式碼,而且也因為 GObject 的關係可以輕易地產生其它程式語言的 binding。
例如:輸入以下的程式碼儲存成 hello.gs
init
        print "Hello World"
然後再執行以下的指令就可以看到結果了。
$ valac hello.gs
$ ./hello
如果說要看到中間轉譯出來的 C 語言程式碼可以輸入以下指令:
$ valac -C hello.gs
於是就可以看到 hello.c 產生出來了。
/* hello.c generated by valac 0.14.0, the Vala compiler
 * generated from hello.gs, do not modify */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

void _vala_main (gchar** args, int args_length1);

void _vala_main (gchar** args, int args_length1) {
        g_print ("Hello World\n");
}

int main (int argc, char ** argv) {
        g_type_init ();
        _vala_main (argv, argc);
        return 0;
}
看看裡面的內容是不是一般所熟悉的 C 語言程式碼。:)
參考資料:Genie - GNOME Live!

AMD Graphics Drivers 非官方 PPA - ppa:fourdollars/fglrx

因為我自己工作上的需要所以偶而會測試 AMD 官方最新 release 出來的 Graphics Drivers
剛剛更新了 ppa:fourdollars/fglrx 給 Ubuntu 10.04/10.10/11.04/11.10 使用
目前使用的是 AMD 在 12/13/2011 釋出的 AMD Catalyst™ 11.11 Proprietary Linux x86 Display Driver
最新的 AMD Graphics Drivers 可以參考 http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx
有 AMD Graphics Drivers 使用問題的網友可以試試看,另外要特別聲明這只是使用 AMD 官方釋出的套件產生出來的,因此有問題找我也解決不了。:P

2012年1月13日 星期五

betaradio v1.4 released

BetaRadio 是一款使用 Vala 程式語言寫出來的網路收音機程式,專門用來收聽台灣的網路電台。

專案網址:
http://code.google.com/p/betaradio/

新功能:
1. 改善 Unity 整合性
2. 使用多執行緒改善回應速度

錯誤修正:
1. 修正右鍵點擊無法使用的問題

原始碼下載:
http://code.google.com/p/betaradio/downloads/detail?name=betaradio-1.4.tar.bz2

2011年11月21日 星期一

Ubuntu 11.10 繁體中文全新安裝後手動修正問題

共同的部份

1. 系統語言變數設定錯誤
直接修改 /etc/default/locale 內容改成
LANG="zh_TW.UTF-8"
LANGUAGE="zh_TW:en"
然後再執行
$ sudo update-grub
2. fontconfig 字型設定錯誤
正常的設定會是以下的結果
$ fontconfig-voodoo -c
Current config: zh_TW
如果不正常就執行以下命令修正
$ sudo fontconfig-voodoo -a
修正完畢後,重新開機應該就會正常了。

Xubuntu 11.10

1. ibus 導致程式崩潰的問題
$ sudo apt-get install ibus-gtk ibus-gtk3
$ cd /usr/lib/gtk-2.0/2.10.0/
$ sudo ln -s /usr/lib/i386-linux-gnu/gtk-2.0/2.10.0/immodules
如果是使用 AMD64
$ sudo ln -s /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules

2011年11月20日 星期日

在 Sony Ericsson Xperia™ X8 刷 MiniCM7

MiniCM 是一個特別為 Sony Ericsson Xperia™  X10 mini / X8 製作 Android 的 CyanogenMod 客製化的計畫



以下是筆者的安裝步驟筆記,自行刷客製的 Android ROM 有一定的風險,請讀者自行負擔風險,筆者不擔保過程中發生的問題。
  1. 首先需要在 Windows 下載安裝 Sony Ericsson PC Companion 2.0 用來升級跟還原出廠預設版本(安裝過程中有任何問題都可以還原手機上的系統)
  2. 如果 [設定] -> [關於手機] 裡面的 [基頻版本] 不是 015 結尾的話,需要下載 Baseband 015 的 firmware 回來使用 Flashtool 來更新,然後重新啟動手機
  3. 在 Windows 上面安裝使用 SuperOneClick 來取得手機上的 root 權限,然後重新啟動手機
  4. 利用 Android Market 安裝 Apk Installer 用來安裝 Root Explorer,然後重新啟動手機
  5. 然後再將 Xrecovery.zip 裡面的三個檔案利用 Root Explorer 複製到手機系統裡的 /system/bin 底下
  6. 重新啟動系統,看見手機畫面上出現 Sony Ericsson 字樣時不斷地連擊手機上的 Back 鍵,順利的話就可以進入 Xrecovery
  7. 在 Xrecovery 裡面安裝 MiniCM7-2.0.7-X8.zip 跟 gapps-gb-20110828-signed.zip,然後再執行 factory reset 再重新啟動手機就大功告成啦!^o^

PS. 筆者所使用的手機型號是 X8i(E15i)